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.
Non-ConfidentialPDF file icon PDF versionARM DUI0446Z
Copyright © 2010-2016 ARM Limited or its affiliates. All rights reserved.