LLDB mainline
|
Execution context objects refer to objects in the execution of the program that is being debugged. More...
#include <ExecutionContext.h>
Public Member Functions | |
ExecutionContextRef () | |
Default Constructor. | |
ExecutionContextRef (const ExecutionContextRef &rhs) | |
Copy Constructor. | |
ExecutionContextRef (const ExecutionContext *exe_ctx_ptr) | |
Construct using an ExecutionContext object that might be nullptr. | |
ExecutionContextRef (const ExecutionContext &exe_ctx) | |
Construct using an ExecutionContext object. | |
ExecutionContextRef (Target *target, bool adopt_selected) | |
Construct using the target and all the selected items inside of it (the process and its selected thread, and the thread's selected frame). | |
ExecutionContextRef (ExecutionContextScope *exe_scope) | |
Construct using an execution context scope. | |
ExecutionContextRef (ExecutionContextScope &exe_scope) | |
Construct using an execution context scope. | |
~ExecutionContextRef () | |
ExecutionContextRef & | operator= (const ExecutionContextRef &rhs) |
Assignment operator. | |
ExecutionContextRef & | operator= (const ExecutionContext &exe_ctx) |
Assignment operator from a ExecutionContext. | |
void | Clear () |
Clear the object's state. | |
void | SetTargetSP (const lldb::TargetSP &target_sp) |
Set accessor that creates a weak reference to the target referenced in target_sp. | |
void | SetProcessSP (const lldb::ProcessSP &process_sp) |
Set accessor that creates a weak reference to the process referenced in process_sp. | |
void | SetThreadSP (const lldb::ThreadSP &thread_sp) |
Set accessor that creates a weak reference to the thread referenced in thread_sp. | |
void | SetFrameSP (const lldb::StackFrameSP &frame_sp) |
Set accessor that creates a weak reference to the frame referenced in frame_sp. | |
void | SetTargetPtr (Target *target, bool adopt_selected) |
void | SetProcessPtr (Process *process) |
void | SetThreadPtr (Thread *thread) |
void | SetFramePtr (StackFrame *frame) |
lldb::TargetSP | GetTargetSP () const |
Get accessor that creates a strong reference from the weak target reference contained in this object. | |
lldb::ProcessSP | GetProcessSP () const |
Get accessor that creates a strong reference from the weak process reference contained in this object. | |
lldb::ThreadSP | GetThreadSP () const |
Get accessor that creates a strong reference from the weak thread reference contained in this object. | |
lldb::StackFrameSP | GetFrameSP () const |
Get accessor that creates a strong reference from the weak frame reference contained in this object. | |
ExecutionContext | Lock (bool thread_and_frame_only_if_stopped) const |
Create an ExecutionContext object from this object. | |
bool | HasThreadRef () const |
Returns true if this object has a weak reference to a thread. | |
bool | HasFrameRef () const |
Returns true if this object has a weak reference to a frame. | |
void | ClearThread () |
void | ClearFrame () |
Protected Attributes | |
lldb::TargetWP | m_target_wp |
A weak reference to a target. | |
lldb::ProcessWP | m_process_wp |
A weak reference to a process. | |
lldb::ThreadWP | m_thread_wp |
A weak reference to a thread. | |
lldb::tid_t | m_tid = LLDB_INVALID_THREAD_ID |
The thread ID that this object refers to in case the backing object changes. | |
StackID | m_stack_id |
The stack ID that this object refers to in case the backing object changes. |
Execution context objects refer to objects in the execution of the program that is being debugged.
The consist of one or more of the following objects: target, process, thread, and frame. Many objects in the debugger need to track different executions contexts. For example, a local function variable might have an execution context that refers to a stack frame. A global or static variable might refer to a target since a stack frame isn't required in order to evaluate a global or static variable (a process isn't necessarily needed for a global variable since we might be able to read the variable value from a data section in one of the object files in a target). There are two types of objects that hold onto execution contexts: ExecutionContextRef and ExecutionContext. Both of these objects are described below.
Not all objects in an ExecutionContext objects will be valid. If you want to refer strongly (ExecutionContext) or weakly (ExecutionContextRef) to a process, then only the process and target references will be valid. For threads, only the thread, process and target references will be filled in. For frames, all of the objects will be filled in.
These classes are designed to be used as baton objects that get passed to a wide variety of functions that require execution contexts.
"lldb/Target/ExecutionContext.h" A class that holds a weak reference to an execution context.
ExecutionContextRef objects are designed to hold onto an execution context that might change over time. For example, if an object wants to refer to a stack frame, it should hold onto an ExecutionContextRef to a frame object. The backing object that represents the stack frame might change over time and instances of this object can track the logical object that refers to a frame even if it does change.
These objects also don't keep execution objects around longer than they should since they use weak pointers. For example if an object refers to a stack frame and a stack frame is no longer in a thread, then a ExecutionContextRef object that refers to that frame will not be able to get a shared pointer to those objects since they are no longer around.
ExecutionContextRef objects can also be used as objects in classes that want to track a "previous execution context". Since the weak references to the execution objects (target, process, thread and frame) don't keep these objects around, they are safe to keep around.
The general rule of thumb is all long lived objects that want to refer to execution contexts should use ExecutionContextRef objects. The ExecutionContext class is used to temporarily get shared pointers to any execution context objects that are still around so they are guaranteed to exist during a function that requires the objects. ExecutionContext objects should NOT be used for long term storage since they will keep objects alive with extra shared pointer references to these objects.
Definition at line 73 of file ExecutionContext.h.
ExecutionContextRef::ExecutionContextRef | ( | ) |
Default Constructor.
Definition at line 413 of file ExecutionContext.cpp.
References m_process_wp, m_stack_id, m_target_wp, and m_thread_wp.
Referenced by ExecutionContextRef(), operator=(), operator=(), and ~ExecutionContextRef().
|
default |
Copy Constructor.
References ExecutionContextRef().
ExecutionContextRef::ExecutionContextRef | ( | const ExecutionContext * | exe_ctx_ptr | ) |
Construct using an ExecutionContext object that might be nullptr.
If exe_ctx_ptr is valid, then make weak references to any valid objects in the ExecutionContext, otherwise no weak references to any execution context objects will be made.
Definition at line 416 of file ExecutionContext.cpp.
References m_process_wp, m_stack_id, m_target_wp, and m_thread_wp.
ExecutionContextRef::ExecutionContextRef | ( | const ExecutionContext & | exe_ctx | ) |
Construct using an ExecutionContext object.
Make weak references to any valid objects in the ExecutionContext.
Definition at line 422 of file ExecutionContext.cpp.
References m_process_wp, m_stack_id, m_target_wp, and m_thread_wp.
Construct using the target and all the selected items inside of it (the process and its selected thread, and the thread's selected frame).
If there is no selected thread, default to the first thread If there is no selected frame, default to the first frame.
Definition at line 427 of file ExecutionContext.cpp.
References m_process_wp, m_stack_id, m_target_wp, m_thread_wp, and SetTargetPtr().
lldb_private::ExecutionContextRef::ExecutionContextRef | ( | ExecutionContextScope * | exe_scope | ) |
Construct using an execution context scope.
If the ExecutionContextScope object is valid and refers to a frame, make weak references too the frame, thread, process and target. If the ExecutionContextScope object is valid and refers to a thread, make weak references too the thread, process and target. If the ExecutionContextScope object is valid and refers to a process, make weak references too the process and target. If the ExecutionContextScope object is valid and refers to a target, make weak references too the target.
lldb_private::ExecutionContextRef::ExecutionContextRef | ( | ExecutionContextScope & | exe_scope | ) |
Construct using an execution context scope.
If the ExecutionContextScope object refers to a frame, make weak references too the frame, thread, process and target. If the ExecutionContextScope object refers to a thread, make weak references too the thread, process and target. If the ExecutionContextScope object refers to a process, make weak references too the process and target. If the ExecutionContextScope object refers to a target, make weak references too the target.
|
default |
References ExecutionContextRef().
void ExecutionContextRef::Clear | ( | ) |
Clear the object's state.
Sets the process and thread to nullptr, and the frame index to an invalid value.
Definition at line 466 of file ExecutionContext.cpp.
References ClearFrame(), ClearThread(), m_process_wp, and m_target_wp.
Referenced by SetFramePtr(), and SetTargetPtr().
|
inline |
Definition at line 260 of file ExecutionContext.h.
References m_stack_id.
Referenced by Clear(), and SetFrameSP().
|
inline |
Definition at line 255 of file ExecutionContext.h.
References LLDB_INVALID_THREAD_ID, m_thread_wp, and m_tid.
Referenced by Clear(), SetFrameSP(), SetThreadPtr(), and SetThreadSP().
lldb::StackFrameSP ExecutionContextRef::GetFrameSP | ( | ) | const |
Get accessor that creates a strong reference from the weak frame reference contained in this object.
Definition at line 618 of file ExecutionContext.cpp.
References GetThreadSP(), and m_stack_id.
Referenced by lldb_private::ExecutionContext::ExecutionContext(), and lldb_private::GetStoppedExecutionContext().
lldb::ProcessSP ExecutionContextRef::GetProcessSP | ( | ) | const |
Get accessor that creates a strong reference from the weak process reference contained in this object.
Definition at line 586 of file ExecutionContext.cpp.
References m_process_wp.
Referenced by lldb_private::ExecutionContext::ExecutionContext(), lldb_private::GetStoppedExecutionContext(), GetThreadSP(), lldb_private::StructuredDataDarwinLog::InitCompletionHookCallback(), lldb_private::InstrumentationRuntimeMainThreadChecker::NotifyBreakpointHit(), lldb_private::InstrumentationRuntimeTSan::NotifyBreakpointHit(), lldb_private::InstrumentationRuntimeUBSan::NotifyBreakpointHit(), and lldb_private::ReportRetriever::NotifyBreakpointHit().
lldb::TargetSP ExecutionContextRef::GetTargetSP | ( | ) | const |
Get accessor that creates a strong reference from the weak target reference contained in this object.
Definition at line 579 of file ExecutionContext.cpp.
References m_target_wp.
Referenced by lldb_private::ExecutionContext::ExecutionContext(), lldb_private::GetStoppedExecutionContext(), and lldb_private::Watchpoint::VariableWatchpointDisabler().
lldb::ThreadSP ExecutionContextRef::GetThreadSP | ( | ) | const |
Get accessor that creates a strong reference from the weak thread reference contained in this object.
Definition at line 593 of file ExecutionContext.cpp.
References GetProcessSP(), LLDB_INVALID_THREAD_ID, m_thread_wp, and m_tid.
Referenced by lldb_private::ExecutionContext::ExecutionContext(), GetFrameSP(), lldb_private::GetStoppedExecutionContext(), lldb_private::StructuredDataDarwinLog::InitCompletionHookCallback(), lldb_private::InstrumentationRuntimeMainThreadChecker::NotifyBreakpointHit(), lldb_private::InstrumentationRuntimeTSan::NotifyBreakpointHit(), lldb_private::InstrumentationRuntimeUBSan::NotifyBreakpointHit(), lldb_private::ReportRetriever::NotifyBreakpointHit(), lldb_private::InstrumentationRuntimeMainThreadChecker::RetrieveReportData(), lldb_private::InstrumentationRuntimeTSan::RetrieveReportData(), and lldb_private::InstrumentationRuntimeUBSan::RetrieveReportData().
|
inline |
Returns true if this object has a weak reference to a frame.
The return value is only an indication of whether this object has a weak reference and does not indicate whether the weak reference is valid or not.
Definition at line 253 of file ExecutionContext.h.
References m_stack_id.
Referenced by lldb_private::ValueObjectVariable::IsInScope().
|
inline |
Returns true if this object has a weak reference to a thread.
The return value is only an indication of whether this object has a weak reference and does not indicate whether the weak reference is valid or not.
Definition at line 248 of file ExecutionContext.h.
References LLDB_INVALID_THREAD_ID, and m_tid.
ExecutionContext ExecutionContextRef::Lock | ( | bool | thread_and_frame_only_if_stopped | ) | const |
Create an ExecutionContext object from this object.
Create strong references to any execution context objects that are still valid. Any of the returned shared pointers in the ExecutionContext objects is not guaranteed to be valid.
Definition at line 628 of file ExecutionContext.cpp.
Referenced by lldb::SBCommandInterpreter::HandleCommand(), and lldb::SBCommandInterpreter::HandleCommandsFromFile().
ExecutionContextRef & ExecutionContextRef::operator= | ( | const ExecutionContext & | exe_ctx | ) |
Assignment operator from a ExecutionContext.
Make weak references to any strongly referenced objects in exe_ctx.
Definition at line 448 of file ExecutionContext.cpp.
References ExecutionContextRef(), lldb_private::ExecutionContext::GetFrameSP(), lldb_private::ExecutionContext::GetProcessSP(), lldb_private::ExecutionContext::GetTargetSP(), lldb_private::ExecutionContext::GetThreadSP(), LLDB_INVALID_THREAD_ID, m_process_wp, m_stack_id, m_target_wp, m_thread_wp, and m_tid.
ExecutionContextRef & ExecutionContextRef::operator= | ( | const ExecutionContextRef & | rhs | ) |
Assignment operator.
Copy all weak references in rhs.
Definition at line 436 of file ExecutionContext.cpp.
References ExecutionContextRef(), m_process_wp, m_stack_id, m_target_wp, m_thread_wp, and m_tid.
void ExecutionContextRef::SetFramePtr | ( | StackFrame * | frame | ) |
Definition at line 572 of file ExecutionContext.cpp.
References Clear(), and SetFrameSP().
void ExecutionContextRef::SetFrameSP | ( | const lldb::StackFrameSP & | frame_sp | ) |
Set accessor that creates a weak reference to the frame referenced in frame_sp.
If frame_sp is valid this object will create a weak reference to that object, otherwise any previous frame weak reference contained in this object will be reset.
Only the weak reference to the frame will be updated, no other weak references will be modified. If you want this execution context to make a weak reference to the frame's thread, process and target, use the ExecutionContextRef::SetContext() functions.
Definition at line 501 of file ExecutionContext.cpp.
References ClearFrame(), ClearThread(), m_process_wp, m_stack_id, m_target_wp, and SetThreadSP().
Referenced by SetFramePtr(), and SetTargetPtr().
void ExecutionContextRef::SetProcessPtr | ( | Process * | process | ) |
Definition at line 553 of file ExecutionContext.cpp.
References m_process_wp, m_target_wp, and SetProcessSP().
void ExecutionContextRef::SetProcessSP | ( | const lldb::ProcessSP & | process_sp | ) |
Set accessor that creates a weak reference to the process referenced in process_sp.
If process_sp is valid this object will create a weak reference to that object, otherwise any previous process weak reference contained in this object will be reset.
Only the weak reference to the process will be updated, no other weak references will be modified. If you want this execution context to make a weak reference to the target, use the ExecutionContextRef::SetContext() functions.
Definition at line 479 of file ExecutionContext.cpp.
References m_process_wp, m_target_wp, and SetTargetSP().
Referenced by SetProcessPtr(), and SetThreadSP().
Definition at line 513 of file ExecutionContext.cpp.
References Clear(), DoNoSelectMostRelevantFrame, m_process_wp, m_target_wp, SetFrameSP(), SetThreadSP(), lldb_private::StateIsStoppedState(), and lldb_private::ProcessRunLock::ProcessRunLocker::TryLock().
Referenced by ExecutionContextRef().
void ExecutionContextRef::SetTargetSP | ( | const lldb::TargetSP & | target_sp | ) |
Set accessor that creates a weak reference to the target referenced in target_sp.
If target_sp is valid this object will create a weak reference to that object, otherwise any previous target weak reference contained in this object will be reset.
Only the weak reference to the target will be updated, no other weak references will be modified. If you want this execution context to make a weak reference to the target's process, use the ExecutionContextRef::SetContext() functions.
Definition at line 475 of file ExecutionContext.cpp.
References m_target_wp.
Referenced by SetProcessSP().
void ExecutionContextRef::SetThreadPtr | ( | Thread * | thread | ) |
Definition at line 562 of file ExecutionContext.cpp.
References ClearThread(), m_process_wp, m_target_wp, and SetThreadSP().
void ExecutionContextRef::SetThreadSP | ( | const lldb::ThreadSP & | thread_sp | ) |
Set accessor that creates a weak reference to the thread referenced in thread_sp.
If thread_sp is valid this object will create a weak reference to that object, otherwise any previous thread weak reference contained in this object will be reset.
Only the weak reference to the thread will be updated, no other weak references will be modified. If you want this execution context to make a weak reference to the thread's process and target, use the ExecutionContextRef::SetContext() functions.
Definition at line 489 of file ExecutionContext.cpp.
References ClearThread(), m_process_wp, m_target_wp, m_thread_wp, m_tid, and SetProcessSP().
Referenced by SetFrameSP(), SetTargetPtr(), and SetThreadPtr().
|
protected |
A weak reference to a process.
Definition at line 265 of file ExecutionContext.h.
Referenced by Clear(), ExecutionContextRef(), ExecutionContextRef(), ExecutionContextRef(), ExecutionContextRef(), GetProcessSP(), operator=(), operator=(), SetFrameSP(), SetProcessPtr(), SetProcessSP(), SetTargetPtr(), SetThreadPtr(), and SetThreadSP().
|
protected |
The stack ID that this object refers to in case the backing object changes.
Definition at line 270 of file ExecutionContext.h.
Referenced by ClearFrame(), ExecutionContextRef(), ExecutionContextRef(), ExecutionContextRef(), ExecutionContextRef(), GetFrameSP(), HasFrameRef(), operator=(), operator=(), and SetFrameSP().
|
protected |
A weak reference to a target.
Definition at line 264 of file ExecutionContext.h.
Referenced by Clear(), ExecutionContextRef(), ExecutionContextRef(), ExecutionContextRef(), ExecutionContextRef(), GetTargetSP(), operator=(), operator=(), SetFrameSP(), SetProcessPtr(), SetProcessSP(), SetTargetPtr(), SetTargetSP(), SetThreadPtr(), and SetThreadSP().
|
mutableprotected |
A weak reference to a thread.
Definition at line 266 of file ExecutionContext.h.
Referenced by ClearThread(), ExecutionContextRef(), ExecutionContextRef(), ExecutionContextRef(), ExecutionContextRef(), GetThreadSP(), operator=(), operator=(), and SetThreadSP().
|
protected |
The thread ID that this object refers to in case the backing object changes.
Definition at line 267 of file ExecutionContext.h.
Referenced by ClearThread(), GetThreadSP(), HasThreadRef(), operator=(), operator=(), and SetThreadSP().