$ qemu -cdrom image.iso -s -SThe lower-case -s tells QEMU to wait for the GDB session at port 1234. The capital -S instructs QEMU not to start the simulation before you enter c from the GDB prompt.
Once you have QEMU waiting for a connection at port 1234, do the following:
(gdb) target remote localhost:1234After that, you should see something like this:
Remote debugging using localhost:1234GDB is now ready and you can start the simulation, but you still don't have any symbols. GDB allows you to load the symbol information using the symbol command:
0x0000fff0 in ?? ()
(gdb) symbol kernel/kernel.rawInstead of the kernel symbols, you can load symbols of any of the userspace ELF binaries, but bare in mind that you can have only one set of symbols loaded at a time. Now you are ready to proceed and can start the simulation:
(gdb) cLater you can break back to the debugger by pressing Ctrl+C in the GDB window.
This method gives you a nice debugging features for QEMU targets on which HelenOS runs. One problem is that the simulator cannot separate the execution of the kernel from the execution of the separate userspace tasks so if you single step long enough, there will be some context switches that you won't be able to filter out. In this light, the debugging approach seems to be most suitable for debugging the kernel.