[Lldb-commits] [PATCH] D21221: Fix for PrintStackTraces

Ravitheja Addepally via lldb-commits lldb-commits at lists.llvm.org
Tue Jun 14 01:59:56 PDT 2016


ravitheja added a comment.

so regarding this particular situation I want to give little more insight ->
It starts out from here

  0x40143a <+346>: movabsq $0x403e32, %rdi           ; imm = 0x403E32 
  0x401444 <+356>: movb   $0x0, %al
  0x401446 <+358>: callq  0x400d30                  ; symbol stub for: printf
  0x40144b <+363>: movq   0x6071c0, %rdi
  0x401453 <+371>: movl   %eax, -0xdc(%rbp)

->0x401459 <+377>: callq  0x400ed0                  ; symbol stub for: fflush

  0x40145e <+382>: movl   $0x40, %esi
  0x401463 <+387>: leaq   -0xb0(%rbp), %rdi
  0x40146a <+394>: movq   0x607158, %rdx
  0x401472 <+402>: movl   %eax, -0xe0(%rbp)

(lldb) disassemble
a.out`fflush:
->  0x400ed0 <+0>:  jmpq   *0x206212(%rip)           ; _GLOBAL_OFFSET_TABLE_ + 232

  0x400ed6 <+6>:  pushq  $0x1a
  0x400edb <+11>: jmp    0x400d20

(lldb) disassemble 
->  0x400d20:       pushq  0x2062e2(%rip)            ; _GLOBAL_OFFSET_TABLE_ + 8

  0x400d26:       jmpq   *0x2062e4(%rip)           ; _GLOBAL_OFFSET_TABLE_ + 16   I think this jump goes to fflush.

ld-linux-x86-64.so.2`___lldb_unnamed_symbol95$$ld-linux-x86-64.so.2:

  0x7ffff7df04a0 <+0>:  subq   $0x38, %rsp    -> The testcase tries to unwind out of here and fails.
  0x7ffff7df04a4 <+4>:  movq   %rax, (%rsp)
  0x7ffff7df04a8 <+8>:  movq   %rcx, 0x8(%rsp)
  0x7ffff7df04ad <+13>: movq   %rdx, 0x10(%rsp)
  0x7ffff7df04b2 <+18>: movq   %rsi, 0x18(%rsp)
  0x7ffff7df04b7 <+23>: movq   %rdi, 0x20(%rsp)
  0x7ffff7df04bc <+28>: movq   %r8, 0x28(%rsp)
  0x7ffff7df04c1 <+33>: movq   %r9, 0x30(%rsp)
  0x7ffff7df04c6 <+38>: movq   0x40(%rsp), %rsi

Now as you can see, from inside fflush its not possible for the assembly unwind to figure out the situation. 
@jasonmolenda The functions I posted in the lldb-dev are the same, here i am just posting how it got there.
There is eh_frame information for these functions, that is able to correctly point out the CFA.

lldb) image show-unwind --address 0x7ffff7df04a0
UNWIND PLANS for ld-linux-x86-64.so.2`___lldb_unnamed_symbol95$$ld-linux-x86-64.so.2 (start addr 0x7ffff7df04a0)

Asynchronous (not restricted to call-sites) UnwindPlan is 'assembly insn profiling'
Synchronous (restricted to call-sites) UnwindPlan is 'eh_frame CFI'

Assembly language inspection UnwindPlan:
This UnwindPlan originally sourced from assembly insn profiling
This UnwindPlan is sourced from the compiler: no.
This UnwindPlan is valid at all instruction locations: yes.
Address range of this UnwindPlan: [ld-linux-x86-64.so.2..text + 88512-0x0000000000015a30)
row[0]:    0: CFA=rsp +8 => rsp=CFA+0 rip=[CFA-8] 
row[1]:    4: CFA=rsp+64 => rsp=CFA+0 rip=[CFA-8] 
row[2]:   94: CFA=rsp -8 => rsp=CFA+0 rip=[CFA-8]

eh_frame UnwindPlan:
This UnwindPlan originally sourced from eh_frame CFI
This UnwindPlan is sourced from the compiler: yes.
This UnwindPlan is valid at all instruction locations: no.
Address range of this UnwindPlan: [ld-linux-x86-64.so.2..text + 88512-0x0000000000015a21)
row[0]:    0: CFA=rsp+24 => rip=[CFA-8] 
row[1]:    4: CFA=rsp+80 => rip=[CFA-8] 
row[2]:   94: CFA=rsp +8 => rip=[CFA-8]

Arch default UnwindPlan:
This UnwindPlan originally sourced from x86_64 default unwind plan
This UnwindPlan is sourced from the compiler: no.
This UnwindPlan is valid at all instruction locations: no.
row[0]:    0: CFA=rbp+16 => rbp=[CFA-16] rsp=CFA+0 rip=[CFA-8]

Arch default at entry point UnwindPlan:
This UnwindPlan originally sourced from x86_64 at-func-entry default
This UnwindPlan is sourced from the compiler: no.
This UnwindPlan is valid at all instruction locations: not specified.
row[0]:    0: CFA=rsp +8 => rsp=CFA+0 rip=[CFA-8]

As you can see the eh_frame UnwindPlan is correct here.


http://reviews.llvm.org/D21221





More information about the lldb-commits mailing list