66#include "llvm/ADT/ScopeExit.h"
67#include "llvm/ADT/StringRef.h"
68#include "llvm/Support/ErrorHandling.h"
69#include "llvm/Support/FileSystem.h"
70#include "llvm/Support/FormatAdapters.h"
78 const char *prefix_cstr,
79 bool show_stopped_process_status,
Stream &strm) {
84 bool exe_valid =
false;
89 ::strcpy(exe_path,
"<none>");
91 std::string formatted_label =
"";
92 const std::string &label = target->
GetLabel();
94 formatted_label =
" (" + label +
")";
97 strm.
Printf(
"%starget #%u%s: %s", prefix_cstr ? prefix_cstr :
"", target_idx,
98 formatted_label.data(), exe_path);
100 uint32_t properties = 0;
108 strm.
Format(
"{0}platform={1}", properties++ > 0 ?
", " :
" ( ",
109 platform_sp->GetName());
112 bool show_process_status =
false;
115 StateType state = process_sp->GetState();
116 if (show_stopped_process_status)
120 strm.
Printf(
"%spid=%" PRIu64, properties++ > 0 ?
", " :
" ( ", pid);
121 strm.
Printf(
"%sstate=%s", properties++ > 0 ?
", " :
" ( ", state_cstr);
127 if (show_process_status) {
128 const bool only_threads_with_stop_reason =
true;
129 const uint32_t start_frame = 0;
130 const uint32_t num_frames = 1;
131 const uint32_t num_frames_with_source = 1;
132 const bool stop_format =
false;
133 process_sp->GetStatus(strm);
134 process_sp->GetThreadStatus(strm, only_threads_with_stop_reason,
135 start_frame, num_frames, num_frames_with_source,
141 bool show_stopped_process_status,
Stream &strm) {
146 for (uint32_t i = 0; i < num_targets; ++i) {
149 bool is_selected = target_sp.get() == selected_target_sp.get();
151 show_stopped_process_status, strm);
158#define LLDB_OPTIONS_target_dependents
159#include "CommandOptions.inc"
168 return llvm::ArrayRef(g_target_dependents_options);
176 if (option_value.empty()) {
181 const char short_option =
182 g_target_dependents_options[option_idx].short_option;
183 if (short_option ==
'd') {
186 option_value, g_target_dependents_options[option_idx].enum_values, 0,
192 "unrecognized short option '%c'", short_option);
212#pragma mark CommandObjectTargetCreate
218 interpreter,
"target create",
219 "Create a target using the argument as the main executable.",
223 "Fullpath to a core file to use for this target."),
225 "Optional name for this target.", nullptr),
228 "Fullpath to a stand alone debug "
229 "symbols file for when debug symbols "
230 "are not in the executable."),
233 "Fullpath to the file on the remote host if debugging remotely.") {
264 llvm::toString(file.takeError()));
269 if (argc == 1 || core_file || remote_file) {
278 llvm::toString(file.takeError()));
286 bool must_set_platform_path =
false;
291 llvm::StringRef arch_cstr =
m_arch_option.GetArchitectureName();
293 debugger, file_path, arch_cstr,
302 const llvm::StringRef label =
303 m_label.GetOptionValue().GetCurrentValueAsRef();
304 if (!label.empty()) {
305 if (
auto E = target_sp->SetLabel(label))
312 llvm::scope_exit on_error(
314 target_list.DeleteTarget(target_sp);
321 PlatformSP platform_sp = target_sp->GetPlatform();
325 file_spec.
SetFile(file_path, FileSpec::Style::native);
330 if (platform_sp && platform_sp->IsHost() &&
340 if (!platform_sp->GetFileExists(remote_file)) {
341 Status err = platform_sp->PutFile(file_spec, remote_file);
355 Status err = platform_sp->GetFile(remote_file, file_spec);
369 if (platform_sp->IsHost()) {
370 result.
AppendError(
"Supply a local file, not a remote file, "
371 "when debugging on the host.");
374 if (platform_sp->IsConnected() && !platform_sp->GetFileExists(remote_file)) {
375 result.
AppendError(
"remote --> local transfer without local "
376 "path is not implemented yet");
383 target_sp->SetProcessLaunchInfo(launch_info);
387 result.
AppendError(
"no platform found for target");
392 if (symfile || remote_file) {
393 ModuleSP module_sp(target_sp->GetExecutableModule());
396 module_sp->SetSymbolFileFileSpec(symfile);
398 std::string remote_path = remote_file.
GetPath();
399 target_sp->SetArg0(remote_path.c_str());
400 module_sp->SetPlatformFileSpec(remote_file);
405 if (must_set_platform_path) {
408 target_sp->GetOrCreateModule(main_module_spec,
true );
410 module_sp->SetPlatformFileSpec(remote_file);
416 target_sp->AppendExecutableSearchPaths(core_file_dir);
418 ProcessSP process_sp(target_sp->CreateProcess(
419 GetDebugger().GetListener(), llvm::StringRef(), &core_file,
false));
426 target_sp->GetStatistics().GetLoadCoreTime());
427 error = process_sp->LoadCore();
435 "Core file '{0}' ({1}) was loaded.\n", core_file.
GetPath(),
436 target_sp->GetArchitecture().GetArchitectureName());
437 if (
auto core_args = process_sp->GetCoreFileArgs())
448 "Current executable set to '{0}' ({1}).",
450 target_sp->GetArchitecture().GetArchitectureName());
456 "argument, or use the --core option",
472#pragma mark CommandObjectTargetList
478 interpreter,
"target list",
479 "List all current targets in the current debug session.", nullptr) {
488 bool show_stopped_process_status =
false;
490 show_stopped_process_status, strm) == 0) {
497#pragma mark CommandObjectTargetGroups
504 return "accelerator";
506 llvm_unreachable(
"unhandled target group role");
513 "List all target groups and their members.",
517 "List only groups containing this target.", 0) {
531 std::vector<TargetGroupSP> groups = group_list.
GetGroups();
533 std::vector<size_t> group_indexes;
535 group_indexes.resize(groups.size());
536 std::iota(group_indexes.begin(), group_indexes.end(), 0);
538 group_indexes.reserve(args.
size());
539 for (
size_t i = 0; i < args.
size(); ++i) {
540 uint64_t group_index;
542 if (!llvm::to_integer(argument, group_index)) {
546 if (group_index >= groups.size()) {
551 group_indexes.push_back(
static_cast<size_t>(group_index));
557 uint64_t target_index =
561 static_cast<uint32_t
>(target_index)))) {
569 if (groups.empty()) {
576 bool listed_group =
false;
577 for (
size_t group_index : group_indexes) {
579 if (target_filter_sp && !group_sp->GetRole(target_filter_sp))
583 strm.
Format(
"group #{0}", group_index);
584 if (!group_sp->GetDescription().empty())
585 strm.
Format(
": {0}", group_sp->GetDescription());
588 for (
const TargetSP &target_sp : group_sp->GetTargets()) {
589 std::optional<TargetGroup::Role> role = group_sp->GetRole(target_sp);
594 strm.
Format(
" unlisted target: {0}\n",
597 strm.
Format(
" target #{0}: {1}\n", target_index,
602 strm.
PutCString(
"No matching target groups.\n");
615 "Commands for viewing target groups.",
616 "target groups <subcommand>") {
624#pragma mark CommandObjectTargetSelect
630 interpreter,
"target select",
631 "Select a target as the current target by target index.", nullptr) {
644 if (llvm::to_integer(target_identifier, target_idx)) {
645 if (target_idx < num_targets) {
648 bool show_stopped_process_status =
false;
652 if (num_targets > 0) {
654 "index %u is out of range, valid target indexes are 0 - %u",
655 target_idx, num_targets - 1);
658 "index %u is out of range since there are no active targets",
663 for (
size_t i = 0; i < num_targets; i++) {
665 const std::string &label = target_sp->GetLabel();
666 if (!label.empty() && label == target_identifier) {
676 bool show_stopped_process_status =
false;
686 "'target select' takes a single argument: a target index\n");
691#pragma mark CommandObjectTargetDelete
697 "Delete one or more targets by target index.",
703 "Perform extra cleanup to minimize memory consumption after "
704 "deleting the target. "
705 "By default, LLDB will keep in memory any modules previously "
706 "loaded by the target as well "
707 "as all of its debug info. Specifying --clean will unload all of "
708 "these shared modules and "
709 "cause them to be reparsed again the next time the target is run",
724 std::vector<TargetSP> delete_target_list;
731 }
else if (argc > 0) {
734 if (num_targets == 0) {
739 for (
auto &entry : args.
entries()) {
741 if (entry.ref().getAsInteger(0, target_idx)) {
746 if (target_idx < num_targets) {
749 delete_target_list.push_back(target_sp);
755 "target indexes are 0 - %u",
756 target_idx, num_targets - 1);
759 "target index %u is out of range, the only valid index is 0",
770 delete_target_list.push_back(target_sp);
773 const size_t num_targets_to_delete = delete_target_list.size();
774 for (
size_t idx = 0; idx < num_targets_to_delete; ++idx) {
775 target_sp = delete_target_list[idx];
777 target_sp->Destroy();
782 const bool mandatory =
true;
786 (uint32_t)num_targets_to_delete);
799 interpreter,
"target show-launch-environment",
800 "Shows the environment being passed to the process when launched, "
801 "taking info account 3 settings: target.env-vars, "
802 "target.inherit-env and target.unset-env-vars.",
803 nullptr, eCommandRequiresTarget) {}
812 std::vector<Environment::value_type *> env_vector;
813 env_vector.reserve(env.size());
815 env_vector.push_back(&KV);
816 std::sort(env_vector.begin(), env_vector.end(),
817 [](Environment::value_type *a, Environment::value_type *b) {
818 return a->first() < b->first();
822 for (
auto &KV : env_vector)
823 strm.
Format(
"{0}={1}\n", KV->first(), KV->second);
829#pragma mark CommandObjectTargetVariable
838 "Read global variables for the current target, "
839 "before or while running a process.",
840 nullptr, eCommandRequiresTarget),
845 "A basename or fullpath to a file that contains "
846 "global variables. This option can be "
847 "specified multiple times."),
851 "A basename or fullpath to a shared library to use in the search "
853 "variables. This option can be specified multiple times.") {
872 const char *root_name) {
875 if (!valobj_sp->GetTargetSP()->GetDisplayRuntimeSupportValues() &&
876 valobj_sp->IsRuntimeSupportValue())
879 switch (var_sp->GetScope()) {
910 bool show_fullpaths =
false;
911 bool show_module =
true;
912 if (var_sp->DumpDeclaration(&s, show_fullpaths, show_module))
922 if (llvm::Error
error = valobj_sp->Dump(s, options))
928 size_t old_size = variable_list.
GetSize();
933 return variable_list.
GetSize() - old_size;
944 if (variable_list.
Empty())
948 s.
Format(
"Global variables for {0} in {1}:\n",
951 s.
Printf(
"Global variables for %s\n",
952 sc.
module_sp->GetFileSpec().GetPath().c_str());
981 bool use_var_name =
false;
986 "error: invalid regular expression: '%s'\n", arg.c_str());
992 matches = variable_list.
GetSize();
995 arg.c_str(),
m_exe_ctx.GetBestExecutionContextScope(),
997 matches = variable_list.
GetSize();
1005 for (uint32_t global_idx = 0; global_idx < matches; ++global_idx) {
1012 m_exe_ctx.GetBestExecutionContextScope(), var_sp);
1016 use_var_name ? var_sp->GetName().GetCString()
1028 const size_t num_compile_units = compile_units.
GetSize();
1029 const size_t num_shlibs = shlibs.
GetSize();
1030 if (num_compile_units == 0 && num_shlibs == 0) {
1031 bool success =
false;
1038 const bool can_create =
true;
1041 if (comp_unit_varlist_sp) {
1042 size_t count = comp_unit_varlist_sp->GetSize();
1055 "no global variables in current compile unit: {0}\n",
1061 result.
AppendError(
"'target variable' takes one or more global "
1062 "variable names as arguments\n");
1067 if (num_shlibs > 0) {
1068 for (
size_t shlib_idx = 0; shlib_idx < num_shlibs; ++shlib_idx) {
1075 if (num_compile_units > 0) {
1076 for (
size_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx)
1077 module_sp->FindCompileUnits(
1087 "target doesn't contain the specified shared library: %s",
1088 module_file.
GetPath().c_str());
1094 for (
size_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx)
1101 const bool can_create =
true;
1103 sc.comp_unit->GetVariableList(can_create));
1104 if (comp_unit_varlist_sp)
1107 }
else if (sc.module_sp) {
1110 llvm::StringRef(
"."));
1112 sc.module_sp->FindGlobalVariables(all_globals_regex,
UINT32_MAX,
1134#pragma mark CommandObjectTargetModulesSearchPathsAdd
1140 "Add new image search paths substitution pairs to "
1141 "the current target.",
1142 nullptr, eCommandRequiresTarget) {
1161 arg.push_back(old_prefix_arg);
1162 arg.push_back(new_prefix_arg);
1172 assert(target &&
"target guaranteed by eCommandRequiresTarget");
1175 result.
AppendError(
"add requires an even number of arguments\n");
1177 for (
size_t i = 0; i < argc; i += 2) {
1181 if (from[0] && to[0]) {
1183 "target modules search path adding ImageSearchPath "
1184 "pair: '%s' -> '%s'",
1186 bool last_pair = ((argc - i) == 2);
1188 from, to, last_pair);
1192 result.
AppendError(
"<path-prefix> can't be empty\n");
1194 result.
AppendError(
"<new-path-prefix> can't be empty\n");
1201#pragma mark CommandObjectTargetModulesSearchPathsClear
1207 "Clear all current image search path substitution "
1208 "pairs from the current target.",
1209 "target modules search-paths clear",
1210 eCommandRequiresTarget) {}
1217 assert(target &&
"target guaranteed by eCommandRequiresTarget");
1224#pragma mark CommandObjectTargetModulesSearchPathsInsert
1230 "Insert a new image search path substitution pair "
1231 "into the current target at the specified index.",
1232 nullptr, eCommandRequiresTarget) {
1244 arg1.push_back(index_arg);
1260 arg2.push_back(old_prefix_arg);
1261 arg2.push_back(new_prefix_arg);
1279 const size_t num = list.
GetSize();
1280 std::string old_path, new_path;
1281 for (
size_t i = 0; i < num; ++i) {
1285 strm << old_path <<
" -> " << new_path;
1293 assert(target &&
"target guaranteed by eCommandRequiresTarget");
1296 if (argc >= 3 && argc & 1) {
1297 uint32_t insert_idx;
1301 "<index> parameter is not an integer: '%s'",
1310 for (uint32_t i = 0; i < argc; i += 2, ++insert_idx) {
1314 if (from[0] && to[0]) {
1315 bool last_pair = ((argc - i) == 2);
1321 result.
AppendError(
"<path-prefix> can't be empty\n");
1323 result.
AppendError(
"<new-path-prefix> can't be empty\n");
1328 result.
AppendError(
"insert requires at least three arguments\n");
1333#pragma mark CommandObjectTargetModulesSearchPathsList
1339 "List all current image search path substitution "
1340 "pairs in the current target.",
1341 "target modules search-paths list",
1342 eCommandRequiresTarget) {}
1349 assert(target &&
"target guaranteed by eCommandRequiresTarget");
1355#pragma mark CommandObjectTargetModulesSearchPathsQuery
1361 interpreter,
"target modules search-paths query",
1362 "Transform a path using the first applicable image search path.",
1363 nullptr, eCommandRequiresTarget) {
1372 assert(target &&
"target guaranteed by eCommandRequiresTarget");
1374 result.
AppendError(
"query requires one argument\n");
1379 std::string transformed;
1391 bool full_triple, uint32_t width) {
1396 module->GetArchitecture().DumpTriple(arch_strm.AsRawOstream());
1399 std::string arch_str = std::string(arch_strm.
GetString());
1402 strm.
Printf(
"%-*s", width, arch_str.c_str());
1410 module->GetUUID().Dump(strm);
1419 uint32_t num_matches = 0;
1422 num_matches =
module->ResolveSymbolContextsForFileSpec(
1423 file_spec, 0, false, eSymbolContextCompUnit, sc_list);
1425 bool first_module =
true;
1430 strm <<
"Line table for " << sc.comp_unit->GetPrimaryFile() <<
" in `"
1431 <<
module->GetFileSpec().GetFilename() << "\n";
1432 LineTable *line_table = sc.comp_unit->GetLineTable();
1438 strm <<
"No line table";
1440 first_module =
false;
1448 if (file_spec_ptr) {
1450 std::string fullpath = file_spec_ptr->
GetPath();
1451 strm.
Printf(
"%-*s", width, fullpath.c_str());
1460 strm.
Printf(
"%-*s", width,
"");
1465 if (file_spec_ptr) {
1468 llvm::AlignStyle::Left, width));
1475 strm.
Printf(
"%-*s", width,
"");
1480 if (file_spec_ptr) {
1483 llvm::AlignStyle::Left, width));
1490 strm.
Printf(
"%-*s", width,
"");
1494 std::lock_guard<std::recursive_mutex> guard(module_list.
GetMutex());
1495 const size_t num_modules = module_list.
GetSize();
1496 if (num_modules == 0)
1499 size_t num_dumped = 0;
1500 strm.
Format(
"Dumping headers for {0} module(s).\n", num_modules);
1504 if (num_dumped++ > 0) {
1508 ObjectFile *objfile = module_sp->GetObjectFile();
1510 objfile->
Dump(&strm);
1512 strm.
Format(
"No object file for module: {0:F}\n",
1513 module_sp->GetFileSpec());
1528 sort_order, name_preference);
1534 SectionList *section_list =
module->GetSectionList();
1536 strm.
Printf(
"Sections for '%s' (%s):\n",
1549 symbol_file->Dump(strm);
1557 Module *module,
bool errors_only,
1558 bool load_all_debug_info) {
1562 if (symbol_file->GetSeparateDebugInfo(d, errors_only,
1563 load_all_debug_info)) {
1565 std::make_shared<StructuredData::Dictionary>(std::move(d)));
1578 "------------------ --- -----------------------------------------");
1587 strm.
Printf(
"0x%16.16" PRIx64
" ", dwo_id);
1591 llvm::StringRef
error;
1593 strm <<
"E " <<
error;
1595 llvm::StringRef resolved_dwo_path;
1597 resolved_dwo_path)) {
1598 strm <<
" " << resolved_dwo_path;
1599 if (resolved_dwo_path.ends_with(
".dwp")) {
1600 llvm::StringRef dwo_name;
1602 strm <<
"(" << dwo_name <<
")";
1615 strm.
PutCString(
"------------------ --- ---------------------");
1622 uint32_t oso_mod_time;
1624 strm.
Printf(
"0x%16.16" PRIx32
" ", oso_mod_time);
1626 llvm::StringRef
error;
1628 strm <<
"E " <<
error;
1630 llvm::StringRef oso_path;
1632 strm <<
" " << oso_path;
1641 bool verbose,
bool all_ranges,
Stream &strm,
1642 std::optional<Stream::HighlightSettings> settings = std::nullopt) {
1644 strm.
Indent(
" Address: ");
1649 strm.
Indent(
" Summary: ");
1665 Module *module, uint32_t resolve_mask,
1667 bool verbose,
bool all_ranges) {
1676 else if (so_addr.
GetModule().get() != module)
1685 DumpAddress(exe_scope, so_addr, verbose, all_ranges, strm);
1694 const char *name,
bool name_is_regex,
1695 bool verbose,
bool all_ranges) {
1699 Symtab *symtab =
module->GetSymtab();
1705 std::vector<uint32_t> match_indexes;
1707 uint32_t num_matches = 0;
1708 if (name_is_regex) {
1717 if (num_matches > 0) {
1719 strm.
Printf(
"%u symbols match %s'%s' in ", num_matches,
1720 name_is_regex ?
"the regular expression " :
"", name);
1727 for (uint32_t i = 0; i < num_matches; ++i) {
1734 use_color && name_is_regex
1735 ? std::optional<Stream::HighlightSettings>{settings}
1743 use_color && name_is_regex
1744 ? std::optional<Stream::HighlightSettings>{settings}
1765 std::optional<Stream::HighlightSettings> settings = std::nullopt) {
1767 bool first_module =
true;
1773 if (sc.line_entry.IsValid())
1774 addr = sc.line_entry.range.GetBaseAddress();
1775 else if (sc.block && sc.block->GetContainingInlinedBlock())
1776 sc.block->GetContainingInlinedBlock()->GetStartAddress(addr);
1778 addr = sc.GetFunctionOrSymbolAddress();
1780 DumpAddress(exe_scope, addr, verbose, all_ranges, strm, settings);
1781 first_module =
false;
1788 const char *name,
bool name_is_regex,
1790 bool verbose,
bool all_ranges) {
1791 if (module && name && name[0]) {
1793 size_t num_matches = 0;
1794 if (name_is_regex) {
1796 module->FindFunctions(function_name_regex, options, sc_list);
1799 module->FindFunctions(function_name, CompilerDeclContext(),
1800 eFunctionNameTypeAuto, options, sc_list);
1802 num_matches = sc_list.
GetSize();
1805 strm.
Printf(
"%" PRIu64
" match%s found in ", (uint64_t)num_matches,
1806 num_matches > 1 ?
"es" :
"");
1811 strm, sc_list, verbose, all_ranges);
1820 Module *module,
const char *name_cstr,
1821 bool name_is_regex) {
1822 if (module && name_cstr && name_cstr[0]) {
1825 module->FindTypes(query, results);
1830 sc.
module_sp =
module->shared_from_this();
1834 if (type_list.
Empty())
1837 const uint64_t num_matches = type_list.
GetSize();
1840 strm.
Printf(
"%" PRIu64
" match%s found in ", num_matches,
1841 num_matches > 1 ?
"es" :
"");
1849 type_sp->GetFullCompilerType();
1852 TypeSP typedef_type_sp(type_sp);
1853 TypeSP typedefed_type_sp(typedef_type_sp->GetTypedefType());
1854 while (typedefed_type_sp) {
1856 strm.
Printf(
" typedef '%s': ",
1857 typedef_type_sp->GetName().GetCString());
1858 typedefed_type_sp->GetFullCompilerType();
1861 typedef_type_sp = typedefed_type_sp;
1862 typedefed_type_sp = typedef_type_sp->GetTypedefType();
1873 const char *name_cstr,
bool name_is_regex) {
1876 module.FindTypes(query, results);
1879 sc.
module_sp =
module.shared_from_this();
1881 if (type_list.
Empty())
1893 type_sp->GetFullCompilerType();
1896 TypeSP typedef_type_sp(type_sp);
1897 TypeSP typedefed_type_sp(typedef_type_sp->GetTypedefType());
1898 while (typedefed_type_sp) {
1900 strm.
Printf(
" typedef '%s': ",
1901 typedef_type_sp->GetName().GetCString());
1902 typedefed_type_sp->GetFullCompilerType();
1905 typedef_type_sp = typedefed_type_sp;
1906 typedefed_type_sp = typedef_type_sp->GetTypedefType();
1916 uint32_t line,
bool check_inlines,
1917 bool verbose,
bool all_ranges) {
1918 if (module && file_spec) {
1920 const uint32_t num_matches =
module->ResolveSymbolContextsForFileSpec(
1921 file_spec, line, check_inlines, eSymbolContextEverything, sc_list);
1922 if (num_matches > 0) {
1924 strm.
Printf(
"%u match%s found in ", num_matches,
1925 num_matches > 1 ?
"es" :
"");
1928 strm.
Printf(
":%u", line);
1934 strm, sc_list, verbose, all_ranges);
1943 bool check_global_list) {
1944 FileSpec module_file_spec(module_name);
1947 const size_t initial_size = module_list.
GetSize();
1949 if (check_global_list) {
1951 std::lock_guard<std::recursive_mutex> guard(
1955 for (
size_t image_idx = 0; image_idx < num_modules; ++image_idx) {
1960 module_sp =
module->shared_from_this();
1968 const size_t num_matches = module_list.
GetSize();
1972 if (num_matches == 0) {
1981 return module_list.
GetSize() - initial_size;
1984#pragma mark CommandObjectTargetModulesModuleAutoComplete
2011#pragma mark CommandObjectTargetModulesSourceFileAutoComplete
2021 const char *syntax, uint32_t flags)
2036#pragma mark CommandObjectTargetModulesDumpObjfile
2043 interpreter,
"target modules dump objfile",
2044 "Dump the object file headers from one or more target modules.",
2045 nullptr, eCommandRequiresTarget) {}
2052 assert(target &&
"target guaranteed by eCommandRequiresTarget");
2053 size_t num_dumped = 0;
2058 if (num_dumped == 0) {
2059 result.
AppendError(
"the target has no associated executable images");
2064 const char *arg_cstr;
2065 for (
int arg_idx = 0;
2068 size_t num_matched =
2070 if (num_matched == 0) {
2072 "unable to find an image that matches '{0}'", arg_cstr);
2080 if (num_dumped > 0) {
2083 result.
AppendError(
"no matching executable images found");
2088#define LLDB_OPTIONS_target_modules_dump_symtab
2089#include "CommandOptions.inc"
2096 interpreter,
"target modules dump symtab",
2097 "Dump the symbol table from one or more target modules.", nullptr,
2098 eCommandRequiresTarget) {}
2115 switch (short_option) {
2128 llvm_unreachable(
"Unimplemented option");
2139 return llvm::ArrayRef(g_target_modules_dump_symtab_options);
2149 assert(target &&
"target guaranteed by eCommandRequiresTarget");
2150 uint32_t num_dumped = 0;
2158 std::lock_guard<std::recursive_mutex> guard(module_list.
GetMutex());
2159 const size_t num_modules = module_list.
GetSize();
2160 if (num_modules > 0) {
2162 "Dumping symbol table for {0} modules.\n", num_modules);
2164 if (num_dumped > 0) {
2169 "Interrupted in dump all symtabs with {0} "
2170 "of {1} dumped.", num_dumped, num_modules))
2175 module_sp.get(),
m_options.m_sort_order,
2179 result.
AppendError(
"the target has no associated executable images");
2184 const char *arg_cstr;
2185 for (
int arg_idx = 0;
2189 const size_t num_matches =
2191 if (num_matches > 0) {
2194 if (num_dumped > 0) {
2199 "Interrupted in dump symtab list with {0} of {1} dumped.",
2200 num_dumped, num_matches))
2205 module_sp.get(),
m_options.m_sort_order,
2211 "unable to find an image that matches '{0}'", arg_cstr);
2218 result.
AppendError(
"no matching executable images found");
2225#pragma mark CommandObjectTargetModulesDumpSections
2234 interpreter,
"target modules dump sections",
2235 "Dump the sections from one or more target modules.",
2237 nullptr, eCommandRequiresTarget) {}
2244 assert(target &&
"target guaranteed by eCommandRequiresTarget");
2245 uint32_t num_dumped = 0;
2250 if (num_modules == 0) {
2251 result.
AppendError(
"the target has no associated executable images");
2257 for (
size_t image_idx = 0; image_idx < num_modules; ++image_idx) {
2259 "Interrupted in dump all sections with {0} of {1} dumped",
2260 image_idx, num_modules))
2270 const char *arg_cstr;
2271 for (
int arg_idx = 0;
2275 const size_t num_matches =
2277 if (num_matches > 0) {
2278 for (
size_t i = 0; i < num_matches; ++i) {
2280 "Interrupted in dump section list with {0} of {1} dumped.",
2293 std::lock_guard<std::recursive_mutex> guard(
2297 "unable to find an image that matches '{0}'", arg_cstr);
2305 result.
AppendError(
"no matching executable images found");
2310#pragma mark CommandObjectTargetModulesDumpClangAST
2319 interpreter,
"target modules dump ast",
2320 "Dump the clang ast for a given module's symbol file.",
2321 "target modules dump ast [--filter <name>] [<file1> ...]",
2322 eCommandRequiresTarget),
2324 "Dump only the decls whose names contain the specified filter "
2341 assert(target &&
"target guaranteed by eCommandRequiresTarget");
2343 const size_t num_modules = module_list.
GetSize();
2344 if (num_modules == 0) {
2345 result.
AppendError(
"the target has no associated executable images");
2349 llvm::StringRef filter =
m_filter.GetOptionValue().GetCurrentValueAsRef();
2358 if (
SymbolFile *sf = module_sp->GetSymbolFile())
2369 const size_t num_matches =
2371 if (num_matches == 0) {
2373 std::lock_guard<std::recursive_mutex> guard(
2377 "unable to find an image that matches '{0}'", arg.c_str());
2381 for (
size_t i = 0; i < num_matches; ++i) {
2383 "Interrupted in dump clang ast list with {0} of {1} dumped.",
2397#pragma mark CommandObjectTargetModulesDumpSymfile
2406 interpreter,
"target modules dump symfile",
2407 "Dump the debug symbol file for one or more target modules.",
2409 nullptr, eCommandRequiresTarget) {}
2416 assert(target &&
"target guaranteed by eCommandRequiresTarget");
2417 uint32_t num_dumped = 0;
2422 std::lock_guard<std::recursive_mutex> guard(target_modules.
GetMutex());
2423 const size_t num_modules = target_modules.
GetSize();
2424 if (num_modules == 0) {
2425 result.
AppendError(
"the target has no associated executable images");
2429 "Dumping debug symbols for {0} modules.\n", num_modules);
2432 "debug symbols with {0} of {1} modules dumped",
2433 num_dumped, num_modules))
2441 const char *arg_cstr;
2442 for (
int arg_idx = 0;
2446 const size_t num_matches =
2448 if (num_matches > 0) {
2449 for (
size_t i = 0; i < num_matches; ++i) {
2451 "of {1} requested modules",
2462 "unable to find an image that matches '{0}'", arg_cstr);
2469 result.
AppendError(
"no matching executable images found");
2474#pragma mark CommandObjectTargetModulesDumpLineTable
2475#define LLDB_OPTIONS_target_modules_dump
2476#include "CommandOptions.inc"
2485 interpreter,
"target modules dump line-table",
2486 "Dump the line table for one or more compilation units.", nullptr,
2487 eCommandRequiresTarget) {}
2496 uint32_t total_num_dumped = 0;
2499 result.
AppendError(
"file option must be specified");
2503 const char *arg_cstr;
2504 for (
int arg_idx = 0;
2510 std::lock_guard<std::recursive_mutex> guard(target_modules.
GetMutex());
2511 size_t num_modules = target_modules.
GetSize();
2512 if (num_modules > 0) {
2513 uint32_t num_dumped = 0;
2516 "Interrupted in dump all line tables with "
2517 "{0} of {1} dumped", num_dumped,
2528 if (num_dumped == 0)
2532 total_num_dumped += num_dumped;
2537 if (total_num_dumped > 0)
2540 result.
AppendError(
"no source filenames matched any command arguments");
2550 assert(option_idx == 0 &&
"We only have one option.");
2561 return llvm::ArrayRef(g_target_modules_dump_options);
2570#pragma mark CommandObjectTargetModulesDumpSeparateDebugInfoFiles
2571#define LLDB_OPTIONS_target_modules_dump_separate_debug_info
2572#include "CommandOptions.inc"
2582 interpreter,
"target modules dump separate-debug-info",
2583 "List the separate debug info symbol files for one or more target "
2585 nullptr, eCommandRequiresTarget) {}
2602 switch (short_option) {
2608 m_json.SetCurrentValue(
true);
2609 m_json.SetOptionWasSet();
2616 llvm_unreachable(
"Unimplemented option");
2628 return llvm::ArrayRef(g_target_modules_dump_separate_debug_info_options);
2639 assert(target &&
"target guaranteed by eCommandRequiresTarget");
2640 uint32_t num_dumped = 0;
2646 std::lock_guard<std::recursive_mutex> guard(target_modules.
GetMutex());
2647 const size_t num_modules = target_modules.
GetSize();
2648 if (num_modules == 0) {
2649 result.
AppendError(
"the target has no associated executable images");
2655 "Interrupted in dumping all "
2656 "separate debug info with {0} of {1} modules dumped",
2657 num_dumped, num_modules))
2668 const char *arg_cstr;
2669 for (
int arg_idx = 0;
2673 const size_t num_matches =
2675 if (num_matches > 0) {
2676 for (
size_t i = 0; i < num_matches; ++i) {
2678 "Interrupted dumping {0} "
2679 "of {1} requested modules",
2690 "unable to find an image that matches '{0}'", arg_cstr);
2694 if (num_dumped > 0) {
2699 separate_debug_info_lists_by_module.
Dump(strm,
2703 separate_debug_info_lists_by_module.
ForEach(
2713 if (!separate_debug_info_list) {
2717 llvm::StringRef type;
2718 llvm::StringRef symfile;
2725 "separate-debug-info-files", files))) {
2729 strm <<
"Symbol file: " << symfile;
2731 strm <<
"Type: \"" << type <<
"\"";
2733 if (type ==
"dwo") {
2735 }
else if (type ==
"oso") {
2739 "found unsupported debug info type '{0}'", type);
2746 result.
AppendError(
"no matching executable images found");
2753#pragma mark CommandObjectTargetModulesDump
2762 interpreter,
"target modules dump",
2763 "Commands for dumping information about one or more target "
2765 "target modules dump "
2766 "[objfile|symtab|sections|ast|symfile|line-table|pcm-info|separate-"
2768 "[<file1> <file2> ...]") {
2800 "Add a new module to the current target's modules.",
2801 "target modules add [<module>]",
2802 eCommandRequiresTarget),
2805 "Fullpath to a stand alone debug "
2806 "symbols file for when debug symbols "
2807 "are not in the executable.") {
2826 assert(target &&
"target guaranteed by eCommandRequiresTarget");
2852 "Unable to create the executable or symbol file with "
2853 "UUID %s with path %s and symbol file %s",
2858 "Unable to create the executable or symbol file with "
2859 "UUID %s with path %s",
2865 "or symbol file with UUID %s",
2874 "Unable to locate the executable or symbol file with UUID %s",
2881 "one or more executable image paths must be specified");
2885 for (
auto &entry : args.
entries()) {
2886 if (entry.ref().empty())
2902 module_spec,
true , &
error));
2904 const char *error_cstr =
error.AsCString();
2916 std::string resolved_path = file_spec.
GetPath();
2917 if (resolved_path != entry.ref()) {
2919 "invalid module path '%s' with resolved path '%s'",
2920 entry.ref().str().c_str(), resolved_path.c_str());
2943 interpreter,
"target modules load",
2944 "Set the load addresses for one or more sections in a target "
2946 "target modules load [--file <module> --uuid <uuid>] <sect-name> "
2947 "<address> [<sect-name> <address> ....]",
2948 eCommandRequiresTarget),
2950 "Fullpath or basename for module to load.",
""),
2952 "Write file contents to the memory.", false, true),
2954 "Set PC to the entry point."
2955 " Only applicable with '--load' option.",
2958 "Set the load address for all sections to be the "
2959 "virtual address in the file plus the offset.",
2977 assert(target &&
"target guaranteed by eCommandRequiresTarget");
2978 const bool load =
m_load_option.GetOptionValue().GetCurrentValue();
2979 const bool set_pc =
m_pc_option.GetOptionValue().GetCurrentValue();
2983 bool search_using_module_spec =
false;
2990 if (module_list.
GetSize() == 1) {
2991 search_using_module_spec =
true;
2999 search_using_module_spec =
true;
3000 const char *arg_cstr =
m_file_option.GetOptionValue().GetCurrentValue();
3001 const bool use_global_module_list =
true;
3004 target, arg_cstr, module_list, use_global_module_list);
3005 if (num_matches == 1) {
3008 }
else if (num_matches > 1) {
3009 search_using_module_spec =
false;
3013 search_using_module_spec =
false;
3020 search_using_module_spec =
true;
3025 if (search_using_module_spec) {
3028 const size_t num_matches = matching_modules.
GetSize();
3031 if (num_matches == 1) {
3034 ObjectFile *objfile =
module->GetObjectFile();
3036 SectionList *section_list =
module->GetSectionList();
3038 bool changed =
false;
3043 const bool slide_is_offset =
true;
3044 module->SetLoadAddress(*target, slide, slide_is_offset,
3047 result.
AppendError(
"one or more section name + load "
3048 "address pair must be specified");
3053 result.
AppendError(
"The \"--slide <offset>\" option can't "
3054 "be used in conjunction with setting "
3055 "section load addresses.\n");
3059 for (
size_t i = 0; i < argc; i += 2) {
3062 if (sect_name && load_addr_cstr) {
3064 if (llvm::to_integer(load_addr_cstr, load_addr)) {
3068 if (section_sp->IsThreadSpecific()) {
3070 "thread specific sections are not yet "
3071 "supported (section '%s')",
3079 "section '{0}' loaded at {1:x}", sect_name,
3084 "matches the section "
3091 "invalid load address string '%s'", load_addr_cstr);
3096 result.
AppendError(
"section names must be followed by "
3097 "a load address.\n");
3099 result.
AppendError(
"one or more section name + load "
3100 "address pair must be specified.\n");
3119 if (set_pc && !file_entry.
IsValid()) {
3120 result.
AppendError(
"No entry address in object file");
3123 std::vector<ObjectFile::LoadableData> loadables(
3125 if (loadables.size() == 0) {
3129 Status error = process->WriteObjectFile(std::move(loadables));
3135 ThreadList &thread_list = process->GetThreadList();
3139 if (!reg_context->SetPC(file_entry_addr)) {
3147 module->GetFileSpec().GetPath(path, sizeof(path));
3152 module->GetFileSpec().GetPath(path, sizeof(path));
3158 if (module_spec_file) {
3159 module_spec_file->
GetPath(path,
sizeof(path));
3165 std::string uuid_str;
3174 if (num_matches > 1) {
3176 "multiple modules match%s%s%s%s:", path[0] ?
" file=" :
"", path,
3177 !uuid_str.empty() ?
" uuid=" :
"", uuid_str.c_str());
3178 for (
size_t i = 0; i < num_matches; ++i) {
3186 "no modules were found that match%s%s%s%s",
3187 path[0] ?
" file=" :
"", path, !uuid_str.empty() ?
" uuid=" :
"",
3192 result.
AppendError(
"either the \"--file <module>\" or the \"--uuid "
3193 "<uuid>\" option must be specified.\n");
3207#pragma mark CommandObjectTargetModulesList
3209#define LLDB_OPTIONS_target_modules_list
3210#include "CommandOptions.inc"
3225 if (short_option ==
'g') {
3227 }
else if (short_option ==
'a') {
3231 unsigned long width = 0;
3232 option_arg.getAsInteger(0, width);
3245 return llvm::ArrayRef(g_target_modules_list_options);
3257 interpreter,
"target modules list",
3258 "List current executable and dependent shared library images.",
3259 nullptr, eCommandAllowsDummyTarget) {
3270 const bool use_global_module_list =
m_options.m_use_global_module_list;
3273 if (!use_global_module_list && (!target || target->
IsDummyTarget())) {
3294 "Couldn't find module matching address: 0x%" PRIx64,
3299 "Couldn't find module containing address: 0x%" PRIx64,
3305 size_t num_modules = 0;
3311 std::unique_lock<std::recursive_mutex> guard(
3317 if (use_global_module_list) {
3327 target, arg.c_str(), module_list, use_global_module_list);
3328 if (num_matches == 0) {
3337 module_list_ptr = &module_list;
3340 std::unique_lock<std::recursive_mutex> lock;
3341 if (module_list_ptr !=
nullptr) {
3343 std::unique_lock<std::recursive_mutex>(module_list_ptr->
GetMutex());
3345 num_modules = module_list_ptr->
GetSize();
3348 if (num_modules > 0) {
3349 for (uint32_t image_idx = 0; image_idx < num_modules; ++image_idx) {
3352 if (module_list_ptr) {
3354 module = module_sp.get();
3356 module = Module::GetAllocatedModuleAtIndex(image_idx);
3357 module_sp =
module->shared_from_this();
3360 const size_t indent = strm.
Printf(
"[%3u] ", image_idx);
3366 if (use_global_module_list)
3368 "the global module list has no matching modules");
3370 result.
AppendError(
"the target has no matching modules");
3372 if (use_global_module_list)
3373 result.
AppendError(
"the global module list is empty");
3376 "the target has no associated executable images");
3383 if (module ==
nullptr) {
3388 bool dump_object_name =
false;
3390 m_options.m_format_array.push_back(std::make_pair(
'u', 0));
3391 m_options.m_format_array.push_back(std::make_pair(
'h', 0));
3392 m_options.m_format_array.push_back(std::make_pair(
'f', 0));
3393 m_options.m_format_array.push_back(std::make_pair(
'S', 0));
3395 const size_t num_entries =
m_options.m_format_array.size();
3396 bool print_space =
false;
3397 for (
size_t i = 0; i < num_entries; ++i) {
3401 const char format_char =
m_options.m_format_array[i].first;
3402 uint32_t width =
m_options.m_format_array[i].second;
3403 switch (format_char) {
3414 dump_object_name =
true;
3423 dump_object_name =
true;
3430 uint32_t addr_nibble_width =
3433 ObjectFile *objfile =
module->GetObjectFile();
3440 base_addr.
Dump(&strm, &target,
3444 if (format_char ==
'o') {
3446 strm.
Printf(
"0x%*.*" PRIx64, addr_nibble_width,
3451 strm.
Printf(
"0x%*.*" PRIx64, addr_nibble_width,
3452 addr_nibble_width, load_addr);
3463 strm.
Printf(
"%*s", addr_nibble_width + 2,
"");
3468 size_t ref_count = 0;
3469 char in_shared_cache =
'Y';
3471 ModuleSP module_sp(module->shared_from_this());
3473 in_shared_cache =
'N';
3476 ref_count = module_sp.use_count() - 1;
3479 strm.
Printf(
"{%c %*" PRIu64
"}", in_shared_cache, width, (uint64_t)ref_count);
3481 strm.
Printf(
"{%c %" PRIu64
"}", in_shared_cache, (uint64_t)ref_count);
3488 symbol_file->GetObjectFile()->GetFileSpec();
3489 if (format_char ==
'S') {
3491 if (!symfile_spec || symfile_spec == module->
GetFileSpec()) {
3492 print_space =
false;
3496 strm.
Printf(
"\n%*s", indent,
"");
3499 dump_object_name =
true;
3502 strm.
Printf(
"%.*s", width,
"<NONE>");
3507 llvm::AlignStyle::Left, width));
3511 strm.
Printf(
"%p",
static_cast<void *
>(module));
3516 const uint32_t state =
module->GetSymtabState();
3517 if (state & eSymtabStateLoadedFromCache)
3519 if (state & eSymtabStateParsedFromObjectFile)
3521 if (state & eSymtabStateSavedToCache)
3523 if (state & eSymtabStateSymbolFileAddedSymbols)
3528 llvm::fmt_align(flags, llvm::AlignStyle::Left, width));
3539 if (dump_object_name) {
3541 !object_name.empty())
3542 strm.
Format(
"({0})", object_name);
3543 std::optional<addr_t> memory_addr =
module->GetMemoryModuleAddress();
3544 if (memory_addr.has_value())
3545 strm.
Printf(
"(0x%" PRIx64
")", memory_addr.value());
3553#pragma mark CommandObjectTargetModulesShowUnwind
3556#define LLDB_OPTIONS_target_modules_show_unwind
3557#include "CommandOptions.inc"
3582 switch (short_option) {
3584 m_str = std::string(option_arg);
3590 "invalid address string '%s'", option_arg.str().c_str());
3595 m_str = std::string(option_arg);
3600 bool value, success;
3606 "invalid boolean value '{}' passed for -c option", option_arg);
3611 llvm_unreachable(
"Unimplemented option");
3625 return llvm::ArrayRef(g_target_modules_show_unwind_options);
3639 interpreter,
"target modules show-unwind",
3640 "Show synthesized unwind instructions for a function.", nullptr,
3641 eCommandRequiresTarget | eCommandRequiresProcess |
3642 eCommandProcessMustBeLaunched | eCommandProcessMustBePaused) {}
3654 abi = process->
GetABI().get();
3656 if (process ==
nullptr) {
3658 "You must have a process running to use this command.");
3664 result.
AppendError(
"the process must be paused to use this command");
3670 result.
AppendError(
"the process must be paused to use this command");
3682 function_options, sc_list);
3688 module_sp->ResolveSymbolContextForAddress(addr,
3689 eSymbolContextEverything, sc);
3696 "address-expression or function name option must be specified.");
3707 if (sc.symbol ==
nullptr && sc.function ==
nullptr)
3709 if (!sc.module_sp || sc.module_sp->GetObjectFile() ==
nullptr)
3711 Address addr = sc.GetFunctionOrSymbolAddress();
3721 UnwindTable &uw_table = sc.module_sp->GetUnwindTable();
3728 if (!func_unwinders_sp)
3732 "UNWIND PLANS for {0}`{1} (start addr {2:x})\n",
3733 sc.module_sp->GetPlatformFileSpec().GetFilename(), funcname,
3739 for (
size_t i = 0; i < count; i++) {
3741 if (strcmp(funcname.
GetCString(), trap_func_name) == 0)
3744 "treated as a trap handler function via user setting.\n");
3748 const std::vector<std::string> &trap_handler_names(
3749 platform_sp->GetTrapHandlerSymbolNames());
3750 for (
const std::string &trap_name : trap_handler_names) {
3751 if (llvm::StringRef(trap_name) == funcname) {
3754 "name is listed by the platform as a trap handler.\n");
3761 if (std::shared_ptr<const UnwindPlan> plan_sp =
3762 func_unwinders_sp->GetUnwindPlanAtNonCallSite(*target, *thread)) {
3764 "Asynchronous (not restricted to call-sites) UnwindPlan is '{0}'\n",
3765 plan_sp->GetSourceName());
3767 if (std::shared_ptr<const UnwindPlan> plan_sp =
3768 func_unwinders_sp->GetUnwindPlanAtCallSite(*target, *thread)) {
3770 "Synchronous (restricted to call-sites) UnwindPlan is '{0}'\n",
3771 plan_sp->GetSourceName());
3773 if (std::shared_ptr<const UnwindPlan> plan_sp =
3774 func_unwinders_sp->GetUnwindPlanFastUnwind(*target, *thread)) {
3776 plan_sp->GetSourceName());
3781 if (std::shared_ptr<const UnwindPlan> plan_sp =
3782 func_unwinders_sp->GetAssemblyUnwindPlan(*target, *thread)) {
3784 "Assembly language inspection UnwindPlan:\n");
3790 if (std::shared_ptr<const UnwindPlan> plan_sp =
3791 func_unwinders_sp->GetObjectFileUnwindPlan(*target)) {
3798 if (std::shared_ptr<const UnwindPlan> plan_sp =
3799 func_unwinders_sp->GetObjectFileAugmentedUnwindPlan(*target,
3807 if (std::shared_ptr<const UnwindPlan> plan_sp =
3808 func_unwinders_sp->GetEHFrameUnwindPlan(*target)) {
3815 if (std::shared_ptr<const UnwindPlan> plan_sp =
3816 func_unwinders_sp->GetEHFrameAugmentedUnwindPlan(*target,
3824 if (std::shared_ptr<const UnwindPlan> plan_sp =
3825 func_unwinders_sp->GetDebugFrameUnwindPlan(*target)) {
3832 if (std::shared_ptr<const UnwindPlan> plan_sp =
3833 func_unwinders_sp->GetDebugFrameAugmentedUnwindPlan(*target,
3841 if (std::shared_ptr<const UnwindPlan> plan_sp =
3842 func_unwinders_sp->GetArmUnwindUnwindPlan(*target)) {
3849 if (std::shared_ptr<const UnwindPlan> plan_sp =
3850 func_unwinders_sp->GetSymbolFileUnwindPlan(*thread)) {
3857 if (std::shared_ptr<const UnwindPlan> plan_sp =
3858 func_unwinders_sp->GetCompactUnwindUnwindPlan(*target)) {
3865 if (std::shared_ptr<const UnwindPlan> plan_sp =
3866 func_unwinders_sp->GetUnwindPlanFastUnwind(*target, *thread)) {
3875 if (
UnwindPlanSP plan_sp = abi_sp->CreateDefaultUnwindPlan()) {
3876 assert(((!plan_sp || plan_sp->GetRowCount() == 0 ||
3877 plan_sp->GetRowAtIndex(0)
3878 ->GetUnspecifiedRegistersAreUndefined())) &&
3879 "Default UnwindPlan must set "
3880 "UnspecifiedRegistersAreUndefined to true");
3887 if (
UnwindPlanSP plan_sp = abi_sp->CreateFunctionEntryUnwindPlan()) {
3889 "Arch default at entry point UnwindPlan:\n");
3905#define LLDB_OPTIONS_target_modules_lookup
3906#include "CommandOptions.inc"
3933 switch (short_option) {
3941 if (option_arg.getAsInteger(0,
m_offset))
3943 "invalid offset string '%s'", option_arg.str().c_str());
3947 m_str = std::string(option_arg);
3952 m_file.SetFile(option_arg, FileSpec::Style::native);
3963 "invalid line number string '%s'", option_arg.str().c_str());
3970 m_str = std::string(option_arg);
3975 m_str = std::string(option_arg);
3980 m_str = std::string(option_arg);
4000 llvm_unreachable(
"Unimplemented option");
4025 "conjunction with --verbose.");
4031 return llvm::ArrayRef(g_target_modules_lookup_options);
4052 "Look up information within executable and "
4053 "dependent shared library images.",
4054 nullptr, eCommandRequiresTarget) {
4063 bool &syntax_error) {
4081 const SymbolContext &sym_ctx(frame->GetSymbolContext(eSymbolContextModule));
4111 eSymbolContextEverything |
4113 ?
static_cast<int>(eSymbolContextVariable)
4158 m_options.m_use_regex, function_options,
4183 syntax_error =
true;
4194 assert(target &&
"target guaranteed by eCommandRequiresTarget");
4195 bool syntax_error =
false;
4197 uint32_t num_successful_lookups = 0;
4206 num_successful_lookups++;
4216 std::lock_guard<std::recursive_mutex> guard(target_modules.
GetMutex());
4217 if (target_modules.
GetSize() == 0) {
4218 result.
AppendError(
"the target has no associated executable images");
4226 num_successful_lookups++;
4231 const char *arg_cstr;
4236 const size_t num_matches =
4238 if (num_matches > 0) {
4239 for (
size_t j = 0; j < num_matches; ++j) {
4244 num_successful_lookups++;
4250 "unable to find an image that matches '{0}'", arg_cstr);
4254 if (num_successful_lookups > 0)
4263#pragma mark CommandObjectMultiwordImageSearchPaths
4272 interpreter,
"target modules search-paths",
4273 "Commands for managing module search paths for a target.",
4274 "target modules search-paths <subcommand> [<subcommand-options>]") {
4296#pragma mark CommandObjectTargetModules
4305 "Commands for accessing information for one or "
4306 "more target modules.",
4307 "target modules <sub-command> ...") {
4341 interpreter,
"target symbols add",
4342 "Add a debug symbol file to one of the target's current modules by "
4343 "specifying a path to a debug symbols file or by using the options "
4344 "to specify a module.",
4345 "target symbols add <cmd-options> [<symfile>]",
4346 eCommandRequiresTarget),
4350 "Locate the debug symbols for the shared library specified by "
4354 "Locate the debug symbols for the currently selected frame.", false,
4357 "Locate the debug symbols for every frame in "
4358 "the current call stack.",
4381 if (!symbol_fspec) {
4383 "one or more executable image paths must be specified");
4388 symbol_fspec.
GetPath(symfile_path,
sizeof(symfile_path));
4403 if (symfile_module_specs.
GetSize() > 0) {
4409 symfile_module_spec)) {
4413 symfile_uuid_module_spec.
GetUUID() = symfile_module_spec.
GetUUID();
4419 if (matching_modules.
IsEmpty()) {
4422 const size_t num_symfile_module_specs = symfile_module_specs.
GetSize();
4424 i < num_symfile_module_specs && matching_modules.
IsEmpty(); ++i) {
4426 i, symfile_module_spec)) {
4430 symfile_uuid_module_spec.
GetUUID() =
4431 symfile_module_spec.
GetUUID();
4442 if (matching_modules.
IsEmpty())
4445 while (matching_modules.
IsEmpty()) {
4449 if (!filename_no_extension)
4461 if (matching_modules.
GetSize() > 1) {
4463 "use the --uuid option to resolve the "
4469 if (matching_modules.
GetSize() == 1) {
4475 module_sp->SetSymbolFileFileSpec(symbol_fspec);
4481 if (object_file && object_file->
GetFileSpec() == symbol_fspec) {
4483 const FileSpec &module_fs = module_sp->GetFileSpec();
4485 "symbol file '{0}' has been added to '{1}'", symfile_path,
4491 module_list.
Append(module_sp);
4496 std::list<Status> errors;
4498 for (
const auto &err : errors)
4507 module_sp->SetSymbolFileFileSpec(
FileSpec());
4512 ss_symfile_uuid <<
" (";
4514 ss_symfile_uuid <<
')';
4517 "symbol file '%s'%s does not match any existing module%s", symfile_path,
4519 !llvm::sys::fs::is_regular_file(symbol_fspec.
GetPath())
4520 ?
"\n please specify the full path to the symbol file"
4547 error_strm.
PutCString(
"unable to find debug symbols for UUID ");
4567 module_spec.
GetFileSpec() = module_sp->GetFileSpec();
4569 module_spec.
GetUUID() = module_sp->GetUUID();
4578 "unable to find debug symbols for the executable file ");
4593 "a process must exist in order to use the --frame option");
4612 if (!frame_module_sp) {
4618 module_spec.
GetUUID() = frame_module_sp->GetUUID();
4620 module_spec.
GetFileSpec() = frame_module_sp->GetPlatformFileSpec();
4623 result.
AppendError(
"unable to find debug symbols for the current frame");
4636 "a process must exist in order to use the --stack option");
4653 bool symbols_found =
false;
4654 uint32_t frame_count = thread->GetStackFrameCount();
4655 for (uint32_t i = 0; i < frame_count; ++i) {
4659 frame_sp->GetSymbolContext(eSymbolContextModule).module_sp);
4660 if (!frame_module_sp)
4664 module_spec.
GetUUID() = frame_module_sp->GetUUID();
4665 module_spec.
GetFileSpec() = frame_module_sp->GetPlatformFileSpec();
4668 bool current_frame_flush =
false;
4670 symbols_found =
true;
4671 flush |= current_frame_flush;
4674 if (!symbols_found) {
4676 "unable to find debug symbols in the current call stack");
4688 const bool uuid_option_set =
4690 const bool file_option_set =
m_file_option.GetOptionValue().OptionWasSet();
4691 const bool frame_option_set =
4693 const bool stack_option_set =
4698 if (uuid_option_set)
4700 else if (file_option_set)
4702 else if (frame_option_set)
4704 else if (stack_option_set)
4707 result.
AppendError(
"one or more symbol file paths must be specified, "
4708 "or options must be specified");
4710 if (uuid_option_set) {
4711 result.
AppendError(
"specify either one or more paths to symbol files "
4712 "or use the --uuid option without arguments");
4713 }
else if (frame_option_set) {
4714 result.
AppendError(
"specify either one or more paths to symbol files "
4715 "or use the --frame option without arguments");
4716 }
else if (file_option_set && argc > 1) {
4717 result.
AppendError(
"specify at most one symbol file path when "
4718 "--shlib option is set");
4722 for (
auto &entry : args.
entries()) {
4723 if (!entry.ref().empty()) {
4725 symbol_file_spec.
SetFile(entry.ref(), FileSpec::Style::native);
4727 if (file_option_set) {
4734 ->ResolveSymbolFile(*target, module_spec, symfile_spec)
4739 bool symfile_exists =
4742 if (symfile_exists) {
4746 std::string resolved_symfile_path =
4748 if (resolved_symfile_path != entry.ref()) {
4750 "invalid module path '%s' with resolved path '%s'",
4751 entry.c_str(), resolved_symfile_path.c_str());
4777#pragma mark CommandObjectTargetSymbols
4786 interpreter,
"target symbols",
4787 "Commands for adding and managing debug symbol files.",
4788 "target symbols <sub-command> ...") {
4802#pragma mark CommandObjectTargetStopHookAdd
4805#define LLDB_OPTIONS_target_stop_hook_add
4806#include "CommandOptions.inc"
4818 return llvm::ArrayRef(g_target_stop_hook_add_options);
4824 const int short_option =
4825 g_target_stop_hook_add_options[option_idx].short_option;
4827 switch (short_option) {
4834 if (option_arg.getAsInteger(0,
m_line_end)) {
4836 "invalid end line number: \"%s\"", option_arg.str().c_str());
4843 bool value, success;
4849 "invalid boolean value '%s' passed for -G option",
4850 option_arg.str().c_str());
4855 "invalid start line number: \"%s\"", option_arg.str().c_str());
4884 "invalid thread id string '%s'", option_arg.str().c_str());
4901 "invalid thread index string '%s'", option_arg.str().c_str());
4911 bool value, success;
4917 "invalid boolean value '%s' passed for -F option",
4918 option_arg.str().c_str());
4922 llvm_unreachable(
"Unimplemented option");
4957 eFunctionNameTypeAuto;
4975 "Add a hook to be executed when the target stops."
4976 "The hook can either be a list of commands or an "
4977 "appropriately defined Python class. You can also "
4978 "add filters so the hook only runs a certain stop "
4980 "target stop-hook add", eCommandAllowsDummyTarget),
4986Command Based stop-hooks:
4987-------------------------
4988 Stop hooks can run a list of lldb commands by providing one or more
4989 --one-liner options. The commands will get run in the order they are added.
4990 Or you can provide no commands, in which case you will enter a command editor
4991 where you can enter the commands to be run.
4993Python Based Stop Hooks:
4994------------------------
4995 Stop hooks can be implemented with a suitably defined Python class, whose name
4996 is passed in the --python-class option.
4998 When the stop hook is added, the class is initialized by calling:
5000 def __init__(self, target, extra_args, internal_dict):
5002 target: The target that the stop hook is being added to.
5003 extra_args: An SBStructuredData Dictionary filled with the -key -value
5004 option pairs passed to the command.
5005 dict: An implementation detail provided by lldb.
5007 Then when the stop-hook triggers, lldb will run the 'handle_stop' method.
5008 The method has the signature:
5010 def handle_stop(self, exe_ctx, stream):
5012 exe_ctx: An SBExecutionContext for the thread that has stopped.
5013 stream: An SBStream, anything written to this stream will be printed in the
5014 the stop message when the process stops.
5016 Return Value: The method returns "should_stop". If should_stop is false
5017 from all the stop hook executions on threads that stopped
5018 with a reason, then the process will continue. Note that this
5019 will happen only after all the stop hooks are run.
5023 Stop hooks can be set to always run, or to only run when the stopped thread
5024 matches the filter options passed on the command line. The available filter
5025 options include a shared library or a thread or queue specification,
5026 a line range in a source file, a function name or a class name.
5046 "Enter your stop hook command(s). Type 'DONE' to end.\n");
5052 std::string &line)
override {
5058 locked_stream.
Printf(
"error: stop hook #%" PRIu64
5059 " aborted, no commands.\n",
5065 Target::StopHookCommandLine *hook_ptr =
5066 static_cast<Target::StopHookCommandLine *
>(
m_stop_hook_sp.get());
5071 LockedStreamFile locked_stream = output_sp->Lock();
5072 locked_stream.
Printf(
"Stop hook #%" PRIu64
" added.\n",
5081 void DoExecute(Args &command, CommandReturnObject &result)
override {
5085 assert(target &&
"target guaranteed by eCommandRequiresTarget");
5088 ? Target::StopHook::StopHookKind::CommandBased
5089 : Target::StopHook::StopHookKind::ScriptBased);
5092 std::unique_ptr<SymbolContextSpecifier> specifier_up;
5095 std::make_unique<SymbolContextSpecifier>(target->shared_from_this());
5098 specifier_up->AddSpecification(
5104 specifier_up->AddSpecification(
5110 specifier_up->AddSpecification(
m_options.m_file_name.c_str(),
5115 specifier_up->AddLineSpecification(
5121 specifier_up->AddLineSpecification(
5125 if (!
m_options.m_function_name.empty()) {
5126 specifier_up->AddSpecification(
5133 new_hook_sp->SetSpecifier(specifier_up.release());
5136 new_hook_sp->SetRunAtInitialStop(
m_options.m_at_initial_stop);
5141 ThreadSpec *thread_spec =
new ThreadSpec();
5156 new_hook_sp->SetThreadSpecifier(thread_spec);
5166 new_hook_sp->GetID());
5169 Target::StopHookScripted *hook_ptr =
5170 static_cast<Target::StopHookScripted *
>(new_hook_sp.get());
5171 ScriptedMetadata scripted_metadata(
5175 if (
error.Success())
5177 new_hook_sp->GetID());
5201#pragma mark CommandObjectTargetStopHookDelete
5209 interpreter,
"target stop-hook delete",
"Delete a stop-hook.",
5210 "target stop-hook delete [<idx>]", eCommandAllowsDummyTarget) {
5213Deletes the stop hook by index.
5215At any given stop, all enabled stop hooks that pass the stop filter will
5216get a chance to run. That means if one stop-hook deletes another stop hook
5217while executing, the deleted stop hook will still fire for the stop at which
5236 assert(target &&
"target guaranteed by eCommandRequiresTarget");
5239 if (num_args == 0) {
5247 for (
size_t i = 0; i < num_args; i++) {
5265#pragma mark CommandObjectTargetStopHookEnableDisable
5272 bool enable,
const char *name,
5273 const char *help,
const char *syntax)
5275 eCommandAllowsDummyTarget),
5293 assert(target &&
"target guaranteed by eCommandRequiresTarget");
5298 if (num_args == 0) {
5301 for (
size_t i = 0; i < num_args; i++) {
5323#pragma mark CommandObjectTargetStopHookList
5326#define LLDB_OPTIONS_target_stop_hook_list
5327#include "CommandOptions.inc"
5333 "List all stop-hooks.", nullptr,
5334 eCommandAllowsDummyTarget) {}
5350 switch (short_option) {
5355 llvm_unreachable(
"Unimplemented option");
5366 return llvm::ArrayRef(g_target_stop_hook_list_options);
5376 assert(target &&
"target guaranteed by eCommandRequiresTarget");
5377 bool printed_hook =
false;
5382 printed_hook =
true;
5395#pragma mark CommandObjectMultiwordTargetStopHooks
5403 interpreter,
"target stop-hook",
5404 "Commands for operating on debugger target stop-hooks.",
5405 "target stop-hook <subcommand> [<subcommand-options>]") {
5413 interpreter,
false,
"target stop-hook disable [<id>]",
5414 "Disable a stop-hook.",
"target stop-hook disable")));
5417 interpreter,
true,
"target stop-hook enable [<id>]",
5418 "Enable a stop-hook.",
"target stop-hook enable")));
5426#pragma mark CommandObjectTargetHookAdd
5428#define LLDB_OPTIONS_target_hook_add
5429#include "CommandOptions.inc"
5440 return llvm::ArrayRef(g_target_hook_add_options);
5446 const int short_option =
5447 g_target_hook_add_options[option_idx].short_option;
5448 switch (short_option) {
5467 uint32_t thread_index;
5468 if (option_arg.getAsInteger(0, thread_index))
5470 option_arg.str().c_str());
5478 if (option_arg.getAsInteger(0, thread_id))
5480 option_arg.str().c_str());
5500 if (option_arg.getAsInteger(0, line))
5502 "invalid start line number '%s'", option_arg.str().c_str());
5510 if (option_arg.getAsInteger(0, line))
5512 "invalid end line number '%s'", option_arg.str().c_str());
5527 bool value, success;
5533 "invalid boolean value '%s' passed for -G option",
5534 option_arg.str().c_str());
5538 bool value, success;
5544 "invalid boolean value '%s' passed for -I option",
5545 option_arg.str().c_str());
5549 llvm_unreachable(
"unhandled option");
5601 interpreter,
"target hook add",
5602 "Add a hook to be executed on target lifecycle events.",
5603 "target hook add", eCommandAllowsDummyTarget),
5610 Specify which triggers the hook responds to with --on-load (-L),
5611 --on-unload (-u), and/or --on-stop (-S). At least one trigger is required.
5612 Provide commands with --one-liner (-o), or omit -o to enter an interactive
5613 command editor. All commands run for every trigger the hook is signed up
5614 for; there is no per-trigger command list.
5617 target hook add -L -o "script print('module loaded')"
5618 target hook add -L -u -o "script print('module event')"
5619 target hook add -S -o "bt"
5620 target hook add -L -u -S -o "script print('all events')"
5621 target hook add -S -s mylib.so -n main -o "bt"
5622 target hook add -S -G true -o "thread info"
5626 Provide a Python class with --python-class (-P). The class controls which
5627 events it handles by implementing the corresponding methods; you do not
5628 specify triggers on the command line. Use -k <key> -v <value> to pass
5629 extra_args to the class constructor.
5632 target hook add -P mymodule.MyHook
5633 target hook add -P mymodule.MyHook -k verbose -v true
5635 The Python class should implement at least one of these methods:
5638 def __init__(self, target, extra_args, internal_dict):
5639 self.target = target
5640 def handle_module_loaded(self, stream):
5642 def handle_module_unloaded(self, stream):
5644 def handle_stop(self, exe_ctx, stream):
5645 return True # True = should_stop, False = continue
5649 Filters (-s, -f, -l, -e, -c, -n, -x, -t, -T, -q) restrict when the hook
5650 fires. They apply to both command-based and Python class hooks.
5673 "Enter your hook command(s). Type 'DONE' to end.\n");
5679 std::string &line)
override {
5684 LockedStreamFile locked_stream = error_sp->Lock();
5685 locked_stream.
Printf(
"error: hook #%" PRIu64
5686 " aborted, no commands.\n",
5691 auto *hook =
static_cast<Target::HookCommandLine *
>(
m_hook_sp.get());
5692 hook->SetActionFromString(line);
5695 LockedStreamFile locked_stream = output_sp->Lock();
5696 locked_stream.
Printf(
"Hook #%" PRIu64
" added.\n",
5705 void DoExecute(Args &command, CommandReturnObject &result)
override {
5708 assert(target &&
"target guaranteed by eCommandRequiresTarget");
5714 result.
AppendError(
"at least one trigger must be specified: "
5715 "--on-load (-L), --on-unload (-u), or --on-stop (-S)");
5720 is_python_class ? Target::Hook::HookKind::ScriptBased
5721 : Target::Hook::HookKind::CommandBased;
5725 if (!is_python_class) {
5728 static_cast<Target::HookCommandLine *
>(new_hook_sp.get());
5729 uint32_t trigger_mask = 0;
5736 cmd_hook->SetTriggerMask(trigger_mask);
5744 std::make_unique<SymbolContextSpecifier>(target->shared_from_this());
5747 specifier_up->AddSpecification(
5752 specifier_up->AddSpecification(
5757 specifier_up->AddSpecification(
m_options.m_file_name.c_str(),
5761 specifier_up->AddLineSpecification(
5766 specifier_up->AddLineSpecification(
5770 specifier_up->AddSpecification(
5774 new_hook_sp->SetSCSpecifier(specifier_up.release());
5779 ThreadSpec *thread_spec =
new ThreadSpec();
5793 new_hook_sp->SetThreadSpecifier(thread_spec);
5803 new_hook_sp->GetID());
5805 auto *hook =
static_cast<Target::HookScripted *
>(new_hook_sp.get());
5806 ScriptedMetadata scripted_metadata(
5809 Status callback_error = hook->SetScriptCallback(scripted_metadata);
5810 if (callback_error.
Fail()) {
5817 new_hook_sp->GetID());
5833#pragma mark CommandObjectTargetHookDelete
5839 "target hook delete [<id>]",
5840 eCommandAllowsDummyTarget) {
5849 assert(target &&
"target guaranteed by eCommandRequiresTarget");
5877#pragma mark CommandObjectTargetHookEnableDisable
5882 bool enable,
const char *name,
5883 const char *help,
const char *syntax)
5885 eCommandAllowsDummyTarget),
5895 assert(target &&
"target guaranteed by eCommandRequiresTarget");
5923#pragma mark CommandObjectTargetHookModify
5925#define LLDB_OPTIONS_target_hook_modify
5926#include "CommandOptions.inc"
5938 return llvm::ArrayRef(g_target_hook_modify_options);
5944 const int short_option =
5945 g_target_hook_modify_options[option_idx].short_option;
5946 switch (short_option) {
5954 llvm_unreachable(
"unhandled option");
5970 "Modify trigger settings on a hook.",
5971 "target hook modify [--enable-trigger <name>] "
5972 "[--disable-trigger <name>] [<id>]",
5973 eCommandAllowsDummyTarget) {
5976Modify trigger settings on command-based hooks. Scripted hooks derive their
5977triggers from the class methods and cannot be modified.
5979If no hook ID is given, the last added hook is modified.
5981Valid trigger names: load, unload, stop.
5984 target hook modify --enable-trigger stop 1
5985 target hook modify --disable-trigger load 1
5986 target hook modify --enable-trigger stop (modifies last added hook)
5998 if (name ==
"unload")
6007 assert(target &&
"target guaranteed by eCommandRequiresTarget");
6010 result.
AppendError(
"at least one of --enable-trigger or "
6011 "--disable-trigger must be specified");
6019 if (num_hooks == 0) {
6040 if (hook_sp->GetHookKind() != Target::Hook::HookKind::CommandBased) {
6041 result.
AppendError(
"cannot modify triggers on a scripted hook; "
6042 "triggers are determined by the class methods");
6045 auto *cmd_hook =
static_cast<Target::HookCommandLine *
>(hook_sp.get());
6047 if (!
m_options.m_enable_trigger.empty()) {
6051 "Valid names: load, unload, stop",
6055 cmd_hook->AddTrigger(trigger);
6058 if (!
m_options.m_disable_trigger.empty()) {
6062 "Valid names: load, unload, stop",
6066 cmd_hook->RemoveTrigger(trigger);
6076#pragma mark CommandObjectTargetHookList
6082 "target hook list", eCommandAllowsDummyTarget) {}
6089 assert(target &&
"target guaranteed by eCommandRequiresTarget");
6091 if (num_hooks == 0) {
6094 for (
size_t i = 0; i < num_hooks; i++) {
6105#pragma mark CommandObjectMultiwordTargetHooks
6111 interpreter,
"target hook",
6112 "Commands for operating on target hooks.",
6113 "target hook <subcommand> [<subcommand-options>]") {
6120 interpreter,
false,
"target hook disable",
6121 "Disable a hook.",
"target hook disable [<id> ...]")));
6124 interpreter,
true,
"target hook enable",
6125 "Enable a hook.",
"target hook enable [<id> ...]")));
6135#pragma mark CommandObjectTargetDumpTypesystem
6142 interpreter,
"target dump typesystem",
6143 "Dump the state of the target's internal type system. Intended to "
6144 "be used for debugging LLDB itself.",
6145 nullptr, eCommandRequiresTarget) {}
6161#pragma mark CommandObjectTargetDumpSectionLoadList
6168 interpreter,
"target dump section-load-list",
6169 "Dump the state of the target's internal section load list. "
6170 "Intended to be used for debugging LLDB itself.",
6171 nullptr, eCommandRequiresTarget) {}
6178 assert(target &&
"target guaranteed by eCommandRequiresTarget");
6184#pragma mark CommandObjectTargetDump
6192 interpreter,
"target dump",
6193 "Commands for dumping information about the target.",
6194 "target dump [typesystem|section-load-list]") {
6206#pragma mark CommandObjectTargetFrameProvider
6208#define LLDB_OPTIONS_target_frame_provider_register
6209#include "CommandOptions.inc"
6215 interpreter,
"target frame-provider register",
6216 "Register frame provider for all threads in this target.", nullptr,
6217 eCommandRequiresTarget),
6230 uint32_t index)
override {
6231 return std::string(
"");
6257 result.
SetError(id_or_err.takeError());
6262 "successfully registered scripted frame provider '{0}' for target",
6275 interpreter,
"target frame-provider clear",
6276 "Clear all registered frame providers from this target.", nullptr,
6277 eCommandRequiresTarget) {}
6299 interpreter,
"target frame-provider list",
6300 "List all registered frame providers for the target.", nullptr,
6301 eCommandRequiresTarget) {}
6312 if (descriptors.empty()) {
6313 result.
AppendMessage(
"no frame providers registered for this target.");
6319 strm << llvm::formatv(
"{0} frame provider(s) registered:\n\n",
6320 descriptors.size());
6322 for (
const auto &entry : descriptors) {
6324 descriptor.
Dump(&strm);
6336 interpreter,
"target frame-provider remove",
6337 "Remove a registered frame provider from the target by id.",
6338 "target frame-provider remove <provider-id>",
6339 eCommandRequiresTarget) {
6351 std::vector<uint32_t> removed_provider_ids;
6353 uint32_t provider_id = 0;
6354 if (!llvm::to_integer(command[i].ref(), provider_id)) {
6355 result.
AppendError(
"target frame-provider remove requires integer "
6356 "provider id argument");
6362 "no frame provider named '%u' found in target", provider_id);
6365 removed_provider_ids.push_back(provider_id);
6368 if (
size_t num_removed_providers = removed_provider_ids.size()) {
6370 "Successfully removed {0} frame-providers.", num_removed_providers);
6373 result.
AppendError(
"0 frame providers removed.\n");
6382 interpreter,
"target frame-provider",
6383 "Commands for registering and viewing frame providers for the "
6385 "target frame-provider [<sub-command-options>] ") {
6403#pragma mark CommandObjectMultiwordTarget
6410 "Commands for operating on debugger targets.",
6411 "target <subcommand> [<subcommand-options>]") {
static bool GetSeparateDebugInfoList(StructuredData::Array &list, Module *module, bool errors_only, bool load_all_debug_info)
static uint32_t DumpTargetList(TargetList &target_list, bool show_stopped_process_status, Stream &strm)
static void DumpModuleUUID(Stream &strm, Module *module)
static void DumpModuleSections(CommandInterpreter &interpreter, Stream &strm, Module *module)
static void DumpModuleArchitecture(Stream &strm, Module *module, bool full_triple, uint32_t width)
static bool LookupAddressInModule(CommandInterpreter &interpreter, Stream &strm, Module *module, uint32_t resolve_mask, lldb::addr_t raw_addr, lldb::addr_t offset, bool verbose, bool all_ranges)
static void DumpTargetInfo(uint32_t target_idx, Target *target, const char *prefix_cstr, bool show_stopped_process_status, Stream &strm)
static void DumpDirectory(Stream &strm, const FileSpec *file_spec_ptr, uint32_t width)
static uint32_t LookupSymbolInModule(CommandInterpreter &interpreter, Stream &strm, Module *module, const char *name, bool name_is_regex, bool verbose, bool all_ranges)
static size_t LookupTypeInModule(Target *target, CommandInterpreter &interpreter, Stream &strm, Module *module, const char *name_cstr, bool name_is_regex)
static bool DumpModuleSymbolFile(Stream &strm, Module *module)
static void DumpFullpath(Stream &strm, const FileSpec *file_spec_ptr, uint32_t width)
static llvm::StringRef GetTargetGroupRoleName(TargetGroup::Role role)
static void DumpDwoFilesTable(Stream &strm, StructuredData::Array &dwo_listings)
static size_t LookupFunctionInModule(CommandInterpreter &interpreter, Stream &strm, Module *module, const char *name, bool name_is_regex, const ModuleFunctionSearchOptions &options, bool verbose, bool all_ranges)
static size_t LookupTypeHere(Target *target, CommandInterpreter &interpreter, Stream &strm, Module &module, const char *name_cstr, bool name_is_regex)
static uint32_t DumpCompileUnitLineTable(CommandInterpreter &interpreter, Stream &strm, Module *module, const FileSpec &file_spec, lldb::DescriptionLevel desc_level)
static void DumpBasename(Stream &strm, const FileSpec *file_spec_ptr, uint32_t width)
static size_t DumpModuleObjfileHeaders(Stream &strm, ModuleList &module_list)
static uint32_t LookupFileAndLineInModule(CommandInterpreter &interpreter, Stream &strm, Module *module, const FileSpec &file_spec, uint32_t line, bool check_inlines, bool verbose, bool all_ranges)
static void DumpSymbolContextList(ExecutionContextScope *exe_scope, Stream &strm, const SymbolContextList &sc_list, bool verbose, bool all_ranges, std::optional< Stream::HighlightSettings > settings=std::nullopt)
static void DumpOsoFilesTable(Stream &strm, StructuredData::Array &oso_listings)
static size_t FindModulesByName(Target *target, const char *module_name, ModuleList &module_list, bool check_global_list)
static void DumpModuleSymtab(CommandInterpreter &interpreter, Stream &strm, Module *module, SortOrder sort_order, Mangled::NamePreference name_preference)
static llvm::raw_ostream & error(Stream &strm)
#define INTERRUPT_REQUESTED(debugger,...)
This handy define will keep you from having to generate a report for the interruption by hand.
#define LLDB_LOGF(log,...)
#define LLDB_SCOPED_TIMERF(...)
CommandObjectMultiwordTargetHooks(CommandInterpreter &interpreter)
~CommandObjectMultiwordTargetHooks() override=default
~CommandObjectMultiwordTargetStopHooks() override=default
CommandObjectMultiwordTargetStopHooks(CommandInterpreter &interpreter)
OptionGroupString m_label
OptionGroupPlatform m_platform_options
~CommandObjectTargetCreate() override=default
Options * GetOptions() override
OptionGroupFile m_symbol_file
OptionGroupFile m_remote_file
OptionGroupOptions m_option_group
OptionGroupArchitecture m_arch_option
CommandObjectTargetCreate(CommandInterpreter &interpreter)
OptionGroupDependents m_add_dependents
OptionGroupFile m_core_file
void DoExecute(Args &command, CommandReturnObject &result) override
OptionGroupBoolean m_cleanup_option
OptionGroupOptions m_option_group
void DoExecute(Args &args, CommandReturnObject &result) override
CommandObjectTargetDelete(CommandInterpreter &interpreter)
OptionGroupBoolean m_all_option
~CommandObjectTargetDelete() override=default
Options * GetOptions() override
Dumps the SectionLoadList of the selected Target.
void DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectTargetDumpSectionLoadList() override=default
CommandObjectTargetDumpSectionLoadList(CommandInterpreter &interpreter)
Dumps the TypeSystem of the selected Target.
CommandObjectTargetDumpTypesystem(CommandInterpreter &interpreter)
~CommandObjectTargetDumpTypesystem() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
Multi-word command for 'target dump'.
CommandObjectTargetDump(CommandInterpreter &interpreter)
~CommandObjectTargetDump() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectTargetFrameProviderClear(CommandInterpreter &interpreter)
~CommandObjectTargetFrameProviderClear() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectTargetFrameProviderList() override=default
CommandObjectTargetFrameProviderList(CommandInterpreter &interpreter)
OptionGroupPythonClassWithDict m_class_options
~CommandObjectTargetFrameProviderRegister() override=default
Options * GetOptions() override
OptionGroupOptions m_all_options
CommandObjectTargetFrameProviderRegister(CommandInterpreter &interpreter)
std::optional< std::string > GetRepeatCommand(Args ¤t_command_args, uint32_t index) override
Get the command that appropriate for a "repeat" of the current command.
void DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectTargetFrameProviderRemove() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectTargetFrameProviderRemove(CommandInterpreter &interpreter)
~CommandObjectTargetFrameProvider() override=default
CommandObjectTargetFrameProvider(CommandInterpreter &interpreter)
OptionGroupOptions m_option_group
OptionGroupUInt64 m_target_option
Options * GetOptions() override
void DoExecute(Args &args, CommandReturnObject &result) override
CommandObjectTargetGroupsList(CommandInterpreter &interpreter)
~CommandObjectTargetGroupsList() override=default
~CommandObjectTargetGroups() override=default
CommandObjectTargetGroups(CommandInterpreter &interpreter)
std::string m_thread_name
std::string m_function_name
std::string m_module_name
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
void OptionParsingStarting(ExecutionContext *execution_context) override
std::vector< std::string > m_one_liner
~CommandOptions() override=default
CommandObjectTargetHookAdd(CommandInterpreter &interpreter)
void DoExecute(Args &command, CommandReturnObject &result) override
OptionGroupOptions m_all_options
OptionGroupPythonClassWithDict m_python_class_options
void IOHandlerInputComplete(IOHandler &io_handler, std::string &line) override
Called when a line or lines have been retrieved.
~CommandObjectTargetHookAdd() override=default
Options * GetOptions() override
void IOHandlerActivated(IOHandler &io_handler, bool interactive) override
CommandObjectTargetHookDelete(CommandInterpreter &interpreter)
~CommandObjectTargetHookDelete() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectTargetHookEnableDisable() override=default
CommandObjectTargetHookEnableDisable(CommandInterpreter &interpreter, bool enable, const char *name, const char *help, const char *syntax)
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectTargetHookList(CommandInterpreter &interpreter)
void DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectTargetHookList() override=default
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
~CommandOptions() override=default
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
void OptionParsingStarting(ExecutionContext *execution_context) override
std::string m_enable_trigger
std::string m_disable_trigger
Modify trigger settings on a hook.
void DoExecute(Args &command, CommandReturnObject &result) override
Options * GetOptions() override
static uint32_t ParseTriggerName(llvm::StringRef name)
CommandObjectTargetHookModify(CommandInterpreter &interpreter)
~CommandObjectTargetHookModify() override=default
CommandObjectTargetList(CommandInterpreter &interpreter)
void DoExecute(Args &args, CommandReturnObject &result) override
~CommandObjectTargetList() override=default
OptionGroupOptions m_option_group
OptionGroupFile m_symbol_file
CommandObjectTargetModulesAdd(CommandInterpreter &interpreter)
void DoExecute(Args &args, CommandReturnObject &result) override
OptionGroupUUID m_uuid_option_group
~CommandObjectTargetModulesAdd() override=default
Options * GetOptions() override
CommandObjectTargetModulesDumpClangAST(CommandInterpreter &interpreter)
Options * GetOptions() override
void DoExecute(Args &command, CommandReturnObject &result) override
OptionGroupString m_filter
~CommandObjectTargetModulesDumpClangAST() override=default
OptionGroupOptions m_option_group
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
void OptionParsingStarting(ExecutionContext *execution_context) override
~CommandObjectTargetModulesDumpLineTable() override=default
Options * GetOptions() override
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectTargetModulesDumpLineTable(CommandInterpreter &interpreter)
void DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectTargetModulesDumpObjfile() override=default
CommandObjectTargetModulesDumpObjfile(CommandInterpreter &interpreter)
CommandObjectTargetModulesDumpSections(CommandInterpreter &interpreter)
~CommandObjectTargetModulesDumpSections() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
void OptionParsingStarting(ExecutionContext *execution_context) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
~CommandOptions() override=default
OptionValueBoolean m_errors_only
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
OptionValueBoolean m_json
OptionValueBoolean m_load_all_debug_info
~CommandObjectTargetModulesDumpSeparateDebugInfoFiles() override=default
CommandObjectTargetModulesDumpSeparateDebugInfoFiles(CommandInterpreter &interpreter)
void DoExecute(Args &command, CommandReturnObject &result) override
Options * GetOptions() override
CommandObjectTargetModulesDumpSymfile(CommandInterpreter &interpreter)
~CommandObjectTargetModulesDumpSymfile() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
void OptionParsingStarting(ExecutionContext *execution_context) override
~CommandOptions() override=default
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
OptionValueBoolean m_prefer_mangled
Options * GetOptions() override
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectTargetModulesDumpSymtab(CommandInterpreter &interpreter)
~CommandObjectTargetModulesDumpSymtab() override=default
~CommandObjectTargetModulesDump() override=default
CommandObjectTargetModulesDump(CommandInterpreter &interpreter)
CommandObjectTargetModulesImageSearchPaths(CommandInterpreter &interpreter)
~CommandObjectTargetModulesImageSearchPaths() override=default
bool m_use_global_module_list
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
void OptionParsingStarting(ExecutionContext *execution_context) override
FormatWidthCollection m_format_array
std::vector< std::pair< char, uint32_t > > FormatWidthCollection
~CommandOptions() override=default
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
lldb::addr_t m_module_addr
CommandObjectTargetModulesList(CommandInterpreter &interpreter)
~CommandObjectTargetModulesList() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
void PrintModule(Target &target, Module *module, int indent, Stream &strm)
Options * GetOptions() override
OptionGroupBoolean m_pc_option
OptionGroupUInt64 m_slide_option
OptionGroupBoolean m_load_option
void DoExecute(Args &args, CommandReturnObject &result) override
Options * GetOptions() override
OptionGroupUUID m_uuid_option_group
~CommandObjectTargetModulesLoad() override=default
OptionGroupOptions m_option_group
CommandObjectTargetModulesLoad(CommandInterpreter &interpreter)
OptionGroupString m_file_option
~CommandOptions() override=default
void OptionParsingStarting(ExecutionContext *execution_context) override
Status OptionParsingFinished(ExecutionContext *execution_context) override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
bool LookupInModule(CommandInterpreter &interpreter, Module *module, CommandReturnObject &result, bool &syntax_error)
Options * GetOptions() override
@ eLookupTypeFunctionOrSymbol
~CommandObjectTargetModulesLookup() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
bool LookupHere(CommandInterpreter &interpreter, CommandReturnObject &result, bool &syntax_error)
CommandObjectTargetModulesLookup(CommandInterpreter &interpreter)
CommandObjectTargetModulesModuleAutoComplete(CommandInterpreter &interpreter, const char *name, const char *help, const char *syntax, uint32_t flags=0)
~CommandObjectTargetModulesModuleAutoComplete() override=default
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
~CommandObjectTargetModulesSearchPathsAdd() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectTargetModulesSearchPathsAdd(CommandInterpreter &interpreter)
void DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectTargetModulesSearchPathsClear() override=default
CommandObjectTargetModulesSearchPathsClear(CommandInterpreter &interpreter)
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
~CommandObjectTargetModulesSearchPathsInsert() override=default
CommandObjectTargetModulesSearchPathsInsert(CommandInterpreter &interpreter)
void DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectTargetModulesSearchPathsList() override=default
CommandObjectTargetModulesSearchPathsList(CommandInterpreter &interpreter)
void DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectTargetModulesSearchPathsQuery() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectTargetModulesSearchPathsQuery(CommandInterpreter &interpreter)
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
void OptionParsingStarting(ExecutionContext *execution_context) override
~CommandOptions() override=default
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
@ eLookupTypeFunctionOrSymbol
CommandObjectTargetModulesShowUnwind(CommandInterpreter &interpreter)
void DoExecute(Args &command, CommandReturnObject &result) override
Options * GetOptions() override
~CommandObjectTargetModulesShowUnwind() override=default
CommandObjectTargetModulesSourceFileAutoComplete(CommandInterpreter &interpreter, const char *name, const char *help, const char *syntax, uint32_t flags)
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
~CommandObjectTargetModulesSourceFileAutoComplete() override=default
~CommandObjectTargetModules() override=default
const CommandObjectTargetModules & operator=(const CommandObjectTargetModules &)=delete
CommandObjectTargetModules(const CommandObjectTargetModules &)=delete
CommandObjectTargetModules(CommandInterpreter &interpreter)
~CommandObjectTargetSelect() override=default
void DoExecute(Args &args, CommandReturnObject &result) override
CommandObjectTargetSelect(CommandInterpreter &interpreter)
CommandObjectTargetShowLaunchEnvironment(CommandInterpreter &interpreter)
void DoExecute(Args &args, CommandReturnObject &result) override
~CommandObjectTargetShowLaunchEnvironment() override=default
uint32_t m_func_name_type_mask
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
std::string m_function_name
std::vector< std::string > m_one_liner
~CommandOptions() override=default
std::string m_thread_name
void OptionParsingStarting(ExecutionContext *execution_context) override
std::string m_module_name
OptionGroupOptions m_all_options
Target::StopHookSP m_stop_hook_sp
void IOHandlerActivated(IOHandler &io_handler, bool interactive) override
CommandObjectTargetStopHookAdd(CommandInterpreter &interpreter)
void IOHandlerInputComplete(IOHandler &io_handler, std::string &line) override
Called when a line or lines have been retrieved.
~CommandObjectTargetStopHookAdd() override=default
Options * GetOptions() override
OptionGroupPythonClassWithDict m_python_class_options
void DoExecute(Args &command, CommandReturnObject &result) override
void DoExecute(Args &command, CommandReturnObject &result) override
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
CommandObjectTargetStopHookDelete(CommandInterpreter &interpreter)
~CommandObjectTargetStopHookDelete() override=default
~CommandObjectTargetStopHookEnableDisable() override=default
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectTargetStopHookEnableDisable(CommandInterpreter &interpreter, bool enable, const char *name, const char *help, const char *syntax)
~CommandOptions() override=default
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
void OptionParsingStarting(ExecutionContext *execution_context) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
void DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectTargetStopHookList() override=default
Options * GetOptions() override
CommandObjectTargetStopHookList(CommandInterpreter &interpreter)
bool AddSymbolsForUUID(CommandReturnObject &result, bool &flush)
bool DownloadObjectAndSymbolFile(ModuleSpec &module_spec, CommandReturnObject &result, bool &flush)
bool AddSymbolsForStack(CommandReturnObject &result, bool &flush)
OptionGroupBoolean m_current_stack_option
OptionGroupBoolean m_current_frame_option
CommandObjectTargetSymbolsAdd(CommandInterpreter &interpreter)
bool AddSymbolsForFrame(CommandReturnObject &result, bool &flush)
OptionGroupOptions m_option_group
~CommandObjectTargetSymbolsAdd() override=default
Options * GetOptions() override
void DoExecute(Args &args, CommandReturnObject &result) override
OptionGroupFile m_file_option
OptionGroupUUID m_uuid_option_group
bool AddModuleSymbols(Target *target, ModuleSpec &module_spec, bool &flush, CommandReturnObject &result)
bool AddSymbolsForFile(CommandReturnObject &result, bool &flush)
const CommandObjectTargetSymbols & operator=(const CommandObjectTargetSymbols &)=delete
CommandObjectTargetSymbols(CommandInterpreter &interpreter)
~CommandObjectTargetSymbols() override=default
CommandObjectTargetSymbols(const CommandObjectTargetSymbols &)=delete
OptionGroupFormat m_option_format
void DumpGlobalVariableList(const ExecutionContext &exe_ctx, const SymbolContext &sc, const VariableList &variable_list, CommandReturnObject &result)
void DumpValueObject(Stream &s, VariableSP &var_sp, ValueObjectSP &valobj_sp, const char *root_name)
static size_t GetVariableCallback(void *baton, const char *name, VariableList &variable_list)
static const uint32_t SHORT_OPTION_SHLB
CommandObjectTargetVariable(CommandInterpreter &interpreter)
OptionGroupFileList m_option_shared_libraries
void DoExecute(Args &args, CommandReturnObject &result) override
Options * GetOptions() override
OptionGroupFileList m_option_compile_units
static const uint32_t SHORT_OPTION_FILE
OptionGroupVariable m_option_variable
OptionGroupValueObjectDisplay m_varobj_options
OptionGroupOptions m_option_group
~CommandObjectTargetVariable() override=default
~OptionGroupDependents() override=default
OptionGroupDependents()=default
LoadDependentFiles m_load_dependent_files
OptionGroupDependents(const OptionGroupDependents &)=delete
const OptionGroupDependents & operator=(const OptionGroupDependents &)=delete
void OptionParsingStarting(ExecutionContext *execution_context) override
Status SetOptionValue(uint32_t, const char *, ExecutionContext *)=delete
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, ExecutionContext *execution_context) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
virtual lldb::addr_t FixCodeAddress(lldb::addr_t pc)
Some targets might use bits in a code address to indicate a mode switch.
A section + offset based address class.
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
bool SetLoadAddress(lldb::addr_t load_addr, Target *target, bool allow_section_end=false)
Set the address to represent load_addr.
@ DumpStyleFileAddress
Display as the file address (if any).
@ DumpStyleSectionNameOffset
Display as the section name + offset.
@ DumpStyleDetailedSymbolContext
Detailed symbol context information for an address for all symbol context members.
@ DumpStyleInvalid
Invalid dump style.
@ DumpStyleModuleWithFileAddress
Display as the file address with the module name prepended (if any).
@ DumpStyleResolvedDescription
Display the details about what an address resolves to.
bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, DumpStyle fallback_style=DumpStyleInvalid, uint32_t addr_byte_size=UINT32_MAX, bool all_ranges=false, std::optional< Stream::HighlightSettings > settings=std::nullopt) const
Dump a description of this object to a Stream.
lldb::ModuleSP GetModule() const
Get accessor for the module for this address.
lldb::addr_t GetFileAddress() const
Get the file address.
bool IsValid() const
Check if the object state is valid.
An architecture specification class.
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
bool IsValid() const
Tests if this ArchSpec is valid.
void DumpTriple(llvm::raw_ostream &s) const
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
A command line argument class.
void Shift()
Shifts the first argument C string value of the array off the argument array.
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
llvm::ArrayRef< ArgEntry > entries() const
const char * GetArgumentAtIndex(size_t idx) const
Gets the null-terminated C string argument pointer for the argument at index idx.
static bool InvokeCommonCompletionCallbacks(CommandInterpreter &interpreter, uint32_t completion_mask, lldb_private::CompletionRequest &request, SearchFilter *searcher)
bool Confirm(llvm::StringRef message, bool default_answer)
ExecutionContext GetExecutionContext(bool adopt_dummy_target=true) const
Returns the execution context the interpreter should run a command in.
CommandObjectMultiwordTarget(CommandInterpreter &interpreter)
~CommandObjectMultiwordTarget() override
bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override
CommandObjectMultiword(CommandInterpreter &interpreter, const char *name, const char *help=nullptr, const char *syntax=nullptr, uint32_t flags=0)
friend class CommandInterpreter
CommandObjectParsed(CommandInterpreter &interpreter, const char *name, const char *help=nullptr, const char *syntax=nullptr, uint32_t flags=0)
std::vector< CommandArgumentData > CommandArgumentEntry
virtual void SetHelpLong(llvm::StringRef str)
void AddSimpleArgumentList(lldb::CommandArgumentType arg_type, ArgumentRepetitionType repetition_type=eArgRepeatPlain)
ExecutionContext m_exe_ctx
virtual const char * GetInvalidTargetDescription()
std::vector< CommandArgumentEntry > m_arguments
CommandInterpreter & GetCommandInterpreter()
CommandInterpreter & m_interpreter
virtual void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector)
The default version handles argument definitions that have only one argument type,...
Target * GetTarget()
Get the target this command should operate on.
void AppendMessage(llvm::StringRef in_string)
void AppendError(llvm::StringRef in_string)
const ValueObjectList & GetValueObjectList() const
void AppendWarningWithFormatv(const char *format, Args &&...args)
Stream & GetErrorStream()
void SetStatus(lldb::ReturnStatus status)
void SetError(Status error)
void AppendErrorWithFormat(const char *format,...) __attribute__((format(printf
void void AppendMessageWithFormatv(const char *format, Args &&...args)
lldb::ReturnStatus GetStatus() const
void AppendWarning(llvm::StringRef in_string)
void AppendErrorWithFormatv(const char *format, Args &&...args)
Stream & GetOutputStream()
A class that describes a compilation unit.
lldb::VariableListSP GetVariableList(bool can_create)
Get the variable list for a compile unit.
const FileSpec & GetPrimaryFile() const
Return the primary source spec associated with this compile unit.
"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.
size_t GetCursorIndex() const
A uniqued constant string class.
bool IsEmpty() const
Test for empty string.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
const char * GetCString() const
Get the string value as a C string.
A class to manage flag bits.
TargetList & GetTargetList()
Get accessor for the target list.
TargetGroupList & GetTargetGroupList()
llvm::StringRef GetRegexMatchAnsiSuffix() const
Target & GetDummyTarget()
llvm::StringRef GetRegexMatchAnsiPrefix() const
ScriptInterpreter * GetScriptInterpreter(bool can_create=true, std::optional< lldb::ScriptLanguage > language={})
DumpValueObjectOptions & SetRootValueObjectName(const char *name=nullptr)
DumpValueObjectOptions & SetFormat(lldb::Format format=lldb::eFormatDefault)
A class that measures elapsed time in an exception safe way.
"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.
ExecutionContextScope * GetBestExecutionContextScope() const
Target * GetTargetPtr() const
Returns a pointer to the target object.
const FileSpec & GetFileSpecAtIndex(size_t idx) const
Get file at index.
size_t GetSize() const
Get the number of files in the file list.
void SetFile(llvm::StringRef path, Style style)
Change the file specified with a new path.
llvm::StringRef GetFileNameStrippingExtension() const
Return the filename without the extension part.
void SetFilename(llvm::StringRef filename)
Filename string set accessor.
llvm::StringRef GetFilename() const
Filename string const get accessor.
llvm::StringRef GetDirectory() const
Directory string const get accessor.
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
void SetDirectory(llvm::StringRef directory)
Directory string set accessor.
void Dump(llvm::raw_ostream &s) const
Dump this object to a Stream.
bool ResolveExecutableLocation(FileSpec &file_spec)
Call into the Host to see if it can help find the file.
bool Exists(const FileSpec &file_spec) const
Returns whether the given file exists.
int Open(const char *path, int flags, int mode=0600)
Wraps open in a platform-independent way.
static FileSystem & Instance()
void Resolve(llvm::SmallVectorImpl< char > &path, bool force_make_absolute=false)
Resolve path to make it canonical.
IOHandlerDelegateMultiline(llvm::StringRef end_line, Completion completion=Completion::None)
A delegate class for use with IOHandler subclasses.
lldb::LockableStreamFileSP GetErrorStreamFileSP()
lldb::LockableStreamFileSP GetOutputStreamFileSP()
void GetDescription(Stream *s, Target *target, lldb::DescriptionLevel level)
A collection class for Module objects.
void FindFunctions(ConstString name, lldb::FunctionNameType name_type_mask, const ModuleFunctionSearchOptions &options, SymbolContextList &sc_list) const
ModuleIterableNoLocking ModulesNoLocking() const
static bool ModuleIsInCache(const Module *module_ptr)
void FindGlobalVariables(ConstString name, size_t max_matches, VariableList &variable_list) const
Find global and static variables by name.
std::recursive_mutex & GetMutex() const
lldb::ModuleSP FindFirstModule(const ModuleSpec &module_spec) const
Finds the first module whose file specification matches module_spec.
lldb::ModuleSP GetModuleAtIndexUnlocked(size_t idx) const
Get the module shared pointer for the module at index idx without acquiring the ModuleList mutex.
void FindCompileUnits(const FileSpec &path, SymbolContextList &sc_list) const
Find compile units by partial or full path.
bool AppendIfNeeded(const lldb::ModuleSP &new_module, bool notify=true)
Append a module to the module list, if it is not already there.
Module * GetModulePointerAtIndex(size_t idx) const
Get the module pointer for the module at index idx.
void FindModules(const ModuleSpec &module_spec, ModuleList &matching_module_list) const
Finds modules whose file specification matches module_spec.
lldb::ModuleSP GetModuleAtIndex(size_t idx) const
Get the module shared pointer for the module at index idx.
void Append(const lldb::ModuleSP &module_sp, bool notify=true)
Append a module to the module list.
static size_t RemoveOrphanSharedModules(bool mandatory)
static void FindSharedModules(const ModuleSpec &module_spec, ModuleList &matching_module_list)
bool LoadScriptingResourcesInTarget(Target *target, std::list< Status > &errors, bool continue_on_error=true)
ModuleIterable Modules() const
size_t GetSize() const
Gets the size of the module list.
bool GetModuleSpecAtIndex(size_t i, ModuleSpec &module_spec) const
bool FindMatchingModuleSpec(const ModuleSpec &module_spec, ModuleSpec &match_module_spec) const
FileSpec & GetPlatformFileSpec()
ArchSpec & GetArchitecture()
FileSpec * GetFileSpecPtr()
FileSpec & GetSymbolFileSpec()
A class that describes an executable image and its associated object and symbol files.
const lldb_private::UUID & GetUUID()
Get a reference to the UUID value contained in this object.
virtual SymbolFile * GetSymbolFile(bool can_create=true, Stream *feedback_strm=nullptr)
Get the module's symbol file.
static Module * GetAllocatedModuleAtIndex(size_t idx)
llvm::StringRef GetObjectName() const
static std::recursive_mutex & GetAllocationModuleCollectionMutex()
bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr)
Symtab * GetSymtab(bool can_create=true)
Get the module's symbol table.
bool MatchesModuleSpec(const ModuleSpec &module_ref)
static size_t GetNumberAllocatedModules()
const ArchSpec & GetArchitecture() const
Get const accessor for the module architecture.
std::string GetSpecificationDescription() const
Get the module path and object name.
const FileSpec & GetFileSpec() const
Get const accessor for the module file specification.
const llvm::sys::TimePoint & GetModificationTime() const
A plug-in interface definition class for object file parsers.
virtual void Dump(Stream *s)=0
Dump a description of this object to a Stream.
virtual std::vector< LoadableData > GetLoadableData(Target &target)
Loads this objfile to memory.
virtual lldb_private::Address GetEntryPointAddress()
Returns the address of the Entry Point in this object file - if the object file doesn't have an entry...
virtual FileSpec & GetFileSpec()
Get accessor to the object file specification.
static ModuleSpecList GetModuleSpecifications(const FileSpec &file, lldb::offset_t file_offset, lldb::offset_t file_size, lldb::DataExtractorSP=lldb::DataExtractorSP())
virtual lldb_private::Address GetBaseAddress()
Returns base address of this object file.
A command line option parsing protocol class.
std::vector< Option > m_getopt_table
bool RemapPath(llvm::StringRef path, std::string &new_path) const
void Insert(llvm::StringRef path, llvm::StringRef replacement, uint32_t insert_idx, bool notify)
void Append(llvm::StringRef path, llvm::StringRef replacement, bool notify)
bool GetPathsAtIndex(uint32_t idx, std::string &path, std::string &new_path) const
void Dump(Stream *s, int pair_index=-1)
static bool DownloadObjectAndSymbolFile(ModuleSpec &module_spec, Status &error, bool force_lookup=true, bool copy_executable=true)
void SetExecutableFile(const FileSpec &exe_file, bool add_exe_file_as_first_arg)
A plug-in interface definition class for debugging a process.
ThreadList & GetThreadList()
void Flush()
Flush all data in the process.
lldb::StateType GetState()
Get accessor for the current process state.
const lldb::ABISP & GetABI()
bool IsValid() const
Test if this object contains a valid regular expression.
virtual lldb::ScriptedFrameProviderInterfaceSP CreateScriptedFrameProviderInterface()
lldb::SectionSP FindSectionByName(llvm::StringRef section_name) const
void Dump(llvm::raw_ostream &s, unsigned indent, Target *target, bool show_header, uint32_t depth) const
This base class provides an interface to stack frames.
virtual const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope)
Provide a SymbolContext for this StackFrame's current pc value.
virtual uint32_t GetFrameIndex() const
Query this frame to find what frame it is in this Thread's StackFrameList.
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
static Status FromErrorString(const char *str)
bool Fail() const
Test for error condition.
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
static Status static Status FromErrorStringWithFormatv(const char *format, Args &&...args)
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)
Forwards the arguments to llvm::formatv and writes to the stream.
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
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.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
void SetIndentLevel(unsigned level)
Set the current indentation level.
void PutCStringColorHighlighted(llvm::StringRef text, std::optional< HighlightSettings > settings=std::nullopt)
Output a C string to the stream with color highlighting.
size_t EOL()
Output and End of Line character to the stream.
void IndentLess(unsigned amount=2)
Decrement the current indentation level.
void IndentMore(unsigned amount=2)
Increment the current indentation level.
unsigned GetIndentLevel() const
Get the current indentation level.
void AddItem(const ObjectSP &item)
bool ForEach(std::function< bool(Object *object)> const &foreach_callback) const
bool GetValueForKeyAsInteger(llvm::StringRef key, IntType &result) const
bool GetValueForKeyAsString(llvm::StringRef key, llvm::StringRef &result) const
bool GetValueForKeyAsArray(llvm::StringRef key, Array *&result) const
Dictionary * GetAsDictionary()
void Dump(lldb_private::Stream &s, bool pretty_print=true) const
Defines a list of symbol context objects.
uint32_t GetSize() const
Get accessor for a symbol context list size.
void Append(const SymbolContext &sc)
Append a new symbol context to the list.
@ eClassOrNamespaceSpecified
Defines a symbol context baton that can be handed other debug core functions.
Function * function
The Function for a given query.
void SortTypeList(TypeMap &type_map, TypeList &type_list) const
Sorts the types in TypeMap according to SymbolContext to TypeList.
lldb::ModuleSP module_sp
The Module for a given query.
CompileUnit * comp_unit
The CompileUnit for a given query.
Symbol * symbol
The Symbol for a given query.
Provides public interface for all SymbolFiles.
virtual ObjectFile * GetObjectFile()=0
bool ValueIsAddress() const
bool GetByteSizeIsValid() const
Address & GetAddressRef()
lldb::addr_t GetByteSize() const
ConstString GetDisplayName() const
uint64_t GetRawValue() const
Get the raw value of the symbol from the symbol table.
Symbol * SymbolAtIndex(size_t idx)
uint32_t AppendSymbolIndexesWithName(ConstString symbol_name, std::vector< uint32_t > &matches)
uint32_t AppendSymbolIndexesMatchingRegExAndType(const RegularExpression ®ex, lldb::SymbolType symbol_type, std::vector< uint32_t > &indexes, Mangled::NamePreference name_preference=Mangled::ePreferDemangled)
A thread-safe collection of target groups.
std::vector< lldb::TargetGroupSP > GetGroups() const
Return a snapshot of the target groups.
Role
Describes the part a target plays in this group.
lldb::TargetSP GetTargetAtIndex(uint32_t index) const
Status CreateTarget(Debugger &debugger, llvm::StringRef user_exe_path, llvm::StringRef triple_str, LoadDependentFiles get_dependent_modules, const OptionGroupPlatform *platform_options, lldb::TargetSP &target_sp)
Create a new Target.
uint32_t GetIndexOfTarget(lldb::TargetSP target_sp) const
void SetSelectedTarget(uint32_t index)
bool DeleteTarget(lldb::TargetSP &target_sp)
Delete a Target object from the list.
lldb::TargetSP GetSelectedTarget()
size_t GetNumTargets() const
bool GetUserSpecifiedTrapHandlerNames(Args &args) const
Environment GetEnvironment() const
void SetActionFromStrings(const std::vector< std::string > &strings)
Populate the command list from a vector of individual command strings.
void SetActionFromString(const std::string &strings)
void SetActionFromStrings(const std::vector< std::string > &strings)
Status SetScriptCallback(const ScriptedMetadata &scripted_metadata)
void ModulesDidLoad(ModuleList &module_list)
This call may preload module symbols, and may do so in parallel depending on the following target set...
llvm::Expected< uint32_t > AddScriptedFrameProviderDescriptor(const ScriptedFrameProviderDescriptor &descriptor)
Add or update a scripted frame provider descriptor for this target.
Module * GetExecutableModulePointer()
bool RemoveHookByID(lldb::user_id_t uid)
PathMappingList & GetImageSearchPathList()
size_t GetNumHooks() const
std::shared_ptr< StopHook > StopHookSP
void SymbolsDidLoad(ModuleList &module_list)
const std::vector< StopHookSP > GetStopHooks(bool internal=false) const
const llvm::MapVector< uint32_t, ScriptedFrameProviderDescriptor > & GetScriptedFrameProviderDescriptors() const
Get all scripted frame provider descriptors for this target.
bool RemoveScriptedFrameProviderDescriptor(uint32_t id)
Remove a scripted frame provider descriptor by id.
HookSP CreateHook(Hook::HookKind kind)
void DumpSectionLoadList(Stream &s)
bool SetHookEnabledStateByID(lldb::user_id_t uid, bool enabled)
const lldb::ProcessSP & GetProcessSP() const
lldb::ModuleSP GetOrCreateModule(const ModuleSpec &module_spec, bool notify, Status *error_ptr=nullptr, bool invoke_symbol_locators=true)
Find a binary on the system and return its Module, or return an existing Module that is already in th...
void UndoCreateStopHook(lldb::user_id_t uid)
If you tried to create a stop hook, and that failed, call this to remove the stop hook,...
bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr, uint32_t stop_id=SectionLoadHistory::eStopIDNow, bool allow_section_end=false)
HookSP GetHookByID(lldb::user_id_t uid)
bool SetStopHookActiveStateByID(lldb::user_id_t uid, bool active_state)
void SetAllStopHooksActiveState(bool active_state)
StopHookSP CreateStopHook(StopHook::StopHookKind kind, bool internal=false)
Add an empty stop hook to the Target's stop hook list, and returns a shared pointer to the new hook.
void SetAllHooksEnabledState(bool enabled)
void RemoveAllStopHooks()
void UndoCreateHook(lldb::user_id_t uid)
Removes the most recently created hook.
HookSP GetHookAtIndex(size_t index)
lldb::PlatformSP GetPlatform()
const ModuleList & GetImages() const
Get accessor for the images for this process.
const ArchSpec & GetArchitecture() const
bool IsDummyTarget() const
const std::string & GetLabel() const
void ClearScriptedFrameProviderDescriptors()
Clear all scripted frame provider descriptors for this target.
std::shared_ptr< Hook > HookSP
lldb::ProcessSP CalculateProcess() override
bool SetSectionLoadAddress(const lldb::SectionSP §ion, lldb::addr_t load_addr, bool warn_multiple=false)
bool RemoveStopHookByID(lldb::user_id_t uid)
lldb::ThreadSP GetSelectedThread()
uint32_t GetSize(bool can_update=true)
lldb::ThreadSP GetThreadAtIndex(uint32_t idx, bool can_update=true)
void SetIndex(uint32_t index)
void SetName(llvm::StringRef name)
void SetTID(lldb::tid_t tid)
void SetQueueName(llvm::StringRef queue_name)
lldb::TypeSP GetTypeAtIndex(uint32_t idx) const
A class that contains all state required for type lookups.
This class tracks the state and results of a TypeQuery.
void Dump(Stream &s) const
std::string GetAsString(llvm::StringRef separator="-") const
lldb::FuncUnwindersSP GetFuncUnwindersContainingAddress(const Address &addr, const SymbolContext &sc)
lldb::FuncUnwindersSP GetUncachedFuncUnwindersContainingAddress(const Address &addr, const SymbolContext &sc)
A collection of ValueObject values that.
void Append(const lldb::ValueObjectSP &val_obj_sp)
lldb::ValueObjectSP GetValueObjectAtIndex(size_t idx)
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, const lldb::VariableSP &var_sp)
lldb::VariableSP GetVariableAtIndex(size_t idx) const
static Status GetValuesForVariableExpressionPath(llvm::StringRef variable_expr_path, ExecutionContextScope *scope, GetVariableCallback callback, void *baton, VariableList &variable_list, ValueObjectList &valobj_list)
#define LLDB_OPT_SET_FROM_TO(A, B)
#define LLDB_INVALID_LINE_NUMBER
#define LLDB_INVALID_THREAD_ID
#define LLDB_INVALID_INDEX32
#define LLDB_INVALID_ADDRESS
#define LLDB_INVALID_PROCESS_ID
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.
std::vector< OptionArgElement > OptionElementVector
bool StateIsStoppedState(lldb::StateType state, bool must_exist)
Check if a state represents a state where the process or thread is stopped.
void DumpAddress(llvm::raw_ostream &s, uint64_t addr, uint32_t addr_size, const char *prefix=nullptr, const char *suffix=nullptr)
Output an address value to this stream.
const char * StateAsCString(lldb::StateType state)
Converts a StateType to a C string.
std::string toString(FormatterBytecode::OpCodes op)
std::shared_ptr< lldb_private::TypeSystem > TypeSystemSP
std::shared_ptr< lldb_private::ABI > ABISP
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::TargetGroup > TargetGroupSP
std::shared_ptr< lldb_private::ScriptedMetadata > ScriptedMetadataSP
std::shared_ptr< lldb_private::CommandObject > CommandObjectSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
Format
Display format definitions.
std::shared_ptr< lldb_private::Platform > PlatformSP
StateType
Process and Thread States.
std::shared_ptr< lldb_private::FuncUnwinders > FuncUnwindersSP
std::shared_ptr< lldb_private::Type > TypeSP
std::shared_ptr< lldb_private::Process > ProcessSP
@ eReturnStatusSuccessFinishResult
@ eReturnStatusSuccessFinishNoResult
@ eArgTypeUnsignedInteger
std::shared_ptr< lldb_private::VariableList > VariableListSP
std::shared_ptr< lldb_private::UnwindPlan > UnwindPlanSP
std::shared_ptr< lldb_private::Variable > VariableSP
std::shared_ptr< lldb_private::ScriptedFrameProviderInterface > ScriptedFrameProviderInterfaceSP
@ eValueTypeVariableGlobal
globals variable
@ eValueTypeVariableLocal
function local variables
@ eValueTypeVariableArgument
function argument variables
@ eValueTypeVariableStatic
static variable
@ eValueTypeVariableThreadLocal
thread local storage variable
std::shared_ptr< lldb_private::LockableStreamFile > LockableStreamFileSP
std::shared_ptr< lldb_private::Section > SectionSP
std::shared_ptr< lldb_private::Target > TargetSP
std::shared_ptr< lldb_private::RegisterContext > RegisterContextSP
std::shared_ptr< lldb_private::Module > ModuleSP
Used to build individual command argument lists.
ArgumentRepetitionType arg_repetition
lldb::CommandArgumentType arg_type
Options used by Module::FindFunctions.
bool include_inlines
Include inlined functions.
bool include_symbols
Include the symbol table.
static int64_t ToOptionEnum(llvm::StringRef s, const OptionEnumValues &enum_values, int32_t fail_value, Status &error)
static lldb::addr_t ToAddress(const ExecutionContext *exe_ctx, llvm::StringRef s, lldb::addr_t fail_value, Status *error_ptr)
Try to parse an address.
static bool ToBoolean(llvm::StringRef s, bool fail_value, bool *success_ptr)
This struct contains the metadata needed to instantiate a frame provider and optional filters to cont...
void Dump(Stream *s) const
Dump a description of this descriptor to the given stream.
lldb::ScriptedFrameProviderInterfaceSP interface_sp
Interface for calling static methods on the provider class.
Struct to store information for color highlighting in the stream.