Sunday, April 13, 2014

Linux kernel debuggers: Overview


Linux kernel and kernel modules can be debugged with either kdb front end or kgdb/gdb front end. Both the front ends rely on the same backend/core debug engine.

System debugger internals - Architecture

TBD.

Kgdb/gdb frontend

  • Source level debugging
  • Provides debugging interface over a serial console. So, to debug using kgdb, requires an external development machine with serial port connected to target/test machine.  Keyboard based debugging is not possible with kgdb. The development machine is expected to have the binaries & source files. The target/test machine is expected to execute the kernel binaries. 
  • Debugging capabilities are same as gdb used for user space application debugging. Fore more details about gdb, please see GNU's GDB documentation at http://sourceware.org/gdb/current/onlinedocs/gdb/.
  • Requires kernel recompilation to enable kdb compile flags - CONFIG_KGDB, CONFIG_KGDB_SERIAL_CONSOLE. In addition, enabling CONFIG_FRAME_POINTER helps get better stack traces.
  • Can be enabled from boot parameters or in sysfs interface after boot up.

kdb frontend
  • Very basic debugger: Assembly level (not C source code level) debugging, but we can access function names if the kernel were compiled with CONFIG_KALLSYMS.
  • Provides a in-built debugger interface rather than mandate external interface. So, can be debugged without requiring a second machine. However, kdb provides flexibility to interface through console directly or through serial console.
  • Basic debugging capability: breakpoints, single stepping, read/write memory, print backtrace, etc
  • Requires kernel recompilation to enable all kgdb flags & kdb compile flags - CONFIG_KGDB, CONFIG_KGDB_SERIAL_CONSOLE, CONFIG_KGDB_KDB & CONFIG_KDB_KEYBOARD. In addition, enabling CONFIG_FRAME_POINTER helps get better stack traces.
  • Can be enabled from boot parameters or in sysfs interface after boot up.


We can dynamically switch from kdb front end to kgdb front end and vice versa.

No comments:

UA-48797665-1