[Lldb-commits] [lldb] r241051 - Ignore "push/pop {sp}" in emulation based unwinding

Tamas Berghammer tberghammer at google.com
Tue Jun 30 02:35:46 PDT 2015


Author: tberghammer
Date: Tue Jun 30 04:35:46 2015
New Revision: 241051

URL: http://llvm.org/viewvc/llvm-project?rev=241051&view=rev
Log:
Ignore "push/pop {sp}" in emulation based unwinding

These instructions confusing the unwind code because in case of a
push it assumes that the original valu of a register is pushed to
the stack what is not neccessarily true in case of SP. The same is
true for the pop (in the opposite way).

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

Added:
    lldb/trunk/test/functionalities/unwind/standard/hand_written/divmod.cpp
Modified:
    lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
    lldb/trunk/test/functionalities/unwind/standard/TestStandardUnwind.py

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=241051&r1=241050&r2=241051&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp (original)
+++ lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp Tue Jun 30 04:35:46 2015
@@ -422,13 +422,17 @@ UnwindAssemblyInstEmulation::WriteMemory
         case EmulateInstruction::eContextPushRegisterOnStack:
             {
                 uint32_t reg_num = LLDB_INVALID_REGNUM;
-                const uint32_t unwind_reg_kind = m_unwind_plan_ptr->GetRegisterKind();
+                uint32_t generic_regnum = LLDB_INVALID_REGNUM;
                 if (context.info_type == EmulateInstruction::eInfoTypeRegisterToRegisterPlusOffset)
+                {
+                    const uint32_t unwind_reg_kind = m_unwind_plan_ptr->GetRegisterKind();
                     reg_num = context.info.RegisterToRegisterPlusOffset.data_reg.kinds[unwind_reg_kind];
+                    generic_regnum = context.info.RegisterToRegisterPlusOffset.data_reg.kinds[eRegisterKindGeneric];
+                }
                 else
                     assert (!"unhandled case, add code to handle this!");
 
-                if (reg_num != LLDB_INVALID_REGNUM)
+                if (reg_num != LLDB_INVALID_REGNUM && generic_regnum != LLDB_REGNUM_GENERIC_SP)
                 {
                     if (m_pushed_regs.find (reg_num) == m_pushed_regs.end())
                     {
@@ -570,7 +574,8 @@ UnwindAssemblyInstEmulation::WriteRegist
         case EmulateInstruction::eContextPopRegisterOffStack:
             {
                 const uint32_t reg_num = reg_info->kinds[m_unwind_plan_ptr->GetRegisterKind()];
-                if (reg_num != LLDB_INVALID_REGNUM)
+                const uint32_t generic_regnum = reg_info->kinds[eRegisterKindGeneric];
+                if (reg_num != LLDB_INVALID_REGNUM && generic_regnum != LLDB_REGNUM_GENERIC_SP)
                 {
                     m_curr_row->SetRegisterLocationToSame (reg_num, /*must_replace*/ false);
                     m_curr_row_modified = true;

Modified: lldb/trunk/test/functionalities/unwind/standard/TestStandardUnwind.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/unwind/standard/TestStandardUnwind.py?rev=241051&r1=241050&r2=241051&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/unwind/standard/TestStandardUnwind.py (original)
+++ lldb/trunk/test/functionalities/unwind/standard/TestStandardUnwind.py Tue Jun 30 04:35:46 2015
@@ -40,8 +40,6 @@ class StandardUnwindTest(TestBase):
                 "__memcpy_base",         # Function reached by a fall through from the previous function
                 "__memcpy_base_aligned", # Function reached by a fall through from the previous function
                 "__subdf3",              # __aeabi_ui2d jumps into the middle of the function. Possibly missing symbol?
-                "__aeabi_ldivmod",       # llvm.org/pr23879 ("push {sp}" not handled correctly)
-                "__aeabi_uldivmod",      # llvm.org/pr23879 ("push {sp}" not handled correctly)
             ]
             no_step_function_names = [
                 "__sync_fetch_and_add_4", # Calls into a special SO where we can't set a breakpoint

Added: lldb/trunk/test/functionalities/unwind/standard/hand_written/divmod.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/unwind/standard/hand_written/divmod.cpp?rev=241051&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/unwind/standard/hand_written/divmod.cpp (added)
+++ lldb/trunk/test/functionalities/unwind/standard/hand_written/divmod.cpp Tue Jun 30 04:35:46 2015
@@ -0,0 +1,15 @@
+//===-- divmod.cpp ----------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int
+main(int argc, char const *argv[])
+{
+    signed long long a = 123456789, b = 12, c = a / b, d = a % b;
+    unsigned long long e = 123456789, f = 12, g = e / f, h = e % f;
+}





More information about the lldb-commits mailing list