libunwind-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libunwind] Updating the stack pointer in dwarf_cursor


From: Max Asbock
Subject: [libunwind] Updating the stack pointer in dwarf_cursor
Date: Fri, 27 Aug 2004 10:52:24 -0700

When unwinding unoptimized code on x86_64 the value for RSP in
dwarf_cursor retains the original value obtained from ucontext and
doesn't get updated. So if you do
unw_get_reg (&cursor, UNW_REG_SP, &sp);
you always get the original value, regardless of which frame you are in.

Here is why:

gcc generates:

call:      push %RIP
prologue:  pushq %RBP
           movq  %SRSP, %RBP

the corresponding dwarf unwind info is (use readelf -w=f to see it)
CIE:
  DW_CFA_def_cfa: r7 ofs 8
  DW_CFA_offset: r16 at cfa-8
FDE:  
  DW_CFA_advance_loc: 1 to <x>
  DW_CFA_def_cfa_offset: 16
  DW_CFA_offset: r6 at cfa-16
  DW_CFA_advance_loc: 3 to <x+3>
  DW_CFA_def_cfa_reg: r6

After run_cfi_program ran on these commands the state record says
CFA is stored in r6 (RBP) offset 8
r6 (RBP) and r16 (RIP) are stored in memory on the stack
apply_reg_state then updates the CFA in the cursor as well as RBP and
RIP, but there is no update to RSP.
I think we need to somehow relate the CFA and RSP and update RSP
accordingly (we already do a similar thing for the case when the CFA is
stored in RSP). I haven't come up with a solution yet, but I will think
about it some more.

max




reply via email to

[Prev in Thread] Current Thread [Next in Thread]