65 return *g_settings_ptr;
68#define LLDB_PROPERTIES_thread
69#include "TargetProperties.inc"
72#define LLDB_PROPERTIES_thread
73#include "TargetPropertiesEnum.inc"
77 :
public Cloneable<ThreadOptionValueProperties, OptionValueProperties> {
93 if (
this != instance_properties)
97 return ProtectedGetPropertyAtIndex(idx);
103 m_collection_sp = std::make_shared<ThreadOptionValueProperties>(
"thread");
113 const uint32_t idx = ePropertyStepAvoidRegex;
114 return GetPropertyAtIndexAs<const RegularExpression *>(idx);
118 const uint32_t idx = ePropertyStepAvoidLibraries;
119 return GetPropertyAtIndexAs<FileSpecList>(idx, {});
123 const uint32_t idx = ePropertyEnableThreadTrace;
124 return GetPropertyAtIndexAs<bool>(
125 idx, g_thread_properties[idx].default_uint_value != 0);
129 const uint32_t idx = ePropertyStepInAvoidsNoDebug;
130 return GetPropertyAtIndexAs<bool>(
131 idx, g_thread_properties[idx].default_uint_value != 0);
135 const uint32_t idx = ePropertyStepOutAvoidsNoDebug;
136 return GetPropertyAtIndexAs<bool>(
137 idx, g_thread_properties[idx].default_uint_value != 0);
141 const uint32_t idx = ePropertyMaxBacktraceDepth;
142 return GetPropertyAtIndexAs<uint64_t>(
143 idx, g_thread_properties[idx].default_uint_value);
147 const uint32_t idx = ePropertySingleThreadPlanTimeout;
148 return GetPropertyAtIndexAs<uint64_t>(
149 idx, g_thread_properties[idx].default_uint_value);
155 return "Thread::ThreadEventData";
159 : m_thread_sp(thread_sp), m_stack_id() {}
163 : m_thread_sp(thread_sp), m_stack_id(stack_id) {}
205 frame_sp = thread_sp->GetStackFrameList()->GetFrameWithStackID(
215 static constexpr llvm::StringLiteral class_name(
"lldb.thread");
221 Broadcaster(process.GetTarget().GetDebugger().GetBroadcasterManager(),
227 : process.GetNextThreadIndexID(tid)),
236 LLDB_LOGF(log,
"%p Thread::Thread(tid = 0x%4.4" PRIx64
")",
237 static_cast<void *
>(
this),
GetID());
244 LLDB_LOGF(log,
"%p Thread::~Thread(tid = 0x%4.4" PRIx64
")",
245 static_cast<void *
>(
this),
GetID());
265 std::make_shared<ThreadEventData>(shared_from_this(), new_frame_id);
273 StackFrameSP frame_sp = stack_frame_list_sp->GetFrameAtIndex(
274 stack_frame_list_sp->GetSelectedFrameIndex(select_most_relevant));
302 const bool broadcast =
true;
307 bool already_shown =
false;
309 frame_sp->GetSymbolContext(eSymbolContextLineEntry));
317 "OpenFileInExternalEditor failed: {0}");
319 already_shown =
true;
323 bool show_frame_info =
true;
324 bool show_source = !already_shown;
326 return frame_sp->GetStatus(output_stream, show_frame_info, show_source);
339 GetProcess()->GetWarningsUnsupportedLanguage())) {
343 GetProcess()->PrintWarningUnsupportedLanguage(sc);
353 const uint32_t stop_id = process_sp ? process_sp->GetStopID() :
UINT32_MAX;
363 bool have_valid_completed_plan = completed_plan_sp && completed_plan_sp->PlanSucceeded();
364 bool plan_failed = completed_plan_sp && !completed_plan_sp->PlanSucceeded();
365 bool plan_overrides_trace =
366 have_valid_stop_info && have_valid_completed_plan
369 if (have_valid_stop_info && !plan_overrides_trace && !plan_failed) {
371 }
else if (completed_plan_sp) {
394 const uint32_t process_stop_id = process_sp->GetStopID();
427 process_sp->GetTarget().GetArchitecturePlugin())
428 arch->OverrideStopInfo(*
this);
444 return stop_info_sp->GetStopReason();
479 LLDB_LOGF(log,
"%p: tid = 0x%" PRIx64
": stop info = %s (stop_id = %u)",
480 static_cast<void *
>(
this),
GetID(),
481 stop_info_sp ? stop_info_sp->GetDescription() :
"<NULL>",
512 if (reg_checkpoint_sp) {
514 if (reg_ctx_sp && reg_ctx_sp->ReadAllRegisterValues(*reg_checkpoint_sp))
544 reg_ctx_sp->InvalidateIfNeeded(
true);
582 auto recognized_frame_sp = frame_sp->GetRecognizedFrame();
584 if (!recognized_frame_sp)
587 std::string recognized_stop_description =
588 recognized_frame_sp->GetStopDescription();
590 if (!recognized_stop_description.empty())
591 return recognized_stop_description;
598 std::string raw_stop_description;
599 if (stop_info_sp && stop_info_sp->IsValid()) {
600 raw_stop_description = stop_info_sp->GetDescription();
601 assert((!raw_stop_description.empty() ||
603 "StopInfo returned an empty description.");
605 return raw_stop_description;
628 const addr_t thread_pc = reg_ctx_sp->GetPC();
630 GetProcess()->GetBreakpointSiteList().FindByAddress(thread_pc);
637 bool push_step_over_bp_plan =
false;
642 push_step_over_bp_plan =
true;
644 push_step_over_bp_plan =
true;
646 if (push_step_over_bp_plan) {
648 if (step_bp_plan_sp) {
649 step_bp_plan_sp->SetPrivate(
true);
654 step_bp_plan_sp.get());
675 if (backing_thread_sp)
676 backing_thread_sp->SetTemporaryResumeState(resume_state);
688 const uint32_t process_stop_id =
GetProcess()->GetStopID();
701 bool need_to_resume =
false;
704 need_to_resume = plan_ptr->
WillResume(resume_state,
true);
718 if (need_to_resume) {
724 return need_to_resume;
738 bool should_stop =
true;
744 "Thread::%s for tid = 0x%4.4" PRIx64
" 0x%4.4" PRIx64
745 ", should_stop = 0 (ignore since thread was suspended)",
752 "Thread::%s for tid = 0x%4.4" PRIx64
" 0x%4.4" PRIx64
753 ", should_stop = 0 (ignore since thread was suspended)",
763 "Thread::%s for tid = 0x%4.4" PRIx64
" 0x%4.4" PRIx64
764 ", pc = 0x%16.16" PRIx64
765 ", should_stop = 0 (ignore since no stop reason)",
777 "Thread::%s(%p) for tid = 0x%4.4" PRIx64
" 0x%4.4" PRIx64
778 ", pc = 0x%16.16" PRIx64,
782 LLDB_LOGF(log,
"^^^^^^^^ Thread::ShouldStop Begin ^^^^^^^^");
799 if (private_stop_info &&
800 !private_stop_info->ShouldStopSynchronous(event_ptr)) {
801 LLDB_LOGF(log,
"StopInfo::ShouldStop async callback says we should not "
802 "stop, returning ShouldStop of false.");
821 bool done_processing_current_plan =
false;
824 done_processing_current_plan =
true;
840 should_stop = plan_ptr->
ShouldStop(event_ptr);
859 done_processing_current_plan =
863 if (should_force_run) {
867 done_processing_current_plan =
true;
875 if (!done_processing_current_plan) {
876 bool override_stop =
false;
880 should_stop = current_plan->
ShouldStop(event_ptr);
881 LLDB_LOGF(log,
"Base plan says should stop: %i.", should_stop);
890 should_stop = current_plan->
ShouldStop(event_ptr);
898 override_stop =
true;
899 LLDB_LOGF(log,
"Plan %s auto-continue: true.",
913 if (current_plan ==
nullptr) {
945 "Plan %s being discarded in cleanup, it says it is already done.",
968 LLDB_LOGF(log,
"vvvvvvvv Thread::ShouldStop End (returning %i) vvvvvvvv",
982 "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
983 ": returning vote %i (state was suspended or invalid)",
991 "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
992 ": returning vote %i (temporary state was suspended or invalid)",
999 "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
1000 ": returning vote %i (thread didn't stop for a reason.)",
1005 if (
GetPlans().AnyCompletedPlans()) {
1009 "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
1010 ": returning vote for complete stack's back plan",
1027 "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
1028 ": returning vote %i for current plan",
1029 GetID(), thread_vote);
1043 if (
GetPlans().AnyCompletedPlans()) {
1047 "Current Plan for thread %d(%p) (0x%4.4" PRIx64
1048 ", %s): %s being asked whether we should report run.",
1056 "Current Plan for thread %d(%p) (0x%4.4" PRIx64
1057 ", %s): %s being asked whether we should report run.",
1087 assert(thread_plan_sp &&
"Don't push an empty thread plan.");
1093 LLDB_LOGF(log,
"Thread::PushPlan(0x%p): \"%s\", tid = 0x%4.4" PRIx64
".",
1094 static_cast<void *
>(
this), s.
GetData(),
1095 thread_plan_sp->GetThread().GetID());
1105 LLDB_LOGF(log,
"Popping plan: \"%s\", tid = 0x%4.4" PRIx64
".",
1106 popped_plan_sp->GetName(), popped_plan_sp->GetThread().GetID());
1114 LLDB_LOGF(log,
"Discarding plan: \"%s\", tid = 0x%4.4" PRIx64
".",
1115 discarded_plan_sp->GetName(),
1116 discarded_plan_sp->GetThread().GetID());
1168 bool abort_other_plans) {
1171 if (!thread_plan_sp->ValidatePlan(&s)) {
1173 thread_plan_sp.reset();
1178 if (abort_other_plans)
1187 if (!thread_plan_sp->ValidatePlan(&s)) {
1189 thread_plan_sp.reset();
1202 if (up_to_plan_ptr ==
nullptr)
1216 "Discarding thread plans for thread tid = 0x%4.4" PRIx64
1218 GetID(),
static_cast<void *
>(up_to_plan_ptr));
1226 "Discarding thread plans for thread (tid = 0x%4.4" PRIx64
1241 if (!innermost_expr_plan) {
1242 error.SetErrorString(
"No expressions currently active on this thread");
1252 return thread_plan_sp;
1256 bool step_over,
bool abort_other_plans,
bool stop_other_threads,
1261 return thread_plan_sp;
1267 Status &status,
LazyBool step_out_avoids_code_withoug_debug_info) {
1269 thread_plan_sp = std::make_shared<ThreadPlanStepOverRange>(
1270 *
this, range, addr_context, stop_other_threads,
1271 step_out_avoids_code_withoug_debug_info);
1274 return thread_plan_sp;
1280 bool abort_other_plans,
const LineEntry &line_entry,
1282 Status &status,
LazyBool step_out_avoids_code_withoug_debug_info) {
1283 const bool include_inlined_functions =
true;
1284 auto address_range =
1287 abort_other_plans, address_range, addr_context, stop_other_threads,
1288 status, step_out_avoids_code_withoug_debug_info);
1293 const SymbolContext &addr_context,
const char *step_in_target,
1295 LazyBool step_in_avoids_code_without_debug_info,
1296 LazyBool step_out_avoids_code_without_debug_info) {
1298 *
this, range, addr_context, step_in_target, stop_other_threads,
1299 step_in_avoids_code_without_debug_info,
1300 step_out_avoids_code_without_debug_info));
1302 return thread_plan_sp;
1307 bool abort_other_plans,
const LineEntry &line_entry,
1308 const SymbolContext &addr_context,
const char *step_in_target,
1310 LazyBool step_in_avoids_code_without_debug_info,
1311 LazyBool step_out_avoids_code_without_debug_info) {
1312 const bool include_inlined_functions =
false;
1316 addr_context, step_in_target, stop_other_threads, status,
1317 step_in_avoids_code_without_debug_info,
1318 step_out_avoids_code_without_debug_info);
1322 bool abort_other_plans,
SymbolContext *addr_context,
bool first_insn,
1323 bool stop_other_threads,
Vote report_stop_vote,
Vote report_run_vote,
1324 uint32_t frame_idx,
Status &status,
1325 LazyBool step_out_avoids_code_without_debug_info) {
1327 *
this, addr_context, first_insn, stop_other_threads, report_stop_vote,
1328 report_run_vote, frame_idx, step_out_avoids_code_without_debug_info));
1331 return thread_plan_sp;
1335 bool abort_other_plans,
SymbolContext *addr_context,
bool first_insn,
1336 bool stop_other_threads,
Vote report_stop_vote,
Vote report_run_vote,
1337 uint32_t frame_idx,
Status &status,
bool continue_to_next_branch) {
1338 const bool calculate_return_value =
1341 *
this, addr_context, first_insn, stop_other_threads, report_stop_vote,
1342 report_run_vote, frame_idx,
eLazyBoolNo, continue_to_next_branch,
1343 calculate_return_value));
1350 return thread_plan_sp;
1354 bool abort_other_plans,
1355 bool stop_other_threads,
1359 if (!thread_plan_sp || !thread_plan_sp->ValidatePlan(
nullptr))
1363 return thread_plan_sp;
1368 bool stop_other_threads,
1374 return thread_plan_sp;
1378 bool abort_other_plans,
lldb::addr_t *address_list,
size_t num_addresses,
1379 bool stop_other_threads, uint32_t frame_idx,
Status &status) {
1381 *
this, address_list, num_addresses, stop_other_threads, frame_idx));
1384 return thread_plan_sp;
1388 bool abort_other_plans,
const char *class_name,
1394 thread_plan_sp->SetStopOthers(stop_other_threads);
1396 return thread_plan_sp;
1405 target_sp = process_sp->CalculateTarget();
1465 "Could not find frame with index %d in thread 0x%" PRIx64
".",
1466 frame_idx,
GetID());
1479 return return_error;
1482 Thread *thread = frame_sp->GetThread().get();
1483 uint32_t older_frame_idx = frame_sp->GetFrameIndex() + 1;
1485 if (!older_frame_sp) {
1487 return return_error;
1490 if (return_value_sp) {
1493 return_error.
SetErrorString(
"Could not find ABI to set return value.");
1494 return return_error;
1496 SymbolContext sc = frame_sp->GetSymbolContext(eSymbolContextFunction);
1501 if ( (
false) && sc.
function !=
nullptr) {
1503 if (function_type) {
1509 ValueObjectSP cast_value_sp = return_value_sp->Cast(return_type);
1510 if (cast_value_sp) {
1512 return_value_sp = cast_value_sp;
1518 return_error = abi->SetReturnValueObject(older_frame_sp, return_value_sp);
1520 return return_error;
1528 if (youngest_frame_sp) {
1531 bool copy_success = reg_ctx_sp->CopyFromRegisterContext(
1532 older_frame_sp->GetRegisterContext());
1537 auto data_sp = std::make_shared<ThreadEventData>(shared_from_this());
1549 return return_error;
1554 for (
size_t n = 0; n < list.size(); n++) {
1563 bool can_leave_function, std::string *warnings) {
1572 std::vector<Address> candidates, within_function, outside_function;
1574 within_function, outside_function);
1581 if (!within_function.empty())
1582 candidates = within_function;
1583 else if (outside_function.size() == 1 && can_leave_function)
1584 candidates = outside_function;
1587 if (candidates.empty()) {
1588 if (outside_function.empty()) {
1589 return Status(
"Cannot locate an address for %s:%i.",
1591 }
else if (outside_function.size() == 1) {
1592 return Status(
"%s:%i is outside the current function.",
1597 return Status(
"%s:%i has multiple candidate locations:\n%s",
1604 if (warnings && candidates.size() > 1) {
1606 sstr.
Printf(
"%s:%i appears multiple times in this function, selecting the "
1607 "first location:\n",
1610 *warnings = std::string(sstr.
GetString());
1613 if (!reg_ctx->
SetPC(dest))
1614 return Status(
"Cannot change PC to target address.");
1623 if (!process || !format)
1632 frame_sc = frame_sp->GetSymbolContext(eSymbolContextEverything);
1637 &exe_ctx,
nullptr,
nullptr,
false,
false);
1650 assert(thread_format);
1706 return "breakpoint";
1708 return "watchpoint";
1720 return "vfork done";
1722 return "plan complete";
1724 return "thread exiting";
1726 return "instrumentation break";
1728 return "processor trace";
1730 return "async interrupt";
1733 return "StopReason = " + std::to_string(reason);
1739 return "only this thread";
1741 return "all threads";
1743 return "only during stepping";
1746 return "RunMode = " + std::to_string(mode);
1750 uint32_t num_frames, uint32_t num_frames_with_source,
1751 bool stop_format,
bool show_hidden,
bool only_stacks) {
1758 bool is_selected =
false;
1763 strm.
Printf(
"%c ", is_selected ?
'*' :
' ');
1768 frame_sp->GetSymbolContext(eSymbolContextLineEntry));
1774 "OpenFileInExternalEditor failed: {0}");
1783 size_t num_frames_shown = 0;
1784 if (num_frames > 0) {
1787 const bool show_frame_info =
true;
1788 const bool show_frame_unique = only_stacks;
1789 const char *selected_frame_marker =
nullptr;
1790 if (num_frames == 1 || only_stacks ||
1794 selected_frame_marker =
"* ";
1797 strm, start_frame, num_frames, show_frame_info, num_frames_with_source,
1798 show_frame_unique, show_hidden, selected_frame_marker);
1799 if (num_frames == 1)
1803 return num_frames_shown;
1807 bool print_json_thread,
bool print_json_stopinfo) {
1808 const bool stop_format =
false;
1814 if (print_json_thread || print_json_stopinfo) {
1815 if (thread_info && print_json_thread) {
1816 thread_info->Dump(strm);
1823 stop_info->Dump(strm);
1833 thread_info->GetObjectForDotSeparatedPath(
"activity");
1835 thread_info->GetObjectForDotSeparatedPath(
"breadcrumb");
1837 thread_info->GetObjectForDotSeparatedPath(
"trace_messages");
1839 bool printed_activity =
false;
1846 strm.
Format(
" Activity '{0}', {1:x}\n",
1847 name->GetAsString()->GetValue(),
1848 id->GetUnsignedIntegerValue());
1850 printed_activity =
true;
1852 bool printed_breadcrumb =
false;
1854 if (printed_activity)
1860 if (breadcrumb_text &&
1862 strm.
Format(
" Current Breadcrumb: {0}\n",
1863 breadcrumb_text->GetAsString()->GetValue());
1865 printed_breadcrumb =
true;
1868 if (printed_breadcrumb)
1871 const size_t msg_count = messages_array->
GetSize();
1872 if (msg_count > 0) {
1873 strm.
Printf(
" %zu trace messages:\n", msg_count);
1874 for (
size_t i = 0; i < msg_count; i++) {
1883 strm.
Format(
" {0}\n", message_text->GetAsString()->GetValue());
1895 uint32_t num_frames,
bool show_frame_info,
1896 uint32_t num_frames_with_source,
1899 show_frame_info, num_frames_with_source,
1900 false, show_hidden);
1926 GetProcess()->GetBreakpointSiteList().FindByAddress(
pc);
1927 if (bp_site_sp &&
static_cast<break_id_t>(value) == bp_site_sp->GetID())
1936 LazyBool step_in_avoids_code_without_debug_info,
1937 LazyBool step_out_avoids_code_without_debug_info)
1946 const bool abort_other_plans =
false;
1948 if (source_step && frame_sp && frame_sp->HasDebugInformation()) {
1949 SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
1952 step_in_avoids_code_without_debug_info,
1953 step_out_avoids_code_without_debug_info);
1956 false, abort_other_plans, run_mode,
error);
1959 new_plan_sp->SetIsControllingPlan(
true);
1960 new_plan_sp->SetOkayToDiscard(
false);
1966 error.SetErrorString(
"process not stopped");
1972 LazyBool step_out_avoids_code_without_debug_info) {
1980 const bool abort_other_plans =
false;
1982 if (source_step && frame_sp && frame_sp->HasDebugInformation()) {
1983 SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
1986 step_out_avoids_code_without_debug_info);
1989 true, abort_other_plans, run_mode,
error);
1992 new_plan_sp->SetIsControllingPlan(
true);
1993 new_plan_sp->SetOkayToDiscard(
false);
1999 error.SetErrorString(
"process not stopped");
2008 const bool first_instruction =
false;
2009 const bool stop_other_threads =
false;
2010 const bool abort_other_plans =
false;
2013 abort_other_plans,
nullptr, first_instruction, stop_other_threads,
2016 new_plan_sp->SetIsControllingPlan(
true);
2017 new_plan_sp->SetOkayToDiscard(
false);
2023 error.SetErrorString(
"process not stopped");
2030 if (
auto recognized_frame = frame_sp->GetRecognizedFrame())
2031 if (
auto e = recognized_frame->GetExceptionObject())
2037 if (
auto e = runtime->GetExceptionObjectForThread(shared_from_this()))
2052 if (
auto bt = runtime->GetBacktraceThreadFromException(exception))
2062 Target &target = process_sp->GetTarget();
2064 assert(platform_sp);
2071 std::optional<uint64_t> type_size = type.
GetByteSize(
nullptr);
2073 llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>> data =
2078 DataExtractor data_extractor{data.get()->getBufferStart(), data.get()->getBufferSize(),
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
#define LLDB_LOG_ERROR(log, error,...)
static void DumpAddressList(Stream &s, const std::vector< Address > &list, ExecutionContextScope *exe_scope)
ThreadOptionValueProperties(llvm::StringRef name)
const Property * GetPropertyAtIndex(size_t idx, const ExecutionContext *exe_ctx) const override
A section + offset based address range class.
A section + offset based address class.
@ DumpStyleSectionNameOffset
Display as the section name + offset.
@ DumpStyleResolvedDescription
Display the details about what an address resolves to.
An architecture specification class.
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
llvm::Triple & GetTriple()
Architecture triple accessor.
An event broadcasting class.
bool EventTypeHasListeners(uint32_t event_type)
void BroadcastEvent(lldb::EventSP &event_sp)
Broadcast an event which has no associated data.
void CheckInWithManager()
A class that implements CRTP-based "virtual constructor" idiom.
Generic representation of a type in a programming language.
std::optional< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
CompilerType GetFunctionReturnType() const
void DumpTypeDescription(lldb::DescriptionLevel level=lldb::eDescriptionLevelFull) const
Dump to stdout.
"lldb/Utility/ArgCompletionRequest.h"
void TryCompleteCurrentArg(llvm::StringRef completion, llvm::StringRef description="")
Adds a possible completion string if the completion would complete the current argument.
A uniqued constant string class.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
A class to manage flag bits.
bool GetUseExternalEditor() const
const FormatEntity::Entry * GetThreadStopFormat() const
const FormatEntity::Entry * GetThreadFormat() const
llvm::StringRef GetExternalEditor() const
A plug-in interface definition class for dynamic loaders.
virtual lldb::addr_t GetThreadLocalData(const lldb::ModuleSP module, const lldb::ThreadSP thread, lldb::addr_t tls_file_addr)
Retrieves the per-module TLS block for a given thread.
virtual bool IsFullyInitialized()
Return whether the dynamic loader is fully initialized and it's safe to call its APIs.
virtual llvm::StringRef GetFlavor() const =0
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
void SetFrameSP(const lldb::StackFrameSP &frame_sp)
Set accessor to set only the frame shared pointer.
const lldb::TargetSP & GetTargetSP() const
Get accessor to get the target shared pointer.
StackFrame * GetFramePtr() const
Returns a pointer to the frame object.
void SetContext(const lldb::TargetSP &target_sp, bool get_process)
Target * GetTargetPtr() const
Returns a pointer to the target object.
Target & GetTargetRef() const
Returns a reference to the target object.
Process * GetProcessPtr() const
Returns a pointer to the process object.
RegisterContext * GetRegisterContext() const
Thread * GetThreadPtr() const
Returns a pointer to the thread object.
const ConstString & GetFilename() const
Filename string const get accessor.
CompilerType GetCompilerType()
Type * GetType()
Get accessor for the type that describes the function return value type, and parameter types.
static llvm::Error OpenFileInExternalEditor(llvm::StringRef editor, const FileSpec &file_spec, uint32_t line_no)
void FindAddressesForLine(const lldb::TargetSP target_sp, const FileSpec &file, uint32_t line, Function *function, std::vector< Address > &output_local, std::vector< Address > &output_extern)
Find addresses by file/line.
Property * ProtectedGetPropertyAtIndex(size_t idx)
static lldb::OptionValuePropertiesSP CreateLocalCopy(const Properties &global_properties)
static bool GetRestartedFromEvent(const Event *event_ptr)
A plug-in interface definition class for debugging a process.
ThreadList & GetThreadList()
Status Resume()
Resumes all of a process's threads as configured using the Thread run control functions.
virtual SystemRuntime * GetSystemRuntime()
Get the system runtime plug-in for this process.
lldb::StateType GetState()
Get accessor for the current process state.
lldb::OptionValuePropertiesSP m_collection_sp
virtual lldb::OptionValuePropertiesSP GetValueProperties() const
This base class provides an interface to stack frames.
const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope)
Provide a SymbolContext for this StackFrame's current pc value.
bool HasDebugInformation()
Determine whether this StackFrame has debug information available or not.
int SetErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Set the current error string to a formatted error string.
void SetErrorString(llvm::StringRef err_str)
Set the current error string to err_str.
bool Success() const
Test for success condition.
static lldb::StopInfoSP CreateStopReasonWithPlan(lldb::ThreadPlanSP &plan, lldb::ValueObjectSP return_valobj_sp, lldb::ExpressionVariableSP expression_variable_sp)
static lldb::StopInfoSP CreateStopReasonWithSignal(Thread &thread, int signo, const char *description=nullptr, std::optional< int > code=std::nullopt)
virtual void WillResume(lldb::StateType resume_state)
const char * GetData() const
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
void Format(const char *format, Args &&... args)
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
void IndentLess(unsigned amount=2)
Decrement the current indentation level.
void IndentMore(unsigned amount=2)
Increment the current indentation level.
ObjectSP GetItemAtIndex(size_t idx) const
ObjectSP GetValueForKey(llvm::StringRef key) const
Dictionary * GetAsDictionary()
std::shared_ptr< Object > ObjectSP
Defines a symbol context baton that can be handed other debug core functions.
Function * function
The Function for a given query.
LineEntry line_entry
The LineEntry for a given query.
A plug-in interface definition class for system runtimes.
virtual bool SafeToCallFunctionsOnThisThread(lldb::ThreadSP thread_sp)
Determine whether it is safe to run an expression on a given thread.
lldb::PlatformSP GetPlatform()
const ModuleList & GetImages() const
Get accessor for the images for this process.
const ArchSpec & GetArchitecture() const
lldb::ThreadSP GetSelectedThread()
bool SetSelectedThreadByID(lldb::tid_t tid, bool notify=false)
void ClearShouldStopHereCallbacks()
void DiscardPlansUpToPlan(ThreadPlan *up_to_plan_ptr)
lldb::ThreadPlanSP PopPlan()
bool AnyCompletedPlans() const
lldb::ThreadPlanSP GetCompletedPlan(bool skip_private=true) const
lldb::ExpressionVariableSP GetExpressionVariable() const
bool IsPlanDone(ThreadPlan *plan) const
void RestoreCompletedPlanCheckpoint(size_t checkpoint)
lldb::ThreadPlanSP GetPlanByIndex(uint32_t plan_idx, bool skip_private=true) const
lldb::ValueObjectSP GetReturnValueObject() const
void PushPlan(lldb::ThreadPlanSP new_plan_sp)
void DiscardConsultingControllingPlans()
lldb::ThreadPlanSP DiscardPlan()
bool WasPlanDiscarded(ThreadPlan *plan) const
size_t CheckpointCompletedPlans()
ThreadPlan * GetInnermostExpression() const
lldb::ThreadPlanSP GetCurrentPlan() const
ThreadPlan * GetPreviousPlan(ThreadPlan *current_plan) const
lldb::addr_t GetBreakpointLoadAddress() const
void SetAutoContinue(bool do_it)
virtual bool IsLeafPlan()
virtual Vote ShouldReportStop(Event *event_ptr)
virtual bool OkayToDiscard()
virtual bool ShouldAutoContinue(Event *event_ptr)
Returns whether this thread plan overrides the ShouldStop of subsequently processed plans.
Vote ShouldReportRun(Event *event_ptr)
const char * GetName() const
Returns the name of this thread plan.
ThreadPlanKind GetKind() const
virtual bool ShouldRunBeforePublicStop()
bool PlanExplainsStop(Event *event_ptr)
@ eKindStepOverBreakpoint
bool TracerExplainsStop()
bool WillResume(lldb::StateType resume_state, bool current_plan)
virtual bool MischiefManaged()
virtual bool IsPlanStale()
virtual bool WillStop()=0
virtual bool ShouldStop(Event *event_ptr)=0
virtual bool IsBasePlan()
bool GetStepInAvoidsNoDebug() const
~ThreadProperties() override
const RegularExpression * GetSymbolsToAvoidRegexp()
The regular expression returned determines symbols that this thread won't stop in during "step-in" op...
bool GetTraceEnabledState() const
ThreadProperties(bool is_global)
uint64_t GetMaxBacktraceDepth() const
FileSpecList GetLibrariesToAvoid() const
bool GetStepOutAvoidsNoDebug() const
uint64_t GetSingleThreadPlanTimeout() const
bool ThreadPassesBasicTests(Thread &thread) const
~ThreadEventData() override
static const ThreadEventData * GetEventDataFromEvent(const Event *event_ptr)
static lldb::ThreadSP GetThreadFromEvent(const Event *event_ptr)
void Dump(Stream *s) const override
static lldb::StackFrameSP GetStackFrameFromEvent(const Event *event_ptr)
static llvm::StringRef GetFlavorString()
StackID GetStackID() const
lldb::ThreadSP GetThread() const
static StackID GetStackIDFromEvent(const Event *event_ptr)
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.
bool IsThreadPlanDone(ThreadPlan *plan) const
Checks whether the given plan is in the completed plans for this stop.
virtual lldb::user_id_t GetProtocolID() const
lldb::ThreadSP GetCurrentExceptionBacktrace()
std::optional< lldb::addr_t > GetPreviousFrameZeroPC()
Request the pc value the thread had when previously stopped.
void BroadcastSelectedFrameChange(StackID &new_frame_id)
Status UnwindInnermostExpression()
Unwinds the thread stack for the innermost expression plan currently on the thread plan stack.
const uint32_t m_index_id
A unique 1 based index assigned to each thread for easy UI/command line access.
void SetShouldRunBeforePublicStop(bool newval)
virtual lldb::StackFrameSP GetStackFrameAtIndex(uint32_t idx)
bool CompletedPlanOverridesBreakpoint() const
Check if we have completed plan to override breakpoint stop reason.
lldb::StackFrameListSP m_curr_frames_sp
The stack frames that get lazily populated after a thread stops.
virtual bool SafeToCallFunctions()
Check whether this thread is safe to run functions.
void RestoreThreadStateFromCheckpoint(ThreadStateCheckpoint &saved_state)
Status QueueThreadPlan(lldb::ThreadPlanSP &plan_sp, bool abort_other_plans)
Queues a generic thread plan.
bool WasThreadPlanDiscarded(ThreadPlan *plan) const
Checks whether the given plan is in the discarded plans for this stop.
virtual lldb::RegisterContextSP GetRegisterContext()=0
virtual lldb::addr_t GetThreadPointer()
Retrieves the per-thread data area.
@ eBroadcastBitSelectedFrameChanged
@ eBroadcastBitStackChanged
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)
virtual bool RestoreRegisterStateFromCheckpoint(ThreadStateCheckpoint &saved_state)
uint32_t m_stop_info_stop_id
void AutoCompleteThreadPlans(CompletionRequest &request) const
Format the thread plan information for auto completion.
std::recursive_mutex m_frame_mutex
Multithreaded protection for m_state.
static void SettingsInitialize()
void SetShouldReportStop(Vote vote)
virtual lldb::StopInfoSP GetPrivateStopInfo(bool calculate=true)
uint32_t GetIndexID() const
std::optional< lldb::addr_t > m_prev_framezero_pc
Frame 0's PC the last time this thread was stopped.
Status ReturnFromFrame(lldb::StackFrameSP frame_sp, lldb::ValueObjectSP return_value_sp, bool broadcast=false)
void CalculateExecutionContext(ExecutionContext &exe_ctx) override
Reconstruct the object's execution context into sc.
void DiscardThreadPlans(bool force)
Discards the plans queued on the plan stack of the current thread.
void SetStopInfo(const lldb::StopInfoSP &stop_info_sp)
bool GetDescription(Stream &s, lldb::DescriptionLevel level, bool print_json_thread, bool print_json_stopinfo)
static std::string RunModeAsString(lldb::RunMode mode)
void SetTemporaryResumeState(lldb::StateType new_state)
virtual bool MatchesSpec(const ThreadSpec *spec)
lldb::ProcessSP CalculateProcess() override
StructuredData::ObjectSP GetExtendedInfo()
Retrieve a dictionary of information about this thread.
virtual lldb::addr_t GetThreadLocalData(const lldb::ModuleSP module, lldb::addr_t tls_file_addr)
Retrieves the per-module TLS block for a thread.
void SetStopInfoToNothing()
virtual void DestroyThread()
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 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...
lldb::StackFrameSP GetSelectedFrame(SelectMostRelevant select_most_relevant)
virtual bool IsStillAtLastBreakpointHit()
std::recursive_mutex m_state_mutex
Multithreaded protection for m_state.
ThreadPlan * GetPreviousPlan(ThreadPlan *plan) const
virtual const char * GetName()
void PushPlan(lldb::ThreadPlanSP plan_sp)
lldb::StackFrameListSP m_prev_frames_sp
The previous stack frames from the last time this thread stopped.
virtual void ClearStackFrames()
ThreadPlan * GetCurrentPlan() const
Gets the plan which will execute next on the plan stack.
virtual Unwind & GetUnwinder()
static llvm::StringRef GetStaticBroadcasterClass()
void SetResumeSignal(int signal)
lldb::ValueObjectSP GetReturnValueObject() const
Gets the outer-most return value from the completed plans.
virtual lldb::ThreadSP GetBackingThread() const
lldb::ExpressionVariableSP GetExpressionVariable() const
Gets the outer-most expression variable from the completed plans.
Vote ShouldReportRun(Event *event_ptr)
lldb::TargetSP CalculateTarget() override
static std::string StopReasonAsString(lldb::StopReason reason)
virtual void WillResume(lldb::StateType resume_state)
Thread(Process &process, lldb::tid_t tid, bool use_invalid_index_id=false)
Constructor.
bool ThreadStoppedForAReason()
size_t GetStackFrameStatus(Stream &strm, uint32_t first_frame, uint32_t num_frames, bool show_frame_info, uint32_t num_frames_with_source, bool show_hidden)
std::string GetStopDescriptionRaw()
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...
virtual Status StepOver(bool source_step, LazyBool step_out_avoids_code_without_debug_info=eLazyBoolCalculate)
Default implementation for stepping over.
bool ShouldResume(lldb::StateType resume_state)
std::unique_ptr< lldb_private::Unwind > m_unwinder_up
It gets set in Thread::ShouldResume.
std::unique_ptr< ThreadPlanStack > m_null_plan_stack_up
lldb::StateType GetTemporaryResumeState() const
virtual bool CheckpointThreadState(ThreadStateCheckpoint &saved_state)
void SetState(lldb::StateType state)
lldb::ProcessSP GetProcess() const
lldb::StackFrameSP CalculateStackFrame() override
lldb::StateType GetResumeState() const
Gets the USER resume state for this thread.
uint32_t SetSelectedFrame(lldb_private::StackFrame *frame, bool broadcast=false)
lldb::StopInfoSP m_stop_info_sp
The private stop reason for this thread.
lldb::ProcessWP m_process_wp
The process that owns this thread.
void DumpUsingSettingsFormat(Stream &strm, uint32_t frame_idx, bool stop_format)
LazyBool m_override_should_notify
lldb::ThreadSP CalculateThread() override
Status ReturnFromFrameWithIndex(uint32_t frame_idx, lldb::ValueObjectSP return_value_sp, bool broadcast=false)
virtual Status StepOut(uint32_t frame_idx=0)
Default implementation for stepping out.
virtual llvm::Expected< std::unique_ptr< llvm::MemoryBuffer > > GetSiginfo(size_t max_size) const
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.
lldb::StateType GetState() const
lldb::StateType m_state
The state of our process.
virtual lldb::ThreadPlanSP QueueThreadPlanForStepScripted(bool abort_other_plans, const char *class_name, StructuredData::ObjectSP extra_args_sp, bool stop_other_threads, Status &status)
bool m_extended_info_fetched
void CalculatePublicStopInfo()
static void SettingsTerminate()
bool SetSelectedFrameByIndex(uint32_t frame_idx, bool broadcast=false)
lldb::StopReason GetStopReason()
ThreadPlanStack & GetPlans() const
lldb::ValueObjectSP GetSiginfoValue()
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.
uint32_t m_stop_info_override_stop_id
int m_resume_signal
The signal that should be used when continuing this thread.
bool StopInfoIsUpToDate() const
lldb::StackFrameSP GetStackFrameSPForStackFramePtr(StackFrame *stack_frame_ptr)
lldb::ThreadPlanSP GetCompletedPlan() const
Gets the outer-most plan that was popped off the plan stack in the most recent stop.
lldb::ValueObjectSP GetCurrentException()
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 lldb::StackFrameSP GetFrameWithConcreteFrameIndex(uint32_t unwind_idx)
bool ShouldStop(Event *event_ptr)
Status JumpToLine(const FileSpec &file, uint32_t line, bool can_leave_function, std::string *warnings=nullptr)
bool DumpUsingFormat(Stream &strm, uint32_t frame_idx, const FormatEntity::Entry *format)
Print a description of this thread using the provided thread format.
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.
void FrameSelectedCallback(lldb_private::StackFrame *frame)
lldb::ThreadPlanSP QueueBasePlan(bool abort_other_plans)
Queues the base plan for a thread.
static ThreadProperties & GetGlobalProperties()
uint32_t GetCurrentInlinedDepth()
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.
std::string GetStopDescription()
StructuredData::ObjectSP m_extended_info
lldb::StopInfoSP GetStopInfo()
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::StackFrameListSP GetStackFrameList()
bool m_should_run_before_public_stop
Vote ShouldReportStop(Event *event_ptr)
bool SetSelectedFrameByIndexNoisily(uint32_t frame_idx, Stream &output_stream)
virtual bool CalculateStopInfo()=0
Ask the thread subclass to set its stop info.
lldb::StateType m_resume_state
This state is used to force a thread to be suspended from outside the ThreadPlan logic.
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.
size_t GetStatus(Stream &strm, uint32_t start_frame, uint32_t num_frames, uint32_t num_frames_with_source, bool stop_format, bool show_hidden, bool only_stacks=false)
lldb::RegisterContextSP m_reg_context_sp
The register context for this thread's current register state.
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size, lldb::addr_t address=LLDB_INVALID_ADDRESS)
#define LLDB_INVALID_SIGNAL_NUMBER
#define LLDB_INVALID_INDEX32
#define LLDB_INVALID_ADDRESS
#define LLDB_INVALID_FRAME_ID
@ DoNoSelectMostRelevantFrame
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
bool StateIsStoppedState(lldb::StateType state, bool must_exist)
Check if a state represents a state where the process or thread is stopped.
const char * StateAsCString(lldb::StateType state)
Converts a StateType to a C string.
std::shared_ptr< lldb_private::ThreadPlan > ThreadPlanSP
std::shared_ptr< lldb_private::ABI > ABISP
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::BreakpointSite > BreakpointSiteSP
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
@ eDescriptionLevelInitial
@ eDescriptionLevelVerbose
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::ExpressionVariable > ExpressionVariableSP
std::shared_ptr< lldb_private::Platform > PlatformSP
StateType
Process and Thread States.
@ eStateUnloaded
Process is object is valid, but not currently loaded.
@ eStateStopped
Process or thread is stopped and can be examined.
@ eStateSuspended
Process or thread is in a suspended state as far as the debugger is concerned while other processes o...
@ eStateRunning
Process or thread is running and can't be examined.
@ eStateStepping
Process or thread is in the process of stepping and can not be examined.
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::StopInfo > StopInfoSP
StopReason
Thread stop reasons.
@ eStopReasonInstrumentation
@ eStopReasonPlanComplete
@ eStopReasonExec
Program was re-exec'ed.
@ eStopReasonInterrupt
Thread requested interrupt.
@ eStopReasonProcessorTrace
@ eStopReasonThreadExiting
std::shared_ptr< lldb_private::Target > TargetSP
@ eStructuredDataTypeDictionary
@ eStructuredDataTypeInteger
@ eStructuredDataTypeArray
@ eStructuredDataTypeString
std::shared_ptr< lldb_private::RegisterContext > RegisterContextSP
std::shared_ptr< lldb_private::Module > ModuleSP
std::shared_ptr< lldb_private::RegisterCheckpoint > RegisterCheckpointSP
std::shared_ptr< lldb_private::StackFrameList > StackFrameListSP
A line table entry class.
AddressRange GetSameLineContiguousAddressRange(bool include_inlined_functions) const
Give the range for this LineEntry + any additional LineEntries for this same source line that are con...
uint32_t line
The source line number, or LLDB_INVALID_LINE_NUMBER if there is no line number information.
const FileSpec & GetFile() const
Helper to access the file.
uint32_t current_inlined_depth
lldb::RegisterCheckpointSP register_backup_sp
size_t m_completed_plan_checkpoint
lldb::StopInfoSP stop_info_sp
A mix in class that contains a generic user ID.
lldb::user_id_t GetID() const
Get accessor for the user ID.