bochs debugging

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
paranoid
Posts: 3
Joined: Tue Apr 06, 2010 7:34 am

bochs debugging

Post by paranoid »

i am a noob in os development...so my doubt may sound silly... :)
i was just trying to run a simple code in bochs by making a virtual floppy..the code is

org 0x7c00
bits 16
start :
cli
hlt
times 510 - ($-$$) db 0
dw 0xAA55

it was successful showing that booting from floppy...
however i thought of just using the bochs internal debugger...
on the commandline i gave breakpoint at 0x7c00 as the bootloader code starts from there..
then the next command was 'c' to continue execution till my breakpoint is hit
however i think i m not reaching the breakpoint...what i get is something like this

Next at t=0
(0) [0xfffffff0] f000:fff0 (unk. ctxt): jmp far f000:e05b ; ea5be000f0
<bochs:1> b 0x7c00
<bochs:2> c
(0).[735247] [0x000e0891] 0010:00000000000e0891 (unk. ctxt): wrmsr ; 0f30
Next at t=735248
(0) [0xfffffff0] f000:fff0 (unk. ctxt): jmp far f000:e05b ; ea5be000f0

i cant see anywhere the address 0x7c00....any idea what is wrong?
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: bochs debugging

Post by xenos »

Next at t=0
(0) [0xfffffff0] f000:fff0 (unk. ctxt): jmp far f000:e05b ; ea5be000f0
<bochs:1> b 0x7c00
<bochs:2> c
(0).[735247] [0x000e0891] 0010:00000000000e0891 (unk. ctxt): wrmsr ; 0f30
Next at t=735248
(0) [0xfffffff0] f000:fff0 (unk. ctxt): jmp far f000:e05b ; ea5be000f0
It seems that the CPU is in protected mode (first bold line) and resets due to a triple fault (second bold line). In order to figure out what is happening, it would be interesting to know:
  • How do you create the floppy image?
  • How do you boot it?
  • What does your .bochsrc file look like?
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: bochs debugging

Post by Love4Boobies »

I don't use Bochs but:
  • AFAIK, you need "xor ebx, ebx" to use breakpoints in the Bochs debugger.
  • "cli \n hlt" won't hang the system. See below:

Code: Select all

cli
hang: hlt
jmp hang
^ This is what you want because HLT only halts until an interrupt occurs and CLI only masks IRQs (not IPIs, SMIs and NMIs).

Also, use code tags in your posts.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: bochs debugging

Post by Combuster »

Not reproducable:

Code: Select all

Next at t=0
(0) [0xfffffff0] f000:fff0 (unk. ctxt): jmp far f000:e05b         ; ea5be000f0
<bochs:1> b 0x7c00
<bochs:2> c
00000003867i[BIOS ] $Revision: 1.166 $ $Date: 2006/08/11 17:34:12 $
00000480064i[KBD  ] reset-disable command received
00000720706i[PIDE ] new BM-DMA address: 0xc000
00000845301i[VBIOS] VGABios $Id: vgabios.c,v 1.66 2006/07/10 07:47:51 vruppert Exp $
00000845372i[CLVGA] VBE known Display Interface b0c0
00000845404i[CLVGA] VBE known Display Interface b0c4
00000848329i[VBIOS] VBE Bios $Id: vbe.c,v 1.58 2006/08/19 09:39:43 vruppert Exp $
00001200000i[WGUI ] dimension update x=720 y=400 fontheight=16 fontwidth=9 bpp=8
(0) Breakpoint 1, 0x00007c00 in ?? ()
Next at t=1455808
(0) [0x00007c00] 0000:7c00 (unk. ctxt): jmp .+0x003c (0x00007c3e) ; eb3c
<bochs:3>
What's your Bochs version? BIOS version? How did you get a build with debugger? How did you build the floppy image?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
paranoid
Posts: 3
Joined: Tue Apr 06, 2010 7:34 am

Re: bochs debugging

Post by paranoid »

thanks for quick reply :)
i am working on fedora 12.
i created a virtual floppy using dd command

Code: Select all

dd if=/dev/zero of=floppy.img bs=512 count=2880
then the losetup cmd:

Code: Select all

losetup /dev/loop0 floppy.img
then i formatted it to ext2

Code: Select all

 mkfs -t ext2 /dev/loop0 
finally i copied my binary image boot1.bin(the bootloader code) to the virtual floppy:

Code: Select all

dd if=boot1.bin of=/dev/loop0
my .bochsrc.txt looks like:

Code: Select all

#rom and vga bios images
romimage: file=/usr/share/bochs/BIOS-bochs-latest
vgaromimage:file= /usr/share/bochs/VGABIOS-lgpl-latest
#boot from floppy using our disk image
floppya: 1_44=/dev/loop0,status=inserted 
#logging and reporting
log:bochsout.txt
and i am using bochs 2.4.2 and here is my bios information:
BIOS Information
Vendor: Lenovo
Version: v2.06
Release Date: 05/17/07
Address: 0xE74E0
Runtime Size: 101152 bytes
ROM Size: 1024 kB
Characteristics:
ISA is supported
PCI is supported
PC Card (PCMCIA) is supported
PNP is supported
BIOS is upgradeable
BIOS shadowing is allowed
ESCD support is available
Boot from CD is supported
ACPI is supported
USB legacy is supported
AGP is supported
BIOS boot specification is supported
Targeted content distribution is supported
BIOS Revision: 1.4
Firmware Revision: 0.0
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: bochs debugging

Post by Gigasoft »

To set a breakpoint on 7c00, you should use the command vb 0:0x7c00.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: bochs debugging

Post by Love4Boobies »

No one asked you about your computer's BIOS, Combuster was referring to the Bochs BIOS...
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
paranoid
Posts: 3
Joined: Tue Apr 06, 2010 7:34 am

Re: bochs debugging

Post by paranoid »

No one asked you about your computer's BIOS, Combuster was referring to the Bochs BIOS...
i dont know how to check bochs bios version... :(
can you tell me how to do that?
To set a breakpoint on 7c00, you should use the command vb 0:0x7c00.
i have tried it but i am getting the same result.
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: bochs debugging

Post by Owen »

You wouldn't happen to have accidentally enabled the 32-bit OS hack in the Bochs configuration would you?
Post Reply