Page 1 of 1
Debugging my OS
Posted: Sun Apr 22, 2012 8:32 am
by hegde1997
Hello,
I am using qemu to emulate my OS on windows. Now i am stuck with idt or gdt or both. My code looks all right. But as a whole when i type my irq 0 handling routine doesn't get called and my irq1 handling routine never gets called even once in a few seconds. So i thought to use debugger. I don't know which and how. I thought about gdb but in many places they told remote debugging OS but i don't want any remote debugging. My OS is running on qemu and want to debug my OS.
Re: Debugging my OS
Posted: Sun Apr 22, 2012 8:45 am
by JamesM
Firstly, have you actually enabled interrupts?
Re: Debugging my OS
Posted: Sun Apr 22, 2012 8:45 am
by bubach
I don't know if qemu even has an internal debugger, but bochs do - and I wouldn't survive long without it.
For Bochs 2.5.1 here's an example config which uses a 1.44mb floppy (inserted in A: or mounted as A:)
Code: Select all
# configuration file generated by Bochs
#
# for BOS 0.05, as mounted img or
# physical drive A:\
#
#plugin_ctrl: unmapped=1, biosdev=1, speaker=1, extfpuirq=1, gameport=1, pci_ide=1, acpi=1, ioapic=1
config_interface: win32config
display_library: win32
megs: 32
#romimage: file="C:\Program\Bochs-2.5.1\BIOS-bochs-latest"
#vgaromimage: file="C:\Program\Bochs-2.5.1\VGABIOS-lgpl-latest"
boot: floppy
floppy_bootsig_check: disabled=0
magic_break: enabled=1
floppya: type=1_44, 1_44="a:", status=inserted
# no floppyb
After that you run "bochsdbg.exe" with that config, and you will have to press "C" for continue in the console to let it run pass BIOS code and get into your kernel. To stop at any point in your kernel, insert assembly "xchg bx,bx" which bochs will recognize as a break-point.
You can then press (in the debug console):
C - continue execution
S - step one instruction forward
R - show register contents
X - show memory content at hex location, like "x 0x7c00"
Hope that helps
Re: Debugging my OS
Posted: Sun Apr 22, 2012 11:20 am
by iansjack
When running in qemu it is a remote host (which just happens to be running on the same computer). Follow the instructions for gdb specifying the remote host as "localhost". You can also use the built-in qemu monitor to inspect memory, debug code, display registers and virtual memory mapping, etc.
If you find that difficult, try running under SimNow which has a much more accessible built-in debugger.
Re: Debugging my OS
Posted: Sun Apr 22, 2012 11:36 am
by bluemoon
If you find that difficult, overcome it or give up osdev, really.
debugger is critical tool for osdev.
for qemu, you can start it with -S -s switch, which correspond to gdb-stub and suspend.
then you can use gdb to connect to gdb as above mentioned.
you can also provide gdb with symbol file and put break points in functions, just as debugging ordinary program.