KGDB Version 2
KGDB for Linux 2.6.8-rc1 onwards uses early_param to wait for connection from remote GDB much earlier than previous versions of KGDB.
GDB detach and reattach:
It's possible to detach GDB from a running kernel and reattach it. This operation is as simple as using GDB detach and target remote commands. If GDB dies or has to be killed because of some problem, a new instance of GDB can be started and connected to KGDB as usual with a target remote command.
Support for ethernet:
This feature is still under development. It will allow use of ethernet as gdb-kgdb communication medium instead of a serial cable.
Support for different processor architectures:
i386, powerpc, x86_64, mips and ia64 architectures are supported.
KGDB Version 1
Source level debugging:
A Linux kernel can be debugged at source level using GDB and KGDB. Information about the source code line where a kernel entered kgdb is shown by gdb. Back trace command backtrace shows the function call trace at that point. Variables in functions in the stack trace can be seen using print command after going to the function using frame command.
Support for threads in a kernel:
GDB command info threads can be used to get a listing of threads running in a kernel being debugged. The command also shows the function and source code line where these threads are either running or are waiting for some event. User can switch to any thread and then continue the execution or see its state. Complete state of a thread is available from backtrace and info registers commands. These commands operate on a thread set by thread command.
Support for Multiprocessor systems:
When any one of the processors enters KGDB, KGDB forces all other processors in the system to enter KGDB. Once all processors are in KGDB, it contacts GDB and allows the kernel state to be analyzed through GDB. nmi-watchdog factility is available on multiprocessor systems. When a processor disables interrupts for a long time, nmi-watchdog is called which results in a kernel panic. In presense of KGDB, nmi-watchdog enters KGDB instead, allowing kernel state at the time of nmi-watchdog to be analyzed.
IA32 hardware debuging suppport:
IA32(x86) processors have advanced debugging capabilities available through special purpose debug registers. These facilities are supported by KGDB. IA32 hardware debugging provides watchpoints, which are breakpoints that are triggered when data at a specified address is accessed or modified. Watchpoints can be used to find where some kernel data is being modified.
Console output through GDB:
If enabled in KGDB, KGDB writes console output to GDB which GDB displays on the console it is running on. Getting console output from GDB makes it unecessary to look at the screen of the test machine for seeing kernel messages. Since test machine and developement machine can share the same monitor and keyboard, it saves the trouble of switching monitor to the test machine whenever kernel messages are to be seen.