Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Page Contents

Table of Contents

General Considerations

Note: It is assumed that OpenOCD is built, patched and installed as per instructions on this page.

It is possible to use OpenOCD and Eclipse to source level debug the Linux kernel. This means kernel space (device drivers), not application space (at least not easily and maybe not very useful). For application space, you need to use traditional gdb, not JTAG. The reason is that Linux applications run in virtual address space, so the settings of the MMU must be considered. However, while the Linux kernel also runs at a virtual address, the address space is fixed so it is possible to use openOCD and JTAG.

...

You must build the kernel with the following configuration options. Not that =y means they must be enabled, and =n means  means they just be disabled. Please use menuconfig to confirm each one.

Note that some of these configurations can only be enabled if CONFIG_EXPERT=y.

  • CONFIG_DEBUG_INFO=y
  • CONFIG_DEBUG_INFO_REDUCED=n
  • CONFIG_DEBUG_INFO_SPLIT=n
  • CONFIG_RANDOMIZE_BASE=n
  • CONFIG_EXPERT=y
  • CONFIG_UNMAP_KERNEL_AT_EL0=n

...

To debug modules:

  • CONFIG_KALLSYMS=y

To make sure the HW breakpoint resources are not touched during boot :(as in, when the kernel boots, it clears all hardware breakpoints)

  • CONFIG_CORESIGHT=n
  • PERF_EVENTS=n

To remove code optimization:

  • Because of the default compiler optimization level (-O2), stepping thru the code may be problematic / unpredictable. Using menuconfig you can only select between -O2 and -Os (CC_OPTIMIZE_FOR_PERFORMANCE, CC_OPTIMIZE_FOR_SIZE). There's also a relatively new CC_OPTIMIZE_FOR_PERFORMANCE_O3 to select -O3 but no real way to choose a lower optimization level. It is not mandatory but to get a code flow that is easier to follow, you can manually hack the main Makefile (the one at the base of the source tree) and turn -O2 into -O1:

Kernel Boot Arguments:

You need to add the follow to your kernel boot arguments:

...

Then by launching the debug session (click on the "bug" icon) you should see something like this.

Note: Remove All Breakpoints if something unexpected happens during the launch.

...