[Lldb-commits] [lldb] r123673 - in /lldb/trunk/source/Plugins/Process/Utility: RegisterContextLLDB.cpp RegisterContextLLDB.h UnwindLLDB.cpp

Greg Clayton gclayton at apple.com
Mon Jan 17 13:03:33 PST 2011


Author: gclayton
Date: Mon Jan 17 15:03:33 2011
New Revision: 123673

URL: http://llvm.org/viewvc/llvm-project?rev=123673&view=rev
Log:
Avoid infinite loops in stack backtraces and renamed:

    bool RegisterContextLLDB::GetPC (addr_t& pc);

to:
    bool RegisterContextLLDB::ReadPC (addr_t& pc);
    
To avoid confusion with the GetPC() function that is part of the 
lldb_private::RegisterContext:

    uint64_t RegisterContext::GetPC (uint64_t fail_value);
    
Bad things could happen if the two got intermixed and the wrong one got
called.

Fixed inifinite loop detection by watching for two frames where the
RegisterContextLLDB::CursorSP contains the same start_pc and cfa.

    

Modified:
    lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
    lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h
    lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp

Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=123673&r1=123672&r2=123673&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Mon Jan 17 15:03:33 2011
@@ -1246,7 +1246,7 @@
         return false;
     if (!m_start_pc.IsValid())
     {
-        return GetPC (start_pc); 
+        return ReadPC (start_pc); 
     }
     start_pc = m_start_pc.GetLoadAddress (&m_thread.GetProcess().GetTarget());
     return true;
@@ -1255,7 +1255,7 @@
 // Retrieve the current pc value for THIS frame, as saved by the NEXT frame.
 
 bool
-RegisterContextLLDB::GetPC (addr_t& pc)
+RegisterContextLLDB::ReadPC (addr_t& pc)
 {
     if (!IsValid())
         return false;

Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h?rev=123673&r1=123672&r2=123673&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h Mon Jan 17 15:03:33 2011
@@ -72,7 +72,7 @@
     GetStartPC (lldb::addr_t& start_pc);
 
     bool
-    GetPC (lldb::addr_t& start_pc);
+    ReadPC (lldb::addr_t& start_pc);
 
 private:
 

Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp?rev=123673&r1=123672&r2=123673&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp Mon Jan 17 15:03:33 2011
@@ -76,7 +76,7 @@
     if (!first_register_ctx_ap->GetCFA (first_cursor_sp->cfa))
         return false;
 
-    if (!first_register_ctx_ap->GetPC (first_cursor_sp->start_pc))
+    if (!first_register_ctx_ap->ReadPC (first_cursor_sp->start_pc))
         return false;
 
     // Everything checks out, so release the auto pointer value and let the
@@ -132,7 +132,7 @@
         }
         return false;
     }
-    if (!register_ctx_ap->GetPC (cursor_sp->start_pc))
+    if (!register_ctx_ap->ReadPC (cursor_sp->start_pc))
     {
         if (log)
         {
@@ -141,6 +141,15 @@
         }
         return false;
     }
+    if (!m_frames.empty())
+    {
+        if ((m_frames.back()->start_pc == cursor_sp->start_pc) &&
+            (m_frames.back()->cfa      == cursor_sp->cfa))
+        {
+            // Infinite loop where the current cursor is the same as the previous one...
+            return false;
+        }
+    }
     RegisterContextSP register_ctx_sp(register_ctx_ap.release());
     cursor_sp->reg_ctx = register_ctx_sp;
     m_frames.push_back (cursor_sp);





More information about the lldb-commits mailing list