15#include "lldb/Host/Config.h"
38#include "llvm/ADT/STLExtras.h"
89 for (
auto entry : llvm::enumerate(command.
entries().drop_back())) {
90 if (entry.value().ref() !=
"unsigned")
92 auto next = command.
entries()[entry.index() + 1].ref();
93 if (next ==
"int" || next ==
"short" || next ==
"char" || next ==
"long") {
95 "unsigned {0} being treated as two types. if you meant the combined "
96 "type name use quotes, as in \"unsigned {0}\"",
112 return "synthetic child provider";
117 llvm_unreachable(
"Fully covered switch above!");
120#define LLDB_OPTIONS_type_summary_add
121#include "CommandOptions.inc"
138 return llvm::ArrayRef(g_type_summary_add_options);
172 static const char *g_summary_addreader_instructions =
173 "Enter your Python command(s). Type 'DONE' to end.\n"
174 "def function (valobj,internal_dict):\n"
175 " \"\"\"valobj: an SBValue which you want to provide a summary "
177 " internal_dict: an LLDB support object not to be used\"\"\"\n";
182 locked_stream.
PutCString(g_summary_addreader_instructions);
188 std::string &data)
override {
191#if LLDB_ENABLE_PYTHON
206 std::string funct_name_str;
209 if (funct_name_str.empty()) {
212 "unable to obtain a valid function name from "
213 "the script interpreter.\n");
219 script_format = std::make_shared<ScriptSummaryFormat>(
220 options->m_flags, funct_name_str.c_str(),
221 lines.
CopyList(
" ").c_str(), options->m_ptr_match_depth);
225 for (
const std::string &type_name : options->m_target_types) {
226 AddSummary(type_name, script_format, options->m_match_type,
227 options->m_category, &
error);
230 locked_stream.
Printf(
"error: %s",
error.AsCString());
234 if (!options->m_name.empty()) {
236 options->m_name, script_format, &
error);
239 options->m_name, script_format, &
error);
242 locked_stream.
Printf(
"error: %s",
error.AsCString());
246 locked_stream.
Printf(
"error: %s",
error.AsCString());
249 if (
error.AsCString()) {
251 locked_stream.
Printf(
"error: %s",
error.AsCString());
258 "error: unable to generate a function.\n");
262 locked_stream.
PutCString(
"error: no script interpreter.\n");
266 locked_stream.
Printf(
"error: internal synchronization information "
267 "missing or invalid.\n");
272 "error: empty function, didn't add python command.\n");
277 "error: script interpreter missing, didn't add python command.\n");
295 "Enter your Python command(s). Type 'DONE' to end.\n"
296 "You must define a Python class with these methods:\n"
297 " def __init__(self, valobj: lldb.SBValue, internal_dict):\n"
298 " def num_children(self) -> int:\n"
299 " def get_child_at_index(self, index: int) -> lldb.SBValue | None:\n"
300 " def get_child_index(self, name: str) -> int:\n"
301 " def update(self) -> bool:\n"
303 "class synthProvider:\n";
305#define LLDB_OPTIONS_type_synth_add
306#include "CommandOptions.inc"
323 switch (short_option) {
328 "invalid value for cascade: %s", option_arg.str().c_str());
334 "invalid value for wants-dereference: %s",
335 option_arg.str().c_str());
356 "can't use --regex and --recognizer-function at the same time");
363 "can't use --regex and --recognizer-function at the same time");
368 llvm_unreachable(
"Unimplemented option");
387 return llvm::ArrayRef(g_type_synth_add_options);
421 result.
AppendError(
"must either provide a children list, a Python class "
422 "name, or use -P and type a Python class "
437 std::string &data)
override {
440#if LLDB_ENABLE_PYTHON
455 std::string class_name_str;
457 if (class_name_str.empty()) {
461 "error: unable to obtain a proper name for the class.\n");
467 synth_provider = std::make_shared<ScriptedSyntheticChildren>(
469 .SetCascades(options->m_cascade)
473 class_name_str.c_str());
481 for (
const std::string &type_name : options->m_target_types) {
482 if (!type_name.empty()) {
483 if (
AddSynth(type_name, synth_provider,
484 options->m_match_type, options->m_category,
487 locked_stream.
Printf(
"error: %s\n",
error.AsCString());
492 locked_stream.
PutCString(
"error: invalid type name.\n");
499 locked_stream.
PutCString(
"error: unable to generate a class.\n");
503 locked_stream.
PutCString(
"error: no script interpreter.\n");
508 "error: internal synchronization data missing.\n");
513 "error: empty function, didn't add python command.\n");
518 "error: script interpreter missing, didn't add python command.\n");
537#define LLDB_OPTIONS_type_format_add
538#include "CommandOptions.inc"
549 return llvm::ArrayRef(g_type_format_add_options);
564 const int short_option =
565 g_type_format_add_options[option_idx].short_option;
568 switch (short_option) {
573 "invalid value for cascade: %s", option_value.str().c_str());
591 llvm_unreachable(
"Unimplemented option");
616 "Add a new formatting style for a type.", nullptr),
622The following examples of 'type format add' refer to this code snippet for context:
625 typedef float Afloat;
627 typedef Afloat Bfloat;
635Adding default formatting:
637(lldb) type format add -f hex AInt
638(lldb) frame variable iy
641 " Produces hexadecimal display of iy, because no formatter is available for Bint and \
642the one for Aint is used instead."
645To prevent this use the cascade option '-C no' to prevent evaluation of typedef chains:
648(lldb) type format add -f hex -C no AInt
650Similar reasoning applies to this:
652(lldb) type format add -f hex -C no float -p
655 " All float values and float references are now formatted as hexadecimal, but not \
656pointers to floats. Nor will it change the default display for Afloat and Bfloat objects.");
689 entry = std::make_shared<TypeFormatImpl_Format>(
690 format, TypeFormatImpl::Flags()
695 entry = std::make_shared<TypeFormatImpl_EnumType>(
697 TypeFormatImpl::Flags()
712 for (
auto &arg_entry : command.
entries()) {
713 if (arg_entry.ref().empty()) {
722 if (!typeRX.IsValid()) {
724 "regex format error (maybe this is not really a regex?)");
728 category_sp->AddTypeFormat(arg_entry.ref(), match_type, entry);
735#define LLDB_OPTIONS_type_formatter_delete
736#include "CommandOptions.inc"
751 switch (short_option) {
762 llvm_unreachable(
"Unimplemented option");
775 return llvm::ArrayRef(g_type_formatter_delete_options);
791 "Delete an existing %s for a type.";
794 "Delete an existing %s for a type. Unless you specify a "
795 "specific category or all categories, only the "
796 "'default' category is searched. The names must be exactly as "
797 "shown in the 'type %s list' output";
817 s.
Printf(
"type %s delete", short_kind);
851 if (typeCS.empty()) {
866 bool delete_category =
false;
867 bool extra_deletion =
false;
885 if (delete_category || extra_deletion) {
893#define LLDB_OPTIONS_type_formatter_clear
894#include "CommandOptions.inc"
909 switch (short_option) {
914 llvm_unreachable(
"Unimplemented option");
925 return llvm::ArrayRef(g_type_formatter_clear_options);
940 const char *name,
const char *help)
993 "Delete all existing format styles.") {}
996#define LLDB_OPTIONS_type_formatter_list
997#include "CommandOptions.inc"
999template <
typename FormatterType>
1016 switch (short_option) {
1023 if (
error.Success())
1027 llvm_unreachable(
"Unimplemented option");
1039 return llvm::ArrayRef(g_type_formatter_list_options);
1054 const char *name,
const char *help)
1072 return regex ==
nullptr || s == regex->
GetText() || regex->
Execute(s);
1078 std::unique_ptr<RegularExpression> category_regex;
1079 std::unique_ptr<RegularExpression> formatter_regex;
1081 if (
m_options.m_category_regex.OptionWasSet()) {
1082 category_regex = std::make_unique<RegularExpression>(
1083 m_options.m_category_regex.GetCurrentValueAsRef());
1084 if (!category_regex->IsValid()) {
1086 "syntax error in category regular expression '%s'",
1087 m_options.m_category_regex.GetCurrentValueAsRef().str().c_str());
1094 formatter_regex = std::make_unique<RegularExpression>(arg);
1095 if (!formatter_regex->IsValid()) {
1102 bool any_printed =
false;
1104 auto category_closure =
1105 [&result, &formatter_regex,
1108 "-----------------------\nCategory: %s%s\n-----------------------\n",
1109 category->GetName(), category->IsEnabled() ?
"" :
" (disabled)");
1112 [&result, &formatter_regex,
1116 formatter_regex.get())) {
1119 type_matcher.GetMatchString(),
1120 format_sp->GetDescription());
1124 category->ForEach(print_formatter);
1127 if (
m_options.m_category_language.OptionWasSet()) {
1130 m_options.m_category_language.GetCurrentValue(), category_sp);
1132 category_closure(category_sp);
1135 [&category_regex, &category_closure](
1138 category_closure(category);
1162 "Show a list of current formats.") {}
1166 uint32_t option_idx, llvm::StringRef option_arg,
1169 const int short_option = g_type_summary_add_options[option_idx].short_option;
1172 switch (short_option) {
1177 option_arg.str().c_str());
1180 m_flags.SetDontShowChildren(
false);
1183 m_flags.SetHideEmptyAggregates(
true);
1186 m_flags.SetDontShowValue(
true);
1189 m_flags.SetShowMembersOneLiner(
true);
1195 m_flags.SetSkipPointers(
true);
1200 "invalid integer value for option '%c': %s", short_option,
1205 m_flags.SetSkipReferences(
true);
1210 "can't use --regex and --recognizer-function at the same time");
1217 "can't use --regex and --recognizer-function at the same time");
1222 m_name = std::string(option_arg);
1239 m_flags.SetHideItemNames(
true);
1242 llvm_unreachable(
"Unimplemented option");
1250 m_flags.Clear().SetCascades().SetDontShowChildren().SetDontShowValue(
false);
1251 m_flags.SetShowMembersOneLiner(
false)
1252 .SetSkipPointers(
false)
1253 .SetSkipReferences(
false)
1254 .SetHideItemNames(
false);
1265#if LLDB_ENABLE_PYTHON
1271 if (argc < 1 &&
m_options.m_name.empty()) {
1283 if (!funct_name || !funct_name[0]) {
1289 (
" " +
m_options.m_python_function +
"(valobj,internal_dict)");
1291 script_format = std::make_shared<ScriptSummaryFormat>(
1292 m_options.m_flags, funct_name, code.c_str(),
1299 "the provided function \"{0}\" does not exist - "
1300 "please define it before attempting to use this summary",
1307 result.
AppendError(
"script interpreter missing - unable to generate "
1308 "function wrapper.\n");
1311 StringList funct_sl;
1312 funct_sl <<
m_options.m_python_script.c_str();
1313 std::string funct_name_str;
1315 result.
AppendError(
"unable to generate function wrapper.\n");
1318 if (funct_name_str.empty()) {
1320 "script interpreter failed to generate a valid function name.\n");
1324 std::string code =
" " +
m_options.m_python_script;
1326 script_format = std::make_shared<ScriptSummaryFormat>(
1327 m_options.m_flags, funct_name_str.c_str(), code.c_str(),
1331 auto options = std::make_unique<ScriptAddOptions>(
1335 for (
auto &entry : command.
entries()) {
1336 if (entry.ref().empty()) {
1337 result.
AppendError(
"empty typenames not allowed");
1341 options->m_target_types << std::string(entry.ref());
1359 for (
auto &entry : command.
entries()) {
1372 result.
AppendError(
"added to types, but not given a name");
1381 Args &command, CommandReturnObject &result) {
1384 if (argc < 1 &&
m_options.m_name.empty()) {
1391 if (class_name.empty()) {
1392 result.
AppendError(
"must provide a Python class name");
1401 for (
auto &entry : command.
entries()) {
1414 result.
AppendError(
"added to types, but not given a name");
1428 if (argc < 1 &&
m_options.m_name.empty()) {
1434 if (!
m_options.m_flags.GetShowMembersOneLiner() &&
1436 result.
AppendError(
"empty summary strings not allowed");
1440 const char *format_cstr = (
m_options.m_flags.GetShowMembersOneLiner()
1445 if (strcmp(format_cstr,
"${var%S}") == 0) {
1446 result.
AppendError(
"recursive summary not allowed");
1452 if (!string_format) {
1456 if (string_format->m_error.Fail()) {
1458 string_format->m_error.AsCString(
"<unknown>"));
1465 for (
auto &arg_entry : command.
entries()) {
1466 if (arg_entry.ref().empty()) {
1467 result.
AppendError(
"empty typenames not allowed");
1484 result.
AppendError(
"added to types, but not given a name");
1496 "Add a new summary style for a type.", nullptr),
1509The following examples of 'type summary add' refer to this code snippet for context:
1515 JustADemo(int p = 1, float v = 0.1) : ptr(new int(p)), value(v) {}
1517 JustADemo demo_instance(42, 3.14);
1519 typedef JustADemo NewDemo;
1520 NewDemo new_demo_instance(42, 3.14);
1522(lldb) type summary add --summary-string "the answer is ${*var.ptr}" JustADemo
1524 Subsequently displaying demo_instance with 'frame variable' or 'expression' will display "the answer is 42"
1526(lldb) type summary add --summary-string "the answer is ${*var.ptr}, and the question is ${var.value}" JustADemo
1528 Subsequently displaying demo_instance with 'frame variable' or 'expression' will display "the answer is 42 and the question is 3.14"
1531 "Alternatively, you could define formatting for all pointers to integers and \
1532rely on that when formatting JustADemo to obtain the same result:"
1535(lldb) type summary add --summary-string "${var%V} -> ${*var}" "int *"
1536(lldb) type summary add --summary-string "the answer is ${var.ptr}, and the question is ${var.value}" JustADemo
1539 "Type summaries are automatically applied to derived typedefs, so the examples \
1540above apply to both JustADemo and NewDemo. The cascade option can be used to \
1541suppress this behavior:"
1544(lldb) type summary add --summary-string "${var.ptr}, ${var.value},{${var.byte}}" JustADemo -C no
1546 The summary will now be used for values of JustADemo but not NewDemo.
1549 "By default summaries are shown for pointers and references to values of the \
1550specified type. To suppress formatting for pointers use the -p option, or apply \
1551the corresponding -r option to suppress formatting for references:"
1554(lldb) type summary add -p -r --summary-string "${var.ptr}, ${var.value},{${var.byte}}" JustADemo
1557 "One-line summaries including all fields in a type can be inferred without supplying an \
1558explicit summary string by passing the -c option:"
1561(lldb) type summary add -c JustADemo
1562(lldb) frame variable demo_instance
1563(ptr=<address>, value=3.14)
1566 "Type summaries normally suppress the nested display of individual fields. To \
1567supply a summary to supplement the default structure add the -e option:"
1570(lldb) type summary add -e --summary-string "*ptr = ${*var.ptr}" JustADemo
1573 "Now when displaying JustADemo values the int* is displayed, followed by the \
1574standard LLDB sequence of children, one per line:"
1583 "You can also add summaries written in Python. These scripts use lldb public API to \
1584gather information from your variables and produce a meaningful summary. To start a \
1585multi-line script use the -P option. The function declaration will be displayed along with \
1586a comment describing the two arguments. End your script with the word 'DONE' on a line by \
1590(lldb) type summary add JustADemo -P
1591def function (valobj,internal_dict):
"""valobj: an SBValue which you want to provide a summary for
1592internal_dict: an LLDB support object not to be used"""
1593 value = valobj.GetChildMemberWithName('value');
1594 return 'My value is ' + value.GetValue();
1597Alternatively, the -o option can be used when providing a simple one-line Python script:
1599(lldb) type summary add JustADemo -o "value = valobj.GetChildMemberWithName('value'); return 'My value is ' + value.GetValue();")");
1607#if LLDB_ENABLE_PYTHON
1613#if LLDB_ENABLE_PYTHON
1627 llvm::StringRef type_name_ref(type_name);
1629 if (type_name_ref.ends_with(
"[]")) {
1630 type_name.resize(type_name.length() - 2);
1631 if (type_name.back() !=
' ')
1632 type_name.append(
" ?\\[[0-9]+\\]");
1634 type_name.append(
"\\[[0-9]+\\]");
1651 std::string category_name,
1664 if (!typeRX.IsValid()) {
1667 "regex format error (maybe this is not really a regex?)");
1676 "The provided recognizer function \"%s\" does not exist - "
1677 "please define it before attempting to use this summary.\n",
1682 category->AddTypeSummary(llvm::StringRef(type_name), match_type, entry);
1708 "type summary clear",
1709 "Delete all existing summaries.") {}
1724 "Show a list of current summaries.") {}
1735 summary_sp->GetDescription());
1745#define LLDB_OPTIONS_type_category_define
1746#include "CommandOptions.inc"
1758 ExecutionContext *execution_context)
override {
1762 switch (short_option) {
1770 llvm_unreachable(
"Unimplemented option");
1782 return llvm::ArrayRef(g_type_category_define_options);
1798 "Define a new category as a source of formatters.",
1815 for (
auto &entry : command.
entries()) {
1820 category_sp->AddLanguage(
m_options.m_cate_language.GetCurrentValue());
1821 if (
m_options.m_define_enabled.GetCurrentValue())
1832#define LLDB_OPTIONS_type_category_enable
1833#include "CommandOptions.inc"
1843 ExecutionContext *execution_context)
override {
1847 switch (short_option) {
1849 if (!option_arg.empty()) {
1853 "unrecognized language '%s'", option_arg.str().c_str());
1857 llvm_unreachable(
"Unimplemented option");
1868 return llvm::ArrayRef(g_type_category_enable_options);
1883 "Enable a category as a source of formatters.",
1891 void DoExecute(Args &command, CommandReturnObject &result)
override {
1902 }
else if (argc > 0) {
1903 for (
int i = argc - 1; i >= 0; i--) {
1906 if (typeCS.empty()) {
1913 if (cate->GetCount() == 0) {
1933 "Delete a category and all associated formatters.",
1950 bool success =
true;
1953 for (
int i = argc - 1; i >= 0; i--) {
1956 if (typeCS.empty()) {
1957 result.
AppendError(
"empty category name not allowed");
1972#define LLDB_OPTIONS_type_category_disable
1973#include "CommandOptions.inc"
1983 ExecutionContext *execution_context)
override {
1987 switch (short_option) {
1989 if (!option_arg.empty()) {
1993 "unrecognized language '%s'", option_arg.str().c_str());
1997 llvm_unreachable(
"Unimplemented option");
2008 return llvm::ArrayRef(g_type_category_disable_options);
2023 "Disable a category as a source of formatters.",
2042 }
else if (argc > 0) {
2044 for (
int i = argc - 1; i >= 0; i--) {
2047 if (typeCS.empty()) {
2048 result.
AppendError(
"empty category name not allowed");
2068 "Provide a list of all existing categories.",
2089 std::unique_ptr<RegularExpression> regex;
2093 regex = std::make_unique<RegularExpression>(arg);
2094 if (!regex->IsValid()) {
2096 "syntax error in category regular expression '%s'", arg);
2099 }
else if (argc != 0) {
2108 if (regex->GetText() == category_sp->GetName()) {
2110 }
else if (regex->Execute(category_sp->GetName())) {
2119 "Category: %s\n", category_sp->GetDescription().c_str());
2135 "Show a list of current filters.") {}
2145 interpreter,
"type synthetic list",
2146 "Show a list of current synthetic providers.") {}
2177 "type filter clear",
2178 "Delete all existing filter.") {}
2188 "Delete all existing synthetic providers.") {}
2193 auto options = std::make_unique<SynthAddOptions>(
2198 for (
auto &entry : command.
entries()) {
2199 if (entry.ref().empty()) {
2200 result.
AppendError(
"empty typenames not allowed");
2204 options->m_target_types << std::string(entry.ref());
2228 "directly input Python code",
2235 ScriptedSyntheticChildren *impl =
new ScriptedSyntheticChildren(
2236 SyntheticChildren::Flags()
2238 .SetFrontEndWantsDereference(
m_options.m_wants_deref)
2239 .SetSkipPointers(
m_options.m_skip_pointers)
2240 .SetSkipReferences(
m_options.m_skip_references),
2250 "the provided class '{0}' does not exist - please define it "
2251 "before attempting to use this synthetic provider",
2252 llvm::StringRef(python_class_name));
2261 for (
auto &arg_entry : command.
entries()) {
2262 if (arg_entry.ref().empty()) {
2263 result.
AppendError(
"empty typenames not allowed");
2281 "Add a new synthetic provider for a type.", nullptr),
2289 std::string category_name,
2311 "cannot add synthetic for type {0} when "
2312 "filter is defined in same category!",
2320 if (!typeRX.IsValid()) {
2323 "regex format error (maybe this is not really a regex?)");
2332 "The provided recognizer function \"%s\" does not exist - "
2333 "please define it before attempting to use this summary.\n",
2339 category->AddTypeSynthetic(type_name, match_type, entry);
2343#define LLDB_OPTIONS_type_filter_add
2344#include "CommandOptions.inc"
2362 switch (short_option) {
2367 "invalid value for cascade: %s", option_arg.str().c_str());
2386 llvm_unreachable(
"Unimplemented option");
2403 return llvm::ArrayRef(g_type_filter_add_options);
2450 "cannot add filter for type {0} when "
2451 "synthetic is defined in same "
2465 "regex format error (maybe this is not really a regex?)");
2469 category->AddTypeFilter(llvm::StringRef(type_name), match_type, entry);
2476 "Add a new filter for a type.", nullptr) {
2481The following examples of 'type filter add' refer to this code snippet for context:
2496Adding a simple filter:
2498(lldb) type filter add --child a --child g Foo
2499(lldb) frame variable my_foo
2502 "Produces output where only a and g are displayed. Other children of my_foo \
2503(b, c, d, e, f, h and i) are available by asking for them explicitly:"
2506(lldb) frame variable my_foo.b my_foo.c my_foo.i
2509 "The formatting option --raw on frame variable bypasses the filter, showing \
2510all children of my_foo as if no filter was defined:"
2513(lldb) frame variable my_foo --raw)");
2545 entry->AddExpressionPath(*begin);
2556 for (
auto &arg_entry : command.
entries()) {
2557 if (arg_entry.ref().empty()) {
2558 result.
AppendError(
"empty typenames not allowed");
2562 if (!
AddFilter(arg_entry.ref().str(), entry,
2575#define LLDB_OPTIONS_type_lookup
2576#include "CommandOptions.inc"
2607 return llvm::ArrayRef(g_type_lookup_options);
2614 const int short_option = g_type_lookup_options[option_idx].short_option;
2616 switch (short_option) {
2626 llvm_unreachable(
"Unimplemented option");
2649 "Lookup types and declarations in the current target, "
2650 "following language-specific naming conventions.",
2651 "type lookup <type-specifier>",
2652 eCommandRequiresTarget) {
2665 StreamString stream;
2668 stream.
Printf(
"%s\n", help);
2669 return IterationAction::Continue;
2676 void DoExecute(llvm::StringRef raw_command_line,
2677 CommandReturnObject &result)
override {
2678 if (raw_command_line.empty()) {
2680 "type lookup cannot be invoked without a type name as argument");
2687 OptionsWithRaw args(raw_command_line);
2688 const char *name_of_type = args.GetRawPart().c_str();
2695 ExecutionContextScope *best_scope = exe_ctx.GetBestExecutionContextScope();
2697 bool any_found =
false;
2699 std::vector<Language *> languages;
2701 bool is_global_search =
false;
2704 if ((is_global_search =
2707 languages.push_back(lang);
2708 return IterationAction::Continue;
2721 languages.begin(), languages.end(),
2723 if (!lang1 || !lang2)
2725 LanguageType lt1 = lang1->GetLanguageType();
2726 LanguageType lt2 = lang2->GetLanguageType();
2729 if (lt1 == guessed_language)
2731 if (lt2 == guessed_language)
2738 bool is_first_language =
true;
2744 if (
auto scavenger = language->GetTypeScavenger()) {
2746 if (scavenger->Find(best_scope, name_of_type, search_results) > 0) {
2747 for (
const auto &search_result : search_results) {
2748 if (search_result && search_result->IsValid()) {
2751 this->m_command_options.m_show_help);
2757 if (any_found && is_global_search)
2759 else if (is_first_language && is_global_search &&
2761 is_first_language =
false;
2763 "no type was found in the current language %s matching '%s'; "
2764 "performing a global search across all languages\n",
2778template <
typename FormatterType>
2781 typedef std::function<
typename FormatterType::SharedPointer(ValueObject &)>
2784 const char *formatter_name,
2790 name.
Printf(
"type %s info", formatter_name);
2793 help.
Printf(
"This command evaluates the provided expression and shows "
2794 "which %s is applied to the resulting value (if any).",
2798 syntax.
Printf(
"type %s info <expr>", formatter_name);
2808 assert(target &&
"target guaranteed by eCommandRequiresFrame");
2820 command, frame_sp.get(), result_valobj_sp, options);
2823 result_valobj_sp->GetQualifiedRepresentationIfAvailable(
2826 typename FormatterType::SharedPointer formatter_sp =
2829 std::string description(formatter_sp->GetDescription());
2832 << result_valobj_sp->GetDisplayTypeName().AsCString(
"<unknown>")
2833 <<
") " << command <<
" is: " << description <<
"\n";
2838 << result_valobj_sp->GetDisplayTypeName().AsCString(
"<unknown>")
2839 <<
") " << command <<
"\n";
2843 result.
AppendError(
"failed to evaluate expression");
2856 interpreter,
"type format",
2857 "Commands for customizing value display formats.",
2858 "type format [<sub-command-options>] ") {
2869 interpreter,
"format",
2882 interpreter,
"type synthetic",
2883 "Commands for operating on synthetic type representations.",
2884 "type synthetic [<sub-command-options>] ") {
2896 interpreter,
"synthetic",
2909 "Commands for operating on type filters.",
2910 "type filter [<sub-command-options>] ") {
2928 "Commands for operating on type categories.",
2929 "type category [<sub-command-options>] ") {
2953 interpreter,
"type summary",
2954 "Commands for editing variable summary display options.",
2955 "type summary [<sub-command-options>] ") {
2957 "add",
CommandObjectSP(
new CommandObjectTypeSummaryAdd(interpreter)));
2963 "list",
CommandObjectSP(
new CommandObjectTypeSummaryList(interpreter)));
2965 "info",
CommandObjectSP(
new CommandObjectFormatterInfo<TypeSummaryImpl>(
2966 interpreter,
"summary",
2979 "Commands for operating on the type system.",
2980 "type [<sub-command-options>]") {
static const char * g_synth_addreader_instructions
static bool WarnOnPotentialUnquotedUnsignedType(Args &command, CommandReturnObject &result)
static bool FixArrayTypeNameWithRegex(std::string &type_name)
const char * FormatCategoryToString(FormatCategoryItem item, bool long_name)
static llvm::raw_ostream & error(Stream &strm)
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
~CommandOptions() override=default
OptionValueLanguage m_cate_language
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
OptionValueBoolean m_define_enabled
CommandObjectTypeCategoryDefine(CommandInterpreter &interpreter)
Options * GetOptions() override
~CommandObjectTypeCategoryDefine() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectTypeCategoryDelete(CommandInterpreter &interpreter)
~CommandObjectTypeCategoryDelete() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
lldb::LanguageType m_language
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
void OptionParsingStarting(ExecutionContext *execution_context) override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
~CommandOptions() override=default
CommandObjectTypeCategoryDisable(CommandInterpreter &interpreter)
Options * GetOptions() override
void DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectTypeCategoryDisable() override=default
~CommandOptions() override=default
void OptionParsingStarting(ExecutionContext *execution_context) override
lldb::LanguageType m_language
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
CommandObjectTypeCategoryEnable(CommandInterpreter &interpreter)
void DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectTypeCategoryEnable() override=default
Options * GetOptions() override
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectTypeCategoryList(CommandInterpreter &interpreter)
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
~CommandObjectTypeCategoryList() override=default
CommandObjectTypeCategory(CommandInterpreter &interpreter)
~CommandObjectTypeCategory() override=default
option_vector m_expr_paths
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.
std::vector< std::string > option_vector
option_vector::iterator ExpressionPathsIterator
~CommandOptions() override=default
void OptionParsingStarting(ExecutionContext *execution_context) override
~CommandObjectTypeFilterAdd() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
bool AddFilter(std::string type_name, TypeFilterImplSP entry, FilterFormatType type, std::string category_name, Status *error)
Options * GetOptions() override
CommandObjectTypeFilterAdd(CommandInterpreter &interpreter)
CommandObjectTypeFilterClear(CommandInterpreter &interpreter)
CommandObjectTypeFilterDelete(CommandInterpreter &interpreter)
~CommandObjectTypeFilterDelete() override=default
CommandObjectTypeFilterList(CommandInterpreter &interpreter)
~CommandObjectTypeFilter() override=default
CommandObjectTypeFilter(CommandInterpreter &interpreter)
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
~CommandOptions() override=default
lldb::LanguageType m_language
void OptionParsingStarting(ExecutionContext *execution_context) override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, ExecutionContext *execution_context) override
OptionGroupOptions m_option_group
void DoExecute(llvm::StringRef raw_command_line, CommandReturnObject &result) override
lldb::LanguageType GuessLanguage(StackFrame *frame)
~CommandObjectTypeLookup() override=default
llvm::StringRef GetHelpLong() override
CommandObjectTypeLookup(CommandInterpreter &interpreter)
Options * GetOptions() override
CommandOptions m_command_options
void OptionParsingStarting(ExecutionContext *execution_context) override
std::string m_python_script
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
std::string m_python_function
~CommandOptions() override=default
TypeSummaryImpl::Flags m_flags
FormatterMatchType m_match_type
std::string m_format_string
uint32_t m_ptr_match_depth
~CommandObjectTypeSummaryAdd() override=default
Options * GetOptions() override
bool Execute_ScriptSummary(Args &command, CommandReturnObject &result)
bool AddSummary(std::string type_name, lldb::TypeSummaryImplSP entry, FormatterMatchType match_type, std::string category, Status *error=nullptr)
void DoExecute(Args &command, CommandReturnObject &result) override
OptionGroupOptions m_option_group
void IOHandlerActivated(IOHandler &io_handler, bool interactive) override
bool Execute_StringSummary(Args &command, CommandReturnObject &result)
CommandObjectTypeSummaryAdd(CommandInterpreter &interpreter)
void IOHandlerInputComplete(IOHandler &io_handler, std::string &data) override
Called when a line or lines have been retrieved.
bool AddNamedSummary(std::string summary_name, lldb::TypeSummaryImplSP entry, Status *error=nullptr)
bool Execute_PythonClassSummary(Args &command, CommandReturnObject &result)
OptionGroupPythonClassWithDict m_class_options
void FormatterSpecificDeletion() override
CommandObjectTypeSummaryClear(CommandInterpreter &interpreter)
~CommandObjectTypeSummaryDelete() override=default
bool FormatterSpecificDeletion(llvm::StringRef typeCS) override
CommandObjectTypeSummaryDelete(CommandInterpreter &interpreter)
CommandObjectTypeSummaryList(CommandInterpreter &interpreter)
bool FormatterSpecificList(CommandReturnObject &result) override
CommandObjectTypeSummary(CommandInterpreter &interpreter)
~CommandObjectTypeSummary() 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
FormatterMatchType m_match_type
void IOHandlerInputComplete(IOHandler &io_handler, std::string &data) override
Called when a line or lines have been retrieved.
CommandObjectTypeSynthAdd(CommandInterpreter &interpreter)
bool AddSynth(std::string type_name, lldb::SyntheticChildrenSP entry, FormatterMatchType match_type, std::string category_name, Status *error)
bool Execute_PythonClass(Args &command, CommandReturnObject &result)
Options * GetOptions() override
void IOHandlerActivated(IOHandler &io_handler, bool interactive) override
void DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectTypeSynthAdd() override=default
bool Execute_HandwritePython(Args &command, CommandReturnObject &result)
CommandObjectTypeSynthClear(CommandInterpreter &interpreter)
CommandObjectTypeSynthDelete(CommandInterpreter &interpreter)
~CommandObjectTypeSynthDelete() override=default
CommandObjectTypeSynthList(CommandInterpreter &interpreter)
~CommandObjectTypeSynth() override=default
CommandObjectTypeSynth(CommandInterpreter &interpreter)
StringList m_target_types
ScriptAddOptions(const TypeSummaryImpl::Flags &flags, FormatterMatchType match_type, std::string name, std::string catg, uint32_t m_ptr_match_depth)
uint32_t m_ptr_match_depth
std::shared_ptr< ScriptAddOptions > SharedPointer
TypeSummaryImpl::Flags m_flags
FormatterMatchType m_match_type
SynthAddOptions(bool sptr, bool sref, bool casc, bool wants_deref, FormatterMatchType match_type, std::string catg)
FormatterMatchType m_match_type
StringList m_target_types
std::shared_ptr< SynthAddOptions > SharedPointer
A command line argument class.
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)
ExecutionContext GetExecutionContext(bool adopt_dummy_target=true) const
Returns the execution context the interpreter should run a command in.
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)
CommandObjectRaw(CommandInterpreter &interpreter, llvm::StringRef name, llvm::StringRef help="", llvm::StringRef syntax="", uint32_t flags=0)
CommandObjectType(CommandInterpreter &interpreter)
~CommandObjectType() override
virtual void SetHelpLong(llvm::StringRef str)
void AddSimpleArgumentList(lldb::CommandArgumentType arg_type, ArgumentRepetitionType repetition_type=eArgRepeatPlain)
bool ParseOptionsAndNotify(Args &args, CommandReturnObject &result, OptionGroupOptions &group_options, ExecutionContext &exe_ctx)
ExecutionContext m_exe_ctx
CommandInterpreter & GetCommandInterpreter()
CommandInterpreter & m_interpreter
Thread * GetDefaultThread()
std::string m_cmd_help_long
void SetSyntax(llvm::StringRef str)
void SetCommandName(llvm::StringRef name)
Target * GetTarget()
Get the target this command should operate on.
virtual void SetHelp(llvm::StringRef str)
void AppendError(llvm::StringRef in_string)
void AppendWarningWithFormatv(const char *format, Args &&...args)
void SetStatus(lldb::ReturnStatus status)
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()
"lldb/Utility/ArgCompletionRequest.h"
size_t GetCursorIndex() const
static bool GetCategory(llvm::StringRef category, lldb::TypeCategoryImplSP &entry, bool allow_create=true)
static void DisableStar()
static void ForEach(TypeCategoryMap::ForEachCallback callback)
static bool Delete(llvm::StringRef category)
static void Disable(llvm::StringRef category)
static void Enable(llvm::StringRef category, TypeCategoryMap::Position=TypeCategoryMap::Default)
ScriptInterpreter * GetScriptInterpreter(bool can_create=true, std::optional< lldb::ScriptLanguage > language={})
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
IOHandlerDelegateMultiline(llvm::StringRef end_line, Completion completion=Completion::None)
lldb::LockableStreamFileSP GetErrorStreamFileSP()
lldb::LockableStreamFileSP GetOutputStreamFileSP()
std::set< std::unique_ptr< Result > > ResultSet
static void ForEach(llvm::function_ref< IterationAction(Language *)> callback)
static Language * FindPlugin(lldb::LanguageType language)
static const char * GetNameForLanguageType(lldb::LanguageType language)
Returns the internal LLDB name for the specified language.
virtual const char * GetLanguageSpecificTypeLookupHelp()
static lldb::LanguageType GetLanguageTypeFromString(const char *string)=delete
lldb::LanguageType GuessLanguage() const
Try to guess the language from the mangling.
const std::string & GetName()
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
A command line option parsing protocol class.
std::vector< Option > m_getopt_table
bool IsValid() const
Test if this object contains a valid regular expression.
bool Execute(llvm::StringRef string, llvm::SmallVectorImpl< llvm::StringRef > *matches=nullptr) const
Execute a regular expression match using the compiled regular expression that is already in this obje...
llvm::StringRef GetText() const
Access the regular expression text.
virtual bool GenerateTypeScriptFunction(const char *oneliner, std::string &output, const void *name_token=nullptr)
virtual bool GenerateTypeSynthClass(StringList &input, std::string &output, const void *name_token=nullptr)
virtual bool CheckObjectExists(const char *name)
const char * GetPythonClassName()
This base class provides an interface to stack frames.
virtual SourceLanguage GuessLanguage()
Similar to GetLanguage(), but is allowed to take a potentially incorrect guess if exact information i...
virtual const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope)
Provide a SymbolContext for this StackFrame's current pc value.
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
static Status FromErrorString(const char *str)
static Status static Status FromErrorStringWithFormatv(const char *format, Args &&...args)
const char * GetData() const
llvm::StringRef GetString() const
void Format(const char *format, Args &&... args)
Forwards the arguments to llvm::formatv and writes to 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.
std::string CopyList(const char *item_preamble=nullptr, const char *items_sep="\n") const
size_t SplitIntoLines(const std::string &lines)
Symbol * symbol
The Symbol for a given query.
Flags & SetSkipReferences(bool value=true)
Flags & SetFrontEndWantsDereference(bool value=true)
Flags & SetSkipPointers(bool value=true)
std::shared_ptr< SyntheticChildren > SharedPointer
bool GetEnableSyntheticValue() const
lldb::DynamicValueType GetPreferDynamicValue() const
lldb::ExpressionResults EvaluateExpression(llvm::StringRef expression, ExecutionContextScope *exe_scope, lldb::ValueObjectSP &result_valobj_sp, const EvaluateExpressionOptions &options=EvaluateExpressionOptions(), std::string *fixed_expression=nullptr, ValueObject *ctx_obj=nullptr)
static const Position Default
Class for matching type names.
llvm::StringRef GetMatchString() const
Returns the underlying match string for this TypeMatcher.
std::shared_ptr< TypeSummaryImpl > SharedPointer
lldb::TypeFormatImplSP GetValueFormat()
lldb::TypeSummaryImplSP GetSummaryFormat()
lldb::SyntheticChildrenSP GetSyntheticChildren()
@ DoNoSelectMostRelevantFrame
A class that represents a running process on the host machine.
std::vector< OptionArgElement > OptionElementVector
FormatCategoryItem
Format category entry types.
@ eFormatCategoryItemFormat
@ eFormatCategoryItemSynth
@ eFormatCategoryItemSummary
@ eFormatCategoryItemFilter
@ eTypeCategoryNameCompletion
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::TypeSummaryImpl > TypeSummaryImplSP
std::shared_ptr< lldb_private::CommandObject > CommandObjectSP
std::shared_ptr< lldb_private::TypeFormatImpl > TypeFormatImplSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
Format
Display format definitions.
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
FormatterMatchType
Type of match to be performed when looking for a formatter for a data type.
@ eFormatterMatchCallback
ExpressionResults
The results of expression evaluation.
@ eReturnStatusSuccessFinishResult
@ eReturnStatusSuccessFinishNoResult
std::shared_ptr< lldb_private::SyntheticChildren > SyntheticChildrenSP
std::shared_ptr< lldb_private::TypeCategoryImpl > TypeCategoryImplSP
std::shared_ptr< lldb_private::LockableStreamFile > LockableStreamFileSP
std::shared_ptr< lldb_private::TypeFilterImpl > TypeFilterImplSP
static bool ToBoolean(llvm::StringRef s, bool fail_value, bool *success_ptr)
lldb::LanguageType AsLanguageType() const