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.
NoteUser space parameters (marked
__user) that are not currently mapped in cannot be read by the debugger.
To debug the kernel:
- Compile the kernel source using the following options:
Enables the kernel debug options.
vmlinuxwith debugging information.
Includes full debugging information when compiling the kernel.
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.
NoteIf you are working with Streamline,
CONFIG_PERF_EVENTSmust be enabled.
Compiling the kernel source generates a Linux kernel image and symbol files which contain debug information.
NoteBe 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.
- Load the Linux kernel on to the target.
- Load kernel debug information into the debugger.
NoteIf 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.
- Debug the kernel as required.