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);
104 std::make_shared<ThreadOptionValueProperties>(
ConstString(
"thread"));
114 const uint32_t idx = ePropertyStepAvoidRegex;
115 return GetPropertyAtIndexAs<const RegularExpression *>(idx);
119 const uint32_t idx = ePropertyStepAvoidLibraries;
120 return GetPropertyAtIndexAs<FileSpecList>(idx, {});
124 const uint32_t idx = ePropertyEnableThreadTrace;
125 return GetPropertyAtIndexAs<bool>(
126 idx, g_thread_properties[idx].default_uint_value != 0);
130 const uint32_t idx = ePropertyStepInAvoidsNoDebug;
131 return GetPropertyAtIndexAs<bool>(
132 idx, g_thread_properties[idx].default_uint_value != 0);
136 const uint32_t idx = ePropertyStepOutAvoidsNoDebug;
137 return GetPropertyAtIndexAs<bool>(
138 idx, g_thread_properties[idx].default_uint_value != 0);
142 const uint32_t idx = ePropertyMaxBacktraceDepth;
143 return GetPropertyAtIndexAs<uint64_t>(
144 idx, g_thread_properties[idx].default_uint_value);
150 return "Thread::ThreadEventData";
154 : m_thread_sp(thread_sp), m_stack_id() {}
158 : m_thread_sp(thread_sp), m_stack_id(stack_id) {}
196 StackFrameSP frame_sp;
198 ThreadSP thread_sp = event_data->
GetThread();
200 frame_sp = thread_sp->GetStackFrameList()->GetFrameWithStackID(
216 Broadcaster(process.GetTarget().GetDebugger().GetBroadcasterManager(),
222 : process.GetNextThreadIndexID(tid)),
231 LLDB_LOGF(log,
"%p Thread::Thread(tid = 0x%4.4" PRIx64
")",
232 static_cast<void *
>(
this),
GetID());
239 LLDB_LOGF(log,
"%p Thread::~Thread(tid = 0x%4.4" PRIx64
")",
240 static_cast<void *
>(
this),
GetID());
265 StackFrameSP frame_sp = stack_frame_list_sp->GetFrameAtIndex(
266 stack_frame_list_sp->GetSelectedFrameIndex(select_most_relevant));
294 const bool broadcast =
true;
299 bool already_shown =
false;
301 frame_sp->GetSymbolContext(eSymbolContextLineEntry));
309 "OpenFileInExternalEditor failed: {0}");
311 already_shown =
true;
315 bool show_frame_info =
true;
316 bool show_source = !already_shown;
318 return frame_sp->GetStatus(output_stream, show_frame_info, show_source);
331 GetProcess()->GetWarningsUnsupportedLanguage())) {
335 GetProcess()->PrintWarningUnsupportedLanguage(sc);
355 bool have_valid_completed_plan = completed_plan_sp && completed_plan_sp->PlanSucceeded();
356 bool plan_failed = completed_plan_sp && !completed_plan_sp->PlanSucceeded();
357 bool plan_overrides_trace =
358 have_valid_stop_info && have_valid_completed_plan
361 if (have_valid_stop_info && !plan_overrides_trace && !plan_failed) {
363 }
else if (completed_plan_sp) {
386 const uint32_t process_stop_id = process_sp->GetStopID();
419 process_sp->GetTarget().GetArchitecturePlugin())
420 arch->OverrideStopInfo(*
this);
430 return stop_info_sp->GetStopReason();
465 LLDB_LOGF(log,
"%p: tid = 0x%" PRIx64
": stop info = %s (stop_id = %u)",
466 static_cast<void *
>(
this),
GetID(),
467 stop_info_sp ? stop_info_sp->GetDescription() :
"<NULL>",
496 lldb::RegisterCheckpointSP reg_checkpoint_sp(
498 if (reg_checkpoint_sp) {
499 lldb::RegisterContextSP reg_ctx_sp(frame_sp->GetRegisterContext());
500 if (reg_ctx_sp && reg_ctx_sp->ReadAllRegisterValues(*reg_checkpoint_sp))
523 lldb::RegisterContextSP reg_ctx_sp(frame_sp->GetRegisterContext());
530 reg_ctx_sp->InvalidateIfNeeded(
true);
568 auto recognized_frame_sp = frame_sp->GetRecognizedFrame();
570 if (!recognized_frame_sp)
573 std::string recognized_stop_description =
574 recognized_frame_sp->GetStopDescription();
576 if (!recognized_stop_description.empty())
577 return recognized_stop_description;
584 std::string raw_stop_description;
585 if (stop_info_sp && stop_info_sp->IsValid()) {
586 raw_stop_description = stop_info_sp->GetDescription();
587 assert((!raw_stop_description.empty() ||
589 "StopInfo returned an empty description.");
591 return raw_stop_description;
614 const addr_t thread_pc = reg_ctx_sp->GetPC();
615 BreakpointSiteSP bp_site_sp =
616 GetProcess()->GetBreakpointSiteList().FindByAddress(thread_pc);
623 bool push_step_over_bp_plan =
false;
628 push_step_over_bp_plan =
true;
630 push_step_over_bp_plan =
true;
632 if (push_step_over_bp_plan) {
634 if (step_bp_plan_sp) {
635 step_bp_plan_sp->SetPrivate(
true);
640 step_bp_plan_sp.get());
661 if (backing_thread_sp)
662 backing_thread_sp->SetTemporaryResumeState(resume_state);
687 bool need_to_resume =
false;
690 need_to_resume = plan_ptr->
WillResume(resume_state,
true);
704 if (need_to_resume) {
710 return need_to_resume;
724 bool should_stop =
true;
730 "Thread::%s for tid = 0x%4.4" PRIx64
" 0x%4.4" PRIx64
731 ", should_stop = 0 (ignore since thread was suspended)",
738 "Thread::%s for tid = 0x%4.4" PRIx64
" 0x%4.4" PRIx64
739 ", should_stop = 0 (ignore since thread was suspended)",
749 "Thread::%s for tid = 0x%4.4" PRIx64
" 0x%4.4" PRIx64
750 ", pc = 0x%16.16" PRIx64
751 ", should_stop = 0 (ignore since no stop reason)",
763 "Thread::%s(%p) for tid = 0x%4.4" PRIx64
" 0x%4.4" PRIx64
764 ", pc = 0x%16.16" PRIx64,
768 LLDB_LOGF(log,
"^^^^^^^^ Thread::ShouldStop Begin ^^^^^^^^");
785 if (private_stop_info &&
786 !private_stop_info->ShouldStopSynchronous(event_ptr)) {
787 LLDB_LOGF(log,
"StopInfo::ShouldStop async callback says we should not "
788 "stop, returning ShouldStop of false.");
807 bool done_processing_current_plan =
false;
811 done_processing_current_plan =
true;
821 should_stop = plan_ptr->
ShouldStop(event_ptr);
840 done_processing_current_plan =
844 if (should_force_run) {
848 done_processing_current_plan =
true;
856 if (!done_processing_current_plan) {
857 bool override_stop =
false;
861 should_stop = current_plan->
ShouldStop(event_ptr);
862 LLDB_LOGF(log,
"Base plan says should stop: %i.", should_stop);
871 should_stop = current_plan->
ShouldStop(event_ptr);
879 override_stop =
true;
880 LLDB_LOGF(log,
"Plan %s auto-continue: true.",
894 if (current_plan ==
nullptr) {
926 "Plan %s being discarded in cleanup, it says it is already done.",
949 LLDB_LOGF(log,
"vvvvvvvv Thread::ShouldStop End (returning %i) vvvvvvvv",
963 "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
964 ": returning vote %i (state was suspended or invalid)",
972 "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
973 ": returning vote %i (temporary state was suspended or invalid)",
980 "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
981 ": returning vote %i (thread didn't stop for a reason.)",
986 if (
GetPlans().AnyCompletedPlans()) {
990 "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
991 ": returning vote for complete stack's back plan",
1008 "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
1009 ": returning vote %i for current plan",
1010 GetID(), thread_vote);
1024 if (
GetPlans().AnyCompletedPlans()) {
1028 "Current Plan for thread %d(%p) (0x%4.4" PRIx64
1029 ", %s): %s being asked whether we should report run.",
1037 "Current Plan for thread %d(%p) (0x%4.4" PRIx64
1038 ", %s): %s being asked whether we should report run.",
1068 assert(thread_plan_sp &&
"Don't push an empty thread plan.");
1074 LLDB_LOGF(log,
"Thread::PushPlan(0x%p): \"%s\", tid = 0x%4.4" PRIx64
".",
1075 static_cast<void *
>(
this), s.
GetData(),
1076 thread_plan_sp->GetThread().GetID());
1086 LLDB_LOGF(log,
"Popping plan: \"%s\", tid = 0x%4.4" PRIx64
".",
1087 popped_plan_sp->GetName(), popped_plan_sp->GetThread().GetID());
1095 LLDB_LOGF(log,
"Discarding plan: \"%s\", tid = 0x%4.4" PRIx64
".",
1096 discarded_plan_sp->GetName(),
1097 discarded_plan_sp->GetThread().GetID());
1149 bool abort_other_plans) {
1152 if (!thread_plan_sp->ValidatePlan(&s)) {
1154 thread_plan_sp.reset();
1159 if (abort_other_plans)
1168 if (!thread_plan_sp->ValidatePlan(&s)) {
1170 thread_plan_sp.reset();
1183 if (up_to_plan_ptr ==
nullptr)
1197 "Discarding thread plans for thread tid = 0x%4.4" PRIx64
1199 GetID(),
static_cast<void *
>(up_to_plan_ptr));
1207 "Discarding thread plans for thread (tid = 0x%4.4" PRIx64
1222 if (!innermost_expr_plan) {
1223 error.SetErrorString(
"No expressions currently active on this thread");
1233 return thread_plan_sp;
1237 bool step_over,
bool abort_other_plans,
bool stop_other_threads,
1242 return thread_plan_sp;
1248 Status &status,
LazyBool step_out_avoids_code_withoug_debug_info) {
1249 ThreadPlanSP thread_plan_sp;
1250 thread_plan_sp = std::make_shared<ThreadPlanStepOverRange>(
1251 *
this, range, addr_context, stop_other_threads,
1252 step_out_avoids_code_withoug_debug_info);
1255 return thread_plan_sp;
1261 bool abort_other_plans,
const LineEntry &line_entry,
1263 Status &status,
LazyBool step_out_avoids_code_withoug_debug_info) {
1264 const bool include_inlined_functions =
true;
1265 auto address_range =
1268 abort_other_plans, address_range, addr_context, stop_other_threads,
1269 status, step_out_avoids_code_withoug_debug_info);
1274 const SymbolContext &addr_context,
const char *step_in_target,
1276 LazyBool step_in_avoids_code_without_debug_info,
1277 LazyBool step_out_avoids_code_without_debug_info) {
1279 *
this, range, addr_context, step_in_target, stop_other_threads,
1280 step_in_avoids_code_without_debug_info,
1281 step_out_avoids_code_without_debug_info));
1283 return thread_plan_sp;
1288 bool abort_other_plans,
const LineEntry &line_entry,
1289 const SymbolContext &addr_context,
const char *step_in_target,
1291 LazyBool step_in_avoids_code_without_debug_info,
1292 LazyBool step_out_avoids_code_without_debug_info) {
1293 const bool include_inlined_functions =
false;
1297 addr_context, step_in_target, stop_other_threads, status,
1298 step_in_avoids_code_without_debug_info,
1299 step_out_avoids_code_without_debug_info);
1303 bool abort_other_plans,
SymbolContext *addr_context,
bool first_insn,
1304 bool stop_other_threads,
Vote report_stop_vote,
Vote report_run_vote,
1306 LazyBool step_out_avoids_code_without_debug_info) {
1308 *
this, addr_context, first_insn, stop_other_threads, report_stop_vote,
1309 report_run_vote, frame_idx, step_out_avoids_code_without_debug_info));
1312 return thread_plan_sp;
1316 bool abort_other_plans,
SymbolContext *addr_context,
bool first_insn,
1317 bool stop_other_threads,
Vote report_stop_vote,
Vote report_run_vote,
1318 uint32_t frame_idx,
Status &status,
bool continue_to_next_branch) {
1319 const bool calculate_return_value =
1322 *
this, addr_context, first_insn, stop_other_threads, report_stop_vote,
1323 report_run_vote, frame_idx,
eLazyBoolNo, continue_to_next_branch,
1324 calculate_return_value));
1331 return thread_plan_sp;
1335 bool abort_other_plans,
1336 bool stop_other_threads,
1338 ThreadPlanSP thread_plan_sp(
1340 if (!thread_plan_sp || !thread_plan_sp->ValidatePlan(
nullptr))
1341 return ThreadPlanSP();
1344 return thread_plan_sp;
1349 bool stop_other_threads,
1351 ThreadPlanSP thread_plan_sp(
1355 return thread_plan_sp;
1359 bool abort_other_plans,
lldb::addr_t *address_list,
size_t num_addresses,
1362 *
this, address_list, num_addresses, stop_other_threads, frame_idx));
1365 return thread_plan_sp;
1369 bool abort_other_plans,
const char *class_name,
1375 thread_plan_sp->SetStopOthers(stop_other_threads);
1377 return thread_plan_sp;
1386 target_sp = process_sp->CalculateTarget();
1433 lldb::ValueObjectSP return_value_sp,
1440 "Could not find frame with index %d in thread 0x%" PRIx64
".",
1441 frame_idx,
GetID());
1448 lldb::ValueObjectSP return_value_sp,
1454 return return_error;
1457 Thread *thread = frame_sp->GetThread().get();
1458 uint32_t older_frame_idx = frame_sp->GetFrameIndex() + 1;
1460 if (!older_frame_sp) {
1462 return return_error;
1465 if (return_value_sp) {
1466 lldb::ABISP abi = thread->
GetProcess()->GetABI();
1468 return_error.
SetErrorString(
"Could not find ABI to set return value.");
1469 return return_error;
1471 SymbolContext sc = frame_sp->GetSymbolContext(eSymbolContextFunction);
1476 if ( (
false) && sc.
function !=
nullptr) {
1478 if (function_type) {
1484 ValueObjectSP cast_value_sp = return_value_sp->Cast(return_type);
1485 if (cast_value_sp) {
1487 return_value_sp = cast_value_sp;
1493 return_error = abi->SetReturnValueObject(older_frame_sp, return_value_sp);
1495 return return_error;
1503 if (youngest_frame_sp) {
1504 lldb::RegisterContextSP reg_ctx_sp(youngest_frame_sp->GetRegisterContext());
1506 bool copy_success = reg_ctx_sp->CopyFromRegisterContext(
1507 older_frame_sp->GetRegisterContext());
1523 return return_error;
1528 for (
size_t n = 0; n < list.size(); n++) {
1537 bool can_leave_function, std::string *warnings) {
1546 std::vector<Address> candidates, within_function, outside_function;
1548 within_function, outside_function);
1555 if (!within_function.empty())
1556 candidates = within_function;
1557 else if (outside_function.size() == 1 && can_leave_function)
1558 candidates = outside_function;
1561 if (candidates.empty()) {
1562 if (outside_function.empty()) {
1563 return Status(
"Cannot locate an address for %s:%i.",
1565 }
else if (outside_function.size() == 1) {
1566 return Status(
"%s:%i is outside the current function.",
1571 return Status(
"%s:%i has multiple candidate locations:\n%s",
1578 if (warnings && candidates.size() > 1) {
1580 sstr.
Printf(
"%s:%i appears multiple times in this function, selecting the "
1581 "first location:\n",
1584 *warnings = std::string(sstr.
GetString());
1587 if (!reg_ctx->
SetPC(dest))
1588 return Status(
"Cannot change PC to target address.");
1597 if (process ==
nullptr)
1600 StackFrameSP frame_sp;
1606 frame_sc = frame_sp->GetSymbolContext(eSymbolContextEverything);
1616 assert(thread_format);
1619 &exe_ctx,
nullptr,
nullptr,
false,
false);
1669 return "breakpoint";
1671 return "watchpoint";
1683 return "vfork done";
1685 return "plan complete";
1687 return "thread exiting";
1689 return "instrumentation break";
1691 return "processor trace";
1694 return "StopReason = " + std::to_string(reason);
1700 return "only this thread";
1702 return "all threads";
1704 return "only during stepping";
1707 return "RunMode = " + std::to_string(mode);
1712 bool stop_format,
bool only_stacks) {
1719 bool is_selected =
false;
1724 strm.
Printf(
"%c ", is_selected ?
'*' :
' ');
1729 frame_sp->GetSymbolContext(eSymbolContextLineEntry));
1735 "OpenFileInExternalEditor failed: {0}");
1744 size_t num_frames_shown = 0;
1745 if (num_frames > 0) {
1748 const bool show_frame_info =
true;
1749 const bool show_frame_unique = only_stacks;
1750 const char *selected_frame_marker =
nullptr;
1751 if (num_frames == 1 || only_stacks ||
1755 selected_frame_marker =
"* ";
1758 strm, start_frame, num_frames, show_frame_info, num_frames_with_source,
1759 show_frame_unique, selected_frame_marker);
1760 if (num_frames == 1)
1764 return num_frames_shown;
1768 bool print_json_thread,
bool print_json_stopinfo) {
1769 const bool stop_format =
false;
1775 if (print_json_thread || print_json_stopinfo) {
1776 if (thread_info && print_json_thread) {
1777 thread_info->Dump(strm);
1784 stop_info->Dump(strm);
1794 thread_info->GetObjectForDotSeparatedPath(
"activity");
1796 thread_info->GetObjectForDotSeparatedPath(
"breadcrumb");
1798 thread_info->GetObjectForDotSeparatedPath(
"trace_messages");
1800 bool printed_activity =
false;
1807 strm.
Format(
" Activity '{0}', {1:x}\n",
1808 name->GetAsString()->GetValue(),
1809 id->GetUnsignedIntegerValue());
1811 printed_activity =
true;
1813 bool printed_breadcrumb =
false;
1815 if (printed_activity)
1821 if (breadcrumb_text &&
1823 strm.
Format(
" Current Breadcrumb: {0}\n",
1824 breadcrumb_text->GetAsString()->GetValue());
1826 printed_breadcrumb =
true;
1829 if (printed_breadcrumb)
1832 const size_t msg_count = messages_array->
GetSize();
1833 if (msg_count > 0) {
1834 strm.
Printf(
" %zu trace messages:\n", msg_count);
1835 for (
size_t i = 0; i < msg_count; i++) {
1844 strm.
Format(
" {0}\n", message_text->GetAsString()->GetValue());
1856 uint32_t num_frames,
bool show_frame_info,
1859 strm, first_frame, num_frames, show_frame_info, num_frames_with_source);
1884 BreakpointSiteSP bp_site_sp =
1885 GetProcess()->GetBreakpointSiteList().FindByAddress(
pc);
1886 if (bp_site_sp &&
static_cast<break_id_t>(value) == bp_site_sp->GetID())
1895 LazyBool step_in_avoids_code_without_debug_info,
1896 LazyBool step_out_avoids_code_without_debug_info)
1903 ThreadPlanSP new_plan_sp;
1905 const bool abort_other_plans =
false;
1907 if (source_step && frame_sp && frame_sp->HasDebugInformation()) {
1908 SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
1911 step_in_avoids_code_without_debug_info,
1912 step_out_avoids_code_without_debug_info);
1915 false, abort_other_plans, run_mode,
error);
1918 new_plan_sp->SetIsControllingPlan(
true);
1919 new_plan_sp->SetOkayToDiscard(
false);
1925 error.SetErrorString(
"process not stopped");
1931 LazyBool step_out_avoids_code_without_debug_info) {
1936 ThreadPlanSP new_plan_sp;
1939 const bool abort_other_plans =
false;
1941 if (source_step && frame_sp && frame_sp->HasDebugInformation()) {
1942 SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
1945 step_out_avoids_code_without_debug_info);
1948 true, abort_other_plans, run_mode,
error);
1951 new_plan_sp->SetIsControllingPlan(
true);
1952 new_plan_sp->SetOkayToDiscard(
false);
1958 error.SetErrorString(
"process not stopped");
1967 const bool first_instruction =
false;
1968 const bool stop_other_threads =
false;
1969 const bool abort_other_plans =
false;
1972 abort_other_plans,
nullptr, first_instruction, stop_other_threads,
1975 new_plan_sp->SetIsControllingPlan(
true);
1976 new_plan_sp->SetOkayToDiscard(
false);
1982 error.SetErrorString(
"process not stopped");
1989 if (
auto recognized_frame = frame_sp->GetRecognizedFrame())
1990 if (
auto e = recognized_frame->GetExceptionObject())
1996 if (
auto e = runtime->GetExceptionObjectForThread(shared_from_this()))
2000 return ValueObjectSP();
2011 if (
auto bt = runtime->GetBacktraceThreadFromException(exception))
2021 Target &target = process_sp->GetTarget();
2023 assert(platform_sp);
2030 std::optional<uint64_t> type_size = type.
GetByteSize(
nullptr);
2032 llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>> data =
2037 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)
const Property * GetPropertyAtIndex(uint32_t idx, const ExecutionContext *exe_ctx) const override
ThreadOptionValueProperties(ConstString name)
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.
static lldb::OptionValuePropertiesSP CreateLocalCopy(const Properties &global_properties)
Property * ProtectedGetPropertyAtIndex(uint32_t idx)
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 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
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()
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.
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
static ConstString & GetStaticBroadcasterClass()
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()
@ eBroadcastBitSelectedFrameChanged
@ eBroadcastBitStackChanged
virtual void DestroyThread()
size_t GetStackFrameStatus(Stream &strm, uint32_t first_frame, uint32_t num_frames, bool show_frame_info, uint32_t num_frames_with_source)
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()
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()
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)
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.
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)
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
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.
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.
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
@ eDescriptionLevelInitial
@ eDescriptionLevelVerbose
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.
StopReason
Thread stop reasons.
@ eStopReasonInstrumentation
@ eStopReasonPlanComplete
@ eStopReasonExec
Program was re-exec'ed.
@ eStopReasonProcessorTrace
@ eStopReasonThreadExiting
@ eStructuredDataTypeDictionary
@ eStructuredDataTypeInteger
@ eStructuredDataTypeArray
@ eStructuredDataTypeString
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...
FileSpec file
The source file, possibly mapped by the target.source-map setting.
uint32_t line
The source line number, or zero if there is no line number information.
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.