There seems to be a problem with the Freedos bootloader. (It appears that the bootcode can't find the kernel in certain circumstances.)
So I'm trying to debug the bootloader in qemu with gdb. Following the instructions found on several wiki and freely available online course materials, I run qemu like this
qemu-system-i386 -fda fdboot.img -boot a -s -S
And then connect gdb like this
$ gdb
(gdb) target remote localhost:1234
I can step through the first 10 - 12 instructions with si
which I assume is the SeaBIOS.
But past that, when I try to step into bootloader code, it continues execution without breaking, all the way up to the FreeDos menu prompt. This totally skips the bootloader code which I would like to examine step by step as it is executed.
What do I need to do so that I can step though the bootloader?
[You can download the freedos floppy images from the project website if you want to try yourself.]
In order to use gdb, launch QEMU with the -s and -S options. The -s option will make QEMU listen for an incoming connection from gdb on TCP port 1234, and -S will make QEMU not start the guest until you tell it to from gdb.
Setup a debugger connection to a Windows Image on QEMU Download and install QEMU on Windows. Configure a target QEMU Virtual Windows Image to launch with the required network and BIOS/UEFI settings for debugging. Start the QEMU environment, using the configured launch script. Start the gdbserver on QEMU.
Run the code by typing “run or r”. If you haven't set any breakpoints, run command will simply execute the full program. 11. To see the value of variable, type “print variable_name or p variable_name“.
Works fine here using qemu 1.3 and gdb 7.3.50.20111117 (you didn't say what versions you used). I was able to single step tons of instructions until I got bored and placed a breakpoint to catch the bootloader:
(gdb) br *0x7c00
Breakpoint 1 at 0x7c00
(gdb) c
Continuing.
Breakpoint 1, 0x00007c00 in ?? ()
(gdb) x/i $eip
=> 0x7c00: jmp 0x7c3e
Note that I have set gdb to 16 bit mode first using set architecture i8086
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With