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> {
92 thread->GetValueProperties().get());
93 if (
this != instance_properties)
103 m_collection_sp = std::make_shared<ThreadOptionValueProperties>(
"thread");
113 const uint32_t idx = ePropertyStepAvoidRegex;
118 const uint32_t idx = ePropertyStepAvoidLibraries;
123 const uint32_t idx = ePropertyEnableThreadTrace;
125 idx, g_thread_properties[idx].default_uint_value != 0);
129 const uint32_t idx = ePropertyStepInAvoidsNoDebug;
131 idx, g_thread_properties[idx].default_uint_value != 0);
135 const uint32_t idx = ePropertyStepOutAvoidsNoDebug;
137 idx, g_thread_properties[idx].default_uint_value != 0);
141 const uint32_t idx = ePropertyMaxBacktraceDepth;
143 idx, g_thread_properties[idx].default_uint_value);
147 const uint32_t idx = ePropertySingleThreadPlanTimeout;
149 idx, g_thread_properties[idx].default_uint_value);
155 return "Thread::ThreadEventData";
205 frame_sp = thread_sp->GetStackFrameList()->GetFrameWithStackID(
215 static constexpr llvm::StringLiteral class_name(
"lldb.thread");
221 Broadcaster(process.GetTarget().GetDebugger().GetBroadcasterManager(),
228 : process.GetNextThreadIndexID(tid)),
237 LLDB_LOGF(log,
"%p Thread::Thread(tid = 0x%4.4" PRIx64
")",
238 static_cast<void *
>(
this),
GetID());
245 LLDB_LOGF(log,
"%p Thread::~Thread(tid = 0x%4.4" PRIx64
")",
246 static_cast<void *
>(
this),
GetID());
266 std::make_shared<ThreadEventData>(shared_from_this(), new_frame_id);
274 StackFrameSP frame_sp = stack_frame_list_sp->GetFrameAtIndex(
275 stack_frame_list_sp->GetSelectedFrameIndex(select_most_relevant));
303 const bool broadcast =
true;
308 bool already_shown =
false;
310 frame_sp->GetSymbolContext(eSymbolContextLineEntry));
318 "OpenFileInExternalEditor failed: {0}");
320 already_shown =
true;
324 bool show_frame_info =
true;
325 bool show_source = !already_shown;
327 return frame_sp->GetStatus(output_stream, show_frame_info, show_source);
340 GetProcess()->GetWarningsUnsupportedLanguage())) {
344 GetProcess()->PrintWarningUnsupportedLanguage(sc);
354 const uint32_t stop_id = process_sp ? process_sp->GetStopID() :
UINT32_MAX;
364 bool have_valid_completed_plan = completed_plan_sp && completed_plan_sp->PlanSucceeded();
365 bool plan_failed = completed_plan_sp && !completed_plan_sp->PlanSucceeded();
366 bool plan_overrides_trace =
367 have_valid_stop_info && have_valid_completed_plan
370 if (have_valid_stop_info && !plan_overrides_trace && !plan_failed) {
372 }
else if (completed_plan_sp) {
395 const uint32_t process_stop_id = process_sp->GetStopID();
428 process_sp->GetTarget().GetArchitecturePlugin())
429 arch->OverrideStopInfo(*
this);
445 return stop_info_sp->GetStopReason();
480 LLDB_LOGF(log,
"%p: tid = 0x%" PRIx64
": stop info = %s (stop_id = %u)",
481 static_cast<void *
>(
this),
GetID(),
482 stop_info_sp ? stop_info_sp->GetDescription() :
"<NULL>",
513 if (reg_checkpoint_sp) {
515 if (reg_ctx_sp && reg_ctx_sp->ReadAllRegisterValues(*reg_checkpoint_sp))
546 reg_ctx_sp->InvalidateIfNeeded(
true);
585 auto recognized_frame_sp = frame_sp->GetRecognizedFrame();
587 if (!recognized_frame_sp)
590 std::string recognized_stop_description =
591 recognized_frame_sp->GetStopDescription();
593 if (!recognized_stop_description.empty())
594 return recognized_stop_description;
601 std::string raw_stop_description;
602 if (stop_info_sp && stop_info_sp->IsValid()) {
603 raw_stop_description = stop_info_sp->GetDescription();
604 assert((!raw_stop_description.empty() ||
606 "StopInfo returned an empty description.");
608 return raw_stop_description;
639 if (reg_ctx_sp && process_sp && direction ==
eRunForward) {
640 const addr_t thread_pc = reg_ctx_sp->GetPC();
642 process_sp->GetBreakpointSiteList().FindByAddress(thread_pc);
657 bool push_step_over_bp_plan =
false;
662 push_step_over_bp_plan =
true;
664 push_step_over_bp_plan =
true;
666 if (push_step_over_bp_plan) {
668 if (step_bp_plan_sp) {
669 step_bp_plan_sp->SetPrivate(
true);
674 step_bp_plan_sp.get());
697 if (backing_thread_sp)
698 backing_thread_sp->SetTemporaryResumeState(resume_state);
710 const uint32_t process_stop_id =
GetProcess()->GetStopID();
714 stop_info_sp->WillResume(resume_state);
722 bool need_to_resume =
false;
725 need_to_resume = plan_ptr->
WillResume(resume_state,
true);
739 if (need_to_resume) {
746 return need_to_resume;
760 bool should_stop =
true;
766 "Thread::%s for tid = 0x%4.4" PRIx64
" 0x%4.4" PRIx64
767 ", should_stop = 0 (ignore since thread was suspended)",
774 "Thread::%s for tid = 0x%4.4" PRIx64
" 0x%4.4" PRIx64
775 ", should_stop = 0 (ignore since thread was suspended)",
785 "Thread::%s for tid = 0x%4.4" PRIx64
" 0x%4.4" PRIx64
786 ", pc = 0x%16.16" PRIx64
787 ", should_stop = 0 (ignore since no stop reason)",
799 "Thread::%s(%p) for tid = 0x%4.4" PRIx64
" 0x%4.4" PRIx64
800 ", pc = 0x%16.16" PRIx64,
804 LLDB_LOGF(log,
"^^^^^^^^ Thread::ShouldStop Begin ^^^^^^^^");
821 if (private_stop_info &&
822 !private_stop_info->ShouldStopSynchronous(event_ptr)) {
823 LLDB_LOGF(log,
"StopInfo::ShouldStop async callback says we should not "
824 "stop, returning ShouldStop of false.");
843 bool done_processing_current_plan =
false;
846 done_processing_current_plan =
true;
862 should_stop = plan_ptr->
ShouldStop(event_ptr);
881 done_processing_current_plan =
885 if (should_force_run) {
889 done_processing_current_plan =
true;
897 if (!done_processing_current_plan) {
898 bool override_stop =
false;
902 should_stop = current_plan->
ShouldStop(event_ptr);
903 LLDB_LOGF(log,
"Base plan says should stop: %i.", should_stop);
912 should_stop = current_plan->
ShouldStop(event_ptr);
920 override_stop =
true;
921 LLDB_LOGF(log,
"Plan %s auto-continue: true.",
935 if (current_plan ==
nullptr) {
967 "Plan %s being discarded in cleanup, it says it is already done.",
990 LLDB_LOGF(log,
"vvvvvvvv Thread::ShouldStop End (returning %i) vvvvvvvv",
1004 "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
1005 ": returning vote %i (state was suspended or invalid)",
1013 "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
1014 ": returning vote %i (temporary state was suspended or invalid)",
1021 "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
1022 ": returning vote %i (thread didn't stop for a reason.)",
1027 if (
GetPlans().AnyCompletedPlans()) {
1031 "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
1032 ": returning vote for complete stack's back plan",
1049 "Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
1050 ": returning vote %i for current plan",
1051 GetID(), thread_vote);
1065 if (
GetPlans().AnyCompletedPlans()) {
1069 "Current Plan for thread %d(%p) (0x%4.4" PRIx64
1070 ", %s): %s being asked whether we should report run.",
1078 "Current Plan for thread %d(%p) (0x%4.4" PRIx64
1079 ", %s): %s being asked whether we should report run.",
1109 assert(thread_plan_sp &&
"Don't push an empty thread plan.");
1115 LLDB_LOGF(log,
"Thread::PushPlan(0x%p): \"%s\", tid = 0x%4.4" PRIx64
".",
1116 static_cast<void *
>(
this), s.
GetData(),
1117 thread_plan_sp->GetThread().GetID());
1127 LLDB_LOGF(log,
"Popping plan: \"%s\", tid = 0x%4.4" PRIx64
".",
1128 popped_plan_sp->GetName(), popped_plan_sp->GetThread().GetID());
1136 LLDB_LOGF(log,
"Discarding plan: \"%s\", tid = 0x%4.4" PRIx64
".",
1137 discarded_plan_sp->GetName(),
1138 discarded_plan_sp->GetThread().GetID());
1190 bool abort_other_plans) {
1193 if (!thread_plan_sp->ValidatePlan(&s)) {
1195 thread_plan_sp.reset();
1199 if (abort_other_plans)
1208 if (!thread_plan_sp->ValidatePlan(&s)) {
1210 thread_plan_sp.reset();
1222 if (up_to_plan_ptr ==
nullptr)
1236 "Discarding thread plans for thread tid = 0x%4.4" PRIx64
1238 GetID(),
static_cast<void *
>(up_to_plan_ptr));
1246 "Discarding thread plans for thread (tid = 0x%4.4" PRIx64
1261 if (!innermost_expr_plan) {
1263 "No expressions currently active on this thread");
1273 return thread_plan_sp;
1277 bool step_over,
bool abort_other_plans,
bool stop_other_threads,
1282 return thread_plan_sp;
1288 Status &status,
LazyBool step_out_avoids_code_withoug_debug_info) {
1290 thread_plan_sp = std::make_shared<ThreadPlanStepOverRange>(
1291 *
this, range, addr_context, stop_other_threads,
1292 step_out_avoids_code_withoug_debug_info);
1295 return thread_plan_sp;
1301 bool abort_other_plans,
const LineEntry &line_entry,
1303 Status &status,
LazyBool step_out_avoids_code_withoug_debug_info) {
1304 const bool include_inlined_functions =
true;
1305 auto address_range =
1308 abort_other_plans, address_range, addr_context, stop_other_threads,
1309 status, step_out_avoids_code_withoug_debug_info);
1314 const SymbolContext &addr_context,
const char *step_in_target,
1316 LazyBool step_in_avoids_code_without_debug_info,
1317 LazyBool step_out_avoids_code_without_debug_info) {
1319 *
this, range, addr_context, step_in_target, stop_other_threads,
1320 step_in_avoids_code_without_debug_info,
1321 step_out_avoids_code_without_debug_info));
1323 return thread_plan_sp;
1328 bool abort_other_plans,
const LineEntry &line_entry,
1329 const SymbolContext &addr_context,
const char *step_in_target,
1331 LazyBool step_in_avoids_code_without_debug_info,
1332 LazyBool step_out_avoids_code_without_debug_info) {
1333 const bool include_inlined_functions =
false;
1337 addr_context, step_in_target, stop_other_threads, status,
1338 step_in_avoids_code_without_debug_info,
1339 step_out_avoids_code_without_debug_info);
1343 bool abort_other_plans,
SymbolContext *addr_context,
bool first_insn,
1344 bool stop_other_threads,
Vote report_stop_vote,
Vote report_run_vote,
1345 uint32_t frame_idx,
Status &status,
1346 LazyBool step_out_avoids_code_without_debug_info) {
1348 *
this, addr_context, first_insn, stop_other_threads, report_stop_vote,
1349 report_run_vote, frame_idx, step_out_avoids_code_without_debug_info));
1352 return thread_plan_sp;
1356 bool abort_other_plans,
SymbolContext *addr_context,
bool first_insn,
1357 bool stop_other_threads,
Vote report_stop_vote,
Vote report_run_vote,
1358 uint32_t frame_idx,
Status &status,
bool continue_to_next_branch) {
1359 const bool calculate_return_value =
1362 *
this, stop_other_threads, report_stop_vote, report_run_vote, frame_idx,
1363 continue_to_next_branch, calculate_return_value));
1370 return thread_plan_sp;
1374 bool abort_other_plans,
1375 bool stop_other_threads,
1379 if (!thread_plan_sp || !thread_plan_sp->ValidatePlan(
nullptr))
1383 return thread_plan_sp;
1388 bool stop_other_threads,
1394 return thread_plan_sp;
1398 bool abort_other_plans,
lldb::addr_t *address_list,
size_t num_addresses,
1399 bool stop_other_threads, uint32_t frame_idx,
Status &status) {
1401 *
this, address_list, num_addresses, stop_other_threads, frame_idx));
1404 return thread_plan_sp;
1408 bool abort_other_plans,
const char *class_name,
1414 thread_plan_sp->SetStopOthers(stop_other_threads);
1416 return thread_plan_sp;
1425 target_sp = process_sp->CalculateTarget();
1485 "Could not find frame with index %d in thread 0x%" PRIx64
".",
1486 frame_idx,
GetID());
1499 return return_error;
1502 Thread *thread = frame_sp->GetThread().get();
1503 uint32_t older_frame_idx = frame_sp->GetFrameIndex() + 1;
1504 StackFrameSP older_frame_sp = thread->GetStackFrameAtIndex(older_frame_idx);
1505 if (!older_frame_sp) {
1507 return return_error;
1510 if (return_value_sp) {
1515 return return_error;
1517 SymbolContext sc = frame_sp->GetSymbolContext(eSymbolContextFunction);
1522 if ( (
false) && sc.
function !=
nullptr) {
1524 if (function_type) {
1530 ValueObjectSP cast_value_sp = return_value_sp->Cast(return_type);
1531 if (cast_value_sp) {
1533 return_value_sp = cast_value_sp;
1539 return_error = abi->SetReturnValueObject(older_frame_sp, return_value_sp);
1541 return return_error;
1548 StackFrameSP youngest_frame_sp = thread->GetStackFrameAtIndex(0);
1549 if (youngest_frame_sp) {
1552 bool copy_success = reg_ctx_sp->CopyFromRegisterContext(
1553 older_frame_sp->GetRegisterContext());
1555 thread->DiscardThreadPlans(
true);
1556 thread->ClearStackFrames();
1558 auto data_sp = std::make_shared<ThreadEventData>(shared_from_this());
1571 return return_error;
1576 for (
size_t n = 0; n < list.size(); n++) {
1585 bool can_leave_function, std::string *warnings) {
1594 std::vector<Address> candidates, within_function, outside_function;
1596 within_function, outside_function);
1603 if (!within_function.empty())
1604 candidates = within_function;
1605 else if (outside_function.size() == 1 && can_leave_function)
1606 candidates = outside_function;
1609 if (candidates.empty()) {
1610 if (outside_function.empty()) {
1614 }
else if (outside_function.size() == 1) {
1616 "%s:%i is outside the current function.",
1622 "%s:%i has multiple candidate locations:\n%s",
1629 if (warnings && candidates.size() > 1) {
1631 sstr.
Printf(
"%s:%i appears multiple times in this function, selecting the "
1632 "first location:\n",
1635 *warnings = std::string(sstr.
GetString());
1638 if (!reg_ctx->
SetPC(dest))
1648 if (!process || !format)
1657 frame_sc = frame_sp->GetSymbolContext(eSymbolContextEverything);
1662 &exe_ctx,
nullptr,
nullptr,
false,
false);
1673 thread_format = &format_entry;
1676 thread_format = &format_entry;
1679 assert(thread_format);
1735 return "breakpoint";
1737 return "watchpoint";
1749 return "vfork done";
1751 return "plan complete";
1753 return "thread exiting";
1755 return "instrumentation break";
1757 return "processor trace";
1759 return "async interrupt";
1761 return "history boundary";
1764 return "StopReason = " + std::to_string(reason);
1770 return "only this thread";
1772 return "all threads";
1774 return "only during stepping";
1777 return "RunMode = " + std::to_string(mode);
1781 uint32_t num_frames, uint32_t num_frames_with_source,
1782 bool stop_format,
bool show_hidden,
bool only_stacks) {
1789 bool is_selected =
false;
1794 strm.
Printf(
"%c ", is_selected ?
'*' :
' ');
1799 frame_sp->GetSymbolContext(eSymbolContextLineEntry));
1805 "OpenFileInExternalEditor failed: {0}");
1814 size_t num_frames_shown = 0;
1815 if (num_frames > 0) {
1818 const bool show_frame_info =
true;
1819 const bool show_frame_unique = only_stacks;
1820 const char *selected_frame_marker =
nullptr;
1821 if (num_frames == 1 || only_stacks ||
1825 selected_frame_marker =
"* ";
1828 strm, start_frame, num_frames, show_frame_info, num_frames_with_source,
1829 show_frame_unique, show_hidden, selected_frame_marker);
1830 if (num_frames == 1)
1834 return num_frames_shown;
1838 bool print_json_thread,
bool print_json_stopinfo) {
1839 const bool stop_format =
false;
1845 if (print_json_thread || print_json_stopinfo) {
1846 if (thread_info && print_json_thread) {
1847 thread_info->Dump(strm);
1854 stop_info->Dump(strm);
1864 thread_info->GetObjectForDotSeparatedPath(
"activity");
1866 thread_info->GetObjectForDotSeparatedPath(
"breadcrumb");
1868 thread_info->GetObjectForDotSeparatedPath(
"trace_messages");
1870 bool printed_activity =
false;
1877 strm.
Format(
" Activity '{0}', {1:x}\n",
1878 name->GetAsString()->GetValue(),
1879 id->GetUnsignedIntegerValue());
1881 printed_activity =
true;
1883 bool printed_breadcrumb =
false;
1885 if (printed_activity)
1891 if (breadcrumb_text &&
1893 strm.
Format(
" Current Breadcrumb: {0}\n",
1894 breadcrumb_text->GetAsString()->GetValue());
1896 printed_breadcrumb =
true;
1899 if (printed_breadcrumb)
1902 const size_t msg_count = messages_array->
GetSize();
1903 if (msg_count > 0) {
1904 strm.
Printf(
" %zu trace messages:\n", msg_count);
1905 for (
size_t i = 0; i < msg_count; i++) {
1914 strm.
Format(
" {0}\n", message_text->GetAsString()->GetValue());
1926 uint32_t num_frames,
bool show_frame_info,
1927 uint32_t num_frames_with_source,
1930 show_frame_info, num_frames_with_source,
1931 false, show_hidden);
1958 GetProcess()->GetBreakpointSiteList().FindByAddress(
pc);
1959 if (bp_site_sp &&
static_cast<break_id_t>(value) == bp_site_sp->GetID())
1968 LazyBool step_in_avoids_code_without_debug_info,
1969 LazyBool step_out_avoids_code_without_debug_info)
1978 const bool abort_other_plans =
false;
1980 if (source_step && frame_sp && frame_sp->HasDebugInformation()) {
1981 SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
1984 step_in_avoids_code_without_debug_info,
1985 step_out_avoids_code_without_debug_info);
1988 false, abort_other_plans, run_mode,
error);
1991 new_plan_sp->SetIsControllingPlan(
true);
1992 new_plan_sp->SetOkayToDiscard(
false);
2004 LazyBool step_out_avoids_code_without_debug_info) {
2012 const bool abort_other_plans =
false;
2014 if (source_step && frame_sp && frame_sp->HasDebugInformation()) {
2015 SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
2018 step_out_avoids_code_without_debug_info);
2021 true, abort_other_plans, run_mode,
error);
2024 new_plan_sp->SetIsControllingPlan(
true);
2025 new_plan_sp->SetOkayToDiscard(
false);
2040 const bool first_instruction =
false;
2041 const bool stop_other_threads =
false;
2042 const bool abort_other_plans =
false;
2045 abort_other_plans,
nullptr, first_instruction, stop_other_threads,
2048 new_plan_sp->SetIsControllingPlan(
true);
2049 new_plan_sp->SetOkayToDiscard(
false);
2062 if (
auto recognized_frame = frame_sp->GetRecognizedFrame())
2063 if (
auto e = recognized_frame->GetExceptionObject())
2069 if (
auto e = runtime->GetExceptionObjectForThread(shared_from_this()))
2084 if (
auto bt = runtime->GetBacktraceThreadFromException(exception))
2094 Target &target = process_sp->GetTarget();
2096 assert(platform_sp);
2104 auto type_size_or_err = type.
GetByteSize(
nullptr);
2105 if (!type_size_or_err)
2109 llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>> data =
2115 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.
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.
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
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.
Debugger & GetDebugger() const
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)
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()
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()
@ eBroadcastBitSelectedFrameChanged
@ eBroadcastBitStackChanged
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.
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.