[Lldb-commits] [lldb] r113288 - in /lldb/trunk/source/Plugins/ABI: MacOSX-i386/ABIMacOSX_i386.cpp SysV-x86_64/ABISysV_x86_64.cpp

Sean Callanan scallanan at apple.com
Tue Sep 7 14:23:34 PDT 2010


Author: spyffe
Date: Tue Sep  7 16:23:34 2010
New Revision: 113288

URL: http://llvm.org/viewvc/llvm-project?rev=113288&view=rev
Log:
Updated the x86_64 and i386 ABIs to chain RBP
(i.e., leave the value the same, so that a new
stack frame will be linked to the previous
stack) rather than zeroing out RBP.

This fixes calls to dlopen(), for example, which
does a backtrace to see which image is calling
it.

Modified:
    lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
    lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp

Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp?rev=113288&r1=113287&r2=113288&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp Tue Sep  7 16:23:34 2010
@@ -61,9 +61,12 @@
 {
     RegisterContext *reg_ctx = thread.GetRegisterContext();
     if (!reg_ctx)
-        return false;
-    
+        return false;    
+#define CHAIN_EBP
+
+#ifndef CHAIN_EBP
     uint32_t ebpID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP);
+#endif
     uint32_t eipID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC);
     uint32_t espID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP);
     
@@ -94,10 +97,12 @@
     if (!reg_ctx->WriteRegisterFromUnsigned(espID, sp))
         return false;
     
+#ifndef CHAIN_EBP
     // %ebp is set to a fake value, in our case 0x0x00000000
     
     if (!reg_ctx->WriteRegisterFromUnsigned(ebpID, 0x00000000))
         return false;
+#endif
     
     // %eip is set to the address of the called function.
     

Modified: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp?rev=113288&r1=113287&r2=113288&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp Tue Sep  7 16:23:34 2010
@@ -64,7 +64,12 @@
         return false;
 
     uint32_t rdiID = reg_ctx->GetRegisterInfoByName("rdi", 0)->reg;
+#define CHAIN_RBP
+    
+#ifndef CHAIN_RBP
     uint32_t rbpID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP);
+#endif
+    
     uint32_t ripID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC);
     uint32_t rspID = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP);
 
@@ -90,10 +95,12 @@
     if (!reg_ctx->WriteRegisterFromUnsigned(rspID, sp))
         return false;
 
+#ifndef CHAIN_RBP
     // %rbp is set to a fake value, in our case 0x0000000000000000.
 
     if (!reg_ctx->WriteRegisterFromUnsigned(rbpID, 0x000000000000000))
         return false;
+#endif
 
     // %rip is set to the address of the called function.
 





More information about the lldb-commits mailing list