[Lldb-commits] [lldb] r151705 - in /lldb/trunk: include/lldb/Target/StackFrameList.h include/lldb/Target/Thread.h include/lldb/Target/Unwind.h source/Commands/CommandObjectFrame.cpp source/Plugins/Process/Utility/UnwindLLDB.cpp source/Plugins/Process/Utility/UnwindLLDB.h source/Target/StackFrameList.cpp source/Target/Thread.cpp
Jim Ingham
jingham at apple.com
Tue Feb 28 19:40:23 PST 2012
Author: jingham
Date: Tue Feb 28 21:40:22 2012
New Revision: 151705
URL: http://llvm.org/viewvc/llvm-project?rev=151705&view=rev
Log:
Make the StackFrameList::GetFrameAtIndex only fetch as many stack frames as needed to
get the frame requested.
<rdar://problem/10943135>
Modified:
lldb/trunk/include/lldb/Target/StackFrameList.h
lldb/trunk/include/lldb/Target/Thread.h
lldb/trunk/include/lldb/Target/Unwind.h
lldb/trunk/source/Commands/CommandObjectFrame.cpp
lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp
lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.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=151705&r1=151704&r2=151705&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/StackFrameList.h (original)
+++ lldb/trunk/include/lldb/Target/StackFrameList.h Tue Feb 28 21:40:22 2012
@@ -35,7 +35,7 @@
uint32_t
GetNumFrames (bool can_create = true);
-
+
lldb::StackFrameSP
GetFrameAtIndex (uint32_t idx);
@@ -53,7 +53,7 @@
GetSelectedFrameIndex () const;
// Mark a stack frame as the current frame using the frame index
- void
+ bool
SetSelectedFrameByIndex (uint32_t idx);
void
@@ -91,6 +91,21 @@
Merge (std::auto_ptr<StackFrameList>& curr_ap,
lldb::StackFrameListSP& prev_sp);
+ void
+ GetFramesUpTo (uint32_t end_idx);
+
+ bool
+ GetAllFramesFetched()
+ {
+ return m_concrete_frames_fetched == UINT32_MAX;
+ }
+
+ void
+ SetAllFramesFetched ()
+ {
+ m_concrete_frames_fetched = UINT32_MAX;
+ }
+
//------------------------------------------------------------------
// Classes that inherit from StackFrameList can see and modify these
//------------------------------------------------------------------
@@ -103,6 +118,7 @@
mutable Mutex m_mutex;
collection m_frames;
uint32_t m_selected_frame_idx;
+ uint32_t m_concrete_frames_fetched;
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=151705&r1=151704&r2=151705&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Thread.h (original)
+++ lldb/trunk/include/lldb/Target/Thread.h Tue Feb 28 21:40:22 2012
@@ -356,10 +356,10 @@
return GetStackFrameList().SetSelectedFrame(frame);
}
- void
+ bool
SetSelectedFrameByIndex (uint32_t frame_idx)
{
- GetStackFrameList().SetSelectedFrameByIndex(frame_idx);
+ return GetStackFrameList().SetSelectedFrameByIndex(frame_idx);
}
void
Modified: lldb/trunk/include/lldb/Target/Unwind.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Unwind.h?rev=151705&r1=151704&r2=151705&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Unwind.h (original)
+++ lldb/trunk/include/lldb/Target/Unwind.h Tue Feb 28 21:40:22 2012
@@ -51,6 +51,23 @@
Mutex::Locker locker(m_unwind_mutex);
return DoGetFrameCount();
}
+
+ uint32_t
+ GetFramesUpTo (uint32_t end_idx)
+ {
+ lldb::addr_t cfa;
+ lldb::addr_t pc;
+ uint32_t idx;
+
+ for (idx = 0; idx < end_idx; idx++)
+ {
+ if (!DoGetFrameInfoAtIndex (idx, cfa, pc))
+ {
+ break;
+ }
+ }
+ return idx;
+ }
bool
GetFrameInfoAtIndex (uint32_t frame_idx,
Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=151705&r1=151704&r2=151705&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Tue Feb 28 21:40:22 2012
@@ -196,7 +196,6 @@
Thread *thread = exe_ctx.GetThreadPtr();
if (thread)
{
- const uint32_t num_frames = thread->GetStackFrameCount();
uint32_t frame_idx = UINT32_MAX;
if (m_options.relative_frame_offset != INT32_MIN)
{
@@ -224,6 +223,9 @@
}
else if (m_options.relative_frame_offset > 0)
{
+ // I don't want "up 20" where "20" takes you past the top of the stack to produce
+ // an error, but rather to just go to the top. So I have to count the stack here...
+ const uint32_t num_frames = thread->GetStackFrameCount();
if (num_frames - frame_idx > m_options.relative_frame_offset)
frame_idx += m_options.relative_frame_offset;
else
@@ -262,9 +264,9 @@
}
}
- if (frame_idx < num_frames)
+ bool success = thread->SetSelectedFrameByIndex (frame_idx);
+ if (success)
{
- thread->SetSelectedFrameByIndex (frame_idx);
exe_ctx.SetFrameSP(thread->GetSelectedFrame ());
StackFrame *frame = exe_ctx.GetFramePtr();
if (frame)
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=151705&r1=151704&r2=151705&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp Tue Feb 28 21:40:22 2012
@@ -25,14 +25,15 @@
UnwindLLDB::UnwindLLDB (Thread &thread) :
Unwind (thread),
- m_frames()
+ m_frames(),
+ m_unwind_complete(false)
{
}
uint32_t
UnwindLLDB::DoGetFrameCount()
{
- if (m_frames.empty())
+ if (!m_unwind_complete)
{
//#define DEBUG_FRAME_SPEED 1
#if DEBUG_FRAME_SPEED
@@ -68,6 +69,9 @@
bool
UnwindLLDB::AddFirstFrame ()
{
+ if (m_frames.size() > 0)
+ return true;
+
// First, set up the 0th (initial) frame
CursorSP first_cursor_sp(new Cursor ());
RegisterContextLLDBSP reg_ctx_sp (new RegisterContextLLDB (m_thread,
@@ -75,28 +79,35 @@
first_cursor_sp->sctx,
0, *this));
if (reg_ctx_sp.get() == NULL)
- return false;
+ goto unwind_done;
if (!reg_ctx_sp->IsValid())
- return false;
+ goto unwind_done;
if (!reg_ctx_sp->GetCFA (first_cursor_sp->cfa))
- return false;
+ goto unwind_done;
if (!reg_ctx_sp->ReadPC (first_cursor_sp->start_pc))
- return false;
+ goto unwind_done;
// Everything checks out, so release the auto pointer value and let the
// cursor own it in its shared pointer
first_cursor_sp->reg_ctx_lldb_sp = reg_ctx_sp;
m_frames.push_back (first_cursor_sp);
return true;
+unwind_done:
+ m_unwind_complete = true;
+ return false;
}
// For adding a non-zero stack frame to m_frames.
bool
UnwindLLDB::AddOneMoreFrame (ABI *abi)
{
+ // If we've already gotten to the end of the stack, don't bother to try again...
+ if (m_unwind_complete)
+ return false;
+
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND));
CursorSP cursor_sp(new Cursor ());
@@ -111,7 +122,7 @@
cur_idx,
*this));
if (reg_ctx_sp.get() == NULL)
- return false;
+ goto unwind_done;
if (!reg_ctx_sp->IsValid())
{
@@ -120,7 +131,7 @@
log->Printf("%*sFrame %d invalid RegisterContext for this frame, stopping stack walk",
cur_idx < 100 ? cur_idx : 100, "", cur_idx);
}
- return false;
+ goto unwind_done;
}
if (!reg_ctx_sp->GetCFA (cursor_sp->cfa))
{
@@ -129,7 +140,7 @@
log->Printf("%*sFrame %d did not get CFA for this frame, stopping stack walk",
cur_idx < 100 ? cur_idx : 100, "", cur_idx);
}
- return false;
+ goto unwind_done;
}
if (abi && !abi->CallFrameAddressIsValid(cursor_sp->cfa))
{
@@ -138,7 +149,7 @@
log->Printf("%*sFrame %d did not get a valid CFA for this frame, stopping stack walk",
cur_idx < 100 ? cur_idx : 100, "", cur_idx);
}
- return false;
+ goto unwind_done;
}
if (!reg_ctx_sp->ReadPC (cursor_sp->start_pc))
{
@@ -147,7 +158,7 @@
log->Printf("%*sFrame %d did not get PC for this frame, stopping stack walk",
cur_idx < 100 ? cur_idx : 100, "", cur_idx);
}
- return false;
+ goto unwind_done;
}
if (abi && !abi->CodeAddressIsValid (cursor_sp->start_pc))
{
@@ -156,26 +167,30 @@
log->Printf("%*sFrame %d did not get a valid PC, stopping stack walk",
cur_idx < 100 ? cur_idx : 100, "", cur_idx);
}
- return false;
+ goto unwind_done;
}
if (!m_frames.empty())
{
if (m_frames.back()->start_pc == cursor_sp->start_pc)
{
if (m_frames.back()->cfa == cursor_sp->cfa)
- return false; // Infinite loop where the current cursor is the same as the previous one...
+ goto unwind_done; // Infinite loop where the current cursor is the same as the previous one...
else if (abi->StackUsesFrames())
{
// We might have a CFA that is not using the frame pointer and
// we want to validate that the frame pointer is valid.
if (reg_ctx_sp->GetFP() == 0)
- return false;
+ goto unwind_done;
}
}
}
cursor_sp->reg_ctx_lldb_sp = reg_ctx_sp;
m_frames.push_back (cursor_sp);
return true;
+
+unwind_done:
+ m_unwind_complete = true;
+ return false;
}
bool
Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h?rev=151705&r1=151704&r2=151705&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h Tue Feb 28 21:40:22 2012
@@ -56,6 +56,7 @@
DoClear()
{
m_frames.clear();
+ m_unwind_complete = false;
}
virtual uint32_t
@@ -98,6 +99,10 @@
typedef SHARED_PTR(Cursor) CursorSP;
std::vector<CursorSP> m_frames;
+ bool m_unwind_complete; // If this is true, we've enumerated all the frames in the stack, and m_frames.size() is the
+ // number of frames, etc. Otherwise we've only gone as far as directly asked, and m_frames.size()
+ // is how far we've currently gone.
+
bool AddOneMoreFrame (ABI *abi);
bool AddFirstFrame ();
Modified: lldb/trunk/source/Target/StackFrameList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrameList.cpp?rev=151705&r1=151704&r2=151705&view=diff
==============================================================================
--- lldb/trunk/source/Target/StackFrameList.cpp (original)
+++ lldb/trunk/source/Target/StackFrameList.cpp Tue Feb 28 21:40:22 2012
@@ -44,6 +44,7 @@
m_mutex (Mutex::eMutexTypeRecursive),
m_frames (),
m_selected_frame_idx (0),
+ m_concrete_frames_fetched (0),
m_show_inlined_frames (show_inline_frames)
{
}
@@ -55,168 +56,185 @@
{
}
-
-uint32_t
-StackFrameList::GetNumFrames (bool can_create)
+void
+StackFrameList::GetFramesUpTo(uint32_t end_idx)
{
- Mutex::Locker locker (m_mutex);
+ // We've already gotten more frames than asked for, or we've already finished unwinding, return.
+ if (m_frames.size() > end_idx || GetAllFramesFetched())
+ return;
+
+ Unwind *unwinder = m_thread.GetUnwinder ();
- if (can_create && m_frames.size() <= 1)
+ if (m_show_inlined_frames)
{
- if (m_show_inlined_frames)
- {
#if defined (DEBUG_STACK_FRAMES)
- StreamFile s(stdout, false);
+ StreamFile s(stdout, false);
#endif
- Unwind *unwinder = m_thread.GetUnwinder ();
- addr_t pc = LLDB_INVALID_ADDRESS;
- addr_t cfa = LLDB_INVALID_ADDRESS;
-
- // 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.
- const uint32_t unwind_frame_count = unwinder->GetFrameCount();
-
- StackFrameSP unwind_frame_sp;
- for (uint32_t idx=0; idx<unwind_frame_count; ++idx)
+
+ StackFrameSP unwind_frame_sp;
+ do
+ {
+ uint32_t idx = m_concrete_frames_fetched++;
+ lldb::addr_t pc;
+ lldb::addr_t cfa;
+ if (idx == 0)
{
- if (idx == 0)
+ // We might have already created frame zero, only create it
+ // if we need to
+ if (m_frames.empty())
{
- // We might have already created frame zero, only create it
- // if we need to
- if (m_frames.empty())
- {
- cfa = m_thread.m_reg_context_sp->GetSP();
- m_thread.GetRegisterContext();
- unwind_frame_sp.reset (new StackFrame (m_thread.shared_from_this(),
- m_frames.size(),
- idx,
- m_thread.m_reg_context_sp,
- cfa,
- m_thread.m_reg_context_sp->GetPC(),
- NULL));
- m_frames.push_back (unwind_frame_sp);
- }
- else
- {
- unwind_frame_sp = m_frames.front();
- cfa = unwind_frame_sp->m_id.GetCallFrameAddress();
- }
+ cfa = m_thread.m_reg_context_sp->GetSP();
+ m_thread.GetRegisterContext();
+ unwind_frame_sp.reset (new StackFrame (m_thread.shared_from_this(),
+ m_frames.size(),
+ idx,
+ m_thread.m_reg_context_sp,
+ cfa,
+ m_thread.m_reg_context_sp->GetPC(),
+ NULL));
+ m_frames.push_back (unwind_frame_sp);
}
else
{
- const bool success = unwinder->GetFrameInfoAtIndex(idx, cfa, pc);
- assert (success);
- unwind_frame_sp.reset (new StackFrame (m_thread.shared_from_this(), m_frames.size(), idx, cfa, pc, NULL));
- m_frames.push_back (unwind_frame_sp);
+ unwind_frame_sp = m_frames.front();
+ cfa = unwind_frame_sp->m_id.GetCallFrameAddress();
}
-
- SymbolContext unwind_sc = unwind_frame_sp->GetSymbolContext (eSymbolContextBlock | eSymbolContextFunction);
- Block *unwind_block = unwind_sc.block;
- if (unwind_block)
+ }
+ else
+ {
+ const bool success = unwinder->GetFrameInfoAtIndex(idx, cfa, pc);
+ if (!success)
{
- Address curr_frame_address (unwind_frame_sp->GetFrameCodeAddress());
- // Be sure to adjust the frame address to match the address
- // that was used to lookup the symbol context above. If we are
- // in the first concrete frame, then we lookup using the current
- // address, else we decrement the address by one to get the correct
- // location.
- if (idx > 0)
- curr_frame_address.Slide(-1);
-
- SymbolContext next_frame_sc;
- Address next_frame_address;
+ // We've gotten to the end of the stack.
+ SetAllFramesFetched();
+ break;
+ }
+ unwind_frame_sp.reset (new StackFrame (m_thread.shared_from_this(), m_frames.size(), idx, cfa, pc, NULL));
+ m_frames.push_back (unwind_frame_sp);
+ }
+
+ SymbolContext unwind_sc = unwind_frame_sp->GetSymbolContext (eSymbolContextBlock | eSymbolContextFunction);
+ Block *unwind_block = unwind_sc.block;
+ if (unwind_block)
+ {
+ Address curr_frame_address (unwind_frame_sp->GetFrameCodeAddress());
+ // Be sure to adjust the frame address to match the address
+ // that was used to lookup the symbol context above. If we are
+ // in the first concrete frame, then we lookup using the current
+ // address, else we decrement the address by one to get the correct
+ // location.
+ if (idx > 0)
+ curr_frame_address.Slide(-1);
- while (unwind_sc.GetParentOfInlinedScope(curr_frame_address, next_frame_sc, next_frame_address))
- {
- StackFrameSP frame_sp(new StackFrame (m_thread.shared_from_this(),
- m_frames.size(),
- idx,
- unwind_frame_sp->GetRegisterContextSP (),
- cfa,
- next_frame_address,
- &next_frame_sc));
-
- m_frames.push_back (frame_sp);
- unwind_sc = next_frame_sc;
- curr_frame_address = next_frame_address;
-
- }
+ SymbolContext next_frame_sc;
+ Address next_frame_address;
+
+ while (unwind_sc.GetParentOfInlinedScope(curr_frame_address, next_frame_sc, next_frame_address))
+ {
+ StackFrameSP frame_sp(new StackFrame (m_thread.shared_from_this(),
+ m_frames.size(),
+ idx,
+ unwind_frame_sp->GetRegisterContextSP (),
+ cfa,
+ next_frame_address,
+ &next_frame_sc));
+
+ m_frames.push_back (frame_sp);
+ unwind_sc = next_frame_sc;
+ curr_frame_address = next_frame_address;
}
}
+ } while (m_frames.size() - 1 < end_idx);
- if (m_prev_frames_sp)
- {
- StackFrameList *prev_frames = m_prev_frames_sp.get();
- StackFrameList *curr_frames = this;
+ // Don't try to merge till you've calculated all the frames in this stack.
+ if (GetAllFramesFetched() && m_prev_frames_sp)
+ {
+ StackFrameList *prev_frames = m_prev_frames_sp.get();
+ StackFrameList *curr_frames = this;
#if defined (DEBUG_STACK_FRAMES)
- s.PutCString("\nprev_frames:\n");
- prev_frames->Dump (&s);
- s.PutCString("\ncurr_frames:\n");
- curr_frames->Dump (&s);
- s.EOL();
+ s.PutCString("\nprev_frames:\n");
+ prev_frames->Dump (&s);
+ s.PutCString("\ncurr_frames:\n");
+ curr_frames->Dump (&s);
+ s.EOL();
#endif
- size_t curr_frame_num, prev_frame_num;
-
- for (curr_frame_num = curr_frames->m_frames.size(), prev_frame_num = prev_frames->m_frames.size();
- curr_frame_num > 0 && prev_frame_num > 0;
- --curr_frame_num, --prev_frame_num)
- {
- const size_t curr_frame_idx = curr_frame_num-1;
- const size_t prev_frame_idx = prev_frame_num-1;
- StackFrameSP curr_frame_sp (curr_frames->m_frames[curr_frame_idx]);
- StackFrameSP prev_frame_sp (prev_frames->m_frames[prev_frame_idx]);
-
-#if defined (DEBUG_STACK_FRAMES)
- s.Printf("\n\nCurr frame #%u ", curr_frame_idx);
- if (curr_frame_sp)
- curr_frame_sp->Dump (&s, true, false);
- else
- s.PutCString("NULL");
- s.Printf("\nPrev frame #%u ", prev_frame_idx);
- if (prev_frame_sp)
- prev_frame_sp->Dump (&s, true, false);
- else
- s.PutCString("NULL");
+ size_t curr_frame_num, prev_frame_num;
+
+ for (curr_frame_num = curr_frames->m_frames.size(), prev_frame_num = prev_frames->m_frames.size();
+ curr_frame_num > 0 && prev_frame_num > 0;
+ --curr_frame_num, --prev_frame_num)
+ {
+ const size_t curr_frame_idx = curr_frame_num-1;
+ const size_t prev_frame_idx = prev_frame_num-1;
+ StackFrameSP curr_frame_sp (curr_frames->m_frames[curr_frame_idx]);
+ StackFrameSP prev_frame_sp (prev_frames->m_frames[prev_frame_idx]);
+
+#if defined (DEBUG_STACK_FRAMES)
+ s.Printf("\n\nCurr frame #%u ", curr_frame_idx);
+ if (curr_frame_sp)
+ curr_frame_sp->Dump (&s, true, false);
+ else
+ s.PutCString("NULL");
+ s.Printf("\nPrev frame #%u ", prev_frame_idx);
+ if (prev_frame_sp)
+ prev_frame_sp->Dump (&s, true, false);
+ else
+ s.PutCString("NULL");
#endif
- StackFrame *curr_frame = curr_frame_sp.get();
- StackFrame *prev_frame = prev_frame_sp.get();
-
- if (curr_frame == NULL || prev_frame == NULL)
- break;
+ StackFrame *curr_frame = curr_frame_sp.get();
+ StackFrame *prev_frame = prev_frame_sp.get();
+
+ if (curr_frame == NULL || prev_frame == NULL)
+ break;
- // Check the stack ID to make sure they are equal
- if (curr_frame->GetStackID() != prev_frame->GetStackID())
- break;
-
- prev_frame->UpdatePreviousFrameFromCurrentFrame (*curr_frame);
- // Now copy the fixed up previous frame into the current frames
- // so the pointer doesn't change
- m_frames[curr_frame_idx] = prev_frame_sp;
- //curr_frame->UpdateCurrentFrameFromPreviousFrame (*prev_frame);
-
+ // Check the stack ID to make sure they are equal
+ if (curr_frame->GetStackID() != prev_frame->GetStackID())
+ break;
+
+ prev_frame->UpdatePreviousFrameFromCurrentFrame (*curr_frame);
+ // Now copy the fixed up previous frame into the current frames
+ // so the pointer doesn't change
+ m_frames[curr_frame_idx] = prev_frame_sp;
+ //curr_frame->UpdateCurrentFrameFromPreviousFrame (*prev_frame);
+
#if defined (DEBUG_STACK_FRAMES)
- s.Printf("\n Copying previous frame to current frame");
+ s.Printf("\n Copying previous frame to current frame");
#endif
- }
- // We are done with the old stack frame list, we can release it now
- m_prev_frames_sp.reset();
}
-
+ // We are done with the old stack frame list, we can release it now
+ m_prev_frames_sp.reset();
+ }
+
#if defined (DEBUG_STACK_FRAMES)
- s.PutCString("\n\nNew frames:\n");
- Dump (&s);
- s.EOL();
+ s.PutCString("\n\nNew frames:\n");
+ Dump (&s);
+ s.EOL();
#endif
- }
- else
+ }
+ else
+ {
+ if (end_idx < m_concrete_frames_fetched)
+ return;
+
+ uint32_t num_frames = unwinder->GetFramesUpTo(end_idx);
+ if (num_frames <= end_idx + 1)
{
- m_frames.resize(m_thread.GetUnwinder()->GetFrameCount());
+ //Done unwinding.
+ m_concrete_frames_fetched = UINT32_MAX;
}
+ m_frames.resize(num_frames);
}
+}
+
+uint32_t
+StackFrameList::GetNumFrames (bool can_create)
+{
+ Mutex::Locker locker (m_mutex);
+
+ if (can_create)
+ GetFramesUpTo (UINT32_MAX);
return m_frames.size();
}
@@ -274,36 +292,40 @@
SetFrameAtIndex(idx, frame_sp);
}
- else if (idx < GetNumFrames())
+ else
{
- if (m_show_inlined_frames)
- {
- // When inline frames are enabled we cache up all frames in GetNumFrames()
- frame_sp = m_frames[idx];
- }
- else
+ GetFramesUpTo (idx);
+ if (idx < m_frames.size())
{
- Unwind *unwinder = m_thread.GetUnwinder ();
- if (unwinder)
+ if (m_show_inlined_frames)
+ {
+ // When inline frames are enabled we cache up all frames in GetNumFrames()
+ frame_sp = m_frames[idx];
+ }
+ else
{
- addr_t pc, cfa;
- if (unwinder->GetFrameInfoAtIndex(idx, cfa, pc))
+ Unwind *unwinder = m_thread.GetUnwinder ();
+ if (unwinder)
{
- 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
+ addr_t pc, cfa;
+ if (unwinder->GetFrameInfoAtIndex(idx, cfa, pc))
{
- // Set the symbol scope from the symbol regardless if it is NULL or valid.
- frame_sp->SetSymbolContextScope (frame_sp->GetSymbolContext (eSymbolContextSymbol).symbol);
+ 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);
}
- SetFrameAtIndex(idx, frame_sp);
}
}
}
@@ -390,12 +412,18 @@
}
// Mark a stack frame as the current frame using the frame index
-void
+bool
StackFrameList::SetSelectedFrameByIndex (uint32_t idx)
{
Mutex::Locker locker (m_mutex);
- m_selected_frame_idx = idx;
- SetDefaultFileAndLineToSelectedFrame();
+ StackFrameSP frame_sp (GetFrameAtIndex (idx));
+ if (frame_sp)
+ {
+ SetSelectedFrame(frame_sp.get());
+ return true;
+ }
+ else
+ return false;
}
void
@@ -421,6 +449,7 @@
{
Mutex::Locker locker (m_mutex);
m_frames.clear();
+ m_concrete_frames_fetched = 0;
}
void
Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=151705&r1=151704&r2=151705&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Tue Feb 28 21:40:22 2012
@@ -1069,7 +1069,10 @@
void
Thread::ClearStackFrames ()
{
- if (m_curr_frames_sp && m_curr_frames_sp->GetNumFrames (false) > 1)
+ // Only store away the old "reference" StackFrameList if we got all its frames:
+ // FIXME: At some point we can try to splice in the frames we have fetched into
+ // the new frame as we make it, but let's not try that now.
+ if (m_curr_frames_sp && m_curr_frames_sp->GetAllFramesFetched())
m_prev_frames_sp.swap (m_curr_frames_sp);
m_curr_frames_sp.reset();
}
More information about the lldb-commits
mailing list