Go to the documentation of this file.
9 #ifndef LLDB_TARGET_THREAD_H
10 #define LLDB_TARGET_THREAD_H
29 #define LLDB_THREAD_MAX_STOP_EXC_DATA 8
33 class ThreadPlanStack;
61 class Thread :
public std::enable_shared_from_this<Thread>,
126 lldb::RegisterCheckpointSP
261 virtual const char *
GetInfo() {
return nullptr; }
281 virtual const char *
GetName() {
return nullptr; }
359 virtual lldb::QueueSP
GetQueue() {
return lldb::QueueSP(); }
403 virtual lldb::StackFrameSP
415 lldb::ValueObjectSP return_value_sp,
416 bool broadcast =
false);
419 lldb::ValueObjectSP return_value_sp,
420 bool broadcast =
false);
423 bool can_leave_function,
std::string *warnings =
nullptr);
428 return lldb::StackFrameSP();
438 bool broadcast =
false);
451 virtual lldb::RegisterContextSP
488 size_t start_position = 0)
const;
496 bool print_json_thread,
bool print_json_stopinfo);
644 bool step_over,
bool abort_other_plans,
bool stop_other_threads,
695 bool abort_other_plans,
const LineEntry &line_entry,
749 const SymbolContext &addr_context,
const char *step_in_target,
758 bool abort_other_plans,
const LineEntry &line_entry,
759 const SymbolContext &addr_context,
const char *step_in_target,
805 bool abort_other_plans,
SymbolContext *addr_context,
bool first_insn,
806 bool stop_other_threads,
Vote report_stop_vote,
Vote report_run_vote,
869 bool abort_other_plans,
SymbolContext *addr_context,
bool first_insn,
870 bool stop_other_threads,
Vote report_stop_vote,
Vote report_run_vote,
871 uint32_t frame_idx,
Status &status,
bool continue_to_next_branch =
false);
895 virtual lldb::ThreadPlanSP
897 bool abort_other_plans,
bool stop_other_threads,
921 virtual lldb::ThreadPlanSP
923 bool stop_other_threads,
Status &status);
926 bool abort_other_plans,
lldb::addr_t *address_list,
size_t num_addresses,
929 virtual lldb::ThreadPlanSP
932 bool stop_other_threads,
Status &status);
1099 uint32_t num_frames_with_source,
bool stop_format,
1100 bool only_stacks =
false);
1103 uint32_t num_frames,
bool show_frame_info,
1164 void SetStopInfo(
const lldb::StopInfoSP &stop_info_sp);
1217 void PushPlan(lldb::ThreadPlanSP plan_sp);
1251 virtual llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>>
1253 return llvm::make_error<UnimplementedError>();
1274 mutable std::recursive_mutex
1276 mutable std::recursive_mutex
1311 #endif // LLDB_TARGET_THREAD_H
lldb::StateType m_temporary_resume_state
This state records what the thread was told to do by the thread plan logic for the current resume.
lldb::StackFrameSP GetStackFrameSPForStackFramePtr(StackFrame *stack_frame_ptr)
void DiscardThreadPlans(bool force)
Discards the plans queued on the plan stack of the current thread.
virtual bool ThreadHasQueueInformation() const
Whether this Thread already has all the Queue information cached or not.
std::recursive_mutex m_state_mutex
Multithreaded protection for m_state.
virtual lldb::StopInfoSP GetPrivateStopInfo(bool calculate=true)
uint32_t GetCurrentInlinedDepth()
size_t GetStackFrameStatus(Stream &strm, uint32_t first_frame, uint32_t num_frames, bool show_frame_info, uint32_t num_frames_with_source)
bool StopInfoIsUpToDate() const
@ eBroadcastBitStackChanged
void SetResumeState(lldb::StateType state, bool override_suspend=false)
Sets the USER resume state for this thread.
void AutoCompleteThreadPlans(CompletionRequest &request) const
Format the thread plan information for auto completion.
lldb::StopInfoSP stop_info_sp
bool GetTraceEnabledState() const
int GetResumeSignal() const
uint32_t GetIndexID() const
@ eBroadcastBitThreadSuspended
bool GetDescription(Stream &s, lldb::DescriptionLevel level, bool print_json_thread, bool print_json_stopinfo)
virtual lldb::StackFrameSP GetFrameWithStackID(const StackID &stack_id)
int m_resume_signal
The signal that should be used when continuing this thread.
lldb::RegisterCheckpointSP register_backup_sp
virtual Unwind & GetUnwinder()
virtual llvm::Expected< std::unique_ptr< llvm::MemoryBuffer > > GetSiginfo(size_t max_size) const
virtual void ClearStackFrames()
virtual lldb::ThreadPlanSP QueueThreadPlanForStepOverRange(bool abort_other_plans, const AddressRange &range, const SymbolContext &addr_context, lldb::RunMode stop_other_threads, Status &status, LazyBool step_out_avoids_code_without_debug_info=eLazyBoolCalculate)
Queues the plan used to step through an address range, stepping over function calls.
static StackID GetStackIDFromEvent(const Event *event_ptr)
virtual lldb::addr_t GetQueueLibdispatchQueueAddress()
Retrieve the address of the libdispatch_queue_t struct for queue currently using this Thread.
Status JumpToLine(const FileSpec &file, uint32_t line, bool can_leave_function, std::string *warnings=nullptr)
virtual lldb::ThreadPlanSP QueueThreadPlanForStepOutNoShouldStop(bool abort_other_plans, SymbolContext *addr_context, bool first_insn, bool stop_other_threads, Vote report_stop_vote, Vote report_run_vote, uint32_t frame_idx, Status &status, bool continue_to_next_branch=false)
Queue the plan used to step out of the function at the current PC of a thread.
virtual void ClearBackingThread()
virtual uint64_t GetExtendedBacktraceToken()
Gets the extended backtrace token for this thread.
virtual lldb::queue_id_t GetQueueID()
Retrieve the Queue ID for the queue currently using this Thread.
virtual lldb::ThreadPlanSP QueueThreadPlanForStepOut(bool abort_other_plans, SymbolContext *addr_context, bool first_insn, bool stop_other_threads, Vote report_stop_vote, Vote report_run_vote, uint32_t frame_idx, Status &status, LazyBool step_out_avoids_code_without_debug_info=eLazyBoolCalculate)
Queue the plan used to step out of the function at the current PC of thread.
uint32_t GetSelectedFrameIndex()
lldb::TargetSP CalculateTarget() override
const Thread & operator=(const Thread &)=delete
std::string GetStopDescription()
bool DecrementCurrentInlinedDepth()
Status UnwindInnermostExpression()
Unwinds the thread stack for the innermost expression plan currently on the thread plan stack.
bool DiscardUserThreadPlansUpToIndex(uint32_t thread_index)
Discards the plans queued on the plan stack of the current thread up to and including the plan in tha...
StopReason
Thread stop reasons.
ThreadPlan * GetPreviousPlan(ThreadPlan *plan) const
void SelectMostRelevantFrame()
ThreadPlanStack & GetPlans() const
void Dump(Stream *s) const override
ThreadPlan * GetCurrentPlan() const
Gets the plan which will execute next on the plan stack.
std::unique_ptr< ThreadPlanStack > m_null_plan_stack_up
void RestoreThreadStateFromCheckpoint(ThreadStateCheckpoint &saved_state)
virtual bool RestoreRegisterStateFromCheckpoint(ThreadStateCheckpoint &saved_state)
Status ReturnFromFrameWithIndex(uint32_t frame_idx, lldb::ValueObjectSP return_value_sp, bool broadcast=false)
bool CompletedPlanOverridesBreakpoint() const
Check if we have completed plan to override breakpoint stop reason.
void SetDefaultFileAndLineToSelectedFrame()
lldb::StopReason GetStopReason()
lldb::StackFrameListSP m_curr_frames_sp
The stack frames that get lazily populated after a thread stops.
virtual void SetName(const char *name)
virtual void SetQueueLibdispatchQueueAddress(lldb::addr_t dispatch_queue_t)
bool ShouldStop(Event *event_ptr)
virtual lldb::user_id_t GetProtocolID() const
lldb::StateType GetResumeState() const
Gets the USER resume state for this thread.
virtual bool SafeToCallFunctions()
Check whether this thread is safe to run functions.
static std::string RunModeAsString(lldb::RunMode mode)
virtual lldb::QueueSP GetQueue()
Retrieve the Queue for this thread, if any.
void FrameSelectedCallback(lldb_private::StackFrame *frame)
lldb::StateType GetState() const
~ThreadEventData() override
lldb::ThreadPlanSP GetCompletedPlan() const
Gets the outer-most plan that was popped off the plan stack in the most recent stop.
virtual const char * GetName()
virtual bool CheckpointThreadState(ThreadStateCheckpoint &saved_state)
bool IsThreadPlanDone(ThreadPlan *plan) const
Checks whether the given plan is in the completed plans for this stop.
virtual bool CalculateStopInfo()=0
void BroadcastSelectedFrameChange(StackID &new_frame_id)
static void SettingsTerminate()
lldb::ProcessSP GetProcess() const
void SetTemporaryResumeState(lldb::StateType new_state)
static lldb::ThreadSP GetThreadFromEvent(const Event *event_ptr)
virtual Status StepIn(bool source_step, LazyBool step_in_avoids_code_without_debug_info=eLazyBoolCalculate, LazyBool step_out_avoids_code_without_debug_info=eLazyBoolCalculate)
Default implementation for stepping into.
virtual void DestroyThread()
bool GetStepInAvoidsNoDebug() const
lldb::ProcessSP CalculateProcess() override
ConstString & GetBroadcasterClass() const override
This needs to be filled in if you are going to register the broadcaster with the broadcaster manager ...
lldb::StateType m_state
The state of our process.
Status ReturnFromFrame(lldb::StackFrameSP frame_sp, lldb::ValueObjectSP return_value_sp, bool broadcast=false)
static lldb::StackFrameSP GetStackFrameFromEvent(const Event *event_ptr)
ThreadProperties(bool is_global)
virtual void RefreshStateAfterStop()=0
virtual lldb::RegisterContextSP CreateRegisterContextForFrame(StackFrame *frame)=0
virtual lldb_private::StructuredData::ObjectSP FetchThreadExtendedInfo()
bool ShouldRunBeforePublicStop()
virtual void SetQueueKind(lldb::QueueKind kind)
std::shared_ptr< Object > ObjectSP
lldb::ExpressionVariableSP GetExpressionVariable() const
Gets the outer-most expression variable from the completed plans.
virtual void SetAssociatedWithLibdispatchQueue(lldb_private::LazyBool associated_with_libdispatch_queue)
static ConstString GetFlavorString()
lldb::StackFrameListSP m_prev_frames_sp
The previous stack frames from the last time this thread stopped.
lldb::StateType GetTemporaryResumeState() const
virtual lldb::ThreadPlanSP QueueThreadPlanForStepThrough(StackID &return_stack_id, bool abort_other_plans, bool stop_other_threads, Status &status)
Gets the plan used to step through the code that steps from a function call site at the current PC in...
virtual Status StepOut(uint32_t frame_idx=0)
Default implementation for stepping out.
void SetStopInfo(const lldb::StopInfoSP &stop_info_sp)
void SetStopInfoToNothing()
@ eBroadcastBitThreadSelected
virtual lldb::ThreadPlanSP QueueThreadPlanForStepInRange(bool abort_other_plans, const AddressRange &range, const SymbolContext &addr_context, const char *step_in_target, lldb::RunMode stop_other_threads, Status &status, LazyBool step_in_avoids_code_without_debug_info=eLazyBoolCalculate, LazyBool step_out_avoids_code_without_debug_info=eLazyBoolCalculate)
Queues the plan used to step through an address range, stepping into functions.
virtual lldb::ThreadSP GetBackingThread() const
lldb::ThreadSP GetCurrentExceptionBacktrace()
virtual uint32_t GetStackFrameCount()
const RegularExpression * GetSymbolsToAvoidRegexp()
The regular expression returned determines symbols that this thread won't stop in during "step-in" op...
void DumpTraceInstructions(Stream &s, size_t count, size_t start_position=0) const
Dump count instructions of the thread's Trace starting at the start_position position in reverse orde...
uint32_t m_stop_info_override_stop_id
lldb::ValueObjectSP GetCurrentException()
Vote ShouldReportStop(Event *event_ptr)
StructuredData::ObjectSP GetExtendedInfo()
Retrieve a dictionary of information about this thread.
uint64_t GetMaxBacktraceDepth() const
void CalculatePublicStopInfo()
bool ShouldResume(lldb::StateType resume_state)
void SetState(lldb::StateType state)
string(SUBSTRING ${p} 10 -1 pStripped) if($
lldb::addr_t current_inlined_pc
std::unique_ptr< lldb_private::Unwind > m_unwinder_up
It gets set in Thread::ShouldResume.
virtual void WillResume(lldb::StateType resume_state)
uint32_t SetSelectedFrame(lldb_private::StackFrame *frame, bool broadcast=false)
#define LLDB_INVALID_QUEUE_ID
ConstString GetFlavor() const override
bool GetStepOutAvoidsNoDebug() const
uint32_t current_inlined_depth
uint32_t m_stop_info_stop_id
bool m_should_run_before_public_stop
virtual lldb::addr_t GetThreadPointer()
Retrieves the per-thread data area.
bool SetSelectedFrameByIndexNoisily(uint32_t frame_idx, Stream &output_stream)
virtual lldb::StackFrameSP GetFrameWithConcreteFrameIndex(uint32_t unwind_idx)
lldb::user_id_t GetID() const
Get accessor for the user ID.
lldb::ThreadSP GetThread() const
void CalculateExecutionContext(ExecutionContext &exe_ctx) override
Reconstruct the object's execution context into sc.
lldb::StopInfoSP m_stop_info_sp
The private stop reason for this thread.
static void SettingsInitialize()
virtual lldb_private::LazyBool GetAssociatedWithLibdispatchQueue()
Whether this thread can be associated with a libdispatch queue.
lldb::ThreadPlanSP QueueBasePlan(bool abort_other_plans)
Queues the base plan for a thread.
lldb::ThreadSP CalculateThread() override
size_t GetStatus(Stream &strm, uint32_t start_frame, uint32_t num_frames, uint32_t num_frames_with_source, bool stop_format, bool only_stacks=false)
virtual const char * GetInfo()
virtual bool IsStillAtLastBreakpointHit()
void DiscardThreadPlansUpToPlan(lldb::ThreadPlanSP &up_to_plan_sp)
Discards the plans queued on the plan stack of the current thread up to and including up_to_plan_sp.
@ eStateSuspended
Process or thread is in a suspended state as far as the debugger is concerned while other processes o...
lldb::StopInfoSP GetStopInfo()
Vote ShouldReportRun(Event *event_ptr)
lldb::StackFrameListSP GetStackFrameList()
lldb::ProcessWP m_process_wp
The process that owns this thread.
void SetShouldRunBeforePublicStop(bool newval)
lldb::RegisterContextSP m_reg_context_sp
The register context for this thread's current register state.
std::recursive_mutex m_frame_mutex
Multithreaded protection for m_state.
void PushPlan(lldb::ThreadPlanSP plan_sp)
static ConstString & GetStaticBroadcasterClass()
Status QueueThreadPlan(lldb::ThreadPlanSP &plan_sp, bool abort_other_plans)
Queues a generic thread plan.
StackID GetStackID() const
virtual bool IsOperatingSystemPluginThread() const
lldb::ValueObjectSP GetReturnValueObject() const
Gets the outer-most return value from the completed plans.
virtual lldb::ThreadPlanSP QueueThreadPlanForRunToAddress(bool abort_other_plans, Address &target_addr, bool stop_other_threads, Status &status)
Gets the plan used to continue from the current PC.
virtual lldb::ThreadPlanSP QueueThreadPlanForStepUntil(bool abort_other_plans, lldb::addr_t *address_list, size_t num_addresses, bool stop_others, uint32_t frame_idx, Status &status)
lldb::StackFrameSP GetSelectedFrame()
@ eBroadcastBitThreadResumed
~ThreadProperties() override
#define LLDB_INVALID_ADDRESS
virtual bool MatchesSpec(const ThreadSpec *spec)
bool WasThreadPlanDiscarded(ThreadPlan *plan) const
Checks whether the given plan is in the discarded plans for this stop.
virtual lldb::addr_t GetThreadLocalData(const lldb::ModuleSP module, lldb::addr_t tls_file_addr)
Retrieves the per-module TLS block for a thread.
LazyBool m_override_should_notify
A class that represents a running process on the host machine.
Thread(Process &process, lldb::tid_t tid, bool use_invalid_index_id=false)
Constructor.
bool ThreadStoppedForAReason()
lldb::ThreadSP m_thread_sp
size_t m_completed_plan_checkpoint
virtual lldb::QueueKind GetQueueKind()
Retrieve the Queue kind for the queue currently using this Thread.
virtual lldb::ThreadPlanSP QueueThreadPlanForStepScripted(bool abort_other_plans, const char *class_name, StructuredData::ObjectSP extra_args_sp, bool stop_other_threads, Status &status)
lldb::ValueObjectSP GetSiginfoValue()
virtual void SetQueueID(lldb::queue_id_t new_val)
virtual bool SetBackingThread(const lldb::ThreadSP &thread_sp)
StateType
Process and Thread States.
static std::string StopReasonAsString(lldb::StopReason reason)
lldb::StateType m_resume_state
This state is used to force a thread to be suspended from outside the ThreadPlan logic.
virtual lldb::StackFrameSP GetStackFrameAtIndex(uint32_t idx)
virtual lldb::ThreadPlanSP QueueThreadPlanForStepSingleInstruction(bool step_over, bool abort_other_plans, bool stop_other_threads, Status &status)
Queues the plan used to step one instruction from the current PC of thread.
const ThreadEventData & operator=(const ThreadEventData &)=delete
virtual lldb::RegisterContextSP GetRegisterContext()=0
void SetResumeSignal(int signal)
virtual Status StepOver(bool source_step, LazyBool step_out_avoids_code_without_debug_info=eLazyBoolCalculate)
Default implementation for stepping over.
bool m_extended_info_fetched
const uint32_t m_index_id
A unique 1 based index assigned to each thread for easy UI/command line access.
virtual void SetExtendedBacktraceToken(uint64_t token)
Sets the extended backtrace token for this thread.
virtual void SetQueueName(const char *name)
void DumpUsingSettingsFormat(Stream &strm, uint32_t frame_idx, bool stop_format)
StructuredData::ObjectSP m_extended_info
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
lldb::StackFrameSP CalculateStackFrame() override
std::string GetStopDescriptionRaw()
virtual const char * GetQueueName()
Retrieve the Queue name for the queue currently using this Thread.
virtual uint32_t GetExtendedBacktraceOriginatingIndexID()
@ eBroadcastBitSelectedFrameChanged
bool SetSelectedFrameByIndex(uint32_t frame_idx, bool broadcast=false)
static const ThreadEventData * GetEventDataFromEvent(const Event *event_ptr)
void SetShouldReportStop(Vote vote)
FileSpecList GetLibrariesToAvoid() const
static ThreadProperties & GetGlobalProperties()