6.10.2 About debugging a Linux kernel

DS-5 supports source level debugging of a Linux kernel. The Linux kernel (and associated device drivers) can be debugged in the same way as a standard ELF format executable. For example, you can set breakpoints in the kernel code, step through the source, inspect the call stack, and watch variables.

Note

User space parameters (marked __user) that are not currently mapped in cannot be read by the debugger.
To debug the kernel:
  1. Compile the kernel source using the following options:
    • CONFIG_DEBUG_KERNEL=y
      Enables the kernel debug options.
    • CONFIG_DEBUG_INFO=y
      Builds vmlinux with debugging information.
    • CONFIG_DEBUG_INFO_REDUCED=n
      Includes full debugging information when compiling the kernel.
    • CONFIG_PERF_EVENTS=n
      Disables the performance events subsystem. Some implementations of the performance events subsystem internally make use of hardware breakpoints, disrupting the use of hardware breakpoints set by the debugger. It is recommended to disable this option if you observe the debugger failing to hit hardware breakpoints or failing to report kernel module load and unload events.

      Note

      If you are working with Streamline, this option must be enabled.
    Compiling the kernel source generates a Linux kernel image and symbol files which contain debug information.

    Note

    Be aware that:
    • Other options might be required depending on the type of debugging you want to perform. Check the kernel documentation for details.
    • A Linux kernel is always compiled with full optimizations and inlining enabled, therefore:
      • Stepping through code might not work as expected due to the possible reordering of some instructions.
      • Some variables might be optimized out by the compiler and therefore not be available for the debugger.
  2. Load the Linux kernel on to the target.
  3. Load kernel debug information into the debugger.

    Note

    If the Linux kernel you are debugging runs on multiple cores, then it is recommended to select an SMP connection type when connecting the debugger. Using a single-core connection instead of an SMP connection might result in other cores halting on software breakpoints with no way to resume them.
  4. Debug the kernel as required.
Related concepts
6.10.3 About debugging Linux kernel modules
6.7 About debugging bare-metal symmetric multiprocessing systems
Related tasks
2.7 Configuring a connection to a Linux kernel
Related reference
3.2 Running, stopping, and stepping through an application
5.1 Examining the target execution environment
5.2 Examining the call stack
3.12 Handling UNIX signals
3.13 Handling processor exceptions
11.39 Debug Configurations - Files tab
11.40 Debug Configurations - Debugger tab
11.4 Breakpoints view
11.6 Commands view
11.7 Debug Control view
11.8 Disassembly view
11.14 Memory view
11.16 Modules view
11.17 Registers view
11.26 Variables view
Related information
Debugging a loadable kernel module
Non-ConfidentialPDF file icon PDF versionARM DUI0446W
Copyright © 2010-2015 ARM. All rights reserved.