15#include "lldb/Host/Config.h"
36#include "llvm/ADT/STLExtras.h"
84 for (
auto entry : llvm::enumerate(command.
entries().drop_back())) {
85 if (entry.value().ref() !=
"unsigned")
87 auto next = command.
entries()[entry.index() + 1].ref();
88 if (next ==
"int" || next ==
"short" || next ==
"char" || next ==
"long") {
90 "unsigned %s being treated as two types. if you meant the combined "
92 "name use quotes, as in \"unsigned %s\"\n",
93 next.str().c_str(), next.str().c_str());
108 return "synthetic child provider";
113 llvm_unreachable(
"Fully covered switch above!");
116#define LLDB_OPTIONS_type_summary_add
117#include "CommandOptions.inc"
134 return llvm::ArrayRef(g_type_summary_add_options);
163 static const char *g_summary_addreader_instructions =
164 "Enter your Python command(s). Type 'DONE' to end.\n"
165 "def function (valobj,internal_dict):\n"
166 " \"\"\"valobj: an SBValue which you want to provide a summary "
168 " internal_dict: an LLDB support object not to be used\"\"\"\n";
171 if (output_sp && interactive) {
172 output_sp->PutCString(g_summary_addreader_instructions);
178 std::string &data)
override {
181#if LLDB_ENABLE_PYTHON
196 std::string funct_name_str;
199 if (funct_name_str.empty()) {
200 error_sp->Printf(
"unable to obtain a valid function name from "
201 "the script interpreter.\n");
207 TypeSummaryImplSP script_format;
208 script_format = std::make_shared<ScriptSummaryFormat>(
209 options->m_flags, funct_name_str.c_str(),
214 for (
const std::string &type_name : options->m_target_types) {
216 options->m_match_type, options->m_category,
219 error_sp->Printf(
"error: %s",
error.AsCString());
224 if (options->m_name) {
226 options->m_name, script_format, &
error);
229 options->m_name, script_format, &
error);
231 error_sp->Printf(
"error: %s",
error.AsCString());
235 error_sp->Printf(
"error: %s",
error.AsCString());
239 if (
error.AsCString()) {
240 error_sp->Printf(
"error: %s",
error.AsCString());
246 error_sp->Printf(
"error: unable to generate a function.\n");
250 error_sp->Printf(
"error: no script interpreter.\n");
254 error_sp->Printf(
"error: internal synchronization information "
255 "missing or invalid.\n");
259 error_sp->Printf(
"error: empty function, didn't add python command.\n");
264 "error: script interpreter missing, didn't add python command.\n");
283 "Enter your Python command(s). Type 'DONE' to end.\n"
284 "You must define a Python class with these methods:\n"
285 " def __init__(self, valobj, internal_dict):\n"
286 " def num_children(self):\n"
287 " def get_child_at_index(self, index):\n"
288 " def get_child_index(self, name):\n"
289 " def update(self):\n"
291 "class synthProvider:\n";
293#define LLDB_OPTIONS_type_synth_add
294#include "CommandOptions.inc"
311 switch (short_option) {
315 error.SetErrorStringWithFormat(
"invalid value for cascade: %s",
316 option_arg.str().c_str());
336 error.SetErrorString(
337 "can't use --regex and --recognizer-function at the same time");
343 error.SetErrorString(
344 "can't use --regex and --recognizer-function at the same time");
349 llvm_unreachable(
"Unimplemented option");
367 return llvm::ArrayRef(g_type_synth_add_options);
400 result.
AppendError(
"must either provide a children list, a Python class "
401 "name, or use -P and type a Python class "
409 if (output_sp && interactive) {
416 std::string &data)
override {
419#if LLDB_ENABLE_PYTHON
434 std::string class_name_str;
436 if (class_name_str.empty()) {
438 "error: unable to obtain a proper name for the class.\n");
444 SyntheticChildrenSP synth_provider;
445 synth_provider = std::make_shared<ScriptedSyntheticChildren>(
447 .SetCascades(options->m_cascade)
450 class_name_str.c_str());
452 lldb::TypeCategoryImplSP category;
454 ConstString(options->m_category.c_str()), category);
458 for (
const std::string &type_name : options->m_target_types) {
459 if (!type_name.empty()) {
461 options->m_match_type, options->m_category,
463 error_sp->Printf(
"error: %s\n",
error.AsCString());
468 error_sp->Printf(
"error: invalid type name.\n");
475 error_sp->Printf(
"error: unable to generate a class.\n");
479 error_sp->Printf(
"error: no script interpreter.\n");
483 error_sp->Printf(
"error: internal synchronization data missing.\n");
487 error_sp->Printf(
"error: empty function, didn't add python command.\n");
492 "error: script interpreter missing, didn't add python command.\n");
512#define LLDB_OPTIONS_type_format_add
513#include "CommandOptions.inc"
524 return llvm::ArrayRef(g_type_format_add_options);
539 const int short_option =
540 g_type_format_add_options[option_idx].short_option;
543 switch (short_option) {
547 error.SetErrorStringWithFormat(
"invalid value for cascade: %s",
548 option_value.str().c_str());
566 llvm_unreachable(
"Unimplemented option");
591 "Add a new formatting style for a type.", nullptr),
599 type_arg.push_back(type_style_arg);
605The following examples of 'type format add' refer to this code snippet for context:
608 typedef float Afloat;
610 typedef Afloat Bfloat;
618Adding default formatting:
620(lldb) type format add -f hex AInt
621(lldb) frame variable iy
624 " Produces hexadecimal display of iy, because no formatter is available for Bint and \
625the one for Aint is used instead."
628To prevent this use the cascade option '-C no' to prevent evaluation of typedef chains:
631(lldb) type format add -f hex -C no AInt
633Similar reasoning applies to this:
635(lldb) type format add -f hex -C no float -p
638 " All float values and float references are now formatted as hexadecimal, but not \
639pointers to floats. Nor will it change the default display for Afloat and Bfloat objects.");
669 TypeFormatImplSP entry;
672 entry = std::make_shared<TypeFormatImpl_Format>(
678 entry = std::make_shared<TypeFormatImpl_EnumType>(
687 TypeCategoryImplSP category_sp;
695 for (
auto &arg_entry : command.
entries()) {
696 if (arg_entry.ref().empty()) {
705 if (!typeRX.IsValid()) {
707 "regex format error (maybe this is not really a regex?)");
711 category_sp->AddTypeFormat(arg_entry.ref(), match_type, entry);
719#define LLDB_OPTIONS_type_formatter_delete
720#include "CommandOptions.inc"
735 switch (short_option) {
746 llvm_unreachable(
"Unimplemented option");
759 return llvm::ArrayRef(g_type_formatter_delete_options);
775 "Delete an existing %s for a type.";
778 "Delete an existing %s for a type. Unless you specify a "
779 "specific category or all categories, only the "
780 "'default' category is searched. The names must be exactly as "
781 "shown in the 'type %s list' output";
795 type_arg.push_back(type_style_arg);
809 s.
Printf(
"type %s delete", short_kind);
822 [
this, &request](
const lldb::TypeCategoryImplSP &category_sp) {
849 [
this, typeCS](
const lldb::TypeCategoryImplSP &category_sp) ->
bool {
857 bool delete_category =
false;
858 bool extra_deletion =
false;
861 lldb::TypeCategoryImplSP category;
868 lldb::TypeCategoryImplSP category;
876 if (delete_category || extra_deletion) {
886#define LLDB_OPTIONS_type_formatter_clear
887#include "CommandOptions.inc"
902 switch (short_option) {
907 llvm_unreachable(
"Unimplemented option");
918 return llvm::ArrayRef(g_type_formatter_clear_options);
933 const char *name,
const char *help)
948 [
this](
const TypeCategoryImplSP &category_sp) ->
bool {
953 lldb::TypeCategoryImplSP category;
990 "Delete all existing format styles.") {}
993#define LLDB_OPTIONS_type_formatter_list
994#include "CommandOptions.inc"
996template <
typename FormatterType>
1013 switch (short_option) {
1020 if (
error.Success())
1024 llvm_unreachable(
"Unimplemented option");
1036 return llvm::ArrayRef(g_type_formatter_list_options);
1051 const char *name,
const char *help)
1059 type_arg.push_back(type_style_arg);
1077 return regex ==
nullptr || s == regex->
GetText() || regex->
Execute(s);
1083 std::unique_ptr<RegularExpression> category_regex;
1084 std::unique_ptr<RegularExpression> formatter_regex;
1087 category_regex = std::make_unique<RegularExpression>(
1089 if (!category_regex->IsValid()) {
1091 "syntax error in category regular expression '%s'",
1099 formatter_regex = std::make_unique<RegularExpression>(arg);
1100 if (!formatter_regex->IsValid()) {
1107 bool any_printed =
false;
1109 auto category_closure =
1110 [&result, &formatter_regex,
1111 &any_printed](
const lldb::TypeCategoryImplSP &category) ->
void {
1113 "-----------------------\nCategory: %s%s\n-----------------------\n",
1114 category->GetName(), category->IsEnabled() ?
"" :
" (disabled)");
1117 [&result, &formatter_regex,
1121 formatter_regex.get())) {
1124 "%s: %s\n", type_matcher.GetMatchString().GetCString(),
1125 format_sp->GetDescription().c_str());
1129 category->ForEach(print_formatter);
1133 lldb::TypeCategoryImplSP category_sp;
1137 category_closure(category_sp);
1140 [&category_regex, &category_closure](
1141 const lldb::TypeCategoryImplSP &category) ->
bool {
1143 category_closure(category);
1168 "Show a list of current formats.") {}
1172 uint32_t option_idx, llvm::StringRef option_arg,
1178 switch (short_option) {
1182 error.SetErrorStringWithFormat(
"invalid value for cascade: %s",
1183 option_arg.str().c_str());
1208 error.SetErrorString(
1209 "can't use --regex and --recognizer-function at the same time");
1215 error.SetErrorString(
1216 "can't use --regex and --recognizer-function at the same time");
1241 llvm_unreachable(
"Unimplemented option");
1249 m_flags.
Clear().SetCascades().SetDontShowChildren().SetDontShowValue(
false);
1250 m_flags.SetShowMembersOneLiner(
false)
1251 .SetSkipPointers(
false)
1252 .SetSkipReferences(
false)
1253 .SetHideItemNames(
false);
1257 m_python_script =
"";
1258 m_python_function =
"";
1259 m_format_string =
"";
1260 m_is_add_script =
false;
1261 m_category =
"default";
1264#if LLDB_ENABLE_PYTHON
1276 TypeSummaryImplSP script_format;
1282 if (!funct_name || !funct_name[0]) {
1290 script_format = std::make_shared<ScriptSummaryFormat>(
1297 "The provided function \"%s\" does not exist - "
1298 "please define it before attempting to use this summary.\n",
1305 result.
AppendError(
"script interpreter missing - unable to generate "
1306 "function wrapper.\n");
1311 std::string funct_name_str;
1313 result.
AppendError(
"unable to generate function wrapper.\n");
1316 if (funct_name_str.empty()) {
1318 "script interpreter failed to generate a valid function name.\n");
1324 script_format = std::make_shared<ScriptSummaryFormat>(
1328 auto options = std::make_unique<ScriptAddOptions>(
1332 for (
auto &entry : command.
entries()) {
1333 if (entry.ref().empty()) {
1334 result.
AppendError(
"empty typenames not allowed");
1338 options->m_target_types << std::string(entry.ref());
1356 for (
auto &entry : command.
entries()) {
1369 result.
AppendError(
"added to types, but not given a name");
1391 result.
AppendError(
"empty summary strings not allowed");
1400 if (strcmp(format_cstr,
"${var%S}") == 0) {
1401 result.
AppendError(
"recursive summary not allowed");
1405 std::unique_ptr<StringSummaryFormat> string_format(
1407 if (!string_format) {
1411 if (string_format->m_error.Fail()) {
1413 string_format->m_error.AsCString(
"<unknown>"));
1416 lldb::TypeSummaryImplSP entry(string_format.release());
1420 for (
auto &arg_entry : command.
entries()) {
1421 if (arg_entry.ref().empty()) {
1422 result.
AppendError(
"empty typenames not allowed");
1440 result.
AppendError(
"added to types, but not given a name");
1452 "Add a new summary style for a type.", nullptr),
1460 type_arg.push_back(type_style_arg);
1466The following examples of 'type summary add' refer to this code snippet for context:
1472 JustADemo(int p = 1, float v = 0.1) : ptr(new int(p)), value(v) {}
1474 JustADemo demo_instance(42, 3.14);
1476 typedef JustADemo NewDemo;
1477 NewDemo new_demo_instance(42, 3.14);
1479(lldb) type summary add --summary-string "the answer is ${*var.ptr}" JustADemo
1481 Subsequently displaying demo_instance with 'frame variable' or 'expression' will display "the answer is 42"
1483(lldb) type summary add --summary-string "the answer is ${*var.ptr}, and the question is ${var.value}" JustADemo
1485 Subsequently displaying demo_instance with 'frame variable' or 'expression' will display "the answer is 42 and the question is 3.14"
1488 "Alternatively, you could define formatting for all pointers to integers and \
1489rely on that when formatting JustADemo to obtain the same result:"
1492(lldb) type summary add --summary-string "${var%V} -> ${*var}" "int *"
1493(lldb) type summary add --summary-string "the answer is ${var.ptr}, and the question is ${var.value}" JustADemo
1496 "Type summaries are automatically applied to derived typedefs, so the examples \
1497above apply to both JustADemo and NewDemo. The cascade option can be used to \
1498suppress this behavior:"
1501(lldb) type summary add --summary-string "${var.ptr}, ${var.value},{${var.byte}}" JustADemo -C no
1503 The summary will now be used for values of JustADemo but not NewDemo.
1506 "By default summaries are shown for pointers and references to values of the \
1507specified type. To suppress formatting for pointers use the -p option, or apply \
1508the corresponding -r option to suppress formatting for references:"
1511(lldb) type summary add -p -r --summary-string "${var.ptr}, ${var.value},{${var.byte}}" JustADemo
1514 "One-line summaries including all fields in a type can be inferred without supplying an \
1515explicit summary string by passing the -c option:"
1518(lldb) type summary add -c JustADemo
1519(lldb) frame variable demo_instance
1520(ptr=<address>, value=3.14)
1523 "Type summaries normally suppress the nested display of individual fields. To \
1524supply a summary to supplement the default structure add the -e option:"
1527(lldb) type summary add -e --summary-string "*ptr = ${*var.ptr}" JustADemo
1530 "Now when displaying JustADemo values the int* is displayed, followed by the \
1531standard LLDB sequence of children, one per line:"
1540 "You can also add summaries written in Python. These scripts use lldb public API to \
1541gather information from your variables and produce a meaningful summary. To start a \
1542multi-line script use the -P option. The function declaration will be displayed along with \
1543a comment describing the two arguments. End your script with the word 'DONE' on a line by \
1547(lldb) type summary add JustADemo -P
1548def function (valobj,internal_dict):
"""valobj: an SBValue which you want to provide a summary for
1549internal_dict: an LLDB support object not to be used"""
1550 value = valobj.GetChildMemberWithName('value');
1551 return 'My value is ' + value.GetValue();
1554Alternatively, the -o option can be used when providing a simple one-line Python script:
1556(lldb) type summary add JustADemo -o "value = valobj.GetChildMemberWithName('value'); return 'My value is ' + value.GetValue();")");
1564#if LLDB_ENABLE_PYTHON
1578 if (type_name_ref.endswith(
"[]")) {
1579 std::string type_name_str(type_name.
GetCString());
1580 type_name_str.resize(type_name_str.length() - 2);
1581 if (type_name_str.back() !=
' ')
1582 type_name_str.append(
" ?\\[[0-9]+\\]");
1584 type_name_str.append(
"\\[[0-9]+\\]");
1592 TypeSummaryImplSP entry,
1600 TypeSummaryImplSP entry,
1602 std::string category_name,
1604 lldb::TypeCategoryImplSP category;
1616 if (!typeRX.IsValid()) {
1618 error->SetErrorString(
1619 "regex format error (maybe this is not really a regex?)");
1625 const char *function_name = type_name.
AsCString();
1628 error->SetErrorStringWithFormat(
1629 "The provided recognizer function \"%s\" does not exist - "
1630 "please define it before attempting to use this summary.\n",
1635 category->AddTypeSummary(type_name.
GetStringRef(), match_type, entry);
1661 "type summary clear",
1662 "Delete all existing summaries.") {}
1677 "Show a list of current summaries.") {}
1685 const TypeSummaryImplSP &summary_sp) ->
bool {
1688 summary_sp->GetDescription().c_str());
1698#define LLDB_OPTIONS_type_category_define
1699#include "CommandOptions.inc"
1715 switch (short_option) {
1723 llvm_unreachable(
"Unimplemented option");
1735 return llvm::ArrayRef(g_type_category_define_options);
1751 "Define a new category as a source of formatters.",
1759 type_arg.push_back(type_style_arg);
1784 for (
auto &entry : command.
entries()) {
1785 TypeCategoryImplSP category_sp;
1802#define LLDB_OPTIONS_type_category_enable
1803#include "CommandOptions.inc"
1817 switch (short_option) {
1819 if (!option_arg.empty()) {
1822 error.SetErrorStringWithFormat(
"unrecognized language '%s'",
1823 option_arg.str().c_str());
1827 llvm_unreachable(
"Unimplemented option");
1838 return llvm::ArrayRef(g_type_category_enable_options);
1853 "Enable a category as a source of formatters.",
1861 type_arg.push_back(type_style_arg);
1888 }
else if (argc > 0) {
1889 for (
int i = argc - 1; i >= 0; i--) {
1894 result.
AppendError(
"empty category name not allowed");
1898 lldb::TypeCategoryImplSP cate;
1900 if (cate->GetCount() == 0) {
1921 "Delete a category and all associated formatters.",
1929 type_arg.push_back(type_style_arg);
1954 bool success =
true;
1957 for (
int i = argc - 1; i >= 0; i--) {
1962 result.
AppendError(
"empty category name not allowed");
1972 result.
AppendError(
"cannot delete one or more categories\n");
1979#define LLDB_OPTIONS_type_category_disable
1980#include "CommandOptions.inc"
1994 switch (short_option) {
1996 if (!option_arg.empty()) {
1999 error.SetErrorStringWithFormat(
"unrecognized language '%s'",
2000 option_arg.str().c_str());
2004 llvm_unreachable(
"Unimplemented option");
2015 return llvm::ArrayRef(g_type_category_disable_options);
2030 "Disable a category as a source of formatters.",
2038 type_arg.push_back(type_style_arg);
2065 }
else if (argc > 0) {
2067 for (
int i = argc - 1; i >= 0; i--) {
2072 result.
AppendError(
"empty category name not allowed");
2093 "Provide a list of all existing categories.",
2096 CommandArgumentData type_style_arg;
2101 type_arg.push_back(type_style_arg);
2122 std::unique_ptr<RegularExpression> regex;
2126 regex = std::make_unique<RegularExpression>(arg);
2127 if (!regex->IsValid()) {
2129 "syntax error in category regular expression '%s'", arg);
2132 }
else if (argc != 0) {
2139 [®ex, &result](
const lldb::TypeCategoryImplSP &category_sp) ->
bool {
2142 if (regex->GetText() == category_sp->GetName()) {
2144 }
else if (regex->Execute(category_sp->GetName())) {
2153 "Category: %s\n", category_sp->GetDescription().c_str());
2170 "Show a list of current filters.") {}
2173#if LLDB_ENABLE_PYTHON
2177class CommandObjectTypeSynthList
2182 interpreter,
"type synthetic list",
2183 "Show a list of current synthetic providers.") {}
2199#if LLDB_ENABLE_PYTHON
2209 ~CommandObjectTypeSynthDelete()
override =
default;
2220 "type filter clear",
2221 "Delete all existing filter.") {}
2224#if LLDB_ENABLE_PYTHON
2232 "Delete all existing synthetic providers.") {}
2237 auto options = std::make_unique<SynthAddOptions>(
2241 for (
auto &entry : command.
entries()) {
2242 if (entry.ref().empty()) {
2243 result.
AppendError(
"empty typenames not allowed");
2247 options->m_target_types << std::string(entry.ref());
2271 "directly input Python code.\n",
2276 SyntheticChildrenSP entry;
2291 result.
AppendWarning(
"The provided class does not exist - please define it "
2292 "before attempting to use this synthetic provider");
2296 lldb::TypeCategoryImplSP category;
2302 for (
auto &arg_entry : command.
entries()) {
2303 if (arg_entry.ref().empty()) {
2304 result.
AppendError(
"empty typenames not allowed");
2323 "Add a new synthetic provider for a type.", nullptr),
2326 CommandArgumentData type_style_arg;
2331 type_arg.push_back(type_style_arg);
2337 SyntheticChildrenSP entry,
2339 std::string category_name,
2341 lldb::TypeCategoryImplSP category;
2362 error->SetErrorStringWithFormat(
"cannot add synthetic for type %s when "
2363 "filter is defined in same category!",
2371 if (!typeRX.IsValid()) {
2373 error->SetErrorString(
2374 "regex format error (maybe this is not really a regex?)");
2383 error->SetErrorStringWithFormat(
2384 "The provided recognizer function \"%s\" does not exist - "
2385 "please define it before attempting to use this summary.\n",
2391 category->AddTypeSynthetic(type_name.
GetStringRef(), match_type, entry);
2396#define LLDB_OPTIONS_type_filter_add
2397#include "CommandOptions.inc"
2415 switch (short_option) {
2419 error.SetErrorStringWithFormat(
"invalid value for cascade: %s",
2420 option_arg.str().c_str());
2439 llvm_unreachable(
"Unimplemented option");
2456 return llvm::ArrayRef(g_type_filter_add_options);
2482 lldb::TypeCategoryImplSP category;
2500 lldb::SyntheticChildrenSP entry;
2504 error->SetErrorStringWithFormat(
"cannot add filter for type %s when "
2505 "synthetic is defined in same "
2516 if (!typeRX.IsValid()) {
2518 error->SetErrorString(
2519 "regex format error (maybe this is not really a regex?)");
2523 category->AddTypeFilter(type_name.
GetStringRef(), match_type, entry);
2530 "Add a new filter for a type.", nullptr) {
2532 CommandArgumentData type_style_arg;
2537 type_arg.push_back(type_style_arg);
2543The following examples of 'type filter add' refer to this code snippet for context:
2558Adding a simple filter:
2560(lldb) type filter add --child a --child g Foo
2561(lldb) frame variable my_foo
2564 "Produces output where only a and g are displayed. Other children of my_foo \
2565(b, c, d, e, f, h and i) are available by asking for them explicitly:"
2568(lldb) frame variable my_foo.b my_foo.c my_foo.i
2571 "The formatting option --raw on frame variable bypasses the filter, showing \
2572all children of my_foo as if no filter was defined:"
2575(lldb) frame variable my_foo --raw)");
2607 entry->AddExpressionPath(*begin);
2611 lldb::TypeCategoryImplSP category;
2619 for (
auto &arg_entry : command.
entries()) {
2620 if (arg_entry.ref().empty()) {
2621 result.
AppendError(
"empty typenames not allowed");
2640#define LLDB_OPTIONS_type_lookup
2641#include "CommandOptions.inc"
2672 return llvm::ArrayRef(g_type_lookup_options);
2679 const int short_option = g_type_lookup_options[option_idx].short_option;
2681 switch (short_option) {
2691 llvm_unreachable(
"Unimplemented option");
2714 "Lookup types and declarations in the current target, "
2715 "following language-specific naming conventions.",
2716 "type lookup <type-specifier>",
2717 eCommandRequiresTarget) {
2733 stream.
Printf(
"%s\n", help);
2741 bool DoExecute(llvm::StringRef raw_command_line,
2743 if (raw_command_line.empty()) {
2745 "type lookup cannot be invoked without a type name as argument");
2753 const char *name_of_type = args.GetRawPart().c_str();
2762 bool any_found =
false;
2764 std::vector<Language *> languages;
2766 bool is_global_search =
false;
2769 if ((is_global_search =
2772 languages.push_back(lang);
2786 languages.begin(), languages.end(),
2788 if (!lang1 || !lang2)
2790 LanguageType lt1 = lang1->GetLanguageType();
2791 LanguageType lt2 = lang2->GetLanguageType();
2792 if (lt1 == guessed_language)
2794 if (lt2 == guessed_language)
2801 bool is_first_language =
true;
2803 for (
Language *language : languages) {
2807 if (
auto scavenger = language->GetTypeScavenger()) {
2809 if (scavenger->Find(best_scope, name_of_type, search_results) > 0) {
2810 for (
const auto &search_result : search_results) {
2811 if (search_result && search_result->IsValid()) {
2814 this->m_command_options.m_show_help);
2820 if (any_found && is_global_search)
2822 else if (is_first_language && is_global_search &&
2824 is_first_language =
false;
2826 "no type was found in the current language %s matching '%s'; "
2827 "performing a global search across all languages\n",
2842template <
typename FormatterType>
2845 typedef std::function<
typename FormatterType::SharedPointer(
ValueObject &)>
2848 const char *formatter_name,
2857 help.
Printf(
"This command evaluates the provided expression and shows "
2858 "which %s is applied to the resulting value (if any).",
2862 syntax.
Printf(
"type %s info <expr>", formatter_name);
2878 StackFrameSP frame_sp =
2880 ValueObjectSP result_valobj_sp;
2883 command, frame_sp.get(), result_valobj_sp, options);
2886 result_valobj_sp->GetQualifiedRepresentationIfAvailable(
2887 target_sp->GetPreferDynamicValue(),
2888 target_sp->GetEnableSyntheticValue());
2889 typename FormatterType::SharedPointer formatter_sp =
2892 std::string description(formatter_sp->GetDescription());
2895 << result_valobj_sp->GetDisplayTypeName().AsCString(
"<unknown>")
2896 <<
") " << command <<
" is: " << description <<
"\n";
2901 << result_valobj_sp->GetDisplayTypeName().AsCString(
"<unknown>")
2902 <<
") " << command <<
"\n";
2907 result.
AppendError(
"failed to evaluate expression");
2921 interpreter,
"type format",
2922 "Commands for customizing value display formats.",
2923 "type format [<sub-command-options>] ") {
2934 interpreter,
"format",
2943#if LLDB_ENABLE_PYTHON
2949 interpreter,
"type synthetic",
2950 "Commands for operating on synthetic type representations.",
2951 "type synthetic [<sub-command-options>] ") {
2955 "clear", CommandObjectSP(
new CommandObjectTypeSynthClear(interpreter)));
2956 LoadSubCommand(
"delete", CommandObjectSP(
new CommandObjectTypeSynthDelete(
2959 "list", CommandObjectSP(
new CommandObjectTypeSynthList(interpreter)));
2963 interpreter,
"synthetic",
2969 ~CommandObjectTypeSynth()
override =
default;
2978 "Commands for operating on type filters.",
2979 "type filter [<sub-command-options>] ") {
2997 "Commands for operating on type categories.",
2998 "type category [<sub-command-options>] ") {
3022 interpreter,
"type summary",
3023 "Commands for editing variable summary display options.",
3024 "type summary [<sub-command-options>] ") {
3035 interpreter,
"summary",
3048 "Commands for operating on the type system.",
3049 "type [<sub-command-options>]") {
3058#if LLDB_ENABLE_PYTHON
3060 CommandObjectSP(
new CommandObjectTypeSynth(interpreter)));
static const char * g_synth_addreader_instructions
static bool WarnOnPotentialUnquotedUnsignedType(Args &command, CommandReturnObject &result)
const char * FormatCategoryToString(FormatCategoryItem item, bool long_name)
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 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()
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 & SetSkipPointers(bool value=true)
std::shared_ptr< SyntheticChildren > SharedPointer
lldb::StackFrameSP GetSelectedFrame(SelectMostRelevant select_most_relevant)
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()
@ 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
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)