Debugging kernel code
Debugging application code helps you gain insight into the way code works and what is happening when it misbehaves and you can do the same with the kernel, with some limitations.
You can use kgdb
for source level debugging, in a manner similar to remote debugging with gdbserver
. There is also a self-hosted kernel debugger, kdb
, that is handy for lighter weight tasks such as seeing if an instruction is executed and getting the backtrace to find out how it got there. Finally, there are kernel oops messages and panics, which tell you a lot about the cause of a kernel exception.
Debugging kernel code with kgdb
When looking at kernel code using a source debugger, you must remember that the kernel is a complex system, with real-time behaviors. Don't expect debugging to be as easy as it is for applications. Stepping through code that changes the memory mapping or switches context is likely to produce odd results.
kgdb
is the name given to the kernel GDB stubs that have been...