LLDB mainline
|
#include <StackFrameList.h>
Public Member Functions | |
StackFrameList (Thread &thread, const lldb::StackFrameListSP &prev_frames_sp, bool show_inline_frames) | |
~StackFrameList () | |
uint32_t | GetNumFrames (bool can_create=true) |
Get the number of visible frames. | |
lldb::StackFrameSP | GetFrameAtIndex (uint32_t idx) |
Get the frame at index idx . Invisible frames cannot be indexed. | |
lldb::StackFrameSP | GetFrameWithConcreteFrameIndex (uint32_t unwind_idx) |
Get the first concrete frame with index greater than or equal to idx . | |
lldb::StackFrameSP | GetFrameWithStackID (const StackID &stack_id) |
Retrieve the stack frame with the given ID stack_id . | |
uint32_t | SetSelectedFrame (lldb_private::StackFrame *frame) |
Mark a stack frame as the currently selected frame and return its index. | |
uint32_t | GetSelectedFrameIndex (SelectMostRelevant select_most_relevant_frame) |
Get the currently selected frame index. | |
bool | SetSelectedFrameByIndex (uint32_t idx) |
Mark a stack frame as the currently selected frame using the frame index idx . | |
uint32_t | GetVisibleStackFrameIndex (uint32_t idx) |
If the current inline depth (i.e the number of invisible frames) is valid, subtract it from idx . | |
void | CalculateCurrentInlinedDepth () |
Calculate and set the current inline depth. | |
void | SetDefaultFileAndLineToSelectedFrame () |
If the currently selected frame comes from the currently selected thread, point the default file and line of the thread's target to the location specified by the frame. | |
void | Clear () |
Clear the cache of frames. | |
void | Dump (Stream *s) |
lldb::StackFrameSP | GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr) |
If stack_frame_ptr is contained in this StackFrameList, return its wrapping shared pointer. | |
size_t | GetStatus (Stream &strm, uint32_t first_frame, uint32_t num_frames, bool show_frame_info, uint32_t num_frames_with_source, bool show_unique=false, bool show_hidden=false, const char *frame_marker=nullptr) |
bool | WereAllFramesFetched () const |
Returns whether we have currently fetched all the frames of a stack. | |
Protected Types | |
typedef std::vector< lldb::StackFrameSP > | collection |
typedef collection::iterator | iterator |
typedef collection::const_iterator | const_iterator |
Protected Member Functions | |
bool | SetFrameAtIndex (uint32_t idx, lldb::StackFrameSP &frame_sp) |
Use this API to build a stack frame list (used for scripted threads, for instance.) This API is not meant for StackFrameLists that have unwinders and partake in lazy stack filling (using GetFramesUpTo). | |
bool | GetFramesUpTo (uint32_t end_idx, InterruptionControl allow_interrupt) |
Ensures that frames up to (and including) end_idx are realized in the StackFrameList. | |
bool | GetAllFramesFetched () const |
void | SetAllFramesFetched () |
bool | DecrementCurrentInlinedDepth () |
void | ResetCurrentInlinedDepth () |
uint32_t | GetCurrentInlinedDepth () |
void | SetCurrentInlinedDepth (uint32_t new_depth) |
void | SelectMostRelevantFrame () |
Calls into the stack frame recognizers and stop info to set the most relevant frame. | |
Protected Attributes | |
Thread & | m_thread |
The thread this frame list describes. | |
lldb::StackFrameListSP | m_prev_frames_sp |
The old stack frame list. | |
std::shared_mutex | m_list_mutex |
A mutex for this frame list. | |
std::mutex | m_inlined_depth_mutex |
collection | m_frames |
A cache of frames. | |
std::optional< uint32_t > | m_selected_frame_idx |
The currently selected frame. | |
uint32_t | m_concrete_frames_fetched |
The number of concrete frames fetched while filling the frame list. | |
uint32_t | m_current_inlined_depth |
The number of synthetic function activations (invisible frames) expanded from the concrete frame #0 activation. | |
lldb::addr_t | m_current_inlined_pc |
The program counter value at the currently selected synthetic activation. | |
const bool | m_show_inlined_frames |
Whether or not to show synthetic (inline) frames. Immutable. | |
Private Member Functions | |
uint32_t | SetSelectedFrameNoLock (lldb_private::StackFrame *frame) |
lldb::StackFrameSP | GetFrameAtIndexNoLock (uint32_t idx, std::shared_lock< std::shared_mutex > &guard) |
bool | FetchFramesUpTo (uint32_t end_idx, InterruptionControl allow_interrupt) |
These two Fetch frames APIs and SynthesizeTailCallFrames are called in GetFramesUpTo, they are the ones that actually add frames. | |
void | FetchOnlyConcreteFramesUpTo (uint32_t end_idx) |
Not currently interruptible so returns void. | |
void | SynthesizeTailCallFrames (StackFrame &next_frame) |
Given that next_frame will be appended to the frame list, synthesize tail call frames between the current end of the list and next_frame . | |
StackFrameList (const StackFrameList &)=delete | |
const StackFrameList & | operator= (const StackFrameList &)=delete |
Friends | |
class | Thread |
class | ScriptedThread |
Definition at line 23 of file StackFrameList.h.
|
protected |
Definition at line 143 of file StackFrameList.h.
|
protected |
Definition at line 145 of file StackFrameList.h.
|
protected |
Definition at line 144 of file StackFrameList.h.
StackFrameList::StackFrameList | ( | Thread & | thread, |
const lldb::StackFrameListSP & | prev_frames_sp, | ||
bool | show_inline_frames | ||
) |
Definition at line 38 of file StackFrameList.cpp.
References m_current_inlined_depth, and m_current_inlined_pc.
StackFrameList::~StackFrameList | ( | ) |
Definition at line 52 of file StackFrameList.cpp.
References Clear().
|
privatedelete |
void StackFrameList::CalculateCurrentInlinedDepth | ( | ) |
Calculate and set the current inline depth.
This may be used to update the StackFrameList's set of inline frames when execution stops, e.g when a breakpoint is hit.
Definition at line 58 of file StackFrameList.cpp.
References GetCurrentInlinedDepth(), ResetCurrentInlinedDepth(), and UINT32_MAX.
void StackFrameList::Clear | ( | ) |
Clear the cache of frames.
Definition at line 850 of file StackFrameList.cpp.
References m_concrete_frames_fetched, m_frames, m_list_mutex, and m_selected_frame_idx.
Referenced by ~StackFrameList().
|
protected |
Definition at line 117 of file StackFrameList.cpp.
References GetCurrentInlinedDepth(), m_current_inlined_depth, m_inlined_depth_mutex, m_show_inlined_frames, and UINT32_MAX.
void StackFrameList::Dump | ( | Stream * | s | ) |
Definition at line 588 of file StackFrameList.cpp.
References lldb_private::StackID::Dump(), lldb_private::StackFrame::DumpUsingSettingsFormat(), lldb_private::Stream::EOL(), lldb_private::StackFrame::GetStackID(), m_frames, m_list_mutex, and lldb_private::Stream::Printf().
Referenced by FetchFramesUpTo(), and GetFramesUpTo().
|
private |
These two Fetch frames APIs and SynthesizeTailCallFrames are called in GetFramesUpTo, they are the ones that actually add frames.
They must be called with the writer end of the list mutex held. Returns true if fetching frames was interrupted, false otherwise.
Definition at line 397 of file StackFrameList.cpp.
References lldb_private::LineEntry::ApplyFileMappings(), lldb_private::SymbolContext::block, lldb_private::Thread::CalculateTarget(), Dump(), lldb_private::Stream::EOL(), GetAllFramesFetched(), GetCurrentInlinedDepth(), lldb_private::Unwind::GetFrameInfoAtIndex(), lldb_private::SymbolContext::GetParentOfInlinedScope(), lldb_private::Thread::GetProcess(), lldb_private::Thread::GetRegisterContext(), lldb_private::StackFrame::GetStackID(), lldb_private::Thread::GetUnwinder(), INTERRUPT_REQUESTED, lldb_private::SymbolContext::line_entry, LLDB_INVALID_ADDRESS, m_concrete_frames_fetched, m_frames, m_prev_frames_sp, m_thread, pc, lldb_private::Stream::Printf(), lldb_private::Stream::PutCString(), lldb_private::StackFrame::Regular, SetAllFramesFetched(), SynthesizeTailCallFrames(), UINT32_MAX, and lldb_private::StackFrame::UpdatePreviousFrameFromCurrentFrame().
Referenced by GetFramesUpTo().
|
private |
Not currently interruptible so returns void.
Definition at line 377 of file StackFrameList.cpp.
References lldb_private::Unwind::GetFramesUpTo(), lldb_private::Thread::GetUnwinder(), lldb_private::Thread::IsValid(), m_concrete_frames_fetched, m_frames, m_thread, and UINT32_MAX.
Referenced by GetFramesUpTo().
|
inlineprotected |
Definition at line 123 of file StackFrameList.h.
References m_concrete_frames_fetched, and UINT32_MAX.
Referenced by FetchFramesUpTo(), GetFramesUpTo(), and WereAllFramesFetched().
|
protected |
Definition at line 65 of file StackFrameList.cpp.
References lldb_private::GetLog(), lldb_private::Thread::GetRegisterContext(), lldb_private::Log::GetVerbose(), LLDB_INVALID_ADDRESS, LLDB_LOGF, m_current_inlined_depth, m_current_inlined_pc, m_inlined_depth_mutex, m_show_inlined_frames, m_thread, lldb_private::Step, and UINT32_MAX.
Referenced by CalculateCurrentInlinedDepth(), DecrementCurrentInlinedDepth(), FetchFramesUpTo(), GetFrameAtIndex(), and SetSelectedFrame().
StackFrameSP StackFrameList::GetFrameAtIndex | ( | uint32_t | idx | ) |
Get the frame at index idx
. Invisible frames cannot be indexed.
Definition at line 608 of file StackFrameList.cpp.
References AllowInterruption, GetCurrentInlinedDepth(), GetFramesUpTo(), lldb_private::GetLog(), lldb_private::Thread::IsValid(), LLDB_LOG, m_frames, m_list_mutex, m_thread, ResetCurrentInlinedDepth(), lldb_private::Thread, and UINT32_MAX.
Referenced by GetFrameWithConcreteFrameIndex(), GetFrameWithStackID(), GetStatus(), SelectMostRelevantFrame(), SetDefaultFileAndLineToSelectedFrame(), and SetSelectedFrameByIndex().
|
private |
|
protected |
Ensures that frames up to (and including) end_idx
are realized in the StackFrameList.
end_idx
can be larger than the actual number of frames, in which case all the frames will be fetched. Acquires the writer end of the list mutex. Returns true if the function was interrupted, false otherwise. Callers should first check (under the shared mutex) whether we need to fetch frames or not.
Definition at line 341 of file StackFrameList.cpp.
References Dump(), FetchFramesUpTo(), FetchOnlyConcreteFramesUpTo(), GetAllFramesFetched(), lldb_private::Thread::IsValid(), m_concrete_frames_fetched, m_frames, m_list_mutex, m_show_inlined_frames, and m_thread.
Referenced by GetFrameAtIndex(), and GetNumFrames().
StackFrameSP StackFrameList::GetFrameWithConcreteFrameIndex | ( | uint32_t | unwind_idx | ) |
Get the first concrete frame with index greater than or equal to idx
.
Unlike GetFrameAtIndex, this cannot return a synthetic frame.
Definition at line 662 of file StackFrameList.cpp.
References GetFrameAtIndex().
StackFrameSP StackFrameList::GetFrameWithStackID | ( | const StackID & | stack_id | ) |
Retrieve the stack frame with the given ID stack_id
.
Definition at line 684 of file StackFrameList.cpp.
References CompareStackID(), GetFrameAtIndex(), lldb_private::StackID::IsValid(), m_frames, and m_list_mutex.
uint32_t StackFrameList::GetNumFrames | ( | bool | can_create = true | ) |
Get the number of visible frames.
Frames may be created if can_create
is true. Synthetic (inline) frames expanded from the concrete frame #0 (aka invisible frames) are not included in this count.
Definition at line 575 of file StackFrameList.cpp.
References DoNotAllowInterruption, GetFramesUpTo(), GetVisibleStackFrameIndex(), m_frames, m_list_mutex, UINT32_MAX, and WereAllFramesFetched().
uint32_t StackFrameList::GetSelectedFrameIndex | ( | SelectMostRelevant | select_most_relevant_frame | ) |
Get the currently selected frame index.
We should only call SelectMostRelevantFrame if (a) the user hasn't already selected a frame, and (b) if this really is a user facing "GetSelectedFrame". SMRF runs the frame recognizers which can do arbitrary work that ends up being dangerous to do internally. Also, for most internal uses we don't actually want the frame changed by the SMRF logic. So unless this is in a command or SB API, you should pass false here.
Definition at line 785 of file StackFrameList.cpp.
References m_selected_frame_idx, and SelectMostRelevantFrame().
Referenced by SetDefaultFileAndLineToSelectedFrame().
lldb::StackFrameSP StackFrameList::GetStackFrameSPForStackFramePtr | ( | StackFrame * | stack_frame_ptr | ) |
If stack_frame_ptr
is contained in this StackFrameList, return its wrapping shared pointer.
Definition at line 858 of file StackFrameList.cpp.
References m_frames, and m_list_mutex.
size_t StackFrameList::GetStatus | ( | Stream & | strm, |
uint32_t | first_frame, | ||
uint32_t | num_frames, | ||
bool | show_frame_info, | ||
uint32_t | num_frames_with_source, | ||
bool | show_unique = false , |
||
bool | show_hidden = false , |
||
const char * | frame_marker = nullptr |
||
) |
Definition at line 874 of file StackFrameList.cpp.
References DoNoSelectMostRelevantFrame, GetFrameAtIndex(), lldb_private::UserID::GetID(), lldb_private::Thread::GetProcess(), lldb_private::Thread::GetSelectedFrame(), lldb_private::Stream::IndentLess(), INTERRUPT_REQUESTED, m_thread, and UINT32_MAX.
|
inline |
If the current inline depth (i.e the number of invisible frames) is valid, subtract it from idx
.
Otherwise simply return idx
.
Definition at line 66 of file StackFrameList.h.
References m_current_inlined_depth, and UINT32_MAX.
Referenced by GetNumFrames().
|
privatedelete |
|
protected |
Definition at line 84 of file StackFrameList.cpp.
References lldb_private::GetLog(), lldb_private::Thread::GetRegisterContext(), lldb_private::Thread::GetStopInfo(), lldb_private::Log::GetVerbose(), LLDB_INVALID_ADDRESS, LLDB_LOGF, m_current_inlined_depth, m_current_inlined_pc, m_inlined_depth_mutex, m_show_inlined_frames, m_thread, lldb_private::Step, and UINT32_MAX.
Referenced by CalculateCurrentInlinedDepth(), and GetFrameAtIndex().
|
protected |
Calls into the stack frame recognizers and stop info to set the most relevant frame.
This can call out to arbitrary user code so it can't hold the StackFrameList mutex.
Definition at line 722 of file StackFrameList.cpp.
References GetFrameAtIndex(), lldb_private::GetLog(), lldb_private::Thread::GetProcess(), lldb_private::Thread::GetStopInfo(), LLDB_LOG, m_thread, SetSelectedFrame(), and lldb_private::Thread.
Referenced by GetSelectedFrameIndex().
|
inlineprotected |
Definition at line 128 of file StackFrameList.h.
References m_concrete_frames_fetched, and UINT32_MAX.
Referenced by FetchFramesUpTo().
|
protected |
Definition at line 131 of file StackFrameList.cpp.
References lldb_private::Thread::GetRegisterContext(), LLDB_INVALID_ADDRESS, m_current_inlined_depth, m_current_inlined_pc, m_inlined_depth_mutex, m_thread, and UINT32_MAX.
void StackFrameList::SetDefaultFileAndLineToSelectedFrame | ( | ) |
If the currently selected frame comes from the currently selected thread, point the default file and line of the thread's target to the location specified by the frame.
Definition at line 829 of file StackFrameList.cpp.
References lldb_private::Thread::CalculateTarget(), DoNoSelectMostRelevantFrame, lldb_private::LineEntry::file_sp, lldb_private::LineEntry::GetFile(), GetFrameAtIndex(), lldb_private::UserID::GetID(), lldb_private::Thread::GetProcess(), GetSelectedFrameIndex(), lldb_private::LineEntry::line, lldb_private::SymbolContext::line_entry, and m_thread.
Referenced by SetSelectedFrame().
|
protected |
Use this API to build a stack frame list (used for scripted threads, for instance.) This API is not meant for StackFrameLists that have unwinders and partake in lazy stack filling (using GetFramesUpTo).
Rather if you are building StackFrameLists with this API, you should build the entire list before making it available for use.
Definition at line 710 of file StackFrameList.cpp.
References m_frames, and m_list_mutex.
uint32_t StackFrameList::SetSelectedFrame | ( | lldb_private::StackFrame * | frame | ) |
Mark a stack frame as the currently selected frame and return its index.
Definition at line 799 of file StackFrameList.cpp.
References GetCurrentInlinedDepth(), m_frames, m_list_mutex, m_selected_frame_idx, SetDefaultFileAndLineToSelectedFrame(), and UINT32_MAX.
Referenced by SelectMostRelevantFrame(), and SetSelectedFrameByIndex().
bool StackFrameList::SetSelectedFrameByIndex | ( | uint32_t | idx | ) |
Mark a stack frame as the currently selected frame using the frame index idx
.
Like GetFrameAtIndex, invisible frames cannot be selected.
Definition at line 820 of file StackFrameList.cpp.
References GetFrameAtIndex(), and SetSelectedFrame().
|
private |
|
private |
Given that next_frame
will be appended to the frame list, synthesize tail call frames between the current end of the list and next_frame
.
If any frames are added, adjust the frame index of next_frame
.
Definition at line 270 of file StackFrameList.cpp.
References lldb_private::StackFrame::Artificial, lldb_private::Function::CalculateSymbolContext(), lldb_private::StackFrame::CalculateTarget(), lldb_private::CallEdge::Call, FindInterveningFrames(), lldb_private::SymbolContext::function, lldb_private::StackFrame::GetConcreteFrameIndex(), lldb_private::Function::GetDisplayName(), lldb_private::GetLog(), lldb_private::StackFrame::GetRegisterContext(), lldb_private::StackFrame::GetSymbolContext(), LLDB_INVALID_ADDRESS, LLDB_LOG, m_frames, m_thread, pc, lldb_private::StackFrame::SetFrameIndex(), lldb_private::ExecutionContext::SetFramePtr(), and lldb_private::Step.
Referenced by FetchFramesUpTo().
bool StackFrameList::WereAllFramesFetched | ( | ) | const |
Returns whether we have currently fetched all the frames of a stack.
Definition at line 140 of file StackFrameList.cpp.
References GetAllFramesFetched(), and m_list_mutex.
Referenced by GetNumFrames().
|
friend |
Definition at line 103 of file StackFrameList.h.
|
friend |
Definition at line 102 of file StackFrameList.h.
|
protected |
The number of concrete frames fetched while filling the frame list.
This is only used when synthetic frames are enabled.
Definition at line 179 of file StackFrameList.h.
Referenced by Clear(), FetchFramesUpTo(), FetchOnlyConcreteFramesUpTo(), GetAllFramesFetched(), GetFramesUpTo(), and SetAllFramesFetched().
|
protected |
The number of synthetic function activations (invisible frames) expanded from the concrete frame #0 activation.
Definition at line 184 of file StackFrameList.h.
Referenced by DecrementCurrentInlinedDepth(), GetCurrentInlinedDepth(), GetVisibleStackFrameIndex(), ResetCurrentInlinedDepth(), SetCurrentInlinedDepth(), and StackFrameList().
|
protected |
The program counter value at the currently selected synthetic activation.
This is only valid if m_current_inlined_depth is valid.
Definition at line 189 of file StackFrameList.h.
Referenced by GetCurrentInlinedDepth(), ResetCurrentInlinedDepth(), SetCurrentInlinedDepth(), and StackFrameList().
|
protected |
A cache of frames.
This may need to be updated when the program counter changes.
Definition at line 170 of file StackFrameList.h.
Referenced by Clear(), Dump(), FetchFramesUpTo(), FetchOnlyConcreteFramesUpTo(), GetFrameAtIndex(), GetFramesUpTo(), GetFrameWithStackID(), GetNumFrames(), GetStackFrameSPForStackFramePtr(), SetFrameAtIndex(), SetSelectedFrame(), and SynthesizeTailCallFrames().
|
mutableprotected |
Definition at line 166 of file StackFrameList.h.
Referenced by DecrementCurrentInlinedDepth(), GetCurrentInlinedDepth(), ResetCurrentInlinedDepth(), and SetCurrentInlinedDepth().
|
mutableprotected |
A mutex for this frame list.
The only public API that requires the unique lock is Clear. All other clients take the shared lock, though if we need more frames we may swap shared for unique to fulfill that requirement.
Definition at line 161 of file StackFrameList.h.
Referenced by Clear(), Dump(), GetFrameAtIndex(), GetFramesUpTo(), GetFrameWithStackID(), GetNumFrames(), GetStackFrameSPForStackFramePtr(), SetFrameAtIndex(), SetSelectedFrame(), and WereAllFramesFetched().
|
protected |
The old stack frame list.
Definition at line 155 of file StackFrameList.h.
Referenced by FetchFramesUpTo().
|
protected |
The currently selected frame.
An optional is used to record whether anyone has set the selected frame on this stack yet. We only let recognizers change the frame if this is the first time GetSelectedFrame is called.
Definition at line 175 of file StackFrameList.h.
Referenced by Clear(), GetSelectedFrameIndex(), and SetSelectedFrame().
|
protected |
Whether or not to show synthetic (inline) frames. Immutable.
Definition at line 192 of file StackFrameList.h.
Referenced by DecrementCurrentInlinedDepth(), GetCurrentInlinedDepth(), GetFramesUpTo(), and ResetCurrentInlinedDepth().
|
protected |
The thread this frame list describes.
Definition at line 148 of file StackFrameList.h.
Referenced by FetchFramesUpTo(), FetchOnlyConcreteFramesUpTo(), GetCurrentInlinedDepth(), GetFrameAtIndex(), GetFramesUpTo(), GetStatus(), ResetCurrentInlinedDepth(), SelectMostRelevantFrame(), SetCurrentInlinedDepth(), SetDefaultFileAndLineToSelectedFrame(), and SynthesizeTailCallFrames().