Skip to main content
KGDB (Kernel GNU Debugger) provides live source-level debugging of a running Qualcomm® Linux kernel. A host machine running GDB connects to the target device over a serial port and can set breakpoints, inspect registers, and step through kernel code, including for dynamically loaded modules.

Required kernel configuration

Enable the following Kconfig options and rebuild the kernel:
Verify on a running system:

Serial setup

KGDB communicates over a serial port using the kgdboc (KGDB over console) driver.

Kernel command-line parameters

Add the following to KERNEL_CMDLINE_EXTRA in meta-qcom/conf/machine/include/qcom-<SoC>.conf:

Disable the watchdog

The Qualcomm SoC watchdog resets the device if the kernel stops responding. Disable it before starting a KGDB session to prevent unexpected resets:

Enter debug mode

Choose one of the following methods to pause the kernel and activate the KGDB stub.

Method 1: kgdbwait (boot-time)

When kgdbwait is present on the kernel command line, the kernel stops during boot and prints the following message on the serial console:
Connect GDB from the host before the kernel proceeds.

Method 2: Magic SysRq (runtime)

From a shell on the target:
The kernel immediately suspends and waits for GDB.

Method 3: Compile-time breakpoint

Insert a hard breakpoint in driver source code:
Rebuild and flash the kernel. The breakpoint fires when the code path executes.

Method 4: Kernel panic (exception-driven)

The kernel automatically enters KGDB mode when an unhandled exception or panic occurs. To deliberately trigger a crash for testing:

Connect GDB from the host

Install gdb-multiarch on the host machine:

Linux host

Windows host

On Windows, set the COM port number above 16 in Device Manager and use the \\.\comN path syntax:
Expected output after connecting:

GDB debug session

Essential GDB commands

Table: GDB command reference

Load module symbols

To debug a dynamically loaded kernel module, retrieve the .text section address from the target:
Then load the symbol file in GDB:
Example:
For the full upstream KGDB documentation, see Debugging kernel and modules via gdb.