[Lldb-commits] [lldb] r178205 - Protect against the case where the current inlined depth is wrong, and leads us to think we can't even get the

Jim Ingham jingham at apple.com
Wed Mar 27 17:13:30 PDT 2013


Author: jingham
Date: Wed Mar 27 19:13:30 2013
New Revision: 178205

URL: http://llvm.org/viewvc/llvm-project?rev=178205&view=rev
Log:
Protect against the case where the current inlined depth is wrong, and leads us to think we can't even get the
frame at index 0.  We should ALWAYS be able to get that.

<rdar://problem/13497571>

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

Modified: lldb/trunk/source/Target/StackFrameList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrameList.cpp?rev=178205&r1=178204&r2=178205&view=diff
==============================================================================
--- lldb/trunk/source/Target/StackFrameList.cpp (original)
+++ lldb/trunk/source/Target/StackFrameList.cpp Wed Mar 27 19:13:30 2013
@@ -497,6 +497,8 @@ StackFrameList::GetFrameAtIndex (uint32_
 {
     StackFrameSP frame_sp;
     Mutex::Locker locker (m_mutex);
+    uint32_t original_idx = idx;
+    
     uint32_t inlined_depth = GetCurrentInlinedDepth();
     if (inlined_depth != UINT32_MAX)
         idx += inlined_depth;
@@ -507,44 +509,63 @@ StackFrameList::GetFrameAtIndex (uint32_
     if (frame_sp)
         return frame_sp;
         
-        // GetFramesUpTo will fill m_frames with as many frames as you asked for,
-        // if there are that many.  If there weren't then you asked for too many
-        // frames.
-        GetFramesUpTo (idx);
-        if (idx < m_frames.size())
+    // GetFramesUpTo will fill m_frames with as many frames as you asked for,
+    // if there are that many.  If there weren't then you asked for too many
+    // frames.
+    GetFramesUpTo (idx);
+    if (idx < m_frames.size())
+    {
+        if (m_show_inlined_frames)
         {
-            if (m_show_inlined_frames)
-            {
-                // When inline frames are enabled we actually create all the frames in GetFramesUpTo.
-                frame_sp = m_frames[idx];
-            }
-            else
+            // When inline frames are enabled we actually create all the frames in GetFramesUpTo.
+            frame_sp = m_frames[idx];
+        }
+        else
+        {
+            Unwind *unwinder = m_thread.GetUnwinder ();
+            if (unwinder)
             {
-                Unwind *unwinder = m_thread.GetUnwinder ();
-                if (unwinder)
+                addr_t pc, cfa;
+                if (unwinder->GetFrameInfoAtIndex(idx, cfa, pc))
                 {
-                    addr_t pc, cfa;
-                    if (unwinder->GetFrameInfoAtIndex(idx, cfa, pc))
+                    frame_sp.reset (new StackFrame (m_thread.shared_from_this(), idx, idx, cfa, pc, NULL));
+                    
+                    Function *function = frame_sp->GetSymbolContext (eSymbolContextFunction).function;
+                    if (function)
                     {
-                        frame_sp.reset (new StackFrame (m_thread.shared_from_this(), idx, idx, cfa, pc, NULL));
-                        
-                        Function *function = frame_sp->GetSymbolContext (eSymbolContextFunction).function;
-                        if (function)
-                        {
-                            // When we aren't showing inline functions we always use
-                            // the top most function block as the scope.
-                            frame_sp->SetSymbolContextScope (&function->GetBlock(false));
-                        }
-                        else 
-                        {
-                            // Set the symbol scope from the symbol regardless if it is NULL or valid.
-                            frame_sp->SetSymbolContextScope (frame_sp->GetSymbolContext (eSymbolContextSymbol).symbol);
-                        }
-                        SetFrameAtIndex(idx, frame_sp);
+                        // When we aren't showing inline functions we always use
+                        // the top most function block as the scope.
+                        frame_sp->SetSymbolContextScope (&function->GetBlock(false));
                     }
+                    else 
+                    {
+                        // Set the symbol scope from the symbol regardless if it is NULL or valid.
+                        frame_sp->SetSymbolContextScope (frame_sp->GetSymbolContext (eSymbolContextSymbol).symbol);
+                    }
+                    SetFrameAtIndex(idx, frame_sp);
                 }
             }
         }
+    }
+    else if (original_idx == 0)
+    {
+        // There should ALWAYS be a frame at index 0.  If something went wrong with the CurrentInlinedDepth such that
+        // there weren't as many frames as we thought taking that into account, then reset the current inlined depth
+        // and return the real zeroth frame.
+        if (m_frames.size() > 0)
+        {
+            ResetCurrentInlinedDepth();
+            frame_sp = m_frames[original_idx];
+        }
+        else
+        {
+            // Why do we have a thread with zero frames, that should not ever happen...
+            if (m_thread.IsValid())
+                assert ("A valid thread has no frames.");
+            
+        }
+    }
+    
     return frame_sp;
 }
 

Modified: lldb/trunk/source/Target/StopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StopInfo.cpp?rev=178205&r1=178204&r2=178205&view=diff
==============================================================================
--- lldb/trunk/source/Target/StopInfo.cpp (original)
+++ lldb/trunk/source/Target/StopInfo.cpp Wed Mar 27 19:13:30 2013
@@ -287,6 +287,13 @@ protected:
         
         Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);
         
+        if (!m_thread.IsValid())
+        {
+            // This shouldn't ever happen, but just in case, don't do more harm.
+            log->Printf ("PerformAction got called with an invalid thread.");
+            return;
+        }
+        
         BreakpointSiteSP bp_site_sp (m_thread.GetProcess()->GetBreakpointSiteList().FindByID (m_value));
         
         if (bp_site_sp)





More information about the lldb-commits mailing list