15#include "lldb/Host/Config.h"
36#include "llvm/ADT/STLExtras.h"
42#define CHECK_FORMATTER_KIND_MASK(VAL) \
43 ((m_formatter_kind_mask & (VAL)) == (VAL))
87 for (
auto entry : llvm::enumerate(command.
entries().drop_back())) {
88 if (entry.value().ref() !=
"unsigned")
90 auto next = command.
entries()[entry.index() + 1].ref();
91 if (next ==
"int" || next ==
"short" || next ==
"char" || next ==
"long") {
93 "unsigned %s being treated as two types. if you meant the combined "
95 "name use quotes, as in \"unsigned %s\"\n",
96 next.str().c_str(), next.str().c_str());
103#define LLDB_OPTIONS_type_summary_add
104#include "CommandOptions.inc"
121 return llvm::ArrayRef(g_type_summary_add_options);
150 static const char *g_summary_addreader_instructions =
151 "Enter your Python command(s). Type 'DONE' to end.\n"
152 "def function (valobj,internal_dict):\n"
153 " \"\"\"valobj: an SBValue which you want to provide a summary "
155 " internal_dict: an LLDB support object not to be used\"\"\"\n";
158 if (output_sp && interactive) {
159 output_sp->PutCString(g_summary_addreader_instructions);
165 std::string &data)
override {
168#if LLDB_ENABLE_PYTHON
183 std::string funct_name_str;
186 if (funct_name_str.empty()) {
187 error_sp->Printf(
"unable to obtain a valid function name from "
188 "the script interpreter.\n");
194 TypeSummaryImplSP script_format;
195 script_format = std::make_shared<ScriptSummaryFormat>(
196 options->m_flags, funct_name_str.c_str(),
201 for (
const std::string &type_name : options->m_target_types) {
203 options->m_match_type, options->m_category,
206 error_sp->Printf(
"error: %s",
error.AsCString());
211 if (options->m_name) {
213 options->m_name, script_format, &
error);
216 options->m_name, script_format, &
error);
218 error_sp->Printf(
"error: %s",
error.AsCString());
222 error_sp->Printf(
"error: %s",
error.AsCString());
226 if (
error.AsCString()) {
227 error_sp->Printf(
"error: %s",
error.AsCString());
233 error_sp->Printf(
"error: unable to generate a function.\n");
237 error_sp->Printf(
"error: no script interpreter.\n");
241 error_sp->Printf(
"error: internal synchronization information "
242 "missing or invalid.\n");
246 error_sp->Printf(
"error: empty function, didn't add python command.\n");
251 "error: script interpreter missing, didn't add python command.\n");
270 "Enter your Python command(s). Type 'DONE' to end.\n"
271 "You must define a Python class with these methods:\n"
272 " def __init__(self, valobj, internal_dict):\n"
273 " def num_children(self):\n"
274 " def get_child_at_index(self, index):\n"
275 " def get_child_index(self, name):\n"
276 " def update(self):\n"
278 "class synthProvider:\n";
280#define LLDB_OPTIONS_type_synth_add
281#include "CommandOptions.inc"
298 switch (short_option) {
302 error.SetErrorStringWithFormat(
"invalid value for cascade: %s",
303 option_arg.str().c_str());
323 error.SetErrorString(
324 "can't use --regex and --recognizer-function at the same time");
330 error.SetErrorString(
331 "can't use --regex and --recognizer-function at the same time");
336 llvm_unreachable(
"Unimplemented option");
354 return llvm::ArrayRef(g_type_synth_add_options);
387 result.
AppendError(
"must either provide a children list, a Python class "
388 "name, or use -P and type a Python class "
396 if (output_sp && interactive) {
403 std::string &data)
override {
406#if LLDB_ENABLE_PYTHON
421 std::string class_name_str;
423 if (class_name_str.empty()) {
425 "error: unable to obtain a proper name for the class.\n");
431 SyntheticChildrenSP synth_provider;
432 synth_provider = std::make_shared<ScriptedSyntheticChildren>(
434 .SetCascades(options->m_cascade)
437 class_name_str.c_str());
439 lldb::TypeCategoryImplSP category;
441 ConstString(options->m_category.c_str()), category);
445 for (
const std::string &type_name : options->m_target_types) {
446 if (!type_name.empty()) {
448 options->m_match_type, options->m_category,
450 error_sp->Printf(
"error: %s\n",
error.AsCString());
455 error_sp->Printf(
"error: invalid type name.\n");
462 error_sp->Printf(
"error: unable to generate a class.\n");
466 error_sp->Printf(
"error: no script interpreter.\n");
470 error_sp->Printf(
"error: internal synchronization data missing.\n");
474 error_sp->Printf(
"error: empty function, didn't add python command.\n");
479 "error: script interpreter missing, didn't add python command.\n");
499#define LLDB_OPTIONS_type_format_add
500#include "CommandOptions.inc"
511 return llvm::ArrayRef(g_type_format_add_options);
526 const int short_option =
527 g_type_format_add_options[option_idx].short_option;
530 switch (short_option) {
534 error.SetErrorStringWithFormat(
"invalid value for cascade: %s",
535 option_value.str().c_str());
553 llvm_unreachable(
"Unimplemented option");
578 "Add a new formatting style for a type.", nullptr),
586 type_arg.push_back(type_style_arg);
592The following examples of 'type format add' refer to this code snippet for context:
595 typedef float Afloat;
597 typedef Afloat Bfloat;
605Adding default formatting:
607(lldb) type format add -f hex AInt
608(lldb) frame variable iy
611 " Produces hexadecimal display of iy, because no formatter is available for Bint and \
612the one for Aint is used instead."
615To prevent this use the cascade option '-C no' to prevent evaluation of typedef chains:
618(lldb) type format add -f hex -C no AInt
620Similar reasoning applies to this:
622(lldb) type format add -f hex -C no float -p
625 " All float values and float references are now formatted as hexadecimal, but not \
626pointers to floats. Nor will it change the default display for Afloat and Bfloat objects.");
656 TypeFormatImplSP entry;
659 entry = std::make_shared<TypeFormatImpl_Format>(
665 entry = std::make_shared<TypeFormatImpl_EnumType>(
674 TypeCategoryImplSP category_sp;
682 for (
auto &arg_entry : command.
entries()) {
683 if (arg_entry.ref().empty()) {
692 if (!typeRX.IsValid()) {
694 "regex format error (maybe this is not really a regex?)");
698 category_sp->AddTypeFormat(arg_entry.ref(), match_type, entry);
706#define LLDB_OPTIONS_type_formatter_delete
707#include "CommandOptions.inc"
722 switch (short_option) {
733 llvm_unreachable(
"Unimplemented option");
746 return llvm::ArrayRef(g_type_formatter_delete_options);
764 const char *name,
const char *help)
773 type_arg.push_back(type_style_arg);
787 [
this, &request](
const lldb::TypeCategoryImplSP &category_sp) {
814 [
this, typeCS](
const lldb::TypeCategoryImplSP &category_sp) ->
bool {
822 bool delete_category =
false;
823 bool extra_deletion =
false;
826 lldb::TypeCategoryImplSP category;
833 lldb::TypeCategoryImplSP category;
841 if (delete_category || extra_deletion) {
851#define LLDB_OPTIONS_type_formatter_clear
852#include "CommandOptions.inc"
867 switch (short_option) {
872 llvm_unreachable(
"Unimplemented option");
883 return llvm::ArrayRef(g_type_formatter_clear_options);
898 const char *name,
const char *help)
913 [
this](
const TypeCategoryImplSP &category_sp) ->
bool {
918 lldb::TypeCategoryImplSP category;
944 "Delete an existing formatting style for a type.") {}
956 "Delete all existing format styles.") {}
959#define LLDB_OPTIONS_type_formatter_list
960#include "CommandOptions.inc"
962template <
typename FormatterType>
979 switch (short_option) {
990 llvm_unreachable(
"Unimplemented option");
1002 return llvm::ArrayRef(g_type_formatter_list_options);
1017 const char *name,
const char *help)
1025 type_arg.push_back(type_style_arg);
1043 return regex ==
nullptr || s == regex->
GetText() || regex->
Execute(s);
1049 std::unique_ptr<RegularExpression> category_regex;
1050 std::unique_ptr<RegularExpression> formatter_regex;
1053 category_regex = std::make_unique<RegularExpression>(
1055 if (!category_regex->IsValid()) {
1057 "syntax error in category regular expression '%s'",
1065 formatter_regex = std::make_unique<RegularExpression>(arg);
1066 if (!formatter_regex->IsValid()) {
1073 bool any_printed =
false;
1075 auto category_closure =
1076 [&result, &formatter_regex,
1077 &any_printed](
const lldb::TypeCategoryImplSP &category) ->
void {
1079 "-----------------------\nCategory: %s%s\n-----------------------\n",
1080 category->GetName(), category->IsEnabled() ?
"" :
" (disabled)");
1083 [&result, &formatter_regex,
1087 formatter_regex.get())) {
1090 "%s: %s\n", type_matcher.GetMatchString().GetCString(),
1091 format_sp->GetDescription().c_str());
1095 category->ForEach(print_formatter);
1099 lldb::TypeCategoryImplSP category_sp;
1103 category_closure(category_sp);
1106 [&category_regex, &category_closure](
1107 const lldb::TypeCategoryImplSP &category) ->
bool {
1109 category_closure(category);
1134 "Show a list of current formats.") {}
1138 uint32_t option_idx, llvm::StringRef option_arg,
1144 switch (short_option) {
1148 error.SetErrorStringWithFormat(
"invalid value for cascade: %s",
1149 option_arg.str().c_str());
1174 error.SetErrorString(
1175 "can't use --regex and --recognizer-function at the same time");
1181 error.SetErrorString(
1182 "can't use --regex and --recognizer-function at the same time");
1207 llvm_unreachable(
"Unimplemented option");
1215 m_flags.
Clear().SetCascades().SetDontShowChildren().SetDontShowValue(
false);
1216 m_flags.SetShowMembersOneLiner(
false)
1217 .SetSkipPointers(
false)
1218 .SetSkipReferences(
false)
1219 .SetHideItemNames(
false);
1223 m_python_script =
"";
1224 m_python_function =
"";
1225 m_format_string =
"";
1226 m_is_add_script =
false;
1227 m_category =
"default";
1230#if LLDB_ENABLE_PYTHON
1242 TypeSummaryImplSP script_format;
1248 if (!funct_name || !funct_name[0]) {
1256 script_format = std::make_shared<ScriptSummaryFormat>(
1263 "The provided function \"%s\" does not exist - "
1264 "please define it before attempting to use this summary.\n",
1271 result.
AppendError(
"script interpreter missing - unable to generate "
1272 "function wrapper.\n");
1277 std::string funct_name_str;
1279 result.
AppendError(
"unable to generate function wrapper.\n");
1282 if (funct_name_str.empty()) {
1284 "script interpreter failed to generate a valid function name.\n");
1290 script_format = std::make_shared<ScriptSummaryFormat>(
1294 auto options = std::make_unique<ScriptAddOptions>(
1298 for (
auto &entry : command.
entries()) {
1299 if (entry.ref().empty()) {
1300 result.
AppendError(
"empty typenames not allowed");
1304 options->m_target_types << std::string(entry.ref());
1322 for (
auto &entry : command.
entries()) {
1335 result.
AppendError(
"added to types, but not given a name");
1357 result.
AppendError(
"empty summary strings not allowed");
1366 if (strcmp(format_cstr,
"${var%S}") == 0) {
1367 result.
AppendError(
"recursive summary not allowed");
1371 std::unique_ptr<StringSummaryFormat> string_format(
1373 if (!string_format) {
1377 if (string_format->m_error.Fail()) {
1379 string_format->m_error.AsCString(
"<unknown>"));
1382 lldb::TypeSummaryImplSP entry(string_format.release());
1386 for (
auto &arg_entry : command.
entries()) {
1387 if (arg_entry.ref().empty()) {
1388 result.
AppendError(
"empty typenames not allowed");
1406 result.
AppendError(
"added to types, but not given a name");
1418 "Add a new summary style for a type.", nullptr),
1426 type_arg.push_back(type_style_arg);
1432The following examples of 'type summary add' refer to this code snippet for context:
1438 JustADemo(int p = 1, float v = 0.1) : ptr(new int(p)), value(v) {}
1440 JustADemo demo_instance(42, 3.14);
1442 typedef JustADemo NewDemo;
1443 NewDemo new_demo_instance(42, 3.14);
1445(lldb) type summary add --summary-string "the answer is ${*var.ptr}" JustADemo
1447 Subsequently displaying demo_instance with 'frame variable' or 'expression' will display "the answer is 42"
1449(lldb) type summary add --summary-string "the answer is ${*var.ptr}, and the question is ${var.value}" JustADemo
1451 Subsequently displaying demo_instance with 'frame variable' or 'expression' will display "the answer is 42 and the question is 3.14"
1454 "Alternatively, you could define formatting for all pointers to integers and \
1455rely on that when formatting JustADemo to obtain the same result:"
1458(lldb) type summary add --summary-string "${var%V} -> ${*var}" "int *"
1459(lldb) type summary add --summary-string "the answer is ${var.ptr}, and the question is ${var.value}" JustADemo
1462 "Type summaries are automatically applied to derived typedefs, so the examples \
1463above apply to both JustADemo and NewDemo. The cascade option can be used to \
1464suppress this behavior:"
1467(lldb) type summary add --summary-string "${var.ptr}, ${var.value},{${var.byte}}" JustADemo -C no
1469 The summary will now be used for values of JustADemo but not NewDemo.
1472 "By default summaries are shown for pointers and references to values of the \
1473specified type. To suppress formatting for pointers use the -p option, or apply \
1474the corresponding -r option to suppress formatting for references:"
1477(lldb) type summary add -p -r --summary-string "${var.ptr}, ${var.value},{${var.byte}}" JustADemo
1480 "One-line summaries including all fields in a type can be inferred without supplying an \
1481explicit summary string by passing the -c option:"
1484(lldb) type summary add -c JustADemo
1485(lldb) frame variable demo_instance
1486(ptr=<address>, value=3.14)
1489 "Type summaries normally suppress the nested display of individual fields. To \
1490supply a summary to supplement the default structure add the -e option:"
1493(lldb) type summary add -e --summary-string "*ptr = ${*var.ptr}" JustADemo
1496 "Now when displaying JustADemo values the int* is displayed, followed by the \
1497standard LLDB sequence of children, one per line:"
1506 "You can also add summaries written in Python. These scripts use lldb public API to \
1507gather information from your variables and produce a meaningful summary. To start a \
1508multi-line script use the -P option. The function declaration will be displayed along with \
1509a comment describing the two arguments. End your script with the word 'DONE' on a line by \
1513(lldb) type summary add JustADemo -P
1514def function (valobj,internal_dict):
"""valobj: an SBValue which you want to provide a summary for
1515internal_dict: an LLDB support object not to be used"""
1516 value = valobj.GetChildMemberWithName('value');
1517 return 'My value is ' + value.GetValue();
1520Alternatively, the -o option can be used when providing a simple one-line Python script:
1522(lldb) type summary add JustADemo -o "value = valobj.GetChildMemberWithName('value'); return 'My value is ' + value.GetValue();")");
1530#if LLDB_ENABLE_PYTHON
1544 if (type_name_ref.endswith(
"[]")) {
1545 std::string type_name_str(type_name.
GetCString());
1546 type_name_str.resize(type_name_str.length() - 2);
1547 if (type_name_str.back() !=
' ')
1548 type_name_str.append(
" ?\\[[0-9]+\\]");
1550 type_name_str.append(
"\\[[0-9]+\\]");
1558 TypeSummaryImplSP entry,
1566 TypeSummaryImplSP entry,
1568 std::string category_name,
1570 lldb::TypeCategoryImplSP category;
1584 error->SetErrorString(
1585 "regex format error (maybe this is not really a regex?)");
1591 const char *function_name = type_name.
AsCString();
1594 error->SetErrorStringWithFormat(
1595 "The provided recognizer function \"%s\" does not exist - "
1596 "please define it before attempting to use this summary.\n",
1601 category->AddTypeSummary(type_name.
GetStringRef(), match_type, entry);
1612 "Delete an existing summary for a type.") {}
1628 "type summary clear",
1629 "Delete all existing summaries.") {}
1644 "Show a list of current summaries.") {}
1652 const TypeSummaryImplSP &summary_sp) ->
bool {
1655 summary_sp->GetDescription().c_str());
1665#define LLDB_OPTIONS_type_category_define
1666#include "CommandOptions.inc"
1682 switch (short_option) {
1690 llvm_unreachable(
"Unimplemented option");
1702 return llvm::ArrayRef(g_type_category_define_options);
1718 "Define a new category as a source of formatters.",
1726 type_arg.push_back(type_style_arg);
1751 for (
auto &entry : command.
entries()) {
1752 TypeCategoryImplSP category_sp;
1769#define LLDB_OPTIONS_type_category_enable
1770#include "CommandOptions.inc"
1784 switch (short_option) {
1786 if (!option_arg.empty()) {
1789 error.SetErrorStringWithFormat(
"unrecognized language '%s'",
1790 option_arg.str().c_str());
1794 llvm_unreachable(
"Unimplemented option");
1805 return llvm::ArrayRef(g_type_category_enable_options);
1820 "Enable a category as a source of formatters.",
1828 type_arg.push_back(type_style_arg);
1855 }
else if (argc > 0) {
1856 for (
int i = argc - 1; i >= 0; i--) {
1861 result.
AppendError(
"empty category name not allowed");
1865 lldb::TypeCategoryImplSP cate;
1867 if (cate->GetCount() == 0) {
1888 "Delete a category and all associated formatters.",
1896 type_arg.push_back(type_style_arg);
1921 bool success =
true;
1924 for (
int i = argc - 1; i >= 0; i--) {
1929 result.
AppendError(
"empty category name not allowed");
1939 result.
AppendError(
"cannot delete one or more categories\n");
1946#define LLDB_OPTIONS_type_category_disable
1947#include "CommandOptions.inc"
1961 switch (short_option) {
1963 if (!option_arg.empty()) {
1966 error.SetErrorStringWithFormat(
"unrecognized language '%s'",
1967 option_arg.str().c_str());
1971 llvm_unreachable(
"Unimplemented option");
1982 return llvm::ArrayRef(g_type_category_disable_options);
1997 "Disable a category as a source of formatters.",
2005 type_arg.push_back(type_style_arg);
2032 }
else if (argc > 0) {
2034 for (
int i = argc - 1; i >= 0; i--) {
2039 result.
AppendError(
"empty category name not allowed");
2060 "Provide a list of all existing categories.",
2063 CommandArgumentData type_style_arg;
2068 type_arg.push_back(type_style_arg);
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) {
2106 [®ex, &result](
const lldb::TypeCategoryImplSP &category_sp) ->
bool {
2109 if (regex->GetText() == category_sp->GetName()) {
2111 }
else if (regex->Execute(category_sp->GetName())) {
2120 "Category: %s\n", category_sp->GetDescription().c_str());
2137 "Show a list of current filters.") {}
2140#if LLDB_ENABLE_PYTHON
2144class CommandObjectTypeSynthList
2149 interpreter,
"type synthetic list",
2150 "Show a list of current synthetic providers.") {}
2162 "Delete an existing filter for a type.") {}
2167#if LLDB_ENABLE_PYTHON
2176 "Delete an existing synthetic provider for a type.") {}
2178 ~CommandObjectTypeSynthDelete()
override =
default;
2189 "type filter clear",
2190 "Delete all existing filter.") {}
2193#if LLDB_ENABLE_PYTHON
2201 "Delete all existing synthetic providers.") {}
2206 auto options = std::make_unique<SynthAddOptions>(
2210 for (
auto &entry : command.
entries()) {
2211 if (entry.ref().empty()) {
2212 result.
AppendError(
"empty typenames not allowed");
2216 options->m_target_types << std::string(entry.ref());
2240 "directly input Python code.\n",
2245 SyntheticChildrenSP entry;
2260 result.
AppendWarning(
"The provided class does not exist - please define it "
2261 "before attempting to use this synthetic provider");
2265 lldb::TypeCategoryImplSP category;
2271 for (
auto &arg_entry : command.
entries()) {
2272 if (arg_entry.ref().empty()) {
2273 result.
AppendError(
"empty typenames not allowed");
2292 "Add a new synthetic provider for a type.", nullptr),
2295 CommandArgumentData type_style_arg;
2300 type_arg.push_back(type_style_arg);
2306 SyntheticChildrenSP entry,
2308 std::string category_name,
2310 lldb::TypeCategoryImplSP category;
2331 error->SetErrorStringWithFormat(
"cannot add synthetic for type %s when "
2332 "filter is defined in same category!",
2342 error->SetErrorString(
2343 "regex format error (maybe this is not really a regex?)");
2352 error->SetErrorStringWithFormat(
2353 "The provided recognizer function \"%s\" does not exist - "
2354 "please define it before attempting to use this summary.\n",
2360 category->AddTypeSynthetic(type_name.
GetStringRef(), match_type, entry);
2365#define LLDB_OPTIONS_type_filter_add
2366#include "CommandOptions.inc"
2384 switch (short_option) {
2388 error.SetErrorStringWithFormat(
"invalid value for cascade: %s",
2389 option_arg.str().c_str());
2408 llvm_unreachable(
"Unimplemented option");
2425 return llvm::ArrayRef(g_type_filter_add_options);
2451 lldb::TypeCategoryImplSP category;
2469 lldb::SyntheticChildrenSP entry;
2473 error->SetErrorStringWithFormat(
"cannot add filter for type %s when "
2474 "synthetic is defined in same "
2487 error->SetErrorString(
2488 "regex format error (maybe this is not really a regex?)");
2492 category->AddTypeFilter(type_name.
GetStringRef(), match_type, entry);
2499 "Add a new filter for a type.", nullptr) {
2501 CommandArgumentData type_style_arg;
2506 type_arg.push_back(type_style_arg);
2512The following examples of 'type filter add' refer to this code snippet for context:
2527Adding a simple filter:
2529(lldb) type filter add --child a --child g Foo
2530(lldb) frame variable my_foo
2533 "Produces output where only a and g are displayed. Other children of my_foo \
2534(b, c, d, e, f, h and i) are available by asking for them explicitly:"
2537(lldb) frame variable my_foo.b my_foo.c my_foo.i
2540 "The formatting option --raw on frame variable bypasses the filter, showing \
2541all children of my_foo as if no filter was defined:"
2544(lldb) frame variable my_foo --raw)");
2576 entry->AddExpressionPath(*begin);
2580 lldb::TypeCategoryImplSP category;
2588 for (
auto &arg_entry : command.
entries()) {
2589 if (arg_entry.ref().empty()) {
2590 result.
AppendError(
"empty typenames not allowed");
2609#define LLDB_OPTIONS_type_lookup
2610#include "CommandOptions.inc"
2641 return llvm::ArrayRef(g_type_lookup_options);
2648 const int short_option = g_type_lookup_options[option_idx].short_option;
2650 switch (short_option) {
2660 llvm_unreachable(
"Unimplemented option");
2683 "Lookup types and declarations in the current target, "
2684 "following language-specific naming conventions.",
2685 "type lookup <type-specifier>",
2686 eCommandRequiresTarget) {
2702 stream.
Printf(
"%s\n", help);
2710 bool DoExecute(llvm::StringRef raw_command_line,
2712 if (raw_command_line.empty()) {
2714 "type lookup cannot be invoked without a type name as argument");
2722 const char *name_of_type = args.GetRawPart().c_str();
2731 bool any_found =
false;
2733 std::vector<Language *> languages;
2735 bool is_global_search =
false;
2738 if ((is_global_search =
2741 languages.push_back(lang);
2755 languages.begin(), languages.end(),
2757 if (!lang1 || !lang2)
2759 LanguageType lt1 = lang1->GetLanguageType();
2760 LanguageType lt2 = lang2->GetLanguageType();
2761 if (lt1 == guessed_language)
2763 if (lt2 == guessed_language)
2770 bool is_first_language =
true;
2772 for (
Language *language : languages) {
2776 if (
auto scavenger = language->GetTypeScavenger()) {
2778 if (scavenger->Find(best_scope, name_of_type, search_results) > 0) {
2779 for (
const auto &search_result : search_results) {
2780 if (search_result && search_result->IsValid()) {
2783 this->m_command_options.m_show_help);
2789 if (any_found && is_global_search)
2791 else if (is_first_language && is_global_search &&
2793 is_first_language =
false;
2795 "no type was found in the current language %s matching '%s'; "
2796 "performing a global search across all languages\n",
2811template <
typename FormatterType>
2814 typedef std::function<
typename FormatterType::SharedPointer(
ValueObject &)>
2817 const char *formatter_name,
2823 name.
Printf(
"type %s info", formatter_name);
2826 help.
Printf(
"This command evaluates the provided expression and shows "
2827 "which %s is applied to the resulting value (if any).",
2831 syntax.
Printf(
"type %s info <expr>", formatter_name);
2848 ValueObjectSP result_valobj_sp;
2851 command, frame_sp.get(), result_valobj_sp, options);
2854 result_valobj_sp->GetQualifiedRepresentationIfAvailable(
2855 target_sp->GetPreferDynamicValue(),
2856 target_sp->GetEnableSyntheticValue());
2857 typename FormatterType::SharedPointer formatter_sp =
2860 std::string description(formatter_sp->GetDescription());
2863 << result_valobj_sp->GetDisplayTypeName().AsCString(
"<unknown>")
2864 <<
") " << command <<
" is: " << description <<
"\n";
2869 << result_valobj_sp->GetDisplayTypeName().AsCString(
"<unknown>")
2870 <<
") " << command <<
"\n";
2875 result.
AppendError(
"failed to evaluate expression");
2889 interpreter,
"type format",
2890 "Commands for customizing value display formats.",
2891 "type format [<sub-command-options>] ") {
2902 interpreter,
"format",
2911#if LLDB_ENABLE_PYTHON
2917 interpreter,
"type synthetic",
2918 "Commands for operating on synthetic type representations.",
2919 "type synthetic [<sub-command-options>] ") {
2923 "clear", CommandObjectSP(
new CommandObjectTypeSynthClear(interpreter)));
2924 LoadSubCommand(
"delete", CommandObjectSP(
new CommandObjectTypeSynthDelete(
2927 "list", CommandObjectSP(
new CommandObjectTypeSynthList(interpreter)));
2931 interpreter,
"synthetic",
2937 ~CommandObjectTypeSynth()
override =
default;
2946 "Commands for operating on type filters.",
2947 "type filter [<sub-command-options>] ") {
2965 "Commands for operating on type categories.",
2966 "type category [<sub-command-options>] ") {
2990 interpreter,
"type summary",
2991 "Commands for editing variable summary display options.",
2992 "type summary [<sub-command-options>] ") {
3003 interpreter,
"summary",
3016 "Commands for operating on the type system.",
3017 "type [<sub-command-options>]") {
3026#if LLDB_ENABLE_PYTHON
3028 CommandObjectSP(
new CommandObjectTypeSynth(interpreter)));
static const char * g_synth_addreader_instructions
static bool WarnOnPotentialUnquotedUnsignedType(Args &command, CommandReturnObject &result)
static bool FixArrayTypeNameWithRegex(ConstString &type_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
Options * GetOptions() override
~CommandObjectTypeCategoryDefine() override=default
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
bool DoExecute(Args &command, CommandReturnObject &result) override
bool DoExecute(Args &command, CommandReturnObject &result) override
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
~CommandObjectTypeCategoryDelete() override=default
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
Options * GetOptions() override
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
~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
bool DoExecute(Args &command, CommandReturnObject &result) override
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
~CommandObjectTypeCategoryEnable() override=default
Options * GetOptions() override
bool DoExecute(Args &command, CommandReturnObject &result) override
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
~CommandObjectTypeCategoryList() override=default
~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
Options * GetOptions() override
bool AddFilter(ConstString type_name, TypeFilterImplSP entry, FilterFormatType type, std::string category_name, Status *error)
bool DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectTypeFilterDelete() override=default
~CommandObjectTypeFilter() override=default
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
bool DoExecute(llvm::StringRef raw_command_line, CommandReturnObject &result) override
OptionGroupOptions m_option_group
lldb::LanguageType GuessLanguage(StackFrame *frame)
~CommandObjectTypeLookup() override=default
llvm::StringRef GetHelpLong() override
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
Set the value of an option.
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
std::string m_python_function
~CommandOptions() override=default
CommandOptions(CommandInterpreter &interpreter)
TypeSummaryImpl::Flags m_flags
FormatterMatchType m_match_type
std::string m_format_string
~CommandObjectTypeSummaryAdd() override=default
Options * GetOptions() override
bool Execute_ScriptSummary(Args &command, CommandReturnObject &result)
void IOHandlerActivated(IOHandler &io_handler, bool interactive) override
bool Execute_StringSummary(Args &command, CommandReturnObject &result)
bool DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectTypeSummaryAdd(CommandInterpreter &interpreter)
void IOHandlerInputComplete(IOHandler &io_handler, std::string &data) override
Called when a line or lines have been retrieved.
bool AddNamedSummary(ConstString summary_name, lldb::TypeSummaryImplSP entry, Status *error=nullptr)
bool AddSummary(ConstString type_name, lldb::TypeSummaryImplSP entry, FormatterMatchType match_type, std::string category, Status *error=nullptr)
void FormatterSpecificDeletion() override
~CommandObjectTypeSummaryDelete() override=default
bool FormatterSpecificDeletion(ConstString typeCS) override
bool FormatterSpecificList(CommandReturnObject &result) override
~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 Execute_PythonClass(Args &command, CommandReturnObject &result)
bool AddSynth(ConstString type_name, lldb::SyntheticChildrenSP entry, FormatterMatchType match_type, std::string category_name, Status *error)
Options * GetOptions() override
void IOHandlerActivated(IOHandler &io_handler, bool interactive) override
~CommandObjectTypeSynthAdd() override=default
bool DoExecute(Args &command, CommandReturnObject &result) override
bool Execute_HandwritePython(Args &command, CommandReturnObject &result)
StringList m_target_types
std::shared_ptr< ScriptAddOptions > SharedPointer
TypeSummaryImpl::Flags m_flags
ScriptAddOptions(const TypeSummaryImpl::Flags &flags, FormatterMatchType match_type, ConstString name, std::string catg)
FormatterMatchType m_match_type
FormatterMatchType m_match_type
StringList m_target_types
std::shared_ptr< SynthAddOptions > SharedPointer
SynthAddOptions(bool sptr, bool sref, bool casc, FormatterMatchType match_type, std::string catg)
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)
@ eTypeCategoryNameCompletion
ExecutionContext GetExecutionContext() const
void GetPythonCommandsFromIOHandler(const char *prompt, IOHandlerDelegate &delegate, void *baton=nullptr)
bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override
CommandObjectType(CommandInterpreter &interpreter)
~CommandObjectType() override
std::vector< CommandArgumentData > CommandArgumentEntry
virtual void SetHelpLong(llvm::StringRef str)
bool ParseOptionsAndNotify(Args &args, CommandReturnObject &result, OptionGroupOptions &group_options, ExecutionContext &exe_ctx)
ExecutionContext m_exe_ctx
std::vector< CommandArgumentEntry > m_arguments
CommandInterpreter & GetCommandInterpreter()
CommandInterpreter & m_interpreter
Thread * GetDefaultThread()
std::string m_cmd_help_long
void SetSyntax(llvm::StringRef str)
void SetCommandName(llvm::StringRef name)
virtual void SetHelp(llvm::StringRef str)
void void AppendError(llvm::StringRef in_string)
void AppendWarningWithFormat(const char *format,...) __attribute__((format(printf
void SetStatus(lldb::ReturnStatus status)
void AppendErrorWithFormat(const char *format,...) __attribute__((format(printf
void AppendMessageWithFormat(const char *format,...) __attribute__((format(printf
void void AppendWarning(llvm::StringRef in_string)
Stream & GetOutputStream()
"lldb/Utility/ArgCompletionRequest.h"
size_t GetCursorIndex() const
A uniqued constant string class.
void SetCString(const char *cstr)
Set the C string value.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
void SetString(const llvm::StringRef &s)
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
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)
lldb::TargetSP GetSelectedTarget()
ScriptInterpreter * GetScriptInterpreter(bool can_create=true, std::optional< lldb::ScriptLanguage > language={})
"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.
StackFrame * GetFramePtr() const
Returns a pointer to the frame object.
ValueType Clear(ValueType mask=~static_cast< ValueType >(0))
Clear one or more flags.
lldb::StreamFileSP GetErrorStreamFileSP()
lldb::StreamFileSP GetOutputStreamFileSP()
std::set< std::unique_ptr< Result > > ResultSet
static Language * FindPlugin(lldb::LanguageType language)
static const char * GetNameForLanguageType(lldb::LanguageType language)
virtual const char * GetLanguageSpecificTypeLookupHelp()
static lldb::LanguageType GetLanguageTypeFromString(const char *string)=delete
static void ForEach(std::function< bool(Language *)> callback)
void Append(OptionGroup *group)
Append options from a OptionGroup class.
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
bool GetCurrentValue() const
lldb::LanguageType GetCurrentValue() const
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
llvm::StringRef GetCurrentValueAsRef() const
Status SetCurrentValue(llvm::StringRef value)
bool OptionWasSet() const
A pair of an option list with a 'raw' string as a suffix.
A command line option parsing protocol class.
void NotifyOptionParsingStarting(ExecutionContext *execution_context)
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.
const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope)
Provide a SymbolContext for this StackFrame's current pc value.
lldb::LanguageType GuessLanguage()
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 & SetSkipPointers(bool value=true)
std::shared_ptr< SyntheticChildren > SharedPointer
lldb::StackFrameSP GetSelectedFrame()
static const Position Default
Class for matching type names.
ConstString GetMatchString() const
Returns the underlying match string for this TypeMatcher.
Flags & SetCascades(bool value=true)
Flags & SetHideEmptyAggregates(bool value=true)
bool GetShowMembersOneLiner() const
Flags & SetSkipPointers(bool value=true)
Flags & SetHideItemNames(bool value=true)
Flags & SetDontShowChildren(bool value=true)
Flags & SetSkipReferences(bool value=true)
Flags & SetShowMembersOneLiner(bool value=true)
Flags & SetDontShowValue(bool value=true)
std::shared_ptr< TypeSummaryImpl > SharedPointer
lldb::TypeFormatImplSP GetValueFormat()
lldb::TypeSummaryImplSP GetSummaryFormat()
lldb::SyntheticChildrenSP GetSyntheticChildren()
A class that represents a running process on the host machine.
std::vector< OptionArgElement > OptionElementVector
@ eFormatCategoryItemFormat
@ eFormatCategoryItemSynth
@ eFormatCategoryItemSummary
@ eFormatCategoryItemFilter
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
Used to build individual command argument lists.
ArgumentRepetitionType arg_repetition
lldb::CommandArgumentType arg_type
static bool ToBoolean(llvm::StringRef s, bool fail_value, bool *success_ptr)