4 ms·
how do debug an OS? is the kernel debugger support from the OS, or it is from an even lower level of the system? Do you get the debugability automatically? or
by billconan 11y ago
how do debug an OS? is the kernel debugger support from the OS, or it is from an even lower level of the system?
Do you get the debugability automatically? or you have to code to support the debugger?
- linuxlizard 11y agoDebugging an OS: - printf - printf to serial port - LEDs attached to GPIOs
- jvns 11y agothe easiest way I found was to attach gdb to qemu (since you're normally running the OS in an emulator). there are instructions for how to do this in a comment on this blog post: http://jvns.ca/blog/2013/12/04/day-37-how-a-keyboard-works/ http://jvns.ca/blog/2013/12/04/day-37-how-a-keyboard-works/ here are the instructions: > Sam Rose Julia Evans • 2 years ago > If you haven't yet experienced the joys of remote debugging with QEMU and gdb, you should totally try it out. > Run qemu with the flag "-monitor stdio" and that should give you a terminal into QEMU. Then in that terminal, run "gdbserver" and it'll open up a gdb server on port 1234. > Then, in another terminal, open gdb and run "target remote :1234" to connect to the gdbserver running in qemu. > At first you'll find that gdb has no fucking idea what's going on. This is because it has no symbol data, so you'll need to load your kernel binary into it with the "file" command. > After loading your kernel symbol table, you should be free to roam around the inside of your kernel using gdb as normal. If gdb isn't familiar to you, I personally really enjoyed Beej's Quick Guide to GDB: http://beej.us/guide/bggdb/ http://beej.us/guide/bggdb/ (pretty much everything by
- phil-opp 11y agoQEMU supports gdb out of the box. Unfortunately gdb has some problems with the transition to 64 bit, but fixing it is relatively easy (you need to build gdb from source though). I just wrote a guide that should make it straightforward: http://os.phil-opp.com/set-up-gdb.html http://os.phil-opp.com/set-up-gdb.html
- phil-opp 11y agoIt's a bit more complicated for real hardware. I think it could be done by using the serial port and hardware breakpoint registers.