Use Case: Setting a Breakpoint at the Beginning of Kernel Initialization

In many cases you may want to stop target execution early during kernel initialization in order to walk up to some point of failure. The easiest way to do this is to set a hardware breakpoint on the start_kernel function in the Linux kernel.

Quicksteps:

  1. Stop the target prior to kernel execution.
  2. Load the kernel symbols.
  3. Create a hardware breakpoint at the start_kernel function.
  4. Resume target execution until the breakpoint is hit.

All steps are described in detail below.

  1. To stop the target prior to kernel execution, choose one of the following steps:
    • Reset the target and stop at the reset vector.
    • Boot the target to the OS boot loader or BIOS boot selection screen and stop the target execution in the debugger.
  2. Use the LOAD command to load your kernel symbols. See also Use Case: Loading Symbols for the Linux* Kernel.
  3. Select View > Source Files to open the Source Files window.
  4. Double-click the file main.c and search for the start_kernel function in the source code of this file.
  5. Select Debug > Create Breakpoint...to open the Create Breakpoint dialog box.
  6. In the Location field, enter start_kernel.
  7. Check the Hard checkbox.
  8. Click OK.

    The breakpoint is set and is displayed with a red icon at the start_kernel function in the Source window of main.c.

  9. Select Run > Run or Continue to resume the target execution.

    The target stops at the breakpoint you set. A yellow pointer in the Source window indicates the current execution point is at your breakpoint.

For more complete information about compiler optimizations, see our Optimization Notice.