KGDB Getting Started

KGDB — Getting Started

KGDB (Linux Kernel Source Level Debugger) allowed developers to debug the running Linux kernel using GDB — the standard GNU debugger — connected over a serial connection or network link to the target machine. This getting-started guide covers the basic setup for using KGDB on a development machine, originally written for the 2004-2005 era (Linux kernel 2.5 and early 2.6).

Prerequisites

  • A development host running Linux with GDB installed
  • A target machine to debug (this could be a second physical machine, a VM, or in some configurations the same machine as the host)
  • A way to connect host to target — typically a null-modem serial cable, or a network connection for KGDB-over-Ethernet
  • A Linux kernel built with KGDB support compiled in

Basic workflow

  1. Patch and build the kernel with KGDB support enabled. This required applying the KGDB patches to the kernel source tree, then building normally with the KGDB-related CONFIG options turned on.
  2. Configure the target machine to boot with KGDB enabled. This typically meant adding KGDB-specific boot arguments and ensuring the serial port (or network interface) used for the debug connection was properly set up.
  3. Connect from the host using GDB’s remote debugging mode. Once the target was paused at a KGDB break point, the host’s GDB session could inspect kernel state — variables, stack frames, structure contents — as if debugging a normal userspace program.
  4. Set breakpoints, step through code, and inspect kernel state using standard GDB commands.

Common first-time issues

The most frequent setup problems involved serial port configuration (wrong baud rate or wrong device), GDB version mismatches between host and the kernel’s debug symbols, and forgetting to compile in KGDB support before building the kernel. The KGDB FAQ and troubleshooting guide cover the most common issues.

Next steps after initial setup

Once you have a working KGDB connection, the natural next steps are reading the Kernel Debugging guide for the techniques specific to kernel debugging (which differ from userspace debugging in important ways), and the Using KGDB guide for the day-to-day workflow patterns. For architecture-specific notes, see x86_64 and PowerPC.

Modern context

Mainline Linux merged KGDB-equivalent functionality starting around the 2.6.26 kernel release. Modern Linux kernels include this support natively — no separate patch needed. The modern equivalent setup is documented in the Linux kernel’s Documentation/dev-tools/kgdb.rst file. The basic workflow (connect GDB from host, debug remote kernel) is unchanged from the LinSys era.


From the archive

 
Getting KGDB
  Home
  Introduction
  Getting KGDB
  Using KGDB
  Credits
  Miscellaneous
  Troubleshooting
  FAQ
  Support
  About KGDB
Downloads Development Version

You can obtain a KGDB
patch and a gdb to use with it from the downloads page. This page contains
the released versions of kgdb. If you want the bleeding edge kgdb, you
can use the Development Version of KGDB. It may
not be stable, though.

Current KGDB release is
2.2. Here is a list of downloads for current relesae.
The kgdb patch: linux-2.6.7-kgdb-2.2.tar.bz2.
GDB for i386: gdbmod-2.2.bz2
GDB for x86_64: x86_64-pc-linux-gdbmod-2.2.bz2

Leave a Comment