70 return *g_settings_ptr;
73#define LLDB_PROPERTIES_thread
74#include "TargetProperties.inc"
77#define LLDB_PROPERTIES_thread
78#include "TargetPropertiesEnum.inc"
82 :
public Cloneable<ThreadOptionValueProperties, OptionValueProperties> {
97 thread->GetValueProperties().get());
98 if (
this != instance_properties)
108 m_collection_sp = std::make_shared<ThreadOptionValueProperties>(
"thread");
118 const uint32_t idx = ePropertyStepAvoidRegex;
123 const uint32_t idx = ePropertyStepAvoidLibraries;
128 const uint32_t idx = ePropertyEnableThreadTrace;
130 idx, g_thread_properties[idx].default_uint_value != 0);
134 const uint32_t idx = ePropertyStepInAvoidsNoDebug;
136 idx, g_thread_properties[idx].default_uint_value != 0);
140 const uint32_t idx = ePropertyStepOutAvoidsNoDebug;
142 idx, g_thread_properties[idx].default_uint_value != 0);
146 const uint32_t idx = ePropertyMaxBacktraceDepth;
148 idx, g_thread_properties[idx].default_uint_value);
152 const uint32_t idx = ePropertySingleThreadPlanTimeout;
154 idx, g_thread_properties[idx].default_uint_value);
160 return "Thread::ThreadEventData";
210 frame_sp = thread_sp->GetStackFrameList()->GetFrameWithStackID(
220 static constexpr llvm::StringLiteral class_name(
"lldb.thread");
226 Broadcaster(process.GetTarget().GetDebugger().GetBroadcasterManager(),
233 : process.GetNextThreadIndexID(tid)),
242 LLDB_LOGF(log,
"%p Thread::Thread(tid = 0x%4.4" PRIx64
")",
243 static_cast<void *
>(
this),
GetID());
250 LLDB_LOGF(log,
"%p Thread::~Thread(tid = 0x%4.4" PRIx64
")",
251 static_cast<void *
>(
this),
GetID());
272 std::make_shared<ThreadEventData>(shared_from_this(), new_frame_id);
280 StackFrameSP frame_sp = stack_frame_list_sp->GetFrameAtIndex(
281 stack_frame_list_sp->GetSelectedFrameIndex(select_most_relevant));
309 const bool broadcast =
true;
314 bool already_shown =
false;
316 frame_sp->GetSymbolContext(eSymbolContextLineEntry));
324 "OpenFileInExternalEditor failed: {0}");
326 already_shown =
true;
330 bool show_frame_info =
true;
331 bool show_source = !already_shown;
333 return frame_sp->GetStatus(output_stream, show_frame_info, show_source);
346 GetProcess()->GetWarningsUnsupportedLanguage())) {
350 GetProcess()->PrintWarningUnsupportedLanguage(sc);
360 const uint32_t stop_id = process_sp ? process_sp->GetStopID() :
UINT32_MAX;
370 bool have_valid_completed_plan = completed_plan_sp && completed_plan_sp->PlanSucceeded();
371 bool plan_failed = completed_plan_sp && !completed_plan_sp->PlanSucceeded();
372 bool plan_overrides_trace =
373 have_valid_stop_info && have_valid_completed_plan
376 if (have_valid_stop_info && !plan_overrides_trace && !plan_failed) {
378 }
else if (completed_plan_sp) {
401 const uint32_t process_stop_id = process_sp->GetStopID();
434 process_sp->GetTarget().GetArchitecturePlugin())
435 arch->OverrideStopInfo(*
this);
451 return stop_info_sp->GetStopReason();
486 LLDB_LOGF(log,
"%p: tid = 0x%" PRIx64
": stop info = %s (stop_id = %u)",
487 static_cast<void *
>(
this),
GetID(),
488 stop_info_sp ? stop_info_sp->GetDescription() :
"<NULL>",
519 if (reg_checkpoint_sp) {
521 if (reg_ctx_sp && reg_ctx_sp->ReadAllRegisterValues(*reg_checkpoint_sp))
552 reg_ctx_sp->InvalidateIfNeeded(
true);
591 auto recognized_frame_sp = frame_sp->GetRecognizedFrame();
593 if (!recognized_frame_sp)
596 std::string recognized_stop_description =
597 recognized_frame_sp->GetStopDescription();
599 if (!recognized_stop_description.empty())
600 return recognized_stop_description;
607 std::string raw_stop_description;
608 if (stop_info_sp && stop_info_sp->IsValid()) {
609 raw_stop_description = stop_info_sp->GetDescription();
610 assert((!raw_stop_description.empty() ||
612 "StopInfo returned an empty description.");
614 return raw_stop_description;
645 if (reg_ctx_sp && process_sp && direction ==
eRunForward) {
646 const addr_t thread_pc = reg_ctx_sp->GetPC();
648 process_sp->GetBreakpointSiteList().FindByAddress(thread_pc);
663 bool push_step_over_bp_plan =
false;
668 push_step_over_bp_plan =
true;
670 push_step_over_bp_plan =
true;
672 if (push_step_over_bp_plan) {
674 if (step_bp_plan_sp) {
675 step_bp_plan_sp->SetPrivate(
true);
680 step_bp_plan_sp.get());
703 if (backing_thread_sp)
704 backing_thread_sp->SetTemporaryResumeState(resume_state);
716 const uint32_t process_stop_id =
GetProcess()->GetStopID();
720 stop_info_sp->WillResume(resume_state);
728 bool need_to_resume =
false;
731 need_to_resume = plan_ptr->
WillResume(resume_state,
true);
745 if (need_to_resume) {
752 return need_to_resume;
766 bool should_stop =
true;
772 "Thread::%s for tid = 0x%4.4" PRIx64
" 0x%4.4" PRIx64
773 ", should_stop = 0 (ignore since thread was suspended)",
780 "Thread::%s for tid = 0x%4.4" PRIx64
" 0x%4.4" PRIx64
781 ", should_stop = 0 (ignore since thread was suspended)",
791 "Thread::%s for tid = 0x%4.4" PRIx64
" 0x%4.4" PRIx64
792 ", pc = 0x%16.16" PRIx64
793 ", should_stop = 0 (ignore since no stop reason)",
805 "Thread::%s(%p) for tid = 0x%4.4" PRIx64
" 0x%4.4" PRIx64
806 ", pc = 0x%16.16" PRIx64,
810 LLDB_LOGF(log,
"^^^^^^^^ Thread::ShouldStop Begin ^^^^^^^^");
827 if (private_stop_info &&
828 !private_stop_info->ShouldStopSynchronous(event_ptr)) {
829 LLDB_LOGF(log,
"StopInfo::ShouldStop async callback says we should not "
830 "stop, returning ShouldStop of false.");
849 bool done_processing_current_plan =
false;
852 done_processing_current_plan =
true;
868 should_stop = plan_ptr->
ShouldStop(event_ptr);
887 done_processing_current_plan =
891 if (should_force_run) {
895 done_processing_current_plan =
true;
903 if (!done_processing_current_plan) {
904 bool override_stop =
false;
908 should_stop = current_plan->
ShouldStop(event_ptr);
909 LLDB_LOGF(log,
"Base plan says should stop: %i.", should_stop);
918 should_stop = current_plan->
ShouldStop(event_ptr);
926 override_stop =
true;
927 LLDB_LOGF(log,
"Plan %s auto-continue: true.",
941 if (current_plan ==
nullptr) {
973 "Plan %s being discarded in cleanup, it says it is already done.",
996 LLDB_LOGF(log,
"vvvvvvvv Thread::ShouldStop End (returning %i) vvvvvvvv",
1010 "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
1011 ": returning vote %i (state was suspended or invalid)",
1019 "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
1020 ": returning vote %i (temporary state was suspended or invalid)",
1027 "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
1028 ": returning vote %i (thread didn't stop for a reason.)",
1033 if (
GetPlans().AnyCompletedPlans()) {
1037 "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
1038 ": returning vote for complete stack's back plan",
1055 "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
1056 ": returning vote %i for current plan",
1057 GetID(), thread_vote);
1071 if (
GetPlans().AnyCompletedPlans()) {
1075 "Current Plan for thread %d(%p) (0x%4.4" PRIx64
1076 ", %s): %s being asked whether we should report run.",
1084 "Current Plan for thread %d(%p) (0x%4.4" PRIx64
1085 ", %s): %s being asked whether we should report run.",
1115 assert(thread_plan_sp &&
"Don't push an empty thread plan.");
1121 LLDB_LOGF(log,
"Thread::PushPlan(0x%p): \"%s\", tid = 0x%4.4" PRIx64
".",
1122 static_cast<void *
>(
this), s.
GetData(),
1123 thread_plan_sp->GetThread().GetID());
1133 LLDB_LOGF(log,
"Popping plan: \"%s\", tid = 0x%4.4" PRIx64
".",
1134 popped_plan_sp->GetName(), popped_plan_sp->GetThread().GetID());
1142 LLDB_LOGF(log,
"Discarding plan: \"%s\", tid = 0x%4.4" PRIx64
".",
1143 discarded_plan_sp->GetName(),
1144 discarded_plan_sp->GetThread().GetID());
1196 bool abort_other_plans) {
1199 if (!thread_plan_sp->ValidatePlan(&s)) {
1201 thread_plan_sp.reset();
1205 if (abort_other_plans)
1214 if (!thread_plan_sp->ValidatePlan(&s)) {
1216 thread_plan_sp.reset();
1228 if (up_to_plan_ptr ==
nullptr)
1242 "Discarding thread plans for thread tid = 0x%4.4" PRIx64
1244 GetID(),
static_cast<void *
>(up_to_plan_ptr));
1252 "Discarding thread plans for thread (tid = 0x%4.4" PRIx64
1267 if (!innermost_expr_plan) {
1269 "No expressions currently active on this thread");
1279 return thread_plan_sp;
1283 bool step_over,
bool abort_other_plans,
bool stop_other_threads,
1288 return thread_plan_sp;
1294 Status &status,
LazyBool step_out_avoids_code_withoug_debug_info) {
1296 thread_plan_sp = std::make_shared<ThreadPlanStepOverRange>(
1297 *
this, range, addr_context, stop_other_threads,
1298 step_out_avoids_code_withoug_debug_info);
1301 return thread_plan_sp;
1307 bool abort_other_plans,
const LineEntry &line_entry,
1309 Status &status,
LazyBool step_out_avoids_code_withoug_debug_info) {
1310 const bool include_inlined_functions =
true;
1311 auto address_range =
1314 abort_other_plans, address_range, addr_context, stop_other_threads,
1315 status, step_out_avoids_code_withoug_debug_info);
1320 const SymbolContext &addr_context,
const char *step_in_target,
1322 LazyBool step_in_avoids_code_without_debug_info,
1323 LazyBool step_out_avoids_code_without_debug_info) {
1325 *
this, range, addr_context, step_in_target, stop_other_threads,
1326 step_in_avoids_code_without_debug_info,
1327 step_out_avoids_code_without_debug_info));
1329 return thread_plan_sp;
1334 bool abort_other_plans,
const LineEntry &line_entry,
1335 const SymbolContext &addr_context,
const char *step_in_target,
1337 LazyBool step_in_avoids_code_without_debug_info,
1338 LazyBool step_out_avoids_code_without_debug_info) {
1339 const bool include_inlined_functions =
false;
1343 addr_context, step_in_target, stop_other_threads, status,
1344 step_in_avoids_code_without_debug_info,
1345 step_out_avoids_code_without_debug_info);
1349 bool abort_other_plans,
SymbolContext *addr_context,
bool first_insn,
1350 bool stop_other_threads,
Vote report_stop_vote,
Vote report_run_vote,
1351 uint32_t frame_idx,
Status &status,
1352 LazyBool step_out_avoids_code_without_debug_info) {
1354 *
this, addr_context, first_insn, stop_other_threads, report_stop_vote,
1355 report_run_vote, frame_idx, step_out_avoids_code_without_debug_info));
1358 return thread_plan_sp;
1362 bool abort_other_plans,
SymbolContext *addr_context,
bool first_insn,
1363 bool stop_other_threads,
Vote report_stop_vote,
Vote report_run_vote,
1364 uint32_t frame_idx,
Status &status,
bool continue_to_next_branch) {
1365 const bool calculate_return_value =
1368 *
this, stop_other_threads, report_stop_vote, report_run_vote, frame_idx,
1369 continue_to_next_branch, calculate_return_value));
1376 return thread_plan_sp;
1380 bool abort_other_plans,
1381 bool stop_other_threads,
1385 if (!thread_plan_sp || !thread_plan_sp->ValidatePlan(
nullptr))
1389 return thread_plan_sp;
1394 bool stop_other_threads,
1400 return thread_plan_sp;
1404 bool abort_other_plans,
lldb::addr_t *address_list,
size_t num_addresses,
1405 bool stop_other_threads, uint32_t frame_idx,
Status &status) {
1407 *
this, address_list, num_addresses, stop_other_threads, frame_idx));
1410 return thread_plan_sp;
1414 bool abort_other_plans,
const char *class_name,
1420 thread_plan_sp->SetStopOthers(stop_other_threads);
1422 return thread_plan_sp;
1431 target_sp = process_sp->CalculateTarget();
1455 Target &target = process_sp->GetTarget();
1459 for (
const auto &entry : descriptors) {
1464 "Failed to load scripted frame provider: {0}");
1501 auto provider_or_err =
1503 if (!provider_or_err)
1504 return provider_or_err.takeError();
1508 return llvm::Error::success();
1555 "Could not find frame with index %d in thread 0x%" PRIx64
".",
1556 frame_idx,
GetID());
1569 return return_error;
1572 Thread *thread = frame_sp->GetThread().get();
1573 uint32_t older_frame_idx = frame_sp->GetFrameIndex() + 1;
1574 StackFrameSP older_frame_sp = thread->GetStackFrameAtIndex(older_frame_idx);
1575 if (!older_frame_sp) {
1577 return return_error;
1580 if (return_value_sp) {
1585 return return_error;
1587 SymbolContext sc = frame_sp->GetSymbolContext(eSymbolContextFunction);
1592 if ( (
false) && sc.
function !=
nullptr) {
1594 if (function_type) {
1600 ValueObjectSP cast_value_sp = return_value_sp->Cast(return_type);
1601 if (cast_value_sp) {
1603 return_value_sp = cast_value_sp;
1609 return_error = abi->SetReturnValueObject(older_frame_sp, return_value_sp);
1611 return return_error;
1618 StackFrameSP youngest_frame_sp = thread->GetStackFrameAtIndex(0);
1619 if (youngest_frame_sp) {
1622 bool copy_success = reg_ctx_sp->CopyFromRegisterContext(
1623 older_frame_sp->GetRegisterContext());
1625 thread->DiscardThreadPlans(
true);
1626 thread->ClearStackFrames();
1628 auto data_sp = std::make_shared<ThreadEventData>(shared_from_this());
1641 return return_error;
1646 for (
size_t n = 0; n < list.size(); n++) {
1655 bool can_leave_function, std::string *warnings) {
1664 std::vector<Address> candidates, within_function, outside_function;
1666 within_function, outside_function);
1673 if (!within_function.empty())
1674 candidates = within_function;
1675 else if (outside_function.size() == 1 && can_leave_function)
1676 candidates = outside_function;
1679 if (candidates.empty()) {
1680 if (outside_function.empty()) {
1684 }
else if (outside_function.size() == 1) {
1686 "%s:%i is outside the current function.",
1692 "%s:%i has multiple candidate locations:\n%s",
1699 if (warnings && candidates.size() > 1) {
1701 sstr.
Printf(
"%s:%i appears multiple times in this function, selecting the "
1702 "first location:\n",
1705 *warnings = std::string(sstr.
GetString());
1708 if (!reg_ctx->
SetPC(dest))
1718 if (!process || !format)
1727 frame_sc = frame_sp->GetSymbolContext(eSymbolContextEverything);
1732 &exe_ctx,
nullptr,
nullptr,
false,
false);
1743 thread_format = &format_entry;
1746 thread_format = &format_entry;
1749 assert(thread_format);
1805 return "breakpoint";
1807 return "watchpoint";
1819 return "vfork done";
1821 return "plan complete";
1823 return "thread exiting";
1825 return "instrumentation break";
1827 return "processor trace";
1829 return "async interrupt";
1831 return "history boundary";
1834 return "StopReason = " + std::to_string(reason);
1840 return "only this thread";
1842 return "all threads";
1844 return "only during stepping";
1847 return "RunMode = " + std::to_string(mode);
1851 uint32_t num_frames, uint32_t num_frames_with_source,
1852 bool stop_format,
bool show_hidden,
bool only_stacks) {
1859 bool is_selected =
false;
1864 strm.
Printf(
"%c ", is_selected ?
'*' :
' ');
1869 frame_sp->GetSymbolContext(eSymbolContextLineEntry));
1875 "OpenFileInExternalEditor failed: {0}");
1884 size_t num_frames_shown = 0;
1885 if (num_frames > 0) {
1888 const bool show_frame_info =
true;
1889 const bool show_frame_unique = only_stacks;
1890 const char *selected_frame_marker =
nullptr;
1891 if (num_frames == 1 || only_stacks ||
1895 selected_frame_marker =
"* ";
1898 strm, start_frame, num_frames, show_frame_info, num_frames_with_source,
1899 show_frame_unique, show_hidden, selected_frame_marker);
1900 if (num_frames == 1)
1904 return num_frames_shown;
1908 bool print_json_thread,
bool print_json_stopinfo) {
1909 const bool stop_format =
false;
1915 if (print_json_thread || print_json_stopinfo) {
1916 if (thread_info && print_json_thread) {
1917 thread_info->Dump(strm);
1924 stop_info->Dump(strm);
1934 thread_info->GetObjectForDotSeparatedPath(
"activity");
1936 thread_info->GetObjectForDotSeparatedPath(
"breadcrumb");
1938 thread_info->GetObjectForDotSeparatedPath(
"trace_messages");
1940 bool printed_activity =
false;
1947 strm.
Format(
" Activity '{0}', {1:x}\n",
1948 name->GetAsString()->GetValue(),
1949 id->GetUnsignedIntegerValue());
1951 printed_activity =
true;
1953 bool printed_breadcrumb =
false;
1955 if (printed_activity)
1958 breadcrumb->GetAsDictionary();
1961 if (breadcrumb_text &&
1963 strm.
Format(
" Current Breadcrumb: {0}\n",
1964 breadcrumb_text->GetAsString()->GetValue());
1966 printed_breadcrumb =
true;
1969 if (printed_breadcrumb)
1972 const size_t msg_count = messages_array->
GetSize();
1973 if (msg_count > 0) {
1974 strm.
Printf(
" %zu trace messages:\n", msg_count);
1975 for (
size_t i = 0; i < msg_count; i++) {
1979 message->GetAsDictionary();
1984 strm.
Format(
" {0}\n", message_text->GetAsString()->GetValue());
1996 uint32_t num_frames,
bool show_frame_info,
1997 uint32_t num_frames_with_source,
2000 show_frame_info, num_frames_with_source,
2001 false, show_hidden);
2028 GetProcess()->GetBreakpointSiteList().FindByAddress(
pc);
2029 if (bp_site_sp &&
static_cast<break_id_t>(value) == bp_site_sp->GetID())
2038 LazyBool step_in_avoids_code_without_debug_info,
2039 LazyBool step_out_avoids_code_without_debug_info)
2048 const bool abort_other_plans =
false;
2050 if (source_step && frame_sp && frame_sp->HasDebugInformation()) {
2051 SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
2054 step_in_avoids_code_without_debug_info,
2055 step_out_avoids_code_without_debug_info);
2058 false, abort_other_plans, run_mode,
error);
2061 new_plan_sp->SetIsControllingPlan(
true);
2062 new_plan_sp->SetOkayToDiscard(
false);
2074 LazyBool step_out_avoids_code_without_debug_info) {
2082 const bool abort_other_plans =
false;
2084 if (source_step && frame_sp && frame_sp->HasDebugInformation()) {
2085 SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
2088 step_out_avoids_code_without_debug_info);
2091 true, abort_other_plans, run_mode,
error);
2094 new_plan_sp->SetIsControllingPlan(
true);
2095 new_plan_sp->SetOkayToDiscard(
false);
2110 const bool first_instruction =
false;
2111 const bool stop_other_threads =
false;
2112 const bool abort_other_plans =
false;
2115 abort_other_plans,
nullptr, first_instruction, stop_other_threads,
2118 new_plan_sp->SetIsControllingPlan(
true);
2119 new_plan_sp->SetOkayToDiscard(
false);
2132 if (
auto recognized_frame = frame_sp->GetRecognizedFrame())
2133 if (
auto e = recognized_frame->GetExceptionObject())
2139 if (
auto e = runtime->GetExceptionObjectForThread(shared_from_this()))
2154 if (
auto bt = runtime->GetBacktraceThreadFromException(exception))
2164 Target &target = process_sp->GetTarget();
2166 assert(platform_sp);
2174 auto type_size_or_err = type.
GetByteSize(
nullptr);
2175 if (!type_size_or_err)
2179 llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>> data =
2185 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.
bool EventTypeHasListeners(uint32_t event_type)
Broadcaster(lldb::BroadcasterManagerSP manager_sp, std::string name)
Construct with a broadcaster with a name.
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.
llvm::Expected< 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
FormatEntity::Entry GetThreadStopFormat() const
llvm::StringRef GetExternalEditor() const
FormatEntity::Entry GetThreadFormat() 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
T GetPropertyAtIndexAs(uint32_t idx, T default_value, const ExecutionContext *exe_ctx=nullptr) const
This base class provides an interface to stack frames.
virtual StackID & GetStackID()
virtual const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope)
Provide a SymbolContext for this StackFrame's current pc value.
virtual bool HasDebugInformation()
Determine whether this StackFrame has debug information available or not.
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
static Status FromErrorString(const char *str)
static Status FromError(llvm::Error error)
Avoid using this in new code. Migrate APIs to llvm::Expected instead.
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)
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
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.
static llvm::Expected< lldb::SyntheticFrameProviderSP > CreateInstance(lldb::StackFrameListSP input_frames, const ScriptedFrameProviderDescriptor &descriptor)
Try to create a SyntheticFrameProvider instance for the given input frames and descriptor.
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.
Debugger & GetDebugger() const
const llvm::DenseMap< uint32_t, ScriptedFrameProviderDescriptor > & GetScriptedFrameProviderDescriptors() const
Get all scripted frame provider descriptors for this target.
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
ThreadEventData(const lldb::ThreadSP thread_sp)
lldb::ThreadSP GetThread() const
lldb::ThreadSP m_thread_sp
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)
@ eBroadcastBitSelectedFrameChanged
@ eBroadcastBitStackChanged
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.
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)
bool SetupToStepOverBreakpointIfNeeded(lldb::RunDirection direction)
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.
lldb::addr_t m_stopped_at_unexecuted_bp
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()
void ClearScriptedFrameProvider()
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)
llvm::Error LoadScriptedFrameProvider(const ScriptedFrameProviderDescriptor &descriptor)
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::SyntheticFrameProviderSP m_frame_provider_sp
The Scripted Frame Provider, if any.
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
RunDirection
Execution directions.
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
@ eStopReasonHistoryBoundary
@ 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.
This struct contains the metadata needed to instantiate a frame provider and optional filters to cont...
bool AppliesToThread(Thread &thread) const
Check if this descriptor applies to the given thread.
bool IsValid() const
Check if this descriptor has valid metadata for script-based providers.
uint32_t current_inlined_depth
lldb::addr_t stopped_at_unexecuted_bp
lldb::RegisterCheckpointSP register_backup_sp
size_t m_completed_plan_checkpoint
lldb::StopInfoSP stop_info_sp
UserID(lldb::user_id_t uid=LLDB_INVALID_UID)
Construct with optional user ID.
lldb::user_id_t GetID() const
Get accessor for the user ID.