Tracing the Execution Until a Breakpoint

Quicksteps:

In order to trace the code path that led to a certain point:

  • set a breakpoint at the interesting location
  • enable the instruction trace
  • run the target until it stops at the specified breakpoint
  • view the instruction trace

All steps are described in detail below.

  1. Make sure the target is stopped. Select Debug > Create Breakpoint... and set a breakpoint at the desired location.
  2. To enable the execution trace:
    1. Select View > Instruction Trace.
      The Instruction Trace window is opened.
    2. Right-click in the window and select Enable Trace from the window's pop-up menu.
      The Console window displays: itrace: LBR configuration: Trace enabled.
  3. Run or continue the target and let it execute some code (at least one branch instruction).
    The target stops at the breakpoint specified in step 1.
  4. To show the collected instruction trace, enter itrace "print" in the Console window.

    The Console window prints the output, for example:

    xdb> itrace "print"
    process.c:459    cpu_idle(void)
    if (cpuidle_idle_call())
        0xC100A125    E8 B6 A7 44 00                      call 0xC14548E0 <cpuidle_idle_call(void)>
    cpuidle.c:129    cpuidle_idle_call(void)
    {
        0xC14548E0    55                                  push ebp
        0xC14548E1    89 E5                               mov ebp, esp
        0xC14548E3    57                                  push edi
        0xC14548E4    56                                  push esi
        0xC14548E5    53                                  push ebx
        0xC14548E6    83 EC 18                            sub esp, 0x18
        0xC14548E9    3E 8D 74 26 00                      lea esi, ptr [esi]
    return -ENODEV;
        0xC14548EE    BB ED FF FF FF                      mov ebx, 0xFFFFFFED
    

    The Instruction Trace window is automatically updated, for example:

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