Author: tberghammer
Date: Fri Feb 19 04:59:25 2016
New Revision: 261318

URL: http://llvm.org/viewvc/llvm-project?rev=261318&view=rev
Log:
Stack unwinding emulation: handle adjustment of FP

This change is improving the instruction emulation based unwinding to
handle when the frame pointer is adjusted (increment/decrement) after
it has been initialized. The situation can occur in the prologue of
some function where FP is adjusted before it is copied back to SP.

Example code (thumb, generated by gcc 4.8):
< +0>: push  {r4, r7, lr}
< +2>: sub   sp, #0x14
< +4>: add   r7, sp, #0x0
...
<+50>: adds  r7, #0x14 ; The CL fixes the handling of this instruction
<+52>: mov   sp, r7    ; Previously unwinding from here was broken
<+54>: pop   {r4, r7, pc}

Differential revision: http://reviews.llvm.org/D17295

Modified:
    
lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp

Modified: 
lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp?rev=261318&r1=261317&r2=261318&view=diff
==============================================================================
--- 
lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
 Fri Feb 19 04:59:25 2016
@@ -554,7 +554,6 @@ UnwindAssemblyInstEmulation::WriteRegist
         case EmulateInstruction::eContextTableBranchReadMemory:
         case EmulateInstruction::eContextWriteRegisterRandomBits:
         case EmulateInstruction::eContextWriteMemoryRandomBits:
-        case EmulateInstruction::eContextArithmetic:
         case EmulateInstruction::eContextAdvancePC:    
         case EmulateInstruction::eContextReturnFromException:
         case EmulateInstruction::eContextPushRegisterOnStack:
@@ -573,6 +572,22 @@ UnwindAssemblyInstEmulation::WriteRegist
 //            }
             break;
 
+        case EmulateInstruction::eContextArithmetic:
+            {
+                // If we adjusted the current frame pointer by a constant then 
adjust the CFA offset
+                // with the same amount.
+                lldb::RegisterKind kind = m_unwind_plan_ptr->GetRegisterKind();
+                if (m_fp_is_cfa && reg_info->kinds[kind] == 
m_cfa_reg_info.kinds[kind] &&
+                    context.info_type == 
EmulateInstruction::eInfoTypeRegisterPlusOffset &&
+                    context.info.RegisterPlusOffset.reg.kinds[kind] == 
m_cfa_reg_info.kinds[kind])
+                {
+                    const int64_t offset = 
context.info.RegisterPlusOffset.signed_offset;
+                    m_curr_row->GetCFAValue().IncOffset(-1 * offset);
+                    m_curr_row_modified = true;
+                }
+            }
+            break;
+
         case EmulateInstruction::eContextAbsoluteBranchRegister:
         case EmulateInstruction::eContextRelativeBranchImmediate:
             {


_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to