15#include "lldb/Host/Config.h"
39#include "llvm/ADT/STLExtras.h"
90 for (
auto entry : llvm::enumerate(command.
entries().drop_back())) {
91 if (entry.value().ref() !=
"unsigned")
93 auto next = command.
entries()[entry.index() + 1].ref();
94 if (next ==
"int" || next ==
"short" || next ==
"char" || next ==
"long") {
96 "unsigned {0} being treated as two types. if you meant the combined "
97 "type name use quotes, as in \"unsigned {0}\"",
113 return "synthetic child provider";
118 llvm_unreachable(
"Fully covered switch above!");
121#define LLDB_OPTIONS_type_summary_add
122#include "CommandOptions.inc"
139 return llvm::ArrayRef(g_type_summary_add_options);
173 static const char *g_summary_addreader_instructions =
174 "Enter your Python command(s). Type 'DONE' to end.\n"
175 "def function (valobj,internal_dict):\n"
176 " \"\"\"valobj: an SBValue which you want to provide a summary "
178 " internal_dict: an LLDB support object not to be used\"\"\"\n";
183 locked_stream.
PutCString(g_summary_addreader_instructions);
189 std::string &data)
override {
192#if LLDB_ENABLE_PYTHON
207 std::string funct_name_str;
210 if (funct_name_str.empty()) {
213 "unable to obtain a valid function name from "
214 "the script interpreter.\n");
220 script_format = std::make_shared<ScriptSummaryFormat>(
221 options->m_flags, funct_name_str.c_str(),
222 lines.
CopyList(
" ").c_str(), options->m_ptr_match_depth);
226 for (
const std::string &type_name : options->m_target_types) {
227 AddSummary(type_name, script_format, options->m_match_type,
228 options->m_category, &
error);
231 locked_stream.
Printf(
"error: %s",
error.AsCString());
235 if (options->m_name) {
237 options->m_name.GetStringRef().str(), script_format,
241 options->m_name.GetStringRef().str(), script_format,
245 locked_stream.
Printf(
"error: %s",
error.AsCString());
249 locked_stream.
Printf(
"error: %s",
error.AsCString());
252 if (
error.AsCString()) {
254 locked_stream.
Printf(
"error: %s",
error.AsCString());
261 "error: unable to generate a function.\n");
265 locked_stream.
PutCString(
"error: no script interpreter.\n");
269 locked_stream.
Printf(
"error: internal synchronization information "
270 "missing or invalid.\n");
275 "error: empty function, didn't add python command.\n");
280 "error: script interpreter missing, didn't add python command.\n");
298 "Enter your Python command(s). Type 'DONE' to end.\n"
299 "You must define a Python class with these methods:\n"
300 " def __init__(self, valobj: lldb.SBValue, internal_dict):\n"
301 " def num_children(self) -> int:\n"
302 " def get_child_at_index(self, index: int) -> lldb.SBValue | None:\n"
303 " def get_child_index(self, name: str) -> int:\n"
304 " def update(self) -> bool:\n"
306 "class synthProvider:\n";
308#define LLDB_OPTIONS_type_synth_add
309#include "CommandOptions.inc"
326 switch (short_option) {
331 "invalid value for cascade: %s", option_arg.str().c_str());
337 "invalid value for wants-dereference: %s",
338 option_arg.str().c_str());
359 "can't use --regex and --recognizer-function at the same time");
366 "can't use --regex and --recognizer-function at the same time");
371 llvm_unreachable(
"Unimplemented option");
390 return llvm::ArrayRef(g_type_synth_add_options);
424 result.
AppendError(
"must either provide a children list, a Python class "
425 "name, or use -P and type a Python class "
440 std::string &data)
override {
443#if LLDB_ENABLE_PYTHON
458 std::string class_name_str;
460 if (class_name_str.empty()) {
464 "error: unable to obtain a proper name for the class.\n");
470 synth_provider = std::make_shared<ScriptedSyntheticChildren>(
472 .SetCascades(options->m_cascade)
476 class_name_str.c_str());
484 for (
const std::string &type_name : options->m_target_types) {
485 if (!type_name.empty()) {
486 if (
AddSynth(type_name, synth_provider,
487 options->m_match_type, options->m_category,
490 locked_stream.
Printf(
"error: %s\n",
error.AsCString());
495 locked_stream.
PutCString(
"error: invalid type name.\n");
502 locked_stream.
PutCString(
"error: unable to generate a class.\n");
506 locked_stream.
PutCString(
"error: no script interpreter.\n");
511 "error: internal synchronization data missing.\n");
516 "error: empty function, didn't add python command.\n");
521 "error: script interpreter missing, didn't add python command.\n");
540#define LLDB_OPTIONS_type_format_add
541#include "CommandOptions.inc"
552 return llvm::ArrayRef(g_type_format_add_options);
567 const int short_option =
568 g_type_format_add_options[option_idx].short_option;
571 switch (short_option) {
576 "invalid value for cascade: %s", option_value.str().c_str());
594 llvm_unreachable(
"Unimplemented option");
619 "Add a new formatting style for a type.", nullptr),
625The following examples of 'type format add' refer to this code snippet for context:
628 typedef float Afloat;
630 typedef Afloat Bfloat;
638Adding default formatting:
640(lldb) type format add -f hex AInt
641(lldb) frame variable iy
644 " Produces hexadecimal display of iy, because no formatter is available for Bint and \
645the one for Aint is used instead."
648To prevent this use the cascade option '-C no' to prevent evaluation of typedef chains:
651(lldb) type format add -f hex -C no AInt
653Similar reasoning applies to this:
655(lldb) type format add -f hex -C no float -p
658 " All float values and float references are now formatted as hexadecimal, but not \
659pointers to floats. Nor will it change the default display for Afloat and Bfloat objects.");
692 entry = std::make_shared<TypeFormatImpl_Format>(
693 format, TypeFormatImpl::Flags()
698 entry = std::make_shared<TypeFormatImpl_EnumType>(
700 TypeFormatImpl::Flags()
715 for (
auto &arg_entry : command.
entries()) {
716 if (arg_entry.ref().empty()) {
725 if (!typeRX.IsValid()) {
727 "regex format error (maybe this is not really a regex?)");
731 category_sp->AddTypeFormat(arg_entry.ref(), match_type, entry);
738#define LLDB_OPTIONS_type_formatter_delete
739#include "CommandOptions.inc"
754 switch (short_option) {
765 llvm_unreachable(
"Unimplemented option");
778 return llvm::ArrayRef(g_type_formatter_delete_options);
794 "Delete an existing %s for a type.";
797 "Delete an existing %s for a type. Unless you specify a "
798 "specific category or all categories, only the "
799 "'default' category is searched. The names must be exactly as "
800 "shown in the 'type %s list' output";
820 s.
Printf(
"type %s delete", short_kind);
868 bool delete_category =
false;
869 bool extra_deletion =
false;
887 if (delete_category || extra_deletion) {
895#define LLDB_OPTIONS_type_formatter_clear
896#include "CommandOptions.inc"
911 switch (short_option) {
916 llvm_unreachable(
"Unimplemented option");
927 return llvm::ArrayRef(g_type_formatter_clear_options);
942 const char *name,
const char *help)
997 "Delete all existing format styles.") {}
1000#define LLDB_OPTIONS_type_formatter_list
1001#include "CommandOptions.inc"
1003template <
typename FormatterType>
1020 switch (short_option) {
1027 if (
error.Success())
1031 llvm_unreachable(
"Unimplemented option");
1043 return llvm::ArrayRef(g_type_formatter_list_options);
1058 const char *name,
const char *help)
1076 return regex ==
nullptr || s == regex->
GetText() || regex->
Execute(s);
1082 std::unique_ptr<RegularExpression> category_regex;
1083 std::unique_ptr<RegularExpression> formatter_regex;
1085 if (
m_options.m_category_regex.OptionWasSet()) {
1086 category_regex = std::make_unique<RegularExpression>(
1087 m_options.m_category_regex.GetCurrentValueAsRef());
1088 if (!category_regex->IsValid()) {
1090 "syntax error in category regular expression '%s'",
1091 m_options.m_category_regex.GetCurrentValueAsRef().str().c_str());
1098 formatter_regex = std::make_unique<RegularExpression>(arg);
1099 if (!formatter_regex->IsValid()) {
1106 bool any_printed =
false;
1108 auto category_closure =
1109 [&result, &formatter_regex,
1112 "-----------------------\nCategory: %s%s\n-----------------------\n",
1113 category->GetName(), category->IsEnabled() ?
"" :
" (disabled)");
1116 [&result, &formatter_regex,
1120 formatter_regex.get())) {
1123 "%s: %s\n", type_matcher.GetMatchString().GetCString(),
1124 format_sp->GetDescription().c_str());
1128 category->ForEach(print_formatter);
1131 if (
m_options.m_category_language.OptionWasSet()) {
1134 m_options.m_category_language.GetCurrentValue(), category_sp);
1136 category_closure(category_sp);
1139 [&category_regex, &category_closure](
1142 category_closure(category);
1166 "Show a list of current formats.") {}
1170 uint32_t option_idx, llvm::StringRef option_arg,
1173 const int short_option = g_type_summary_add_options[option_idx].short_option;
1176 switch (short_option) {
1181 option_arg.str().c_str());
1184 m_flags.SetDontShowChildren(
false);
1187 m_flags.SetHideEmptyAggregates(
true);
1190 m_flags.SetDontShowValue(
true);
1193 m_flags.SetShowMembersOneLiner(
true);
1199 m_flags.SetSkipPointers(
true);
1204 "invalid integer value for option '%c': %s", short_option,
1209 m_flags.SetSkipReferences(
true);
1214 "can't use --regex and --recognizer-function at the same time");
1221 "can't use --regex and --recognizer-function at the same time");
1226 m_name = std::string(option_arg);
1243 m_flags.SetHideItemNames(
true);
1246 llvm_unreachable(
"Unimplemented option");
1254 m_flags.Clear().SetCascades().SetDontShowChildren().SetDontShowValue(
false);
1255 m_flags.SetShowMembersOneLiner(
false)
1256 .SetSkipPointers(
false)
1257 .SetSkipReferences(
false)
1258 .SetHideItemNames(
false);
1269#if LLDB_ENABLE_PYTHON
1275 if (argc < 1 &&
m_options.m_name.empty()) {
1287 if (!funct_name || !funct_name[0]) {
1293 (
" " +
m_options.m_python_function +
"(valobj,internal_dict)");
1295 script_format = std::make_shared<ScriptSummaryFormat>(
1296 m_options.m_flags, funct_name, code.c_str(),
1303 "the provided function \"{0}\" does not exist - "
1304 "please define it before attempting to use this summary",
1311 result.
AppendError(
"script interpreter missing - unable to generate "
1312 "function wrapper.\n");
1315 StringList funct_sl;
1316 funct_sl <<
m_options.m_python_script.c_str();
1317 std::string funct_name_str;
1319 result.
AppendError(
"unable to generate function wrapper.\n");
1322 if (funct_name_str.empty()) {
1324 "script interpreter failed to generate a valid function name.\n");
1328 std::string code =
" " +
m_options.m_python_script;
1330 script_format = std::make_shared<ScriptSummaryFormat>(
1331 m_options.m_flags, funct_name_str.c_str(), code.c_str(),
1335 auto options = std::make_unique<ScriptAddOptions>(
1340 for (
auto &entry : command.
entries()) {
1341 if (entry.ref().empty()) {
1342 result.
AppendError(
"empty typenames not allowed");
1346 options->m_target_types << std::string(entry.ref());
1364 for (
auto &entry : command.
entries()) {
1377 result.
AppendError(
"added to types, but not given a name");
1386 Args &command, CommandReturnObject &result) {
1389 if (argc < 1 &&
m_options.m_name.empty()) {
1396 if (class_name.empty()) {
1397 result.
AppendError(
"must provide a Python class name");
1406 for (
auto &entry : command.
entries()) {
1419 result.
AppendError(
"added to types, but not given a name");
1433 if (argc < 1 &&
m_options.m_name.empty()) {
1439 if (!
m_options.m_flags.GetShowMembersOneLiner() &&
1441 result.
AppendError(
"empty summary strings not allowed");
1445 const char *format_cstr = (
m_options.m_flags.GetShowMembersOneLiner()
1450 if (strcmp(format_cstr,
"${var%S}") == 0) {
1451 result.
AppendError(
"recursive summary not allowed");
1457 if (!string_format) {
1461 if (string_format->m_error.Fail()) {
1463 string_format->m_error.AsCString(
"<unknown>"));
1470 for (
auto &arg_entry : command.
entries()) {
1471 if (arg_entry.ref().empty()) {
1472 result.
AppendError(
"empty typenames not allowed");
1489 result.
AppendError(
"added to types, but not given a name");
1501 "Add a new summary style for a type.", nullptr),
1514The following examples of 'type summary add' refer to this code snippet for context:
1520 JustADemo(int p = 1, float v = 0.1) : ptr(new int(p)), value(v) {}
1522 JustADemo demo_instance(42, 3.14);
1524 typedef JustADemo NewDemo;
1525 NewDemo new_demo_instance(42, 3.14);
1527(lldb) type summary add --summary-string "the answer is ${*var.ptr}" JustADemo
1529 Subsequently displaying demo_instance with 'frame variable' or 'expression' will display "the answer is 42"
1531(lldb) type summary add --summary-string "the answer is ${*var.ptr}, and the question is ${var.value}" JustADemo
1533 Subsequently displaying demo_instance with 'frame variable' or 'expression' will display "the answer is 42 and the question is 3.14"
1536 "Alternatively, you could define formatting for all pointers to integers and \
1537rely on that when formatting JustADemo to obtain the same result:"
1540(lldb) type summary add --summary-string "${var%V} -> ${*var}" "int *"
1541(lldb) type summary add --summary-string "the answer is ${var.ptr}, and the question is ${var.value}" JustADemo
1544 "Type summaries are automatically applied to derived typedefs, so the examples \
1545above apply to both JustADemo and NewDemo. The cascade option can be used to \
1546suppress this behavior:"
1549(lldb) type summary add --summary-string "${var.ptr}, ${var.value},{${var.byte}}" JustADemo -C no
1551 The summary will now be used for values of JustADemo but not NewDemo.
1554 "By default summaries are shown for pointers and references to values of the \
1555specified type. To suppress formatting for pointers use the -p option, or apply \
1556the corresponding -r option to suppress formatting for references:"
1559(lldb) type summary add -p -r --summary-string "${var.ptr}, ${var.value},{${var.byte}}" JustADemo
1562 "One-line summaries including all fields in a type can be inferred without supplying an \
1563explicit summary string by passing the -c option:"
1566(lldb) type summary add -c JustADemo
1567(lldb) frame variable demo_instance
1568(ptr=<address>, value=3.14)
1571 "Type summaries normally suppress the nested display of individual fields. To \
1572supply a summary to supplement the default structure add the -e option:"
1575(lldb) type summary add -e --summary-string "*ptr = ${*var.ptr}" JustADemo
1578 "Now when displaying JustADemo values the int* is displayed, followed by the \
1579standard LLDB sequence of children, one per line:"
1588 "You can also add summaries written in Python. These scripts use lldb public API to \
1589gather information from your variables and produce a meaningful summary. To start a \
1590multi-line script use the -P option. The function declaration will be displayed along with \
1591a comment describing the two arguments. End your script with the word 'DONE' on a line by \
1595(lldb) type summary add JustADemo -P
1596def function (valobj,internal_dict):
"""valobj: an SBValue which you want to provide a summary for
1597internal_dict: an LLDB support object not to be used"""
1598 value = valobj.GetChildMemberWithName('value');
1599 return 'My value is ' + value.GetValue();
1602Alternatively, the -o option can be used when providing a simple one-line Python script:
1604(lldb) type summary add JustADemo -o "value = valobj.GetChildMemberWithName('value'); return 'My value is ' + value.GetValue();")");
1612#if LLDB_ENABLE_PYTHON
1618#if LLDB_ENABLE_PYTHON
1632 llvm::StringRef type_name_ref(type_name);
1634 if (type_name_ref.ends_with(
"[]")) {
1635 type_name.resize(type_name.length() - 2);
1636 if (type_name.back() !=
' ')
1637 type_name.append(
" ?\\[[0-9]+\\]");
1639 type_name.append(
"\\[[0-9]+\\]");
1656 std::string category_name,
1670 if (!typeRX.IsValid()) {
1673 "regex format error (maybe this is not really a regex?)");
1681 *
error = Status::FromErrorStringWithFormat(
1682 "The provided recognizer function \"%s\" does not exist - "
1683 "please define it before attempting to use this summary.\n",
1688 category->AddTypeSummary(llvm::StringRef(type_name), match_type, entry);
1714 "type summary clear",
1715 "Delete all existing summaries.") {}
1730 "Show a list of current summaries.") {}
1741 summary_sp->GetDescription().c_str());
1751#define LLDB_OPTIONS_type_category_define
1752#include "CommandOptions.inc"
1764 ExecutionContext *execution_context)
override {
1768 switch (short_option) {
1776 llvm_unreachable(
"Unimplemented option");
1788 return llvm::ArrayRef(g_type_category_define_options);
1804 "Define a new category as a source of formatters.",
1821 for (
auto &entry : command.
entries()) {
1826 category_sp->AddLanguage(
m_options.m_cate_language.GetCurrentValue());
1827 if (
m_options.m_define_enabled.GetCurrentValue())
1838#define LLDB_OPTIONS_type_category_enable
1839#include "CommandOptions.inc"
1849 ExecutionContext *execution_context)
override {
1853 switch (short_option) {
1855 if (!option_arg.empty()) {
1858 error = Status::FromErrorStringWithFormat(
1859 "unrecognized language '%s'", option_arg.str().c_str());
1863 llvm_unreachable(
"Unimplemented option");
1874 return llvm::ArrayRef(g_type_category_enable_options);
1889 "Enable a category as a source of formatters.",
1897 void DoExecute(Args &command, CommandReturnObject &result)
override {
1908 }
else if (argc > 0) {
1909 for (
int i = argc - 1; i >= 0; i--) {
1911 ConstString typeCS(typeA);
1914 result.
AppendError(
"empty category name not allowed");
1920 if (cate->GetCount() == 0) {
1940 "Delete a category and all associated formatters.",
1957 bool success =
true;
1960 for (
int i = argc - 1; i >= 0; i--) {
1965 result.
AppendError(
"empty category name not allowed");
1980#define LLDB_OPTIONS_type_category_disable
1981#include "CommandOptions.inc"
1991 ExecutionContext *execution_context)
override {
1995 switch (short_option) {
1997 if (!option_arg.empty()) {
2000 error = Status::FromErrorStringWithFormat(
2001 "unrecognized language '%s'", option_arg.str().c_str());
2005 llvm_unreachable(
"Unimplemented option");
2016 return llvm::ArrayRef(g_type_category_disable_options);
2031 "Disable a category as a source of formatters.",
2050 }
else if (argc > 0) {
2052 for (
int i = argc - 1; i >= 0; i--) {
2054 ConstString typeCS(typeA);
2057 result.
AppendError(
"empty category name not allowed");
2077 "Provide a list of all existing categories.",
2098 std::unique_ptr<RegularExpression> regex;
2102 regex = std::make_unique<RegularExpression>(arg);
2103 if (!regex->IsValid()) {
2105 "syntax error in category regular expression '%s'", arg);
2108 }
else if (argc != 0) {
2117 if (regex->GetText() == category_sp->GetName()) {
2119 }
else if (regex->Execute(category_sp->GetName())) {
2128 "Category: %s\n", category_sp->GetDescription().c_str());
2144 "Show a list of current filters.") {}
2154 interpreter,
"type synthetic list",
2155 "Show a list of current synthetic providers.") {}
2186 "type filter clear",
2187 "Delete all existing filter.") {}
2197 "Delete all existing synthetic providers.") {}
2202 auto options = std::make_unique<SynthAddOptions>(
2207 for (
auto &entry : command.
entries()) {
2208 if (entry.ref().empty()) {
2209 result.
AppendError(
"empty typenames not allowed");
2213 options->m_target_types << std::string(entry.ref());
2237 "directly input Python code",
2244 ScriptedSyntheticChildren *impl =
new ScriptedSyntheticChildren(
2245 SyntheticChildren::Flags()
2247 .SetFrontEndWantsDereference(
m_options.m_wants_deref)
2248 .SetSkipPointers(
m_options.m_skip_pointers)
2249 .SetSkipReferences(
m_options.m_skip_references),
2259 "the provided class '{0}' does not exist - please define it "
2260 "before attempting to use this synthetic provider",
2261 llvm::StringRef(python_class_name));
2271 for (
auto &arg_entry : command.
entries()) {
2272 if (arg_entry.ref().empty()) {
2273 result.
AppendError(
"empty typenames not allowed");
2291 "Add a new synthetic provider for a type.", nullptr),
2299 std::string category_name,
2323 "cannot add synthetic for type {0} when "
2324 "filter is defined in same category!",
2332 if (!typeRX.IsValid()) {
2334 *
error = Status::FromErrorString(
2335 "regex format error (maybe this is not really a regex?)");
2344 "The provided recognizer function \"%s\" does not exist - "
2345 "please define it before attempting to use this summary.\n",
2351 category->AddTypeSynthetic(type_name, match_type, entry);
2355#define LLDB_OPTIONS_type_filter_add
2356#include "CommandOptions.inc"
2374 switch (short_option) {
2379 "invalid value for cascade: %s", option_arg.str().c_str());
2398 llvm_unreachable(
"Unimplemented option");
2415 return llvm::ArrayRef(g_type_filter_add_options);
2464 "cannot add filter for type {0} when "
2465 "synthetic is defined in same "
2476 if (!typeRX.IsValid()) {
2478 *
error = Status::FromErrorString(
2479 "regex format error (maybe this is not really a regex?)");
2483 category->AddTypeFilter(llvm::StringRef(type_name), match_type, entry);
2490 "Add a new filter for a type.", nullptr) {
2495The following examples of 'type filter add' refer to this code snippet for context:
2510Adding a simple filter:
2512(lldb) type filter add --child a --child g Foo
2513(lldb) frame variable my_foo
2516 "Produces output where only a and g are displayed. Other children of my_foo \
2517(b, c, d, e, f, h and i) are available by asking for them explicitly:"
2520(lldb) frame variable my_foo.b my_foo.c my_foo.i
2523 "The formatting option --raw on frame variable bypasses the filter, showing \
2524all children of my_foo as if no filter was defined:"
2527(lldb) frame variable my_foo --raw)");
2559 entry->AddExpressionPath(*begin);
2571 for (
auto &arg_entry : command.
entries()) {
2572 if (arg_entry.ref().empty()) {
2573 result.
AppendError(
"empty typenames not allowed");
2577 if (!
AddFilter(arg_entry.ref().str(), entry,
2590#define LLDB_OPTIONS_type_lookup
2591#include "CommandOptions.inc"
2622 return llvm::ArrayRef(g_type_lookup_options);
2629 const int short_option = g_type_lookup_options[option_idx].short_option;
2631 switch (short_option) {
2641 llvm_unreachable(
"Unimplemented option");
2664 "Lookup types and declarations in the current target, "
2665 "following language-specific naming conventions.",
2666 "type lookup <type-specifier>",
2667 eCommandRequiresTarget) {
2680 StreamString stream;
2683 stream.
Printf(
"%s\n", help);
2684 return IterationAction::Continue;
2691 void DoExecute(llvm::StringRef raw_command_line,
2692 CommandReturnObject &result)
override {
2693 if (raw_command_line.empty()) {
2695 "type lookup cannot be invoked without a type name as argument");
2702 OptionsWithRaw args(raw_command_line);
2703 const char *name_of_type = args.GetRawPart().c_str();
2710 ExecutionContextScope *best_scope = exe_ctx.GetBestExecutionContextScope();
2712 bool any_found =
false;
2714 std::vector<Language *> languages;
2716 bool is_global_search =
false;
2719 if ((is_global_search =
2722 languages.push_back(lang);
2723 return IterationAction::Continue;
2736 languages.begin(), languages.end(),
2738 if (!lang1 || !lang2)
2740 LanguageType lt1 = lang1->GetLanguageType();
2741 LanguageType lt2 = lang2->GetLanguageType();
2744 if (lt1 == guessed_language)
2746 if (lt2 == guessed_language)
2753 bool is_first_language =
true;
2759 if (
auto scavenger = language->GetTypeScavenger()) {
2761 if (scavenger->Find(best_scope, name_of_type, search_results) > 0) {
2762 for (
const auto &search_result : search_results) {
2763 if (search_result && search_result->IsValid()) {
2766 this->m_command_options.m_show_help);
2772 if (any_found && is_global_search)
2774 else if (is_first_language && is_global_search &&
2776 is_first_language =
false;
2778 "no type was found in the current language %s matching '%s'; "
2779 "performing a global search across all languages\n",
2793template <
typename FormatterType>
2796 typedef std::function<
typename FormatterType::SharedPointer(ValueObject &)>
2799 const char *formatter_name,
2805 name.
Printf(
"type %s info", formatter_name);
2808 help.
Printf(
"This command evaluates the provided expression and shows "
2809 "which %s is applied to the resulting value (if any).",
2813 syntax.
Printf(
"type %s info <expr>", formatter_name);
2823 assert(target &&
"target guaranteed by eCommandRequiresFrame");
2835 command, frame_sp.get(), result_valobj_sp, options);
2838 result_valobj_sp->GetQualifiedRepresentationIfAvailable(
2841 typename FormatterType::SharedPointer formatter_sp =
2844 std::string description(formatter_sp->GetDescription());
2847 << result_valobj_sp->GetDisplayTypeName().AsCString(
"<unknown>")
2848 <<
") " << command <<
" is: " << description <<
"\n";
2853 << result_valobj_sp->GetDisplayTypeName().AsCString(
"<unknown>")
2854 <<
") " << command <<
"\n";
2858 result.
AppendError(
"failed to evaluate expression");
2871 interpreter,
"type format",
2872 "Commands for customizing value display formats.",
2873 "type format [<sub-command-options>] ") {
2884 interpreter,
"format",
2897 interpreter,
"type synthetic",
2898 "Commands for operating on synthetic type representations.",
2899 "type synthetic [<sub-command-options>] ") {
2911 interpreter,
"synthetic",
2924 "Commands for operating on type filters.",
2925 "type filter [<sub-command-options>] ") {
2943 "Commands for operating on type categories.",
2944 "type category [<sub-command-options>] ") {
2968 interpreter,
"type summary",
2969 "Commands for editing variable summary display options.",
2970 "type summary [<sub-command-options>] ") {
2972 "add",
CommandObjectSP(
new CommandObjectTypeSummaryAdd(interpreter)));
2978 "list",
CommandObjectSP(
new CommandObjectTypeSummaryList(interpreter)));
2980 "info",
CommandObjectSP(
new CommandObjectFormatterInfo<TypeSummaryImpl>(
2981 interpreter,
"summary",
2994 "Commands for operating on the type system.",
2995 "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
CommandObjectTypeSummaryDelete(CommandInterpreter &interpreter)
bool FormatterSpecificDeletion(ConstString typeCS) override
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
uint32_t m_ptr_match_depth
std::shared_ptr< ScriptAddOptions > SharedPointer
ScriptAddOptions(const TypeSummaryImpl::Flags &flags, FormatterMatchType match_type, ConstString name, std::string catg, uint32_t m_ptr_match_depth)
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)
Stream & GetOutputStream()
"lldb/Utility/ArgCompletionRequest.h"
size_t GetCursorIndex() const
A uniqued constant string class.
const char * GetCString() const
Get the string value as a C string.
static bool Delete(ConstString category)
static void Disable(ConstString category)
static void DisableStar()
static void ForEach(TypeCategoryMap::ForEachCallback callback)
static void Enable(ConstString category, TypeCategoryMap::Position=TypeCategoryMap::Default)
static bool GetCategory(ConstString category, lldb::TypeCategoryImplSP &entry, bool allow_create=true)
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 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
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.
ConstString 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