[Lldb-commits] [PATCH] D12699: Change the looping stack detection code

Tamas Berghammer via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 9 03:28:16 PDT 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL247133: Change the looping stack detection code (authored by tberghammer).

Changed prior to commit:
  http://reviews.llvm.org/D12699?vs=34227&id=34313#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12699

Files:
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp

Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
===================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
@@ -634,28 +634,30 @@
 RegisterContextLLDB::CheckIfLoopingStack ()
 {
     // If we have a bad stack setup, we can get the same CFA value multiple times -- or even
-    // more devious, we can actually oscillate between two CFA values.  Detect that here and
+    // more devious, we can actually oscillate between two CFA values. Detect that here and
     // break out to avoid a possible infinite loop in lldb trying to unwind the stack.
-    addr_t next_frame_cfa;
-    addr_t next_next_frame_cfa = LLDB_INVALID_ADDRESS;
-    if (GetNextFrame().get() && GetNextFrame()->GetCFA(next_frame_cfa))
-    {
-        if (next_frame_cfa == m_cfa)
-        {
-            // We have a loop in the stack unwind
-            return true;
-        }
-        if (GetNextFrame()->GetNextFrame().get() && GetNextFrame()->GetNextFrame()->GetCFA(next_next_frame_cfa)
-            && next_next_frame_cfa == m_cfa)
+    // To detect when we have the same CFA value multiple times, we compare the CFA of the current
+    // frame with the 2nd next frame because in some specail case (e.g. signal hanlders, hand
+    // written assembly without ABI compiance) we can have 2 frames with the same CFA (in theory we
+    // can have arbitrary number of frames with the same CFA, but more then 2 is very very unlikely)
+
+    RegisterContextLLDB::SharedPtr next_frame = GetNextFrame();
+    if (next_frame)
+    {
+        RegisterContextLLDB::SharedPtr next_next_frame = next_frame->GetNextFrame();
+        addr_t next_next_frame_cfa = LLDB_INVALID_ADDRESS;
+        if (next_next_frame && next_next_frame->GetCFA(next_next_frame_cfa))
         {
-            // We have a loop in the stack unwind
-            return true; 
+            if (next_next_frame_cfa == m_cfa)
+            {
+                // We have a loop in the stack unwind
+                return true; 
+            }
         }
     }
     return false;
 }
 
-
 bool
 RegisterContextLLDB::IsFrameZero () const
 {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12699.34313.patch
Type: text/x-patch
Size: 2245 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150909/a1121c21/attachment.bin>


More information about the lldb-commits mailing list