• Alexandre Truong's avatar
    perf arm64: Inject missing frames when using 'perf record --call-graph=fp' · b9f6fbb3
    Alexandre Truong authored
    When unwinding using frame pointers on ARM64, the return address of the
    current function may not have been pushed into the stack when a function
    was interrupted, which makes perf show an incorrect call graph to the
    user.
    
    Consider the following example program:
    
      void leaf() {
          /* long computation */
      }
    
      void parent() {
          // (1)
          leaf();
          // (2)
      }
    
      ... could be compiled into (using gcc -fno-inline -fno-omit-frame-pointer):
    
      leaf:
          /* long computation */
          nop
          ret
      parent:
          // (1)
          stp     x29, x30, [sp, -16]!
          mov     x29, sp
          bl      parent
          nop
          ldp     x29, x30, [sp], 16
          // (2)
          ret
    
    If the program is interrupted at (1), (2), or any point in "leaf:", the
    call graph will skip the callers of the current function. We can unwind
    using the dwarf info and check if the return addr is the same as the LR
    register, and inject the missing frame into the c...
    b9f6fbb3
Build 9.56 KB