Difference between revisions of "KDB"

From eLinux.org
Jump to: navigation, search
(Kernel configuration: add information about kernel configs)
Line 36: Line 36:
  
 
== Kernel configuration ==
 
== Kernel configuration ==
In a 2.6.35 kernel, CONFIG_KGDB=y is used to configured the kgdb (target agent) for the kernel, for gdb.
+
The following descriptions are for a 2.6.35 kernel, using KDB over a serial line between host and target:
  
Use CONFIG_KGDB_SERIAL_CONSOLE=Y to share a serial console with kgdb. Sysrq-g must be used to break in initially.
+
In order to support KDB, "KGDB" support must be turned on first (even if you aren't using kgdb/gdb)
  
Selecting this will automatically set CONSOLE_POLL=N and MAGIC_SYSRQ=Y.
+
* CONFIG_KGDB=Y - turn on basic kernel debug agent support
 +
* CONFIG_KGDB_SERIAL_CONSOLE=Y - to share a serial console with kgdb.
 +
** Sysrq-g must be used to break in initially.
 +
** Selecting this will automatically set CONSOLE_POLL=N and MAGIC_SYSRQ=Y.
 +
* CONFIG_KGDB_KDB=Y - actually turn on the KDB debugger feature
  
CONFIG_KGDB_KDB=Y will include the kdb frontend for kgdb (what the heck does this mean?)
+
Optional other arguments:
 +
* CONFIG_FRAME_POINTER=Y - this allows for better backtrace support in KDB
 +
* CONFIG_DEBUG_RODATA=N - disable this in order to support hardware breakpoints on data accesses
 +
* CONFIG_KALLSYMS=Y - this adds symbolic information to the kernel, useful to see symbols instead of addresses
  
 
== Using gdb to see the kernel source listing ==
 
== Using gdb to see the kernel source listing ==

Revision as of 16:14, 22 June 2011

Here is some information about KDB - the in-kernel debugger for the Linux kernel.

The KDB and KGDB official wiki: https://kgdb.wiki.kernel.org/

Jason Wessel is the current KDB maintainer. Here is a presentation from him at LinuxCon 2010 (August 2010): http://kernel.org/pub/linux/kernel/people/jwessel/dbg_webinar/State_Of_kernel_debugging_LinuxCon2010.pdf

Here are some videos showing use of KDB and KGDB:

Documentation, up-to-date as of 2010, for KDB and KGDB is at: http://kernel.org/pub/linux/kernel/people/jwessel/kdb/

Older Information

See http://www.ibm.com/developerworks/linux/library/l-kdbug/ for a tutorial for the 2.4.20 kernel (from June 2003)

Here's an article from 2002 on KDB vs. KGDB: http://kerneltrap.org/node/112 It has a good discussion excerpt between Andrew Morton and Keith Owens about the relative merits of KDB versus KGDB.

Questions

Here are some questions to answer:

  • What kernel versions are supported?
    • 2.6.35 and on
  • what kernel configs are required to be set?
    • CONFIG_KDB
    • CONFIG_
  • how to invoke the debugger?
    • panic
    • sysrq trigger ('echo g >/proc/sysrq-trigger')
  • how to use agent-proxy to multiplex console and kdb (or is this only for kgdb?)


Kernel configuration

The following descriptions are for a 2.6.35 kernel, using KDB over a serial line between host and target:

In order to support KDB, "KGDB" support must be turned on first (even if you aren't using kgdb/gdb)

  • CONFIG_KGDB=Y - turn on basic kernel debug agent support
  • CONFIG_KGDB_SERIAL_CONSOLE=Y - to share a serial console with kgdb.
    • Sysrq-g must be used to break in initially.
    • Selecting this will automatically set CONSOLE_POLL=N and MAGIC_SYSRQ=Y.
  • CONFIG_KGDB_KDB=Y - actually turn on the KDB debugger feature

Optional other arguments:

  • CONFIG_FRAME_POINTER=Y - this allows for better backtrace support in KDB
  • CONFIG_DEBUG_RODATA=N - disable this in order to support hardware breakpoints on data accesses
  • CONFIG_KALLSYMS=Y - this adds symbolic information to the kernel, useful to see symbols instead of addresses

Using gdb to see the kernel source listing