[Lldb-commits] [lldb] r213914 - Fix an x86 assembler stack unwind calculation for non-volatile registers.

Todd Fiala todd.fiala at gmail.com
Thu Jul 24 18:15:34 PDT 2014


Author: tfiala
Date: Thu Jul 24 20:15:34 2014
New Revision: 213914

URL: http://llvm.org/viewvc/llvm-project?rev=213914&view=rev
Log:
Fix an x86 assembler stack unwind calculation for non-volatile registers.

This change has the practical effect of fixing some backtrace
scenarios that would fail with inferiors running on the Android Art
host-side JVM under Linux x86_64 on Ubuntu 14.04.

See this lldb-commits thread for more details:
http://lists.cs.uiuc.edu/pipermail/lldb-commits/Week-of-Mon-20140721/011988.html

Change by Tong Shen.
Reviewed by Jason Molenda.

Tested:
Ubuntu 14.04 x86_64, clang-3.5-built lldb.
MacOSX 10.10 Preview 4, Xcode 6 Beta 4-built lldb.

Modified:
    lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp

Modified: lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp?rev=213914&r1=213913&r2=213914&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp (original)
+++ lldb/trunk/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp Thu Jul 24 20:15:34 2014
@@ -373,6 +373,12 @@ bool AssemblyParse_x86::push_reg_p (int&
 
 //  movq %rax, -0x10(%rbp) [0x48 0x89 0x45 0xf0]
 //  movl %eax, -0xc(%ebp)  [0x89 0x45 0xf4]
+
+// The offset value returned in rbp_offset will be positive -- 
+// but it must be subtraced from the frame base register to get
+// the actual location.  The positive value returned for the offset
+// is a convention used elsewhere for CFA offsets et al.
+
 bool AssemblyParse_x86::mov_reg_to_local_stack_frame_p (int& regno, int& rbp_offset) {
     uint8_t *p = m_cur_insn_bytes;
     int src_reg_prefix_bit = 0;
@@ -633,7 +639,13 @@ AssemblyParse_x86::get_non_call_site_unw
             {
                 row->SetOffset (current_func_text_offset + insn_len);
                 UnwindPlan::Row::RegisterLocation regloc;
-                regloc.SetAtCFAPlusOffset (-row->GetCFAOffset());
+
+                // stack_offset for 'movq %r15, -80(%rbp)' will be 80.
+                // In the Row, we want to express this as the offset from the CFA.  If the frame base
+                // is rbp (like the above instruction), the CFA offset for rbp is probably 16.  So we
+                // want to say that the value is stored at the CFA address - 96.
+                regloc.SetAtCFAPlusOffset (-(stack_offset + row->GetCFAOffset()));
+
                 row->SetRegisterInfo (lldb_regno, regloc);
                 unwind_plan.AppendRow (row);
                 // Allocate a new Row, populate it with the existing Row contents.





More information about the lldb-commits mailing list