[Lldb-commits] [lldb] r112007 - in /lldb/trunk: include/lldb/Target/StackFrameList.h include/lldb/Target/Thread.h include/lldb/lldb-forward-rtti.h source/Target/StackFrameList.cpp source/Target/Thread.cpp

Greg Clayton gclayton at apple.com
Tue Aug 24 17:35:26 PDT 2010


Author: gclayton
Date: Tue Aug 24 19:35:26 2010
New Revision: 112007

URL: http://llvm.org/viewvc/llvm-project?rev=112007&view=rev
Log:
Cleaned up the inline backtrace code even more by moving all stack backtracing
functionality into StackFrameList. This will allow us to copy the previous
stack backtrace from the previous stop into another variable so we can re-use
as much as possible from the previous stack backtrace.


Modified:
    lldb/trunk/include/lldb/Target/StackFrameList.h
    lldb/trunk/include/lldb/Target/Thread.h
    lldb/trunk/include/lldb/lldb-forward-rtti.h
    lldb/trunk/source/Target/StackFrameList.cpp
    lldb/trunk/source/Target/Thread.cpp

Modified: lldb/trunk/include/lldb/Target/StackFrameList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StackFrameList.h?rev=112007&r1=112006&r2=112007&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/StackFrameList.h (original)
+++ lldb/trunk/include/lldb/Target/StackFrameList.h Tue Aug 24 19:35:26 2010
@@ -28,19 +28,16 @@
     //------------------------------------------------------------------
     // Constructors and Destructors
     //------------------------------------------------------------------
-    StackFrameList();
+    StackFrameList (Thread &thread, bool show_inline_frames);
 
     virtual
     ~StackFrameList();
 
     uint32_t
-    GetNumFrames() const;
+    GetNumFrames();
 
     lldb::StackFrameSP
-    GetFrameAtIndex (uint32_t idx) const;
-
-    bool
-    SetFrameAtIndex (uint32_t idx, lldb::StackFrameSP &frame_sp);
+    GetFrameAtIndex (uint32_t idx);
 
     // Mark a stack frame as the current frame
     uint32_t
@@ -56,15 +53,31 @@
     void
     Clear ();
 
-    // After we have determined the number of frames, we can set the count here
-    // and have the frame info be generated on demand.
-    void
-    SetNumFrames(uint32_t count);
-
     void
     InvalidateFrames (uint32_t start_idx);
 protected:
 
+    bool
+    SetActualFrameAtIndex (uint32_t idx, lldb::StackFrameSP &frame_sp);
+
+    bool
+    SetInlineFrameAtIndex (uint32_t idx, lldb::StackFrameSP &frame_sp);
+
+
+    lldb::StackFrameSP
+    GetActualFrameAtIndex (uint32_t idx) const;
+
+    lldb::StackFrameSP
+    GetInlineFrameAtIndex (uint32_t idx) const;
+
+    typedef struct InlinedFrameInfo
+    {
+        uint32_t concrete_frame_index;
+        uint32_t inline_height;
+        Block *block;
+    } InlinedFrameInfo;
+    typedef std::vector<InlinedFrameInfo> InlinedFrameInfoCollection;
+
     //------------------------------------------------------------------
     // Classes that inherit from StackFrameList can see and modify these
     //------------------------------------------------------------------
@@ -72,9 +85,13 @@
     typedef collection::iterator iterator;
     typedef collection::const_iterator const_iterator;
 
+    Thread &m_thread;
     mutable Mutex m_mutex;
-    collection m_frames;
+    collection m_actual_frames;
+    collection m_inline_frames;
+    InlinedFrameInfoCollection m_inlined_frame_info;
     uint32_t m_current_frame_idx;
+    bool m_show_inlined_frames;
 
 private:
     //------------------------------------------------------------------

Modified: lldb/trunk/include/lldb/Target/Thread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=112007&r1=112006&r2=112007&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Thread.h (original)
+++ lldb/trunk/include/lldb/Target/Thread.h Tue Aug 24 19:35:26 2010
@@ -198,12 +198,7 @@
     CreateRegisterContextForFrame (StackFrame *frame) = 0;
     
     virtual void
-    ClearStackFrames ()
-    {
-        m_concrete_frames.Clear();
-        m_inlined_frames.Clear();
-        m_inlined_frame_info.clear();
-    }
+    ClearStackFrames ();
 
     void
     DumpInfo (Stream &strm,
@@ -522,6 +517,7 @@
 protected:
 
     friend class ThreadPlan;
+    friend class StackFrameList;
 
     void
     PushPlan (lldb::ThreadPlanSP &plan_sp);
@@ -542,13 +538,9 @@
     virtual lldb_private::Unwind *
     GetUnwinder () = 0;
 
-    typedef struct InlinedFrameInfo
-    {
-        uint32_t concrete_frame_index;
-        uint32_t inline_height;
-        Block *block;
-    } InlinedFrameInfo;
-    typedef std::vector<InlinedFrameInfo> InlinedFrameInfoCollection;
+    StackFrameList &
+    GetStackFrameList ();
+
     //------------------------------------------------------------------
     // Classes that inherit from Process can see and modify these
     //------------------------------------------------------------------
@@ -558,15 +550,12 @@
     const uint32_t      m_index_id;         ///< A unique 1 based index assigned to each thread for easy UI/command line access.
     lldb::RegisterContextSP   m_reg_context_sp;   ///< The register context for this thread's current register state.
     lldb::StateType     m_state;            ///< The state of our process.
+    mutable Mutex       m_state_mutex;      ///< Multithreaded protection for m_state.
     plan_stack          m_plan_stack;       ///< The stack of plans this thread is executing.
     plan_stack          m_immediate_plan_stack; ///< The plans that need to get executed before any other work gets done.
     plan_stack          m_completed_plan_stack;  ///< Plans that have been completed by this stop.  They get deleted when the thread resumes.
     plan_stack          m_discarded_plan_stack;  ///< Plans that have been discarded by this stop.  They get deleted when the thread resumes.
-    mutable Mutex       m_state_mutex;      ///< Multithreaded protection for m_state.
-    StackFrameList      m_concrete_frames;  ///< The stack frames that get lazily populated after a thread stops.
-    StackFrameList      m_inlined_frames;   ///< The stack frames that get lazily populated after a thread stops.
-    InlinedFrameInfoCollection m_inlined_frame_info;
-    bool                m_show_inlined_frames;
+    lldb::StackFrameListSP m_frames_sp;      ///< The stack frames that get lazily populated after a thread stops.
     int                 m_resume_signal;    ///< The signal that should be used when continuing this thread.
     lldb::StateType     m_resume_state;     ///< The state that indicates what this thread should do when the process is resumed.
     std::auto_ptr<lldb_private::Unwind> m_unwinder_ap;

Modified: lldb/trunk/include/lldb/lldb-forward-rtti.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward-rtti.h?rev=112007&r1=112006&r2=112007&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-forward-rtti.h (original)
+++ lldb/trunk/include/lldb/lldb-forward-rtti.h Tue Aug 24 19:35:26 2010
@@ -49,6 +49,7 @@
     typedef SharedPtr<lldb_private::Section>::Type SectionSP;
     typedef SharedPtr<lldb_private::SearchFilter>::Type SearchFilterSP;
     typedef SharedPtr<lldb_private::StackFrame>::Type StackFrameSP;
+    typedef SharedPtr<lldb_private::StackFrameList>::Type StackFrameListSP;
     typedef SharedPtr<lldb_private::StateVariable>::Type StateVariableSP;
     typedef SharedPtr<lldb_private::StopInfo>::Type StopInfoSP;
     typedef SharedPtr<lldb_private::StoppointLocation>::Type StoppointLocationSP;

Modified: lldb/trunk/source/Target/StackFrameList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrameList.cpp?rev=112007&r1=112006&r2=112007&view=diff
==============================================================================
--- lldb/trunk/source/Target/StackFrameList.cpp (original)
+++ lldb/trunk/source/Target/StackFrameList.cpp Tue Aug 24 19:35:26 2010
@@ -7,12 +7,18 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/Target/StackFrameList.h"
+
 // C Includes
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
-#include "lldb/Target/StackFrameList.h"
+#include "lldb/Symbol/Block.h"
+#include "lldb/Symbol/Function.h"
+#include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/StackFrame.h"
+#include "lldb/Target/Thread.h"
+#include "lldb/Target/Unwind.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -20,9 +26,12 @@
 //----------------------------------------------------------------------
 // StackFrameList constructor
 //----------------------------------------------------------------------
-StackFrameList::StackFrameList() :
+StackFrameList::StackFrameList(Thread &thread, bool show_inline_frames) :
+    m_thread (thread),
+    m_show_inlined_frames (show_inline_frames),
     m_mutex (Mutex::eMutexTypeRecursive),
-    m_frames (),
+    m_actual_frames (),
+    m_inline_frames (),
     m_current_frame_idx (0)
 {
 }
@@ -36,43 +45,242 @@
 
 
 uint32_t
-StackFrameList::GetNumFrames() const
+StackFrameList::GetNumFrames()
 {
     Mutex::Locker locker (m_mutex);
-    return m_frames.size();
+
+    if (m_show_inlined_frames)
+    {
+        if (m_inlined_frame_info.empty())
+        {
+            Unwind *unwinder = m_thread.GetUnwinder ();
+            // If we are going to show inlined stack frames as actual frames,
+            // we need to calculate all concrete frames first, then iterate
+            // through all of them and count up how many inlined functions are
+            // in each frame. We can then fill in m_inlined_frame_info with
+            // the concrete frame index and inlined depth
+            const uint32_t concrete_frame_count = unwinder->GetFrameCount();
+            
+            addr_t pc, cfa;
+            InlinedFrameInfo inlined_frame_info;
+
+            StackFrameSP frame_sp;
+            for (uint32_t idx=0; idx<concrete_frame_count; ++idx)
+            {
+                if (idx == 0)
+                {
+                    m_thread.GetRegisterContext();
+                    frame_sp.reset (new StackFrame (0, 
+                                                    0, 
+                                                    m_thread, 
+                                                    m_thread.m_reg_context_sp, 
+                                                    m_thread.m_reg_context_sp->GetSP(), 
+                                                    0, 
+                                                    m_thread.m_reg_context_sp->GetPC(), 
+                                                    NULL));
+                }
+                else
+                {
+                    const bool success = unwinder->GetFrameInfoAtIndex(idx, cfa, pc);
+                    assert (success);
+                    frame_sp.reset (new StackFrame (m_inlined_frame_info.size(), idx, m_thread, cfa, 0, pc, NULL));
+                }
+                SetActualFrameAtIndex (idx, frame_sp);
+                Block *block = frame_sp->GetSymbolContext (eSymbolContextBlock).block;
+
+                inlined_frame_info.concrete_frame_index = idx;
+                inlined_frame_info.inline_height = 0;
+                inlined_frame_info.block = block;
+                m_inlined_frame_info.push_back (inlined_frame_info);
+
+                if (block)
+                {
+                    Block *inlined_block;
+                    if (block->InlinedFunctionInfo())
+                        inlined_block = block;
+                    else
+                        inlined_block = block->GetInlinedParent ();
+                        
+                    while (inlined_block)
+                    {
+                        inlined_frame_info.block = inlined_block;
+                        inlined_frame_info.inline_height++;
+                        m_inlined_frame_info.push_back (inlined_frame_info);
+                        inlined_block = inlined_block->GetInlinedParent ();
+                    }
+                }
+            }
+        }
+        return m_inlined_frame_info.size();
+    }
+    else
+    {
+        if (m_actual_frames.empty())
+            m_actual_frames.resize(m_thread.GetUnwinder()->GetFrameCount());
+            
+        return m_actual_frames.size();
+    }
+    return 0;
 }
 
-// After we have determined the number of frames, we can set the count here
-// and have the frame info be generated on demand.
-void
-StackFrameList::SetNumFrames(uint32_t count)
+lldb::StackFrameSP
+StackFrameList::GetActualFrameAtIndex (uint32_t idx) const
 {
-    Mutex::Locker locker (m_mutex);
-    return m_frames.resize(count);
+    StackFrameSP frame_sp;
+        if (idx < m_actual_frames.size())
+            frame_sp = m_actual_frames[idx];
+    return frame_sp;
+}
+
+lldb::StackFrameSP
+StackFrameList::GetInlineFrameAtIndex (uint32_t idx) const
+{
+    StackFrameSP frame_sp;
+    if (idx < m_inline_frames.size())
+        frame_sp = m_inline_frames[idx];
+    return frame_sp;
 }
 
+
 StackFrameSP
-StackFrameList::GetFrameAtIndex (uint32_t idx) const
+StackFrameList::GetFrameAtIndex (uint32_t idx)
 {
     StackFrameSP frame_sp;
     {
         Mutex::Locker locker (m_mutex);
-        if (idx < m_frames.size())
-            frame_sp = m_frames[idx];
+    
+        if (m_show_inlined_frames)
+        {
+            frame_sp = GetInlineFrameAtIndex (idx);
+        }
+        else
+        {
+            frame_sp = GetActualFrameAtIndex (idx);
+        }
+
+        if (frame_sp.get())
+        return frame_sp;
+
+    // Special case the first frame (idx == 0) so that we don't need to
+    // know how many stack frames there are to get it. If we need any other
+    // frames, then we do need to know if "idx" is a valid index.
+    if (idx == 0)
+    {
+        // If this is the first frame, we want to share the thread register
+        // context with the stack frame at index zero.
+        m_thread.GetRegisterContext();
+        assert (m_thread.m_reg_context_sp.get());
+        frame_sp.reset (new StackFrame (0, 
+                                        0, 
+                                        m_thread, 
+                                        m_thread.m_reg_context_sp, 
+                                        m_thread.m_reg_context_sp->GetSP(), 
+                                        0, 
+                                        m_thread.m_reg_context_sp->GetPC(), 
+                                        NULL));
+    }
+    else if (idx < GetNumFrames())
+    {
+        if (m_show_inlined_frames)
+        {
+            if (m_inlined_frame_info[idx].inline_height == 0)
+            {
+                // Same as the concrete stack frame if block is NULL
+                assert (m_inlined_frame_info[idx].concrete_frame_index < m_actual_frames.size());
+                frame_sp = GetActualFrameAtIndex (m_inlined_frame_info[idx].concrete_frame_index);
+            }
+            else 
+            {
+                // We have blocks that were above an inlined function. Inlined
+                // functions are represented as blocks with non-NULL inline
+                // function info. Here we must reconstruct a frame by looking
+                // at the block
+                StackFrameSP previous_frame_sp (m_thread.GetStackFrameAtIndex (idx-1));
+
+                SymbolContext inline_sc;
+                
+                Block *inlined_parent_block = m_inlined_frame_info[idx].block->GetInlinedParent();
+                
+                if (inlined_parent_block)
+                    inlined_parent_block->CalculateSymbolContext (&inline_sc);
+                else
+                {
+                    Block *parent_block = m_inlined_frame_info[idx].block->GetParent();
+                    parent_block->CalculateSymbolContext(&inline_sc);
+                }
+                
+                Address previous_frame_lookup_addr (previous_frame_sp->GetFrameCodeAddress());
+                if (previous_frame_sp->IsConcrete () && previous_frame_sp->GetFrameIndex() > 0)
+                    previous_frame_lookup_addr.Slide (-1);
+
+                AddressRange range;
+                m_inlined_frame_info[idx].block->GetRangeContainingAddress (previous_frame_lookup_addr, range);
+                    
+                const InlineFunctionInfo* inline_info = m_inlined_frame_info[idx].block->InlinedFunctionInfo();
+                assert (inline_info);
+                inline_sc.line_entry.range.GetBaseAddress() = previous_frame_sp->GetFrameCodeAddress();
+                inline_sc.line_entry.file = inline_info->GetCallSite().GetFile();
+                inline_sc.line_entry.line = inline_info->GetCallSite().GetLine();
+                inline_sc.line_entry.column = inline_info->GetCallSite().GetColumn();
+
+                StackFrameSP concrete_frame_sp (GetActualFrameAtIndex (m_inlined_frame_info[idx].concrete_frame_index));
+                assert (previous_frame_sp.get());
+                
+                frame_sp.reset (new StackFrame (idx, 
+                                                m_inlined_frame_info[idx].concrete_frame_index,
+                                                m_thread, 
+                                                concrete_frame_sp->GetRegisterContextSP (),
+                                                concrete_frame_sp->GetStackID().GetCallFrameAddress(),  // CFA
+                                                m_inlined_frame_info[idx].inline_height,                // Inline height
+                                                range.GetBaseAddress(),
+                                                &inline_sc));                                           // The symbol context for this inline frame
+                
+            }
+        }
+        else
+        {
+            Unwind *unwinder = m_thread.GetUnwinder ();
+            if (unwinder)
+            {
+                addr_t pc, cfa;
+                if (unwinder->GetFrameInfoAtIndex(idx, cfa, pc))
+                    frame_sp.reset (new StackFrame (idx, idx, m_thread, cfa, 0, pc, NULL));
+            }
+        }
+    }
+    if (m_show_inlined_frames)
+        SetInlineFrameAtIndex(idx, frame_sp);
+    else
+        SetActualFrameAtIndex(idx, frame_sp);
+    return frame_sp;
+            
     }
     return frame_sp;
 }
 
 bool
-StackFrameList::SetFrameAtIndex (uint32_t idx, StackFrameSP &frame_sp)
+StackFrameList::SetActualFrameAtIndex (uint32_t idx, StackFrameSP &frame_sp)
 {
-    Mutex::Locker locker (m_mutex);
-    if (idx >= m_frames.size())
-        m_frames.resize(idx + 1);
+    if (idx >= m_actual_frames.size())
+        m_actual_frames.resize(idx + 1);
+    // Make sure allocation succeeded by checking bounds again
+    if (idx < m_actual_frames.size())
+    {
+        m_actual_frames[idx] = frame_sp;
+        return true;
+    }
+    return false;   // resize failed, out of memory?
+}
+
+bool
+StackFrameList::SetInlineFrameAtIndex (uint32_t idx, StackFrameSP &frame_sp)
+{
+    if (idx >= m_inline_frames.size())
+        m_inline_frames.resize(idx + 1);
     // Make sure allocation succeeded by checking bounds again
-    if (idx < m_frames.size())
+    if (idx < m_inline_frames.size())
     {
-        m_frames[idx] = frame_sp;
+        m_inline_frames[idx] = frame_sp;
         return true;
     }
     return false;   // resize failed, out of memory?
@@ -90,9 +298,9 @@
 StackFrameList::SetCurrentFrame (lldb_private::StackFrame *frame)
 {
     Mutex::Locker locker (m_mutex);
-    const_iterator pos,
-                   begin = m_frames.begin(),
-                   end = m_frames.end();
+    const_iterator pos;
+    const_iterator begin = m_show_inlined_frames ? m_inline_frames.begin() : m_actual_frames.begin();
+    const_iterator end   = m_show_inlined_frames ? m_inline_frames.end()   : m_actual_frames.end();
     for (pos = begin; pos != end; ++pos)
     {
         if (pos->get() == frame)
@@ -119,17 +327,26 @@
 StackFrameList::Clear ()
 {
     Mutex::Locker locker (m_mutex);
-    m_frames.clear();
+    m_actual_frames.clear();
+    m_inline_frames.clear();
+    m_inlined_frame_info.clear();
 }
 
 void
 StackFrameList::InvalidateFrames (uint32_t start_idx)
 {
     Mutex::Locker locker (m_mutex);
-    size_t num_frames = m_frames.size();
-    while (start_idx < num_frames)
+    if (m_show_inlined_frames)
+    {
+        Clear();
+    }
+    else
     {
-        m_frames[start_idx].reset();
-        ++start_idx;
+        const size_t num_frames = m_actual_frames.size();
+        while (start_idx < num_frames)
+        {
+            m_actual_frames[start_idx].reset();
+            ++start_idx;
+        }
     }
 }

Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=112007&r1=112006&r2=112007&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Tue Aug 24 19:35:26 2010
@@ -45,14 +45,11 @@
     m_index_id (process.GetNextThreadIndexID ()),
     m_reg_context_sp (),
     m_state (eStateUnloaded),
+    m_state_mutex (Mutex::eMutexTypeRecursive),
     m_plan_stack (),
     m_immediate_plan_stack(),
     m_completed_plan_stack(),
-    m_state_mutex (Mutex::eMutexTypeRecursive),
-    m_concrete_frames (),
-    m_inlined_frames (),
-    m_inlined_frame_info (),
-    m_show_inlined_frames (true),
+    m_frames_sp (),
     m_resume_signal (LLDB_INVALID_SIGNAL_NUMBER),
     m_resume_state (eStateRunning),
     m_unwinder_ap ()
@@ -795,200 +792,53 @@
     exe_ctx.frame = NULL;
 }
 
+
+StackFrameList &
+Thread::GetStackFrameList ()
+{
+    if (m_frames_sp.get() == NULL)
+        m_frames_sp.reset (new StackFrameList (*this, true));
+    return *m_frames_sp;
+}
+
+
+
 uint32_t
 Thread::GetStackFrameCount()
 {
-    Unwind *unwinder = GetUnwinder ();
-    if (unwinder)
-    {
-        if (m_show_inlined_frames)
-        {
-            if (m_inlined_frame_info.empty())
-            {
-                // If we are going to show inlined stack frames as actual frames,
-                // we need to calculate all concrete frames first, then iterate
-                // through all of them and count up how many inlined functions are
-                // in each frame. We can then fill in m_inlined_frame_info with
-                // the concrete frame index and inlined depth
-                const uint32_t concrete_frame_count = unwinder->GetFrameCount();
-                
-                addr_t pc, cfa;
-                InlinedFrameInfo inlined_frame_info;
-
-                StackFrameSP frame_sp;
-                for (uint32_t idx=0; idx<concrete_frame_count; ++idx)
-                {
-                    if (idx == 0)
-                    {
-                        GetRegisterContext();
-                        assert (m_reg_context_sp.get());
-                        frame_sp.reset (new StackFrame (0, 0, *this, m_reg_context_sp, m_reg_context_sp->GetSP(), 0, m_reg_context_sp->GetPC(), NULL));
-                    }
-                    else
-                    {
-                        const bool success = unwinder->GetFrameInfoAtIndex(idx, cfa, pc);
-                        assert (success);
-                        frame_sp.reset (new StackFrame (m_inlined_frame_info.size(), idx, *this, cfa, 0, pc, NULL));
-                    }
-                    m_concrete_frames.SetFrameAtIndex(idx, frame_sp);
-                    Block *block = frame_sp->GetSymbolContext (eSymbolContextBlock).block;
+    return GetStackFrameList().GetNumFrames();
+}
 
-                    inlined_frame_info.concrete_frame_index = idx;
-                    inlined_frame_info.inline_height = 0;
-                    inlined_frame_info.block = block;
-                    m_inlined_frame_info.push_back (inlined_frame_info);
 
-                    if (block)
-                    {
-                        Block *inlined_block;
-                        if (block->InlinedFunctionInfo())
-                            inlined_block = block;
-                        else
-                            inlined_block = block->GetInlinedParent ();
-                            
-                        while (inlined_block)
-                        {
-                            inlined_frame_info.block = inlined_block;
-                            inlined_frame_info.inline_height++;
-                            m_inlined_frame_info.push_back (inlined_frame_info);
-                            inlined_block = inlined_block->GetInlinedParent ();
-                        }
-                    }
-                }
-            }
-            return m_inlined_frame_info.size();
-        }
-        else
-        {
-            return unwinder->GetFrameCount();
-        }
-    }
-    return 0;
+void
+Thread::ClearStackFrames ()
+{
+    if (m_frames_sp)
+        m_frames_sp->Clear();
 }
 
 lldb::StackFrameSP
 Thread::GetStackFrameAtIndex (uint32_t idx)
 {
-
-    StackFrameSP frame_sp;
-    
-    if (m_show_inlined_frames)
-        frame_sp = m_inlined_frames.GetFrameAtIndex(idx);
-    else
-        frame_sp = m_concrete_frames.GetFrameAtIndex(idx);
-
-    if (frame_sp.get())
-        return frame_sp;
-
-    // Don't try and fetch a frame while process is running
-// FIXME: This check isn't right because IsRunning checks the Public state, but this
-// is work you need to do - for instance in ShouldStop & friends - before the public 
-// state has been changed.
-//    if (m_process.IsRunning())
-//        return frame_sp;
-
-    // Special case the first frame (idx == 0) so that we don't need to
-    // know how many stack frames there are to get it. If we need any other
-    // frames, then we do need to know if "idx" is a valid index.
-    if (idx == 0)
-    {
-        // If this is the first frame, we want to share the thread register
-        // context with the stack frame at index zero.
-        GetRegisterContext();
-        assert (m_reg_context_sp.get());
-        frame_sp.reset (new StackFrame (0, 0, *this, m_reg_context_sp, m_reg_context_sp->GetSP(), 0, m_reg_context_sp->GetPC(), NULL));
-    }
-    else if (idx < GetStackFrameCount())
-    {
-        if (m_show_inlined_frames)
-        {
-            if (m_inlined_frame_info[idx].inline_height == 0)
-            {
-                // Same as the concrete stack frame if block is NULL
-                frame_sp = m_concrete_frames.GetFrameAtIndex (m_inlined_frame_info[idx].concrete_frame_index);
-            }
-            else 
-            {
-                // We have blocks that were above an inlined function. Inlined
-                // functions are represented as blocks with non-NULL inline
-                // function info. Here we must reconstruct a frame by looking
-                // at the block
-                StackFrameSP previous_frame_sp (GetStackFrameAtIndex (idx-1));
-
-                SymbolContext inline_sc;
-                
-                Block *inlined_parent_block = m_inlined_frame_info[idx].block->GetInlinedParent();
-                
-                if (inlined_parent_block)
-                    inlined_parent_block->CalculateSymbolContext (&inline_sc);
-                else
-                {
-                    Block *parent_block = m_inlined_frame_info[idx].block->GetParent();
-                    parent_block->CalculateSymbolContext(&inline_sc);
-                }
-                
-                Address previous_frame_lookup_addr (previous_frame_sp->GetFrameCodeAddress());
-                if (previous_frame_sp->IsConcrete () && previous_frame_sp->GetFrameIndex() > 0)
-                    previous_frame_lookup_addr.Slide (-1);
-
-                AddressRange range;
-                m_inlined_frame_info[idx].block->GetRangeContainingAddress (previous_frame_lookup_addr, range);
-                    
-                const InlineFunctionInfo* inline_info = m_inlined_frame_info[idx].block->InlinedFunctionInfo();
-                assert (inline_info);
-                inline_sc.line_entry.range.GetBaseAddress() = previous_frame_sp->GetFrameCodeAddress();
-                inline_sc.line_entry.file = inline_info->GetCallSite().GetFile();
-                inline_sc.line_entry.line = inline_info->GetCallSite().GetLine();
-                inline_sc.line_entry.column = inline_info->GetCallSite().GetColumn();
-
-                StackFrameSP concrete_frame_sp (m_concrete_frames.GetFrameAtIndex (m_inlined_frame_info[idx].concrete_frame_index));
-                assert (previous_frame_sp.get());
-                
-                frame_sp.reset (new StackFrame (idx, 
-                                                m_inlined_frame_info[idx].concrete_frame_index,
-                                                *this, 
-                                                concrete_frame_sp->GetRegisterContextSP (),
-                                                concrete_frame_sp->GetStackID().GetCallFrameAddress(),  // CFA
-                                                m_inlined_frame_info[idx].inline_height,                // Inline height
-                                                range.GetBaseAddress(),
-                                                &inline_sc));                                           // The symbol context for this inline frame
-                
-            }
-        }
-        else
-        {
-            Unwind *unwinder = GetUnwinder ();
-            if (unwinder)
-            {
-                addr_t pc, cfa;
-                if (unwinder->GetFrameInfoAtIndex(idx, cfa, pc))
-                    frame_sp.reset (new StackFrame (idx, idx, *this, cfa, 0, pc, NULL));
-            }
-        }
-    }
-    if (m_show_inlined_frames)
-        m_inlined_frames.SetFrameAtIndex(idx, frame_sp);
-    else
-        m_concrete_frames.SetFrameAtIndex(idx, frame_sp);
-    return frame_sp;
+    return StackFrameSP (GetStackFrameList().GetFrameAtIndex(idx));
 }
 
 lldb::StackFrameSP
 Thread::GetCurrentFrame ()
 {
-    return GetStackFrameAtIndex (m_concrete_frames.GetCurrentFrameIndex());
+    return GetStackFrameAtIndex (GetStackFrameList().GetCurrentFrameIndex());
 }
 
 uint32_t
 Thread::SetCurrentFrame (lldb_private::StackFrame *frame)
 {
-    return m_concrete_frames.SetCurrentFrame(frame);
+    return GetStackFrameList().SetCurrentFrame(frame);
 }
 
 void
 Thread::SetCurrentFrameByIndex (uint32_t idx)
 {
-    m_concrete_frames.SetCurrentFrameByIndex(idx);
+    GetStackFrameList().SetCurrentFrameByIndex(idx);
 }
 
 void





More information about the lldb-commits mailing list