Page 1 of 1
bochs debugging
Posted: Tue Apr 06, 2010 8:13 am
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?
Re: bochs debugging
Posted: Tue Apr 06, 2010 8:27 am
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?
Re: bochs debugging
Posted: Tue Apr 06, 2010 8:31 am
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:
^ 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.
Re: bochs debugging
Posted: Tue Apr 06, 2010 8:33 am
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?
Re: bochs debugging
Posted: Tue Apr 06, 2010 8:43 am
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:
then i formatted it to ext2
finally i copied my binary image boot1.bin(the bootloader code) to the virtual floppy:
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
Re: bochs debugging
Posted: Tue Apr 06, 2010 9:07 am
by Gigasoft
To set a breakpoint on 7c00, you should use the command vb 0:0x7c00.
Re: bochs debugging
Posted: Tue Apr 06, 2010 9:11 am
by Love4Boobies
No one asked you about your computer's BIOS, Combuster was referring to the Bochs BIOS...
Re: bochs debugging
Posted: Tue Apr 06, 2010 9:19 am
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.
Re: bochs debugging
Posted: Tue Apr 06, 2010 9:46 am
by Owen
You wouldn't happen to have accidentally enabled the 32-bit OS hack in the Bochs configuration would you?