[Lldb-commits] [lldb] r195499 - Patch from Todd Fiala: lldb will seg fault if for some reason there is no unwinder when StackFrameList::GetFramesUpTo() is called.

Greg Clayton gclayton at apple.com
Fri Nov 22 13:03:42 PST 2013


Author: gclayton
Date: Fri Nov 22 15:03:42 2013
New Revision: 195499

URL: http://llvm.org/viewvc/llvm-project?rev=195499&view=rev
Log:
Patch from Todd Fiala: lldb will seg fault if for some reason there is no unwinder when StackFrameList::GetFramesUpTo() is called.

Mainly patched to stop LLDB from crashing. This can easily happen if you debug to a remote gdbserver that doesn't have any dynamic register info and you don't have a target definition file specified.


Modified:
    lldb/trunk/source/Target/StackFrameList.cpp

Modified: lldb/trunk/source/Target/StackFrameList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrameList.cpp?rev=195499&r1=195498&r2=195499&view=diff
==============================================================================
--- lldb/trunk/source/Target/StackFrameList.cpp (original)
+++ lldb/trunk/source/Target/StackFrameList.cpp Fri Nov 22 15:03:42 2013
@@ -301,7 +301,7 @@ StackFrameList::GetFramesUpTo(uint32_t e
                     if (reg_ctx_sp)
                     {
 
-                        const bool success = unwinder->GetFrameInfoAtIndex(idx, cfa, pc);
+                        const bool success = unwinder && unwinder->GetFrameInfoAtIndex(idx, cfa, pc);
                         // There shouldn't be any way not to get the frame info for frame 0.
                         // But if the unwinder can't make one, lets make one by hand with the
                         // SP as the CFA and see if that gets any further.
@@ -329,7 +329,7 @@ StackFrameList::GetFramesUpTo(uint32_t e
             }
             else
             {
-                const bool success = unwinder->GetFrameInfoAtIndex(idx, cfa, pc);
+                const bool success = unwinder && unwinder->GetFrameInfoAtIndex(idx, cfa, pc);
                 if (!success)
                 {
                     // We've gotten to the end of the stack.
@@ -451,14 +451,17 @@ StackFrameList::GetFramesUpTo(uint32_t e
     {
         if (end_idx < m_concrete_frames_fetched)
             return;
-            
-        uint32_t num_frames = unwinder->GetFramesUpTo(end_idx);
-        if (num_frames <= end_idx + 1)
+
+        if (unwinder)
         {
-            //Done unwinding.
-            m_concrete_frames_fetched = UINT32_MAX;
+            uint32_t num_frames = unwinder->GetFramesUpTo(end_idx);
+            if (num_frames <= end_idx + 1)
+            {
+                //Done unwinding.
+                m_concrete_frames_fetched = UINT32_MAX;
+            }
+            m_frames.resize(num_frames);
         }
-        m_frames.resize(num_frames);
     }
 }
 





More information about the lldb-commits mailing list