64#include "clang/Driver/CreateInvocationFromArgs.h"
65#include "clang/Frontend/CompilerInstance.h"
66#include "clang/Frontend/CompilerInvocation.h"
67#include "clang/Frontend/FrontendActions.h"
68#include "clang/Serialization/ObjectFilePCHContainerReader.h"
69#include "llvm/ADT/ScopeExit.h"
70#include "llvm/ADT/StringRef.h"
71#include "llvm/Support/FileSystem.h"
72#include "llvm/Support/FormatAdapters.h"
79 const char *prefix_cstr,
80 bool show_stopped_process_status,
Stream &strm) {
85 bool exe_valid =
false;
90 ::strcpy(exe_path,
"<none>");
92 std::string formatted_label =
"";
93 const std::string &label = target->
GetLabel();
95 formatted_label =
" (" + label +
")";
98 strm.
Printf(
"%starget #%u%s: %s", prefix_cstr ? prefix_cstr :
"", target_idx,
99 formatted_label.data(), exe_path);
101 uint32_t properties = 0;
109 strm.
Format(
"{0}platform={1}", properties++ > 0 ?
", " :
" ( ",
110 platform_sp->GetName());
113 bool show_process_status =
false;
116 StateType state = process_sp->GetState();
117 if (show_stopped_process_status)
121 strm.
Printf(
"%spid=%" PRIu64, properties++ > 0 ?
", " :
" ( ", pid);
122 strm.
Printf(
"%sstate=%s", properties++ > 0 ?
", " :
" ( ", state_cstr);
128 if (show_process_status) {
129 const bool only_threads_with_stop_reason =
true;
130 const uint32_t start_frame = 0;
131 const uint32_t num_frames = 1;
132 const uint32_t num_frames_with_source = 1;
133 const bool stop_format =
false;
134 process_sp->GetStatus(strm);
135 process_sp->GetThreadStatus(strm, only_threads_with_stop_reason,
136 start_frame, num_frames, num_frames_with_source,
142 bool show_stopped_process_status,
Stream &strm) {
147 for (uint32_t i = 0; i < num_targets; ++i) {
150 bool is_selected = target_sp.get() == selected_target_sp.get();
152 show_stopped_process_status, strm);
159#define LLDB_OPTIONS_target_dependents
160#include "CommandOptions.inc"
169 return llvm::ArrayRef(g_target_dependents_options);
177 if (option_value.empty()) {
182 const char short_option =
183 g_target_dependents_options[option_idx].short_option;
184 if (short_option ==
'd') {
187 option_value, g_target_dependents_options[option_idx].enum_values, 0,
193 "unrecognized short option '%c'", short_option);
213#pragma mark CommandObjectTargetCreate
219 interpreter,
"target create",
220 "Create a target using the argument as the main executable.",
224 "Fullpath to a core file to use for this target."),
226 "Optional name for this target.", nullptr),
229 "Fullpath to a stand alone debug "
230 "symbols file for when debug symbols "
231 "are not in the executable."),
234 "Fullpath to the file on the remote host if debugging remotely.") {
265 llvm::toString(file.takeError()));
270 if (argc == 1 || core_file || remote_file) {
279 llvm::toString(file.takeError()));
287 bool must_set_platform_path =
false;
292 llvm::StringRef arch_cstr =
m_arch_option.GetArchitectureName();
294 debugger, file_path, arch_cstr,
303 const llvm::StringRef label =
304 m_label.GetOptionValue().GetCurrentValueAsRef();
305 if (!label.empty()) {
306 if (
auto E = target_sp->SetLabel(label))
313 llvm::scope_exit on_error(
315 target_list.DeleteTarget(target_sp);
322 PlatformSP platform_sp = target_sp->GetPlatform();
326 file_spec.
SetFile(file_path, FileSpec::Style::native);
331 if (platform_sp && platform_sp->IsHost() &&
341 if (!platform_sp->GetFileExists(remote_file)) {
342 Status err = platform_sp->PutFile(file_spec, remote_file);
356 Status err = platform_sp->GetFile(remote_file, file_spec);
370 if (platform_sp->IsHost()) {
371 result.
AppendError(
"Supply a local file, not a remote file, "
372 "when debugging on the host.");
375 if (platform_sp->IsConnected() && !platform_sp->GetFileExists(remote_file)) {
376 result.
AppendError(
"remote --> local transfer without local "
377 "path is not implemented yet");
384 target_sp->SetProcessLaunchInfo(launch_info);
388 result.
AppendError(
"no platform found for target");
393 if (symfile || remote_file) {
394 ModuleSP module_sp(target_sp->GetExecutableModule());
397 module_sp->SetSymbolFileFileSpec(symfile);
399 std::string remote_path = remote_file.
GetPath();
400 target_sp->SetArg0(remote_path.c_str());
401 module_sp->SetPlatformFileSpec(remote_file);
406 if (must_set_platform_path) {
409 target_sp->GetOrCreateModule(main_module_spec,
true );
411 module_sp->SetPlatformFileSpec(remote_file);
417 target_sp->AppendExecutableSearchPaths(core_file_dir);
419 ProcessSP process_sp(target_sp->CreateProcess(
420 GetDebugger().GetListener(), llvm::StringRef(), &core_file,
false));
427 target_sp->GetStatistics().GetLoadCoreTime());
428 error = process_sp->LoadCore();
436 "Core file '{0}' ({1}) was loaded.\n", core_file.
GetPath(),
437 target_sp->GetArchitecture().GetArchitectureName());
438 if (
auto core_args = process_sp->GetCoreFileArgs())
449 "Current executable set to '{0}' ({1}).",
451 target_sp->GetArchitecture().GetArchitectureName());
457 "argument, or use the --core option",
473#pragma mark CommandObjectTargetList
479 interpreter,
"target list",
480 "List all current targets in the current debug session.", nullptr) {
489 bool show_stopped_process_status =
false;
491 show_stopped_process_status, strm) == 0) {
498#pragma mark CommandObjectTargetSelect
504 interpreter,
"target select",
505 "Select a target as the current target by target index.", nullptr) {
518 if (llvm::to_integer(target_identifier, target_idx)) {
519 if (target_idx < num_targets) {
522 bool show_stopped_process_status =
false;
526 if (num_targets > 0) {
528 "index %u is out of range, valid target indexes are 0 - %u",
529 target_idx, num_targets - 1);
532 "index %u is out of range since there are no active targets",
537 for (
size_t i = 0; i < num_targets; i++) {
539 const std::string &label = target_sp->GetLabel();
540 if (!label.empty() && label == target_identifier) {
550 bool show_stopped_process_status =
false;
560 "'target select' takes a single argument: a target index\n");
565#pragma mark CommandObjectTargetDelete
571 "Delete one or more targets by target index.",
577 "Perform extra cleanup to minimize memory consumption after "
578 "deleting the target. "
579 "By default, LLDB will keep in memory any modules previously "
580 "loaded by the target as well "
581 "as all of its debug info. Specifying --clean will unload all of "
582 "these shared modules and "
583 "cause them to be reparsed again the next time the target is run",
598 std::vector<TargetSP> delete_target_list;
605 }
else if (argc > 0) {
608 if (num_targets == 0) {
613 for (
auto &entry : args.
entries()) {
615 if (entry.ref().getAsInteger(0, target_idx)) {
620 if (target_idx < num_targets) {
623 delete_target_list.push_back(target_sp);
629 "target indexes are 0 - %u",
630 target_idx, num_targets - 1);
633 "target index %u is out of range, the only valid index is 0",
644 delete_target_list.push_back(target_sp);
647 const size_t num_targets_to_delete = delete_target_list.size();
648 for (
size_t idx = 0; idx < num_targets_to_delete; ++idx) {
649 target_sp = delete_target_list[idx];
651 target_sp->Destroy();
656 const bool mandatory =
true;
660 (uint32_t)num_targets_to_delete);
673 interpreter,
"target show-launch-environment",
674 "Shows the environment being passed to the process when launched, "
675 "taking info account 3 settings: target.env-vars, "
676 "target.inherit-env and target.unset-env-vars.",
677 nullptr, eCommandRequiresTarget) {}
686 std::vector<Environment::value_type *> env_vector;
687 env_vector.reserve(env.size());
689 env_vector.push_back(&KV);
690 std::sort(env_vector.begin(), env_vector.end(),
691 [](Environment::value_type *a, Environment::value_type *b) {
692 return a->first() < b->first();
696 for (
auto &KV : env_vector)
697 strm.
Format(
"{0}={1}\n", KV->first(), KV->second);
703#pragma mark CommandObjectTargetVariable
712 "Read global variables for the current target, "
713 "before or while running a process.",
714 nullptr, eCommandRequiresTarget),
719 "A basename or fullpath to a file that contains "
720 "global variables. This option can be "
721 "specified multiple times."),
725 "A basename or fullpath to a shared library to use in the search "
727 "variables. This option can be specified multiple times.") {
746 const char *root_name) {
749 if (!valobj_sp->GetTargetSP()->GetDisplayRuntimeSupportValues() &&
750 valobj_sp->IsRuntimeSupportValue())
753 switch (var_sp->GetScope()) {
784 bool show_fullpaths =
false;
785 bool show_module =
true;
786 if (var_sp->DumpDeclaration(&s, show_fullpaths, show_module))
796 if (llvm::Error
error = valobj_sp->Dump(s, options))
802 size_t old_size = variable_list.
GetSize();
807 return variable_list.
GetSize() - old_size;
818 if (variable_list.
Empty())
822 s.
Format(
"Global variables for {0} in {1}:\n",
825 s.
Printf(
"Global variables for %s\n",
826 sc.
module_sp->GetFileSpec().GetPath().c_str());
855 bool use_var_name =
false;
860 "error: invalid regular expression: '%s'\n", arg.c_str());
866 matches = variable_list.
GetSize();
869 arg.c_str(),
m_exe_ctx.GetBestExecutionContextScope(),
871 matches = variable_list.
GetSize();
879 for (uint32_t global_idx = 0; global_idx < matches; ++global_idx) {
886 m_exe_ctx.GetBestExecutionContextScope(), var_sp);
890 use_var_name ? var_sp->GetName().GetCString()
902 const size_t num_compile_units = compile_units.
GetSize();
903 const size_t num_shlibs = shlibs.
GetSize();
904 if (num_compile_units == 0 && num_shlibs == 0) {
905 bool success =
false;
912 const bool can_create =
true;
915 if (comp_unit_varlist_sp) {
916 size_t count = comp_unit_varlist_sp->GetSize();
929 "no global variables in current compile unit: {0}\n",
935 result.
AppendError(
"'target variable' takes one or more global "
936 "variable names as arguments\n");
941 if (num_shlibs > 0) {
942 for (
size_t shlib_idx = 0; shlib_idx < num_shlibs; ++shlib_idx) {
949 if (num_compile_units > 0) {
950 for (
size_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx)
951 module_sp->FindCompileUnits(
961 "target doesn't contain the specified shared library: %s",
962 module_file.
GetPath().c_str());
968 for (
size_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx)
975 const bool can_create =
true;
977 sc.comp_unit->GetVariableList(can_create));
978 if (comp_unit_varlist_sp)
981 }
else if (sc.module_sp) {
984 llvm::StringRef(
"."));
986 sc.module_sp->FindGlobalVariables(all_globals_regex,
UINT32_MAX,
1008#pragma mark CommandObjectTargetModulesSearchPathsAdd
1014 "Add new image search paths substitution pairs to "
1015 "the current target.",
1016 nullptr, eCommandRequiresTarget) {
1035 arg.push_back(old_prefix_arg);
1036 arg.push_back(new_prefix_arg);
1046 assert(target &&
"target guaranteed by eCommandRequiresTarget");
1049 result.
AppendError(
"add requires an even number of arguments\n");
1051 for (
size_t i = 0; i < argc; i += 2) {
1055 if (from[0] && to[0]) {
1057 "target modules search path adding ImageSearchPath "
1058 "pair: '%s' -> '%s'",
1060 bool last_pair = ((argc - i) == 2);
1062 from, to, last_pair);
1066 result.
AppendError(
"<path-prefix> can't be empty\n");
1068 result.
AppendError(
"<new-path-prefix> can't be empty\n");
1075#pragma mark CommandObjectTargetModulesSearchPathsClear
1081 "Clear all current image search path substitution "
1082 "pairs from the current target.",
1083 "target modules search-paths clear",
1084 eCommandRequiresTarget) {}
1091 assert(target &&
"target guaranteed by eCommandRequiresTarget");
1098#pragma mark CommandObjectTargetModulesSearchPathsInsert
1104 "Insert a new image search path substitution pair "
1105 "into the current target at the specified index.",
1106 nullptr, eCommandRequiresTarget) {
1118 arg1.push_back(index_arg);
1134 arg2.push_back(old_prefix_arg);
1135 arg2.push_back(new_prefix_arg);
1153 const size_t num = list.
GetSize();
1155 for (
size_t i = 0; i < num; ++i) {
1159 strm << old_path <<
" -> " << new_path;
1167 assert(target &&
"target guaranteed by eCommandRequiresTarget");
1170 if (argc >= 3 && argc & 1) {
1171 uint32_t insert_idx;
1175 "<index> parameter is not an integer: '%s'",
1184 for (uint32_t i = 0; i < argc; i += 2, ++insert_idx) {
1188 if (from[0] && to[0]) {
1189 bool last_pair = ((argc - i) == 2);
1195 result.
AppendError(
"<path-prefix> can't be empty\n");
1197 result.
AppendError(
"<new-path-prefix> can't be empty\n");
1202 result.
AppendError(
"insert requires at least three arguments\n");
1207#pragma mark CommandObjectTargetModulesSearchPathsList
1213 "List all current image search path substitution "
1214 "pairs in the current target.",
1215 "target modules search-paths list",
1216 eCommandRequiresTarget) {}
1223 assert(target &&
"target guaranteed by eCommandRequiresTarget");
1229#pragma mark CommandObjectTargetModulesSearchPathsQuery
1235 interpreter,
"target modules search-paths query",
1236 "Transform a path using the first applicable image search path.",
1237 nullptr, eCommandRequiresTarget) {
1246 assert(target &&
"target guaranteed by eCommandRequiresTarget");
1248 result.
AppendError(
"query requires one argument\n");
1265 bool full_triple, uint32_t width) {
1270 module->GetArchitecture().DumpTriple(arch_strm.AsRawOstream());
1273 std::string arch_str = std::string(arch_strm.
GetString());
1276 strm.
Printf(
"%-*s", width, arch_str.c_str());
1284 module->GetUUID().Dump(strm);
1293 uint32_t num_matches = 0;
1296 num_matches =
module->ResolveSymbolContextsForFileSpec(
1297 file_spec, 0, false, eSymbolContextCompUnit, sc_list);
1299 bool first_module =
true;
1304 strm <<
"Line table for " << sc.comp_unit->GetPrimaryFile() <<
" in `"
1305 <<
module->GetFileSpec().GetFilename() << "\n";
1306 LineTable *line_table = sc.comp_unit->GetLineTable();
1312 strm <<
"No line table";
1314 first_module =
false;
1322 if (file_spec_ptr) {
1324 std::string fullpath = file_spec_ptr->
GetPath();
1325 strm.
Printf(
"%-*s", width, fullpath.c_str());
1334 strm.
Printf(
"%-*s", width,
"");
1339 if (file_spec_ptr) {
1348 strm.
Printf(
"%-*s", width,
"");
1353 if (file_spec_ptr) {
1362 strm.
Printf(
"%-*s", width,
"");
1366 std::lock_guard<std::recursive_mutex> guard(module_list.
GetMutex());
1367 const size_t num_modules = module_list.
GetSize();
1368 if (num_modules == 0)
1371 size_t num_dumped = 0;
1372 strm.
Format(
"Dumping headers for {0} module(s).\n", num_modules);
1376 if (num_dumped++ > 0) {
1380 ObjectFile *objfile = module_sp->GetObjectFile();
1382 objfile->
Dump(&strm);
1384 strm.
Format(
"No object file for module: {0:F}\n",
1385 module_sp->GetFileSpec());
1400 sort_order, name_preference);
1406 SectionList *section_list =
module->GetSectionList();
1408 strm.
Printf(
"Sections for '%s' (%s):\n",
1421 symbol_file->Dump(strm);
1429 Module *module,
bool errors_only,
1430 bool load_all_debug_info) {
1434 if (symbol_file->GetSeparateDebugInfo(d, errors_only,
1435 load_all_debug_info)) {
1437 std::make_shared<StructuredData::Dictionary>(std::move(d)));
1450 "------------------ --- -----------------------------------------");
1459 strm.
Printf(
"0x%16.16" PRIx64
" ", dwo_id);
1461 strm.
Printf(
"0x???????????????? ");
1463 llvm::StringRef
error;
1465 strm <<
"E " <<
error;
1467 llvm::StringRef resolved_dwo_path;
1469 resolved_dwo_path)) {
1470 strm <<
" " << resolved_dwo_path;
1471 if (resolved_dwo_path.ends_with(
".dwp")) {
1472 llvm::StringRef dwo_name;
1474 strm <<
"(" << dwo_name <<
")";
1487 strm.
PutCString(
"------------------ --- ---------------------");
1494 uint32_t oso_mod_time;
1496 strm.
Printf(
"0x%16.16" PRIx32
" ", oso_mod_time);
1498 llvm::StringRef
error;
1500 strm <<
"E " <<
error;
1502 llvm::StringRef oso_path;
1504 strm <<
" " << oso_path;
1513 bool verbose,
bool all_ranges,
Stream &strm,
1514 std::optional<Stream::HighlightSettings> settings = std::nullopt) {
1516 strm.
Indent(
" Address: ");
1521 strm.
Indent(
" Summary: ");
1537 Module *module, uint32_t resolve_mask,
1539 bool verbose,
bool all_ranges) {
1548 else if (so_addr.
GetModule().get() != module)
1557 DumpAddress(exe_scope, so_addr, verbose, all_ranges, strm);
1566 const char *name,
bool name_is_regex,
1567 bool verbose,
bool all_ranges) {
1571 Symtab *symtab =
module->GetSymtab();
1577 std::vector<uint32_t> match_indexes;
1579 uint32_t num_matches = 0;
1580 if (name_is_regex) {
1589 if (num_matches > 0) {
1591 strm.
Printf(
"%u symbols match %s'%s' in ", num_matches,
1592 name_is_regex ?
"the regular expression " :
"", name);
1599 for (uint32_t i = 0; i < num_matches; ++i) {
1606 use_color && name_is_regex
1607 ? std::optional<Stream::HighlightSettings>{settings}
1615 use_color && name_is_regex
1616 ? std::optional<Stream::HighlightSettings>{settings}
1637 std::optional<Stream::HighlightSettings> settings = std::nullopt) {
1639 bool first_module =
true;
1645 if (sc.line_entry.IsValid())
1646 addr = sc.line_entry.range.GetBaseAddress();
1647 else if (sc.block && sc.block->GetContainingInlinedBlock())
1648 sc.block->GetContainingInlinedBlock()->GetStartAddress(addr);
1650 addr = sc.GetFunctionOrSymbolAddress();
1652 DumpAddress(exe_scope, addr, verbose, all_ranges, strm, settings);
1653 first_module =
false;
1660 const char *name,
bool name_is_regex,
1662 bool verbose,
bool all_ranges) {
1663 if (module && name && name[0]) {
1665 size_t num_matches = 0;
1666 if (name_is_regex) {
1668 module->FindFunctions(function_name_regex, options, sc_list);
1671 module->FindFunctions(function_name, CompilerDeclContext(),
1672 eFunctionNameTypeAuto, options, sc_list);
1674 num_matches = sc_list.
GetSize();
1677 strm.
Printf(
"%" PRIu64
" match%s found in ", (uint64_t)num_matches,
1678 num_matches > 1 ?
"es" :
"");
1683 strm, sc_list, verbose, all_ranges);
1692 Module *module,
const char *name_cstr,
1693 bool name_is_regex) {
1694 if (module && name_cstr && name_cstr[0]) {
1697 module->FindTypes(query, results);
1702 sc.
module_sp =
module->shared_from_this();
1706 if (type_list.
Empty())
1709 const uint64_t num_matches = type_list.
GetSize();
1712 strm.
Printf(
"%" PRIu64
" match%s found in ", num_matches,
1713 num_matches > 1 ?
"es" :
"");
1721 type_sp->GetFullCompilerType();
1724 TypeSP typedef_type_sp(type_sp);
1725 TypeSP typedefed_type_sp(typedef_type_sp->GetTypedefType());
1726 while (typedefed_type_sp) {
1728 strm.
Printf(
" typedef '%s': ",
1729 typedef_type_sp->GetName().GetCString());
1730 typedefed_type_sp->GetFullCompilerType();
1733 typedef_type_sp = typedefed_type_sp;
1734 typedefed_type_sp = typedef_type_sp->GetTypedefType();
1745 const char *name_cstr,
bool name_is_regex) {
1748 module.FindTypes(query, results);
1751 sc.
module_sp =
module.shared_from_this();
1753 if (type_list.
Empty())
1765 type_sp->GetFullCompilerType();
1768 TypeSP typedef_type_sp(type_sp);
1769 TypeSP typedefed_type_sp(typedef_type_sp->GetTypedefType());
1770 while (typedefed_type_sp) {
1772 strm.
Printf(
" typedef '%s': ",
1773 typedef_type_sp->GetName().GetCString());
1774 typedefed_type_sp->GetFullCompilerType();
1777 typedef_type_sp = typedefed_type_sp;
1778 typedefed_type_sp = typedef_type_sp->GetTypedefType();
1788 uint32_t line,
bool check_inlines,
1789 bool verbose,
bool all_ranges) {
1790 if (module && file_spec) {
1792 const uint32_t num_matches =
module->ResolveSymbolContextsForFileSpec(
1793 file_spec, line, check_inlines, eSymbolContextEverything, sc_list);
1794 if (num_matches > 0) {
1796 strm.
Printf(
"%u match%s found in ", num_matches,
1797 num_matches > 1 ?
"es" :
"");
1800 strm.
Printf(
":%u", line);
1806 strm, sc_list, verbose, all_ranges);
1815 bool check_global_list) {
1816 FileSpec module_file_spec(module_name);
1819 const size_t initial_size = module_list.
GetSize();
1821 if (check_global_list) {
1823 std::lock_guard<std::recursive_mutex> guard(
1827 for (
size_t image_idx = 0; image_idx < num_modules; ++image_idx) {
1832 module_sp =
module->shared_from_this();
1840 const size_t num_matches = module_list.
GetSize();
1844 if (num_matches == 0) {
1853 return module_list.
GetSize() - initial_size;
1856#pragma mark CommandObjectTargetModulesModuleAutoComplete
1883#pragma mark CommandObjectTargetModulesSourceFileAutoComplete
1893 const char *syntax, uint32_t flags)
1908#pragma mark CommandObjectTargetModulesDumpObjfile
1915 interpreter,
"target modules dump objfile",
1916 "Dump the object file headers from one or more target modules.",
1917 nullptr, eCommandRequiresTarget) {}
1924 assert(target &&
"target guaranteed by eCommandRequiresTarget");
1925 size_t num_dumped = 0;
1930 if (num_dumped == 0) {
1931 result.
AppendError(
"the target has no associated executable images");
1936 const char *arg_cstr;
1937 for (
int arg_idx = 0;
1940 size_t num_matched =
1942 if (num_matched == 0) {
1944 "unable to find an image that matches '{0}'", arg_cstr);
1952 if (num_dumped > 0) {
1955 result.
AppendError(
"no matching executable images found");
1960#define LLDB_OPTIONS_target_modules_dump_symtab
1961#include "CommandOptions.inc"
1968 interpreter,
"target modules dump symtab",
1969 "Dump the symbol table from one or more target modules.", nullptr,
1970 eCommandRequiresTarget) {}
1987 switch (short_option) {
2000 llvm_unreachable(
"Unimplemented option");
2011 return llvm::ArrayRef(g_target_modules_dump_symtab_options);
2021 assert(target &&
"target guaranteed by eCommandRequiresTarget");
2022 uint32_t num_dumped = 0;
2030 std::lock_guard<std::recursive_mutex> guard(module_list.
GetMutex());
2031 const size_t num_modules = module_list.
GetSize();
2032 if (num_modules > 0) {
2034 "Dumping symbol table for {0} modules.\n", num_modules);
2036 if (num_dumped > 0) {
2041 "Interrupted in dump all symtabs with {0} "
2042 "of {1} dumped.", num_dumped, num_modules))
2047 module_sp.get(),
m_options.m_sort_order,
2051 result.
AppendError(
"the target has no associated executable images");
2056 const char *arg_cstr;
2057 for (
int arg_idx = 0;
2061 const size_t num_matches =
2063 if (num_matches > 0) {
2066 if (num_dumped > 0) {
2071 "Interrupted in dump symtab list with {0} of {1} dumped.",
2072 num_dumped, num_matches))
2077 module_sp.get(),
m_options.m_sort_order,
2083 "unable to find an image that matches '{0}'", arg_cstr);
2090 result.
AppendError(
"no matching executable images found");
2097#pragma mark CommandObjectTargetModulesDumpSections
2106 interpreter,
"target modules dump sections",
2107 "Dump the sections from one or more target modules.",
2109 nullptr, eCommandRequiresTarget) {}
2116 assert(target &&
"target guaranteed by eCommandRequiresTarget");
2117 uint32_t num_dumped = 0;
2122 if (num_modules == 0) {
2123 result.
AppendError(
"the target has no associated executable images");
2129 for (
size_t image_idx = 0; image_idx < num_modules; ++image_idx) {
2131 "Interrupted in dump all sections with {0} of {1} dumped",
2132 image_idx, num_modules))
2142 const char *arg_cstr;
2143 for (
int arg_idx = 0;
2147 const size_t num_matches =
2149 if (num_matches > 0) {
2150 for (
size_t i = 0; i < num_matches; ++i) {
2152 "Interrupted in dump section list with {0} of {1} dumped.",
2165 std::lock_guard<std::recursive_mutex> guard(
2169 "unable to find an image that matches '{0}'", arg_cstr);
2177 result.
AppendError(
"no matching executable images found");
2186 interpreter,
"target modules dump pcm-info",
2187 "Dump information about the given clang module (pcm).") {
2206 result.
AppendError(
"file must have a .pcm extension");
2215 const char *clang_args[] = {
"clang", pcm_path};
2216 clang::CompilerInstance compiler(clang::createInvocation(clang_args));
2217 compiler.setVirtualFileSystem(
2219 compiler.createDiagnostics();
2223 std::shared_ptr<llvm::raw_ostream> Out(
2225 clang::DumpModuleInfoAction dump_module_info(Out);
2227 compiler.getPCHContainerOperations()->registerReader(
2228 std::make_unique<clang::ObjectFilePCHContainerReader>());
2230 if (compiler.ExecuteAction(dump_module_info))
2235#pragma mark CommandObjectTargetModulesDumpClangAST
2244 interpreter,
"target modules dump ast",
2245 "Dump the clang ast for a given module's symbol file.",
2246 "target modules dump ast [--filter <name>] [<file1> ...]",
2247 eCommandRequiresTarget),
2249 "Dump only the decls whose names contain the specified filter "
2266 assert(target &&
"target guaranteed by eCommandRequiresTarget");
2268 const size_t num_modules = module_list.
GetSize();
2269 if (num_modules == 0) {
2270 result.
AppendError(
"the target has no associated executable images");
2274 llvm::StringRef filter =
m_filter.GetOptionValue().GetCurrentValueAsRef();
2283 if (
SymbolFile *sf = module_sp->GetSymbolFile())
2294 const size_t num_matches =
2296 if (num_matches == 0) {
2298 std::lock_guard<std::recursive_mutex> guard(
2302 "unable to find an image that matches '{0}'", arg.c_str());
2306 for (
size_t i = 0; i < num_matches; ++i) {
2308 "Interrupted in dump clang ast list with {0} of {1} dumped.",
2322#pragma mark CommandObjectTargetModulesDumpSymfile
2331 interpreter,
"target modules dump symfile",
2332 "Dump the debug symbol file for one or more target modules.",
2334 nullptr, eCommandRequiresTarget) {}
2341 assert(target &&
"target guaranteed by eCommandRequiresTarget");
2342 uint32_t num_dumped = 0;
2347 std::lock_guard<std::recursive_mutex> guard(target_modules.
GetMutex());
2348 const size_t num_modules = target_modules.
GetSize();
2349 if (num_modules == 0) {
2350 result.
AppendError(
"the target has no associated executable images");
2354 "Dumping debug symbols for {0} modules.\n", num_modules);
2357 "debug symbols with {0} of {1} modules dumped",
2358 num_dumped, num_modules))
2366 const char *arg_cstr;
2367 for (
int arg_idx = 0;
2371 const size_t num_matches =
2373 if (num_matches > 0) {
2374 for (
size_t i = 0; i < num_matches; ++i) {
2376 "of {1} requested modules",
2387 "unable to find an image that matches '{0}'", arg_cstr);
2394 result.
AppendError(
"no matching executable images found");
2399#pragma mark CommandObjectTargetModulesDumpLineTable
2400#define LLDB_OPTIONS_target_modules_dump
2401#include "CommandOptions.inc"
2410 interpreter,
"target modules dump line-table",
2411 "Dump the line table for one or more compilation units.", nullptr,
2412 eCommandRequiresTarget) {}
2421 uint32_t total_num_dumped = 0;
2424 result.
AppendError(
"file option must be specified");
2428 const char *arg_cstr;
2429 for (
int arg_idx = 0;
2435 std::lock_guard<std::recursive_mutex> guard(target_modules.
GetMutex());
2436 size_t num_modules = target_modules.
GetSize();
2437 if (num_modules > 0) {
2438 uint32_t num_dumped = 0;
2441 "Interrupted in dump all line tables with "
2442 "{0} of {1} dumped", num_dumped,
2453 if (num_dumped == 0)
2457 total_num_dumped += num_dumped;
2462 if (total_num_dumped > 0)
2465 result.
AppendError(
"no source filenames matched any command arguments");
2475 assert(option_idx == 0 &&
"We only have one option.");
2486 return llvm::ArrayRef(g_target_modules_dump_options);
2495#pragma mark CommandObjectTargetModulesDumpSeparateDebugInfoFiles
2496#define LLDB_OPTIONS_target_modules_dump_separate_debug_info
2497#include "CommandOptions.inc"
2507 interpreter,
"target modules dump separate-debug-info",
2508 "List the separate debug info symbol files for one or more target "
2510 nullptr, eCommandRequiresTarget) {}
2527 switch (short_option) {
2533 m_json.SetCurrentValue(
true);
2534 m_json.SetOptionWasSet();
2541 llvm_unreachable(
"Unimplemented option");
2553 return llvm::ArrayRef(g_target_modules_dump_separate_debug_info_options);
2564 assert(target &&
"target guaranteed by eCommandRequiresTarget");
2565 uint32_t num_dumped = 0;
2571 std::lock_guard<std::recursive_mutex> guard(target_modules.
GetMutex());
2572 const size_t num_modules = target_modules.
GetSize();
2573 if (num_modules == 0) {
2574 result.
AppendError(
"the target has no associated executable images");
2580 "Interrupted in dumping all "
2581 "separate debug info with {0} of {1} modules dumped",
2582 num_dumped, num_modules))
2593 const char *arg_cstr;
2594 for (
int arg_idx = 0;
2598 const size_t num_matches =
2600 if (num_matches > 0) {
2601 for (
size_t i = 0; i < num_matches; ++i) {
2603 "Interrupted dumping {0} "
2604 "of {1} requested modules",
2615 "unable to find an image that matches '{0}'", arg_cstr);
2619 if (num_dumped > 0) {
2624 separate_debug_info_lists_by_module.
Dump(strm,
2628 separate_debug_info_lists_by_module.
ForEach(
2638 if (!separate_debug_info_list) {
2642 llvm::StringRef type;
2643 llvm::StringRef symfile;
2650 "separate-debug-info-files", files))) {
2654 strm <<
"Symbol file: " << symfile;
2656 strm <<
"Type: \"" << type <<
"\"";
2658 if (type ==
"dwo") {
2660 }
else if (type ==
"oso") {
2664 "found unsupported debug info type '{0}'", type);
2671 result.
AppendError(
"no matching executable images found");
2678#pragma mark CommandObjectTargetModulesDump
2687 interpreter,
"target modules dump",
2688 "Commands for dumping information about one or more target "
2690 "target modules dump "
2691 "[objfile|symtab|sections|ast|symfile|line-table|pcm-info|separate-"
2693 "[<file1> <file2> ...]") {
2729 "Add a new module to the current target's modules.",
2730 "target modules add [<module>]",
2731 eCommandRequiresTarget),
2734 "Fullpath to a stand alone debug "
2735 "symbols file for when debug symbols "
2736 "are not in the executable.") {
2755 assert(target &&
"target guaranteed by eCommandRequiresTarget");
2781 "Unable to create the executable or symbol file with "
2782 "UUID %s with path %s and symbol file %s",
2787 "Unable to create the executable or symbol file with "
2788 "UUID %s with path %s",
2794 "or symbol file with UUID %s",
2803 "Unable to locate the executable or symbol file with UUID %s",
2810 "one or more executable image paths must be specified");
2814 for (
auto &entry : args.
entries()) {
2815 if (entry.ref().empty())
2831 module_spec,
true , &
error));
2833 const char *error_cstr =
error.AsCString();
2845 std::string resolved_path = file_spec.
GetPath();
2846 if (resolved_path != entry.ref()) {
2848 "invalid module path '%s' with resolved path '%s'",
2849 entry.ref().str().c_str(), resolved_path.c_str());
2872 interpreter,
"target modules load",
2873 "Set the load addresses for one or more sections in a target "
2875 "target modules load [--file <module> --uuid <uuid>] <sect-name> "
2876 "<address> [<sect-name> <address> ....]",
2877 eCommandRequiresTarget),
2879 "Fullpath or basename for module to load.",
""),
2881 "Write file contents to the memory.", false, true),
2883 "Set PC to the entry point."
2884 " Only applicable with '--load' option.",
2887 "Set the load address for all sections to be the "
2888 "virtual address in the file plus the offset.",
2906 assert(target &&
"target guaranteed by eCommandRequiresTarget");
2907 const bool load =
m_load_option.GetOptionValue().GetCurrentValue();
2908 const bool set_pc =
m_pc_option.GetOptionValue().GetCurrentValue();
2912 bool search_using_module_spec =
false;
2919 if (module_list.
GetSize() == 1) {
2920 search_using_module_spec =
true;
2928 search_using_module_spec =
true;
2929 const char *arg_cstr =
m_file_option.GetOptionValue().GetCurrentValue();
2930 const bool use_global_module_list =
true;
2933 target, arg_cstr, module_list, use_global_module_list);
2934 if (num_matches == 1) {
2937 }
else if (num_matches > 1) {
2938 search_using_module_spec =
false;
2942 search_using_module_spec =
false;
2949 search_using_module_spec =
true;
2954 if (search_using_module_spec) {
2957 const size_t num_matches = matching_modules.
GetSize();
2960 if (num_matches == 1) {
2963 ObjectFile *objfile =
module->GetObjectFile();
2965 SectionList *section_list =
module->GetSectionList();
2967 bool changed =
false;
2972 const bool slide_is_offset =
true;
2973 module->SetLoadAddress(*target, slide, slide_is_offset,
2976 result.
AppendError(
"one or more section name + load "
2977 "address pair must be specified");
2982 result.
AppendError(
"The \"--slide <offset>\" option can't "
2983 "be used in conjunction with setting "
2984 "section load addresses.\n");
2988 for (
size_t i = 0; i < argc; i += 2) {
2991 if (sect_name && load_addr_cstr) {
2994 if (llvm::to_integer(load_addr_cstr, load_addr)) {
2998 if (section_sp->IsThreadSpecific()) {
3000 "thread specific sections are not yet "
3001 "supported (section '%s')",
3009 "section '{0}' loaded at {1:x}", sect_name,
3014 "matches the section "
3021 "invalid load address string '%s'", load_addr_cstr);
3026 result.
AppendError(
"section names must be followed by "
3027 "a load address.\n");
3029 result.
AppendError(
"one or more section name + load "
3030 "address pair must be specified.\n");
3049 if (set_pc && !file_entry.
IsValid()) {
3050 result.
AppendError(
"No entry address in object file");
3053 std::vector<ObjectFile::LoadableData> loadables(
3055 if (loadables.size() == 0) {
3059 Status error = process->WriteObjectFile(std::move(loadables));
3065 ThreadList &thread_list = process->GetThreadList();
3069 if (!reg_context->SetPC(file_entry_addr)) {
3077 module->GetFileSpec().GetPath(path, sizeof(path));
3082 module->GetFileSpec().GetPath(path, sizeof(path));
3088 if (module_spec_file) {
3089 module_spec_file->
GetPath(path,
sizeof(path));
3095 std::string uuid_str;
3104 if (num_matches > 1) {
3106 "multiple modules match%s%s%s%s:", path[0] ?
" file=" :
"", path,
3107 !uuid_str.empty() ?
" uuid=" :
"", uuid_str.c_str());
3108 for (
size_t i = 0; i < num_matches; ++i) {
3116 "no modules were found that match%s%s%s%s",
3117 path[0] ?
" file=" :
"", path, !uuid_str.empty() ?
" uuid=" :
"",
3122 result.
AppendError(
"either the \"--file <module>\" or the \"--uuid "
3123 "<uuid>\" option must be specified.\n");
3137#pragma mark CommandObjectTargetModulesList
3139#define LLDB_OPTIONS_target_modules_list
3140#include "CommandOptions.inc"
3155 if (short_option ==
'g') {
3157 }
else if (short_option ==
'a') {
3161 unsigned long width = 0;
3162 option_arg.getAsInteger(0, width);
3175 return llvm::ArrayRef(g_target_modules_list_options);
3187 interpreter,
"target modules list",
3188 "List current executable and dependent shared library images.",
3189 nullptr, eCommandAllowsDummyTarget) {
3200 const bool use_global_module_list =
m_options.m_use_global_module_list;
3203 if (!use_global_module_list && (!target || target->
IsDummyTarget())) {
3224 "Couldn't find module matching address: 0x%" PRIx64,
3229 "Couldn't find module containing address: 0x%" PRIx64,
3235 size_t num_modules = 0;
3241 std::unique_lock<std::recursive_mutex> guard(
3247 if (use_global_module_list) {
3257 target, arg.c_str(), module_list, use_global_module_list);
3258 if (num_matches == 0) {
3267 module_list_ptr = &module_list;
3270 std::unique_lock<std::recursive_mutex> lock;
3271 if (module_list_ptr !=
nullptr) {
3273 std::unique_lock<std::recursive_mutex>(module_list_ptr->
GetMutex());
3275 num_modules = module_list_ptr->
GetSize();
3278 if (num_modules > 0) {
3279 for (uint32_t image_idx = 0; image_idx < num_modules; ++image_idx) {
3282 if (module_list_ptr) {
3284 module = module_sp.get();
3286 module = Module::GetAllocatedModuleAtIndex(image_idx);
3287 module_sp =
module->shared_from_this();
3290 const size_t indent = strm.
Printf(
"[%3u] ", image_idx);
3296 if (use_global_module_list)
3298 "the global module list has no matching modules");
3300 result.
AppendError(
"the target has no matching modules");
3302 if (use_global_module_list)
3303 result.
AppendError(
"the global module list is empty");
3306 "the target has no associated executable images");
3313 if (module ==
nullptr) {
3318 bool dump_object_name =
false;
3320 m_options.m_format_array.push_back(std::make_pair(
'u', 0));
3321 m_options.m_format_array.push_back(std::make_pair(
'h', 0));
3322 m_options.m_format_array.push_back(std::make_pair(
'f', 0));
3323 m_options.m_format_array.push_back(std::make_pair(
'S', 0));
3325 const size_t num_entries =
m_options.m_format_array.size();
3326 bool print_space =
false;
3327 for (
size_t i = 0; i < num_entries; ++i) {
3331 const char format_char =
m_options.m_format_array[i].first;
3332 uint32_t width =
m_options.m_format_array[i].second;
3333 switch (format_char) {
3344 dump_object_name =
true;
3353 dump_object_name =
true;
3360 uint32_t addr_nibble_width =
3363 ObjectFile *objfile =
module->GetObjectFile();
3370 base_addr.
Dump(&strm, &target,
3374 if (format_char ==
'o') {
3376 strm.
Printf(
"0x%*.*" PRIx64, addr_nibble_width,
3381 strm.
Printf(
"0x%*.*" PRIx64, addr_nibble_width,
3382 addr_nibble_width, load_addr);
3393 strm.
Printf(
"%*s", addr_nibble_width + 2,
"");
3398 size_t ref_count = 0;
3399 char in_shared_cache =
'Y';
3401 ModuleSP module_sp(module->shared_from_this());
3403 in_shared_cache =
'N';
3406 ref_count = module_sp.use_count() - 1;
3409 strm.
Printf(
"{%c %*" PRIu64
"}", in_shared_cache, width, (uint64_t)ref_count);
3411 strm.
Printf(
"{%c %" PRIu64
"}", in_shared_cache, (uint64_t)ref_count);
3418 symbol_file->GetObjectFile()->GetFileSpec();
3419 if (format_char ==
'S') {
3421 if (!symfile_spec || symfile_spec == module->
GetFileSpec()) {
3422 print_space =
false;
3426 strm.
Printf(
"\n%*s", indent,
"");
3429 dump_object_name =
true;
3432 strm.
Printf(
"%.*s", width,
"<NONE>");
3437 llvm::AlignStyle::Left, width));
3441 strm.
Printf(
"%p",
static_cast<void *
>(module));
3452 if (dump_object_name) {
3453 const char *object_name =
module->GetObjectName().GetCString();
3455 strm.
Printf(
"(%s)", object_name);
3456 std::optional<addr_t> memory_addr =
module->GetMemoryModuleAddress();
3457 if (memory_addr.has_value())
3458 strm.
Printf(
"(0x%" PRIx64
")", memory_addr.value());
3466#pragma mark CommandObjectTargetModulesShowUnwind
3469#define LLDB_OPTIONS_target_modules_show_unwind
3470#include "CommandOptions.inc"
3495 switch (short_option) {
3497 m_str = std::string(option_arg);
3503 "invalid address string '%s'", option_arg.str().c_str());
3508 m_str = std::string(option_arg);
3513 bool value, success;
3519 "invalid boolean value '{}' passed for -c option", option_arg);
3524 llvm_unreachable(
"Unimplemented option");
3538 return llvm::ArrayRef(g_target_modules_show_unwind_options);
3552 interpreter,
"target modules show-unwind",
3553 "Show synthesized unwind instructions for a function.", nullptr,
3554 eCommandRequiresTarget | eCommandRequiresProcess |
3555 eCommandProcessMustBeLaunched | eCommandProcessMustBePaused) {}
3567 abi = process->
GetABI().get();
3569 if (process ==
nullptr) {
3571 "You must have a process running to use this command.");
3577 result.
AppendError(
"the process must be paused to use this command");
3583 result.
AppendError(
"the process must be paused to use this command");
3595 function_options, sc_list);
3601 module_sp->ResolveSymbolContextForAddress(addr,
3602 eSymbolContextEverything, sc);
3609 "address-expression or function name option must be specified.");
3620 if (sc.symbol ==
nullptr && sc.function ==
nullptr)
3622 if (!sc.module_sp || sc.module_sp->GetObjectFile() ==
nullptr)
3624 Address addr = sc.GetFunctionOrSymbolAddress();
3634 UnwindTable &uw_table = sc.module_sp->GetUnwindTable();
3641 if (!func_unwinders_sp)
3645 "UNWIND PLANS for {0}`{1} (start addr {2:x})\n",
3646 sc.module_sp->GetPlatformFileSpec().GetFilename(), funcname,
3652 for (
size_t i = 0; i < count; i++) {
3654 if (strcmp(funcname.
GetCString(), trap_func_name) == 0)
3657 "treated as a trap handler function via user setting.\n");
3661 const std::vector<ConstString> trap_handler_names(
3662 platform_sp->GetTrapHandlerSymbolNames());
3663 for (
ConstString trap_name : trap_handler_names) {
3664 if (trap_name == funcname) {
3667 "name is listed by the platform as a trap handler.\n");
3674 if (std::shared_ptr<const UnwindPlan> plan_sp =
3675 func_unwinders_sp->GetUnwindPlanAtNonCallSite(*target, *thread)) {
3677 "Asynchronous (not restricted to call-sites) UnwindPlan is '{0}'\n",
3678 plan_sp->GetSourceName());
3680 if (std::shared_ptr<const UnwindPlan> plan_sp =
3681 func_unwinders_sp->GetUnwindPlanAtCallSite(*target, *thread)) {
3683 "Synchronous (restricted to call-sites) UnwindPlan is '{0}'\n",
3684 plan_sp->GetSourceName());
3686 if (std::shared_ptr<const UnwindPlan> plan_sp =
3687 func_unwinders_sp->GetUnwindPlanFastUnwind(*target, *thread)) {
3689 plan_sp->GetSourceName());
3694 if (std::shared_ptr<const UnwindPlan> plan_sp =
3695 func_unwinders_sp->GetAssemblyUnwindPlan(*target, *thread)) {
3697 "Assembly language inspection UnwindPlan:\n");
3703 if (std::shared_ptr<const UnwindPlan> plan_sp =
3704 func_unwinders_sp->GetObjectFileUnwindPlan(*target)) {
3711 if (std::shared_ptr<const UnwindPlan> plan_sp =
3712 func_unwinders_sp->GetObjectFileAugmentedUnwindPlan(*target,
3720 if (std::shared_ptr<const UnwindPlan> plan_sp =
3721 func_unwinders_sp->GetEHFrameUnwindPlan(*target)) {
3728 if (std::shared_ptr<const UnwindPlan> plan_sp =
3729 func_unwinders_sp->GetEHFrameAugmentedUnwindPlan(*target,
3737 if (std::shared_ptr<const UnwindPlan> plan_sp =
3738 func_unwinders_sp->GetDebugFrameUnwindPlan(*target)) {
3745 if (std::shared_ptr<const UnwindPlan> plan_sp =
3746 func_unwinders_sp->GetDebugFrameAugmentedUnwindPlan(*target,
3754 if (std::shared_ptr<const UnwindPlan> plan_sp =
3755 func_unwinders_sp->GetArmUnwindUnwindPlan(*target)) {
3762 if (std::shared_ptr<const UnwindPlan> plan_sp =
3763 func_unwinders_sp->GetSymbolFileUnwindPlan(*thread)) {
3770 if (std::shared_ptr<const UnwindPlan> plan_sp =
3771 func_unwinders_sp->GetCompactUnwindUnwindPlan(*target)) {
3778 if (std::shared_ptr<const UnwindPlan> plan_sp =
3779 func_unwinders_sp->GetUnwindPlanFastUnwind(*target, *thread)) {
3788 if (
UnwindPlanSP plan_sp = abi_sp->CreateDefaultUnwindPlan()) {
3795 if (
UnwindPlanSP plan_sp = abi_sp->CreateFunctionEntryUnwindPlan()) {
3797 "Arch default at entry point UnwindPlan:\n");
3813#define LLDB_OPTIONS_target_modules_lookup
3814#include "CommandOptions.inc"
3841 switch (short_option) {
3849 if (option_arg.getAsInteger(0,
m_offset))
3851 "invalid offset string '%s'", option_arg.str().c_str());
3855 m_str = std::string(option_arg);
3860 m_file.SetFile(option_arg, FileSpec::Style::native);
3871 "invalid line number string '%s'", option_arg.str().c_str());
3878 m_str = std::string(option_arg);
3883 m_str = std::string(option_arg);
3888 m_str = std::string(option_arg);
3908 llvm_unreachable(
"Unimplemented option");
3933 "conjunction with --verbose.");
3939 return llvm::ArrayRef(g_target_modules_lookup_options);
3960 "Look up information within executable and "
3961 "dependent shared library images.",
3962 nullptr, eCommandRequiresTarget) {
3971 bool &syntax_error) {
3989 const SymbolContext &sym_ctx(frame->GetSymbolContext(eSymbolContextModule));
4019 eSymbolContextEverything |
4021 ?
static_cast<int>(eSymbolContextVariable)
4066 m_options.m_use_regex, function_options,
4091 syntax_error =
true;
4102 assert(target &&
"target guaranteed by eCommandRequiresTarget");
4103 bool syntax_error =
false;
4105 uint32_t num_successful_lookups = 0;
4114 num_successful_lookups++;
4124 std::lock_guard<std::recursive_mutex> guard(target_modules.
GetMutex());
4125 if (target_modules.
GetSize() == 0) {
4126 result.
AppendError(
"the target has no associated executable images");
4134 num_successful_lookups++;
4139 const char *arg_cstr;
4144 const size_t num_matches =
4146 if (num_matches > 0) {
4147 for (
size_t j = 0; j < num_matches; ++j) {
4152 num_successful_lookups++;
4158 "unable to find an image that matches '{0}'", arg_cstr);
4162 if (num_successful_lookups > 0)
4171#pragma mark CommandObjectMultiwordImageSearchPaths
4180 interpreter,
"target modules search-paths",
4181 "Commands for managing module search paths for a target.",
4182 "target modules search-paths <subcommand> [<subcommand-options>]") {
4204#pragma mark CommandObjectTargetModules
4213 "Commands for accessing information for one or "
4214 "more target modules.",
4215 "target modules <sub-command> ...") {
4249 interpreter,
"target symbols add",
4250 "Add a debug symbol file to one of the target's current modules by "
4251 "specifying a path to a debug symbols file or by using the options "
4252 "to specify a module.",
4253 "target symbols add <cmd-options> [<symfile>]",
4254 eCommandRequiresTarget),
4258 "Locate the debug symbols for the shared library specified by "
4262 "Locate the debug symbols for the currently selected frame.", false,
4265 "Locate the debug symbols for every frame in "
4266 "the current call stack.",
4289 if (!symbol_fspec) {
4291 "one or more executable image paths must be specified");
4296 symbol_fspec.
GetPath(symfile_path,
sizeof(symfile_path));
4311 if (symfile_module_specs.
GetSize() > 0) {
4317 symfile_module_spec)) {
4321 symfile_uuid_module_spec.
GetUUID() = symfile_module_spec.
GetUUID();
4327 if (matching_modules.
IsEmpty()) {
4330 const size_t num_symfile_module_specs = symfile_module_specs.
GetSize();
4332 i < num_symfile_module_specs && matching_modules.
IsEmpty(); ++i) {
4334 i, symfile_module_spec)) {
4338 symfile_uuid_module_spec.
GetUUID() =
4339 symfile_module_spec.
GetUUID();
4350 if (matching_modules.
IsEmpty())
4353 while (matching_modules.
IsEmpty()) {
4357 if (!filename_no_extension)
4369 if (matching_modules.
GetSize() > 1) {
4371 "use the --uuid option to resolve the "
4377 if (matching_modules.
GetSize() == 1) {
4383 module_sp->SetSymbolFileFileSpec(symbol_fspec);
4389 if (object_file && object_file->
GetFileSpec() == symbol_fspec) {
4391 const FileSpec &module_fs = module_sp->GetFileSpec();
4393 "symbol file '{0}' has been added to '{1}'", symfile_path,
4399 module_list.
Append(module_sp);
4404 std::list<Status> errors;
4406 for (
const auto &err : errors)
4415 module_sp->SetSymbolFileFileSpec(
FileSpec());
4420 ss_symfile_uuid <<
" (";
4422 ss_symfile_uuid <<
')';
4425 "symbol file '%s'%s does not match any existing module%s", symfile_path,
4427 !llvm::sys::fs::is_regular_file(symbol_fspec.
GetPath())
4428 ?
"\n please specify the full path to the symbol file"
4455 error_strm.
PutCString(
"unable to find debug symbols for UUID ");
4475 module_spec.
GetFileSpec() = module_sp->GetFileSpec();
4477 module_spec.
GetUUID() = module_sp->GetUUID();
4486 "unable to find debug symbols for the executable file ");
4501 "a process must exist in order to use the --frame option");
4520 if (!frame_module_sp) {
4526 module_spec.
GetUUID() = frame_module_sp->GetUUID();
4528 module_spec.
GetFileSpec() = frame_module_sp->GetPlatformFileSpec();
4531 result.
AppendError(
"unable to find debug symbols for the current frame");
4544 "a process must exist in order to use the --stack option");
4561 bool symbols_found =
false;
4562 uint32_t frame_count = thread->GetStackFrameCount();
4563 for (uint32_t i = 0; i < frame_count; ++i) {
4567 frame_sp->GetSymbolContext(eSymbolContextModule).module_sp);
4568 if (!frame_module_sp)
4572 module_spec.
GetUUID() = frame_module_sp->GetUUID();
4573 module_spec.
GetFileSpec() = frame_module_sp->GetPlatformFileSpec();
4576 bool current_frame_flush =
false;
4578 symbols_found =
true;
4579 flush |= current_frame_flush;
4582 if (!symbols_found) {
4584 "unable to find debug symbols in the current call stack");
4596 const bool uuid_option_set =
4598 const bool file_option_set =
m_file_option.GetOptionValue().OptionWasSet();
4599 const bool frame_option_set =
4601 const bool stack_option_set =
4606 if (uuid_option_set)
4608 else if (file_option_set)
4610 else if (frame_option_set)
4612 else if (stack_option_set)
4615 result.
AppendError(
"one or more symbol file paths must be specified, "
4616 "or options must be specified");
4618 if (uuid_option_set) {
4619 result.
AppendError(
"specify either one or more paths to symbol files "
4620 "or use the --uuid option without arguments");
4621 }
else if (frame_option_set) {
4622 result.
AppendError(
"specify either one or more paths to symbol files "
4623 "or use the --frame option without arguments");
4624 }
else if (file_option_set && argc > 1) {
4625 result.
AppendError(
"specify at most one symbol file path when "
4626 "--shlib option is set");
4630 for (
auto &entry : args.
entries()) {
4631 if (!entry.ref().empty()) {
4633 symbol_file_spec.
SetFile(entry.ref(), FileSpec::Style::native);
4635 if (file_option_set) {
4642 ->ResolveSymbolFile(*target, module_spec, symfile_spec)
4647 bool symfile_exists =
4650 if (symfile_exists) {
4654 std::string resolved_symfile_path =
4656 if (resolved_symfile_path != entry.ref()) {
4658 "invalid module path '%s' with resolved path '%s'",
4659 entry.c_str(), resolved_symfile_path.c_str());
4685#pragma mark CommandObjectTargetSymbols
4694 interpreter,
"target symbols",
4695 "Commands for adding and managing debug symbol files.",
4696 "target symbols <sub-command> ...") {
4710#pragma mark CommandObjectTargetStopHookAdd
4713#define LLDB_OPTIONS_target_stop_hook_add
4714#include "CommandOptions.inc"
4726 return llvm::ArrayRef(g_target_stop_hook_add_options);
4732 const int short_option =
4733 g_target_stop_hook_add_options[option_idx].short_option;
4735 switch (short_option) {
4742 if (option_arg.getAsInteger(0,
m_line_end)) {
4744 "invalid end line number: \"%s\"", option_arg.str().c_str());
4751 bool value, success;
4757 "invalid boolean value '%s' passed for -G option",
4758 option_arg.str().c_str());
4763 "invalid start line number: \"%s\"", option_arg.str().c_str());
4792 "invalid thread id string '%s'", option_arg.str().c_str());
4809 "invalid thread index string '%s'", option_arg.str().c_str());
4819 bool value, success;
4825 "invalid boolean value '%s' passed for -F option",
4826 option_arg.str().c_str());
4830 llvm_unreachable(
"Unimplemented option");
4865 eFunctionNameTypeAuto;
4883 "Add a hook to be executed when the target stops."
4884 "The hook can either be a list of commands or an "
4885 "appropriately defined Python class. You can also "
4886 "add filters so the hook only runs a certain stop "
4888 "target stop-hook add", eCommandAllowsDummyTarget),
4894Command Based stop-hooks:
4895-------------------------
4896 Stop hooks can run a list of lldb commands by providing one or more
4897 --one-liner options. The commands will get run in the order they are added.
4898 Or you can provide no commands, in which case you will enter a command editor
4899 where you can enter the commands to be run.
4901Python Based Stop Hooks:
4902------------------------
4903 Stop hooks can be implemented with a suitably defined Python class, whose name
4904 is passed in the --python-class option.
4906 When the stop hook is added, the class is initialized by calling:
4908 def __init__(self, target, extra_args, internal_dict):
4910 target: The target that the stop hook is being added to.
4911 extra_args: An SBStructuredData Dictionary filled with the -key -value
4912 option pairs passed to the command.
4913 dict: An implementation detail provided by lldb.
4915 Then when the stop-hook triggers, lldb will run the 'handle_stop' method.
4916 The method has the signature:
4918 def handle_stop(self, exe_ctx, stream):
4920 exe_ctx: An SBExecutionContext for the thread that has stopped.
4921 stream: An SBStream, anything written to this stream will be printed in the
4922 the stop message when the process stops.
4924 Return Value: The method returns "should_stop". If should_stop is false
4925 from all the stop hook executions on threads that stopped
4926 with a reason, then the process will continue. Note that this
4927 will happen only after all the stop hooks are run.
4931 Stop hooks can be set to always run, or to only run when the stopped thread
4932 matches the filter options passed on the command line. The available filter
4933 options include a shared library or a thread or queue specification,
4934 a line range in a source file, a function name or a class name.
4954 "Enter your stop hook command(s). Type 'DONE' to end.\n");
4960 std::string &line)
override {
4966 locked_stream.
Printf(
"error: stop hook #%" PRIu64
4967 " aborted, no commands.\n",
4973 Target::StopHookCommandLine *hook_ptr =
4974 static_cast<Target::StopHookCommandLine *
>(
m_stop_hook_sp.get());
4979 LockedStreamFile locked_stream = output_sp->Lock();
4980 locked_stream.
Printf(
"Stop hook #%" PRIu64
" added.\n",
4989 void DoExecute(Args &command, CommandReturnObject &result)
override {
4993 assert(target &&
"target guaranteed by eCommandRequiresTarget");
4996 ? Target::StopHook::StopHookKind::CommandBased
4997 : Target::StopHook::StopHookKind::ScriptBased);
5000 std::unique_ptr<SymbolContextSpecifier> specifier_up;
5003 std::make_unique<SymbolContextSpecifier>(target->shared_from_this());
5006 specifier_up->AddSpecification(
5012 specifier_up->AddSpecification(
5018 specifier_up->AddSpecification(
m_options.m_file_name.c_str(),
5023 specifier_up->AddLineSpecification(
5029 specifier_up->AddLineSpecification(
5033 if (!
m_options.m_function_name.empty()) {
5034 specifier_up->AddSpecification(
5041 new_hook_sp->SetSpecifier(specifier_up.release());
5044 new_hook_sp->SetRunAtInitialStop(
m_options.m_at_initial_stop);
5049 ThreadSpec *thread_spec =
new ThreadSpec();
5064 new_hook_sp->SetThreadSpecifier(thread_spec);
5074 new_hook_sp->GetID());
5077 Target::StopHookScripted *hook_ptr =
5078 static_cast<Target::StopHookScripted *
>(new_hook_sp.get());
5079 ScriptedMetadata scripted_metadata(
5083 if (
error.Success())
5085 new_hook_sp->GetID());
5109#pragma mark CommandObjectTargetStopHookDelete
5117 interpreter,
"target stop-hook delete",
"Delete a stop-hook.",
5118 "target stop-hook delete [<idx>]", eCommandAllowsDummyTarget) {
5121Deletes the stop hook by index.
5123At any given stop, all enabled stop hooks that pass the stop filter will
5124get a chance to run. That means if one stop-hook deletes another stop hook
5125while executing, the deleted stop hook will still fire for the stop at which
5144 assert(target &&
"target guaranteed by eCommandRequiresTarget");
5147 if (num_args == 0) {
5155 for (
size_t i = 0; i < num_args; i++) {
5173#pragma mark CommandObjectTargetStopHookEnableDisable
5180 bool enable,
const char *name,
5181 const char *help,
const char *syntax)
5183 eCommandAllowsDummyTarget),
5201 assert(target &&
"target guaranteed by eCommandRequiresTarget");
5206 if (num_args == 0) {
5209 for (
size_t i = 0; i < num_args; i++) {
5231#pragma mark CommandObjectTargetStopHookList
5234#define LLDB_OPTIONS_target_stop_hook_list
5235#include "CommandOptions.inc"
5241 "List all stop-hooks.", nullptr,
5242 eCommandAllowsDummyTarget) {}
5258 switch (short_option) {
5263 llvm_unreachable(
"Unimplemented option");
5274 return llvm::ArrayRef(g_target_stop_hook_list_options);
5284 assert(target &&
"target guaranteed by eCommandRequiresTarget");
5285 bool printed_hook =
false;
5290 printed_hook =
true;
5303#pragma mark CommandObjectMultiwordTargetStopHooks
5311 interpreter,
"target stop-hook",
5312 "Commands for operating on debugger target stop-hooks.",
5313 "target stop-hook <subcommand> [<subcommand-options>]") {
5321 interpreter,
false,
"target stop-hook disable [<id>]",
5322 "Disable a stop-hook.",
"target stop-hook disable")));
5325 interpreter,
true,
"target stop-hook enable [<id>]",
5326 "Enable a stop-hook.",
"target stop-hook enable")));
5334#pragma mark CommandObjectTargetHookAdd
5336#define LLDB_OPTIONS_target_hook_add
5337#include "CommandOptions.inc"
5348 return llvm::ArrayRef(g_target_hook_add_options);
5354 const int short_option =
5355 g_target_hook_add_options[option_idx].short_option;
5356 switch (short_option) {
5375 uint32_t thread_index;
5376 if (option_arg.getAsInteger(0, thread_index))
5378 option_arg.str().c_str());
5386 if (option_arg.getAsInteger(0, thread_id))
5388 option_arg.str().c_str());
5408 if (option_arg.getAsInteger(0, line))
5410 "invalid start line number '%s'", option_arg.str().c_str());
5418 if (option_arg.getAsInteger(0, line))
5420 "invalid end line number '%s'", option_arg.str().c_str());
5435 bool value, success;
5441 "invalid boolean value '%s' passed for -G option",
5442 option_arg.str().c_str());
5446 bool value, success;
5452 "invalid boolean value '%s' passed for -I option",
5453 option_arg.str().c_str());
5457 llvm_unreachable(
"unhandled option");
5509 interpreter,
"target hook add",
5510 "Add a hook to be executed on target lifecycle events.",
5511 "target hook add", eCommandAllowsDummyTarget),
5518 Specify which triggers the hook responds to with --on-load (-L),
5519 --on-unload (-u), and/or --on-stop (-S). At least one trigger is required.
5520 Provide commands with --one-liner (-o), or omit -o to enter an interactive
5521 command editor. All commands run for every trigger the hook is signed up
5522 for; there is no per-trigger command list.
5525 target hook add -L -o "script print('module loaded')"
5526 target hook add -L -u -o "script print('module event')"
5527 target hook add -S -o "bt"
5528 target hook add -L -u -S -o "script print('all events')"
5529 target hook add -S -s mylib.so -n main -o "bt"
5530 target hook add -S -G true -o "thread info"
5534 Provide a Python class with --python-class (-P). The class controls which
5535 events it handles by implementing the corresponding methods; you do not
5536 specify triggers on the command line. Use -k <key> -v <value> to pass
5537 extra_args to the class constructor.
5540 target hook add -P mymodule.MyHook
5541 target hook add -P mymodule.MyHook -k verbose -v true
5543 The Python class should implement at least one of these methods:
5546 def __init__(self, target, extra_args, internal_dict):
5547 self.target = target
5548 def handle_module_loaded(self, stream):
5550 def handle_module_unloaded(self, stream):
5552 def handle_stop(self, exe_ctx, stream):
5553 return True # True = should_stop, False = continue
5557 Filters (-s, -f, -l, -e, -c, -n, -x, -t, -T, -q) restrict when the hook
5558 fires. They apply to both command-based and Python class hooks.
5581 "Enter your hook command(s). Type 'DONE' to end.\n");
5587 std::string &line)
override {
5592 LockedStreamFile locked_stream = error_sp->Lock();
5593 locked_stream.
Printf(
"error: hook #%" PRIu64
5594 " aborted, no commands.\n",
5599 auto *hook =
static_cast<Target::HookCommandLine *
>(
m_hook_sp.get());
5600 hook->SetActionFromString(line);
5603 LockedStreamFile locked_stream = output_sp->Lock();
5604 locked_stream.
Printf(
"Hook #%" PRIu64
" added.\n",
5613 void DoExecute(Args &command, CommandReturnObject &result)
override {
5616 assert(target &&
"target guaranteed by eCommandRequiresTarget");
5622 result.
AppendError(
"at least one trigger must be specified: "
5623 "--on-load (-L), --on-unload (-u), or --on-stop (-S)");
5628 is_python_class ? Target::Hook::HookKind::ScriptBased
5629 : Target::Hook::HookKind::CommandBased;
5633 if (!is_python_class) {
5636 static_cast<Target::HookCommandLine *
>(new_hook_sp.get());
5637 uint32_t trigger_mask = 0;
5644 cmd_hook->SetTriggerMask(trigger_mask);
5652 std::make_unique<SymbolContextSpecifier>(target->shared_from_this());
5655 specifier_up->AddSpecification(
5660 specifier_up->AddSpecification(
5665 specifier_up->AddSpecification(
m_options.m_file_name.c_str(),
5669 specifier_up->AddLineSpecification(
5674 specifier_up->AddLineSpecification(
5678 specifier_up->AddSpecification(
5682 new_hook_sp->SetSCSpecifier(specifier_up.release());
5687 ThreadSpec *thread_spec =
new ThreadSpec();
5701 new_hook_sp->SetThreadSpecifier(thread_spec);
5711 new_hook_sp->GetID());
5713 auto *hook =
static_cast<Target::HookScripted *
>(new_hook_sp.get());
5714 ScriptedMetadata scripted_metadata(
5717 Status callback_error = hook->SetScriptCallback(scripted_metadata);
5718 if (callback_error.
Fail()) {
5725 new_hook_sp->GetID());
5741#pragma mark CommandObjectTargetHookDelete
5747 "target hook delete [<id>]",
5748 eCommandAllowsDummyTarget) {
5757 assert(target &&
"target guaranteed by eCommandRequiresTarget");
5785#pragma mark CommandObjectTargetHookEnableDisable
5790 bool enable,
const char *name,
5791 const char *help,
const char *syntax)
5793 eCommandAllowsDummyTarget),
5803 assert(target &&
"target guaranteed by eCommandRequiresTarget");
5831#pragma mark CommandObjectTargetHookModify
5833#define LLDB_OPTIONS_target_hook_modify
5834#include "CommandOptions.inc"
5846 return llvm::ArrayRef(g_target_hook_modify_options);
5852 const int short_option =
5853 g_target_hook_modify_options[option_idx].short_option;
5854 switch (short_option) {
5862 llvm_unreachable(
"unhandled option");
5878 "Modify trigger settings on a hook.",
5879 "target hook modify [--enable-trigger <name>] "
5880 "[--disable-trigger <name>] [<id>]",
5881 eCommandAllowsDummyTarget) {
5884Modify trigger settings on command-based hooks. Scripted hooks derive their
5885triggers from the class methods and cannot be modified.
5887If no hook ID is given, the last added hook is modified.
5889Valid trigger names: load, unload, stop.
5892 target hook modify --enable-trigger stop 1
5893 target hook modify --disable-trigger load 1
5894 target hook modify --enable-trigger stop (modifies last added hook)
5906 if (name ==
"unload")
5915 assert(target &&
"target guaranteed by eCommandRequiresTarget");
5918 result.
AppendError(
"at least one of --enable-trigger or "
5919 "--disable-trigger must be specified");
5927 if (num_hooks == 0) {
5948 if (hook_sp->GetHookKind() != Target::Hook::HookKind::CommandBased) {
5949 result.
AppendError(
"cannot modify triggers on a scripted hook; "
5950 "triggers are determined by the class methods");
5953 auto *cmd_hook =
static_cast<Target::HookCommandLine *
>(hook_sp.get());
5955 if (!
m_options.m_enable_trigger.empty()) {
5959 "Valid names: load, unload, stop",
5963 cmd_hook->AddTrigger(trigger);
5966 if (!
m_options.m_disable_trigger.empty()) {
5970 "Valid names: load, unload, stop",
5974 cmd_hook->RemoveTrigger(trigger);
5984#pragma mark CommandObjectTargetHookList
5990 "target hook list", eCommandAllowsDummyTarget) {}
5997 assert(target &&
"target guaranteed by eCommandRequiresTarget");
5999 if (num_hooks == 0) {
6002 for (
size_t i = 0; i < num_hooks; i++) {
6013#pragma mark CommandObjectMultiwordTargetHooks
6019 interpreter,
"target hook",
6020 "Commands for operating on target hooks.",
6021 "target hook <subcommand> [<subcommand-options>]") {
6028 interpreter,
false,
"target hook disable",
6029 "Disable a hook.",
"target hook disable [<id> ...]")));
6032 interpreter,
true,
"target hook enable",
6033 "Enable a hook.",
"target hook enable [<id> ...]")));
6043#pragma mark CommandObjectTargetDumpTypesystem
6050 interpreter,
"target dump typesystem",
6051 "Dump the state of the target's internal type system. Intended to "
6052 "be used for debugging LLDB itself.",
6053 nullptr, eCommandRequiresTarget) {}
6069#pragma mark CommandObjectTargetDumpSectionLoadList
6076 interpreter,
"target dump section-load-list",
6077 "Dump the state of the target's internal section load list. "
6078 "Intended to be used for debugging LLDB itself.",
6079 nullptr, eCommandRequiresTarget) {}
6086 assert(target &&
"target guaranteed by eCommandRequiresTarget");
6092#pragma mark CommandObjectTargetDump
6100 interpreter,
"target dump",
6101 "Commands for dumping information about the target.",
6102 "target dump [typesystem|section-load-list]") {
6114#pragma mark CommandObjectTargetFrameProvider
6116#define LLDB_OPTIONS_target_frame_provider_register
6117#include "CommandOptions.inc"
6123 interpreter,
"target frame-provider register",
6124 "Register frame provider for all threads in this target.", nullptr,
6125 eCommandRequiresTarget),
6138 uint32_t index)
override {
6139 return std::string(
"");
6165 result.
SetError(id_or_err.takeError());
6170 "successfully registered scripted frame provider '{0}' for target",
6182 interpreter,
"target frame-provider clear",
6183 "Clear all registered frame providers from this target.", nullptr,
6184 eCommandRequiresTarget) {}
6206 interpreter,
"target frame-provider list",
6207 "List all registered frame providers for the target.", nullptr,
6208 eCommandRequiresTarget) {}
6219 if (descriptors.empty()) {
6220 result.
AppendMessage(
"no frame providers registered for this target.");
6226 strm << llvm::formatv(
"{0} frame provider(s) registered:\n\n",
6227 descriptors.size());
6229 for (
const auto &entry : descriptors) {
6231 descriptor.
Dump(&strm);
6243 interpreter,
"target frame-provider remove",
6244 "Remove a registered frame provider from the target by id.",
6245 "target frame-provider remove <provider-id>",
6246 eCommandRequiresTarget) {
6258 std::vector<uint32_t> removed_provider_ids;
6260 uint32_t provider_id = 0;
6261 if (!llvm::to_integer(command[i].ref(), provider_id)) {
6262 result.
AppendError(
"target frame-provider remove requires integer "
6263 "provider id argument");
6269 "no frame provider named '%u' found in target", provider_id);
6272 removed_provider_ids.push_back(provider_id);
6275 if (
size_t num_removed_providers = removed_provider_ids.size()) {
6277 "Successfully removed {0} frame-providers.", num_removed_providers);
6280 result.
AppendError(
"0 frame providers removed.\n");
6289 interpreter,
"target frame-provider",
6290 "Commands for registering and viewing frame providers for the "
6292 "target frame-provider [<sub-command-options>] ") {
6310#pragma mark CommandObjectMultiwordTarget
6317 "Commands for operating on debugger targets.",
6318 "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 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)
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
~CommandObjectTargetModulesDumpClangPCMInfo() override=default
CommandObjectTargetModulesDumpClangPCMInfo(CommandInterpreter &interpreter)
void DoExecute(Args &command, CommandReturnObject &result) override
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.
void Dump(Stream *s, const char *value_if_empty=nullptr) const
Dump the object description to a stream.
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.
const char * AsCString(const char *value_if_empty) const
Get the string value as a C string.
A class to manage flag bits.
TargetList & GetTargetList()
Get accessor for the target list.
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.
void SetDirectory(ConstString directory)
Directory string set accessor.
const ConstString & GetFilename() const
Filename string const get accessor.
const ConstString & GetDirectory() const
Directory string const get accessor.
ConstString GetFileNameStrippingExtension() const
Return the filename without the extension part.
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
void Dump(llvm::raw_ostream &s) const
Dump this object to a Stream.
llvm::StringRef GetFileNameExtension() const
Extract the extension of the file.
void SetFilename(ConstString filename)
Filename string set accessor.
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)
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
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 RemapPath(ConstString path, ConstString &new_path) const
bool GetPathsAtIndex(uint32_t idx, ConstString &path, ConstString &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(ConstString section_dstr) 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)
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.
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)
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)
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::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.