15#include "lldb/Host/Config.h"
38#include "llvm/ADT/STLExtras.h"
89 for (
auto entry : llvm::enumerate(command.
entries().drop_back())) {
90 if (entry.value().ref() !=
"unsigned")
92 auto next = command.
entries()[entry.index() + 1].ref();
93 if (next ==
"int" || next ==
"short" || next ==
"char" || next ==
"long") {
95 "unsigned %s being treated as two types. if you meant the combined "
97 "name use quotes, as in \"unsigned %s\"\n",
98 next.str().c_str(), next.str().c_str());
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);
169 static const char *g_summary_addreader_instructions =
170 "Enter your Python command(s). Type 'DONE' to end.\n"
171 "def function (valobj,internal_dict):\n"
172 " \"\"\"valobj: an SBValue which you want to provide a summary "
174 " internal_dict: an LLDB support object not to be used\"\"\"\n";
179 locked_stream.
PutCString(g_summary_addreader_instructions);
185 std::string &data)
override {
188#if LLDB_ENABLE_PYTHON
203 std::string funct_name_str;
206 if (funct_name_str.empty()) {
209 "unable to obtain a valid function name from "
210 "the script interpreter.\n");
216 script_format = std::make_shared<ScriptSummaryFormat>(
217 options->m_flags, funct_name_str.c_str(),
218 lines.
CopyList(
" ").c_str(), options->m_ptr_match_depth);
222 for (
const std::string &type_name : options->m_target_types) {
224 options->m_match_type, options->m_category,
228 locked_stream.
Printf(
"error: %s",
error.AsCString());
232 if (options->m_name) {
234 options->m_name, script_format, &
error);
237 options->m_name, script_format, &
error);
240 locked_stream.
Printf(
"error: %s",
error.AsCString());
244 locked_stream.
Printf(
"error: %s",
error.AsCString());
247 if (
error.AsCString()) {
249 locked_stream.
Printf(
"error: %s",
error.AsCString());
255 locked_stream.
Printf(
"error: unable to generate a function.\n");
259 locked_stream.
Printf(
"error: no script interpreter.\n");
263 locked_stream.
Printf(
"error: internal synchronization information "
264 "missing or invalid.\n");
269 "error: empty function, didn't add python command.\n");
274 "error: script interpreter missing, didn't add python command.\n");
292 "Enter your Python command(s). Type 'DONE' to end.\n"
293 "You must define a Python class with these methods:\n"
294 " def __init__(self, valobj: lldb.SBValue, internal_dict):\n"
295 " def num_children(self) -> int:\n"
296 " def get_child_at_index(self, index: int) -> lldb.SBValue | None:\n"
297 " def get_child_index(self, name: str) -> int:\n"
298 " def update(self) -> bool:\n"
300 "class synthProvider:\n";
302#define LLDB_OPTIONS_type_synth_add
303#include "CommandOptions.inc"
320 switch (short_option) {
325 "invalid value for cascade: %s", option_arg.str().c_str());
331 "invalid value for wants-dereference: %s",
332 option_arg.str().c_str());
353 "can't use --regex and --recognizer-function at the same time");
360 "can't use --regex and --recognizer-function at the same time");
365 llvm_unreachable(
"Unimplemented option");
384 return llvm::ArrayRef(g_type_synth_add_options);
418 result.
AppendError(
"must either provide a children list, a Python class "
419 "name, or use -P and type a Python class "
434 std::string &data)
override {
437#if LLDB_ENABLE_PYTHON
452 std::string class_name_str;
454 if (class_name_str.empty()) {
458 "error: unable to obtain a proper name for the class.\n");
464 synth_provider = std::make_shared<ScriptedSyntheticChildren>(
466 .SetCascades(options->m_cascade)
470 class_name_str.c_str());
474 ConstString(options->m_category.c_str()), category);
478 for (
const std::string &type_name : options->m_target_types) {
479 if (!type_name.empty()) {
481 options->m_match_type, options->m_category,
484 locked_stream.
Printf(
"error: %s\n",
error.AsCString());
489 locked_stream.
Printf(
"error: invalid type name.\n");
496 locked_stream.
Printf(
"error: unable to generate a class.\n");
500 locked_stream.
Printf(
"error: no script interpreter.\n");
505 "error: internal synchronization data missing.\n");
510 "error: empty function, didn't add python command.\n");
515 "error: script interpreter missing, didn't add python command.\n");
534#define LLDB_OPTIONS_type_format_add
535#include "CommandOptions.inc"
546 return llvm::ArrayRef(g_type_format_add_options);
561 const int short_option =
562 g_type_format_add_options[option_idx].short_option;
565 switch (short_option) {
570 "invalid value for cascade: %s", option_value.str().c_str());
588 llvm_unreachable(
"Unimplemented option");
613 "Add a new formatting style for a type.", nullptr),
619The following examples of 'type format add' refer to this code snippet for context:
622 typedef float Afloat;
624 typedef Afloat Bfloat;
632Adding default formatting:
634(lldb) type format add -f hex AInt
635(lldb) frame variable iy
638 " Produces hexadecimal display of iy, because no formatter is available for Bint and \
639the one for Aint is used instead."
642To prevent this use the cascade option '-C no' to prevent evaluation of typedef chains:
645(lldb) type format add -f hex -C no AInt
647Similar reasoning applies to this:
649(lldb) type format add -f hex -C no float -p
652 " All float values and float references are now formatted as hexadecimal, but not \
653pointers to floats. Nor will it change the default display for Afloat and Bfloat objects.");
686 entry = std::make_shared<TypeFormatImpl_Format>(
687 format, TypeFormatImpl::Flags()
692 entry = std::make_shared<TypeFormatImpl_EnumType>(
694 TypeFormatImpl::Flags()
709 for (
auto &arg_entry : command.
entries()) {
710 if (arg_entry.ref().empty()) {
719 if (!typeRX.IsValid()) {
721 "regex format error (maybe this is not really a regex?)");
725 category_sp->AddTypeFormat(arg_entry.ref(), match_type, entry);
732#define LLDB_OPTIONS_type_formatter_delete
733#include "CommandOptions.inc"
748 switch (short_option) {
759 llvm_unreachable(
"Unimplemented option");
772 return llvm::ArrayRef(g_type_formatter_delete_options);
788 "Delete an existing %s for a type.";
791 "Delete an existing %s for a type. Unless you specify a "
792 "specific category or all categories, only the "
793 "'default' category is searched. The names must be exactly as "
794 "shown in the 'type %s list' output";
814 s.
Printf(
"type %s delete", short_kind);
862 bool delete_category =
false;
863 bool extra_deletion =
false;
881 if (delete_category || extra_deletion) {
889#define LLDB_OPTIONS_type_formatter_clear
890#include "CommandOptions.inc"
905 switch (short_option) {
910 llvm_unreachable(
"Unimplemented option");
921 return llvm::ArrayRef(g_type_formatter_clear_options);
936 const char *name,
const char *help)
991 "Delete all existing format styles.") {}
994#define LLDB_OPTIONS_type_formatter_list
995#include "CommandOptions.inc"
997template <
typename FormatterType>
1014 switch (short_option) {
1021 if (
error.Success())
1025 llvm_unreachable(
"Unimplemented option");
1037 return llvm::ArrayRef(g_type_formatter_list_options);
1052 const char *name,
const char *help)
1070 return regex ==
nullptr || s == regex->
GetText() || regex->
Execute(s);
1076 std::unique_ptr<RegularExpression> category_regex;
1077 std::unique_ptr<RegularExpression> formatter_regex;
1079 if (
m_options.m_category_regex.OptionWasSet()) {
1080 category_regex = std::make_unique<RegularExpression>(
1081 m_options.m_category_regex.GetCurrentValueAsRef());
1082 if (!category_regex->IsValid()) {
1084 "syntax error in category regular expression '%s'",
1085 m_options.m_category_regex.GetCurrentValueAsRef().str().c_str());
1092 formatter_regex = std::make_unique<RegularExpression>(arg);
1093 if (!formatter_regex->IsValid()) {
1100 bool any_printed =
false;
1102 auto category_closure =
1103 [&result, &formatter_regex,
1106 "-----------------------\nCategory: %s%s\n-----------------------\n",
1107 category->GetName(), category->IsEnabled() ?
"" :
" (disabled)");
1110 [&result, &formatter_regex,
1114 formatter_regex.get())) {
1117 "%s: %s\n", type_matcher.GetMatchString().GetCString(),
1118 format_sp->GetDescription().c_str());
1122 category->ForEach(print_formatter);
1125 if (
m_options.m_category_language.OptionWasSet()) {
1128 m_options.m_category_language.GetCurrentValue(), category_sp);
1130 category_closure(category_sp);
1133 [&category_regex, &category_closure](
1136 category_closure(category);
1160 "Show a list of current formats.") {}
1164 uint32_t option_idx, llvm::StringRef option_arg,
1170 switch (short_option) {
1175 option_arg.str().c_str());
1178 m_flags.SetDontShowChildren(
false);
1181 m_flags.SetHideEmptyAggregates(
true);
1184 m_flags.SetDontShowValue(
true);
1187 m_flags.SetShowMembersOneLiner(
true);
1193 m_flags.SetSkipPointers(
true);
1198 "invalid integer value for option '%c': %s", short_option,
1203 m_flags.SetSkipReferences(
true);
1208 "can't use --regex and --recognizer-function at the same time");
1215 "can't use --regex and --recognizer-function at the same time");
1220 m_name.SetString(option_arg);
1237 m_flags.SetHideItemNames(
true);
1240 llvm_unreachable(
"Unimplemented option");
1248 m_flags.Clear().SetCascades().SetDontShowChildren().SetDontShowValue(
false);
1249 m_flags.SetShowMembersOneLiner(
false)
1250 .SetSkipPointers(
false)
1251 .SetSkipReferences(
false)
1252 .SetHideItemNames(
false);
1263#if LLDB_ENABLE_PYTHON
1281 if (!funct_name || !funct_name[0]) {
1287 (
" " +
m_options.m_python_function +
"(valobj,internal_dict)");
1289 script_format = std::make_shared<ScriptSummaryFormat>(
1290 m_options.m_flags, funct_name, code.c_str(),
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");
1309 StringList funct_sl;
1310 funct_sl <<
m_options.m_python_script.c_str();
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");
1322 std::string code =
" " +
m_options.m_python_script;
1324 script_format = std::make_shared<ScriptSummaryFormat>(
1325 m_options.m_flags, funct_name_str.c_str(), code.c_str(),
1329 auto options = std::make_unique<ScriptAddOptions>(
1333 for (
auto &entry : command.
entries()) {
1334 if (entry.ref().empty()) {
1335 result.
AppendError(
"empty typenames not allowed");
1339 options->m_target_types << std::string(entry.ref());
1357 for (
auto &entry : command.
entries()) {
1370 result.
AppendError(
"added to types, but not given a name");
1390 if (!
m_options.m_flags.GetShowMembersOneLiner() &&
1392 result.
AppendError(
"empty summary strings not allowed");
1396 const char *format_cstr = (
m_options.m_flags.GetShowMembersOneLiner()
1401 if (strcmp(format_cstr,
"${var%S}") == 0) {
1402 result.
AppendError(
"recursive summary not allowed");
1408 if (!string_format) {
1412 if (string_format->m_error.Fail()) {
1414 string_format->m_error.AsCString(
"<unknown>"));
1421 for (
auto &arg_entry : command.
entries()) {
1422 if (arg_entry.ref().empty()) {
1423 result.
AppendError(
"empty typenames not allowed");
1441 result.
AppendError(
"added to types, but not given a name");
1453 "Add a new summary style for a type.", nullptr),
1459The following examples of 'type summary add' refer to this code snippet for context:
1465 JustADemo(int p = 1, float v = 0.1) : ptr(new int(p)), value(v) {}
1467 JustADemo demo_instance(42, 3.14);
1469 typedef JustADemo NewDemo;
1470 NewDemo new_demo_instance(42, 3.14);
1472(lldb) type summary add --summary-string "the answer is ${*var.ptr}" JustADemo
1474 Subsequently displaying demo_instance with 'frame variable' or 'expression' will display "the answer is 42"
1476(lldb) type summary add --summary-string "the answer is ${*var.ptr}, and the question is ${var.value}" JustADemo
1478 Subsequently displaying demo_instance with 'frame variable' or 'expression' will display "the answer is 42 and the question is 3.14"
1481 "Alternatively, you could define formatting for all pointers to integers and \
1482rely on that when formatting JustADemo to obtain the same result:"
1485(lldb) type summary add --summary-string "${var%V} -> ${*var}" "int *"
1486(lldb) type summary add --summary-string "the answer is ${var.ptr}, and the question is ${var.value}" JustADemo
1489 "Type summaries are automatically applied to derived typedefs, so the examples \
1490above apply to both JustADemo and NewDemo. The cascade option can be used to \
1491suppress this behavior:"
1494(lldb) type summary add --summary-string "${var.ptr}, ${var.value},{${var.byte}}" JustADemo -C no
1496 The summary will now be used for values of JustADemo but not NewDemo.
1499 "By default summaries are shown for pointers and references to values of the \
1500specified type. To suppress formatting for pointers use the -p option, or apply \
1501the corresponding -r option to suppress formatting for references:"
1504(lldb) type summary add -p -r --summary-string "${var.ptr}, ${var.value},{${var.byte}}" JustADemo
1507 "One-line summaries including all fields in a type can be inferred without supplying an \
1508explicit summary string by passing the -c option:"
1511(lldb) type summary add -c JustADemo
1512(lldb) frame variable demo_instance
1513(ptr=<address>, value=3.14)
1516 "Type summaries normally suppress the nested display of individual fields. To \
1517supply a summary to supplement the default structure add the -e option:"
1520(lldb) type summary add -e --summary-string "*ptr = ${*var.ptr}" JustADemo
1523 "Now when displaying JustADemo values the int* is displayed, followed by the \
1524standard LLDB sequence of children, one per line:"
1533 "You can also add summaries written in Python. These scripts use lldb public API to \
1534gather information from your variables and produce a meaningful summary. To start a \
1535multi-line script use the -P option. The function declaration will be displayed along with \
1536a comment describing the two arguments. End your script with the word 'DONE' on a line by \
1540(lldb) type summary add JustADemo -P
1541def function (valobj,internal_dict):
"""valobj: an SBValue which you want to provide a summary for
1542internal_dict: an LLDB support object not to be used"""
1543 value = valobj.GetChildMemberWithName('value');
1544 return 'My value is ' + value.GetValue();
1547Alternatively, the -o option can be used when providing a simple one-line Python script:
1549(lldb) type summary add JustADemo -o "value = valobj.GetChildMemberWithName('value'); return 'My value is ' + value.GetValue();")");
1557#if LLDB_ENABLE_PYTHON
1571 if (type_name_ref.ends_with(
"[]")) {
1572 std::string type_name_str(type_name.
GetCString());
1573 type_name_str.resize(type_name_str.length() - 2);
1574 if (type_name_str.back() !=
' ')
1575 type_name_str.append(
" ?\\[[0-9]+\\]");
1577 type_name_str.append(
"\\[[0-9]+\\]");
1595 std::string category_name,
1609 if (!typeRX.IsValid()) {
1612 "regex format error (maybe this is not really a regex?)");
1618 const char *function_name = type_name.
AsCString();
1621 *
error = Status::FromErrorStringWithFormat(
1622 "The provided recognizer function \"%s\" does not exist - "
1623 "please define it before attempting to use this summary.\n",
1628 category->AddTypeSummary(type_name.
GetStringRef(), match_type, entry);
1654 "type summary clear",
1655 "Delete all existing summaries.") {}
1670 "Show a list of current summaries.") {}
1681 summary_sp->GetDescription().c_str());
1691#define LLDB_OPTIONS_type_category_define
1692#include "CommandOptions.inc"
1704 ExecutionContext *execution_context)
override {
1708 switch (short_option) {
1716 llvm_unreachable(
"Unimplemented option");
1728 return llvm::ArrayRef(g_type_category_define_options);
1744 "Define a new category as a source of formatters.",
1761 for (
auto &entry : command.
entries()) {
1766 category_sp->AddLanguage(
m_options.m_cate_language.GetCurrentValue());
1767 if (
m_options.m_define_enabled.GetCurrentValue())
1778#define LLDB_OPTIONS_type_category_enable
1779#include "CommandOptions.inc"
1789 ExecutionContext *execution_context)
override {
1793 switch (short_option) {
1795 if (!option_arg.empty()) {
1798 error = Status::FromErrorStringWithFormat(
1799 "unrecognized language '%s'", option_arg.str().c_str());
1803 llvm_unreachable(
"Unimplemented option");
1814 return llvm::ArrayRef(g_type_category_enable_options);
1829 "Enable a category as a source of formatters.",
1837 void DoExecute(Args &command, CommandReturnObject &result)
override {
1848 }
else if (argc > 0) {
1849 for (
int i = argc - 1; i >= 0; i--) {
1851 ConstString typeCS(typeA);
1854 result.
AppendError(
"empty category name not allowed");
1860 if (cate->GetCount() == 0) {
1880 "Delete a category and all associated formatters.",
1897 bool success =
true;
1900 for (
int i = argc - 1; i >= 0; i--) {
1905 result.
AppendError(
"empty category name not allowed");
1920#define LLDB_OPTIONS_type_category_disable
1921#include "CommandOptions.inc"
1931 ExecutionContext *execution_context)
override {
1935 switch (short_option) {
1937 if (!option_arg.empty()) {
1940 error = Status::FromErrorStringWithFormat(
1941 "unrecognized language '%s'", option_arg.str().c_str());
1945 llvm_unreachable(
"Unimplemented option");
1956 return llvm::ArrayRef(g_type_category_disable_options);
1971 "Disable a category as a source of formatters.",
1990 }
else if (argc > 0) {
1992 for (
int i = argc - 1; i >= 0; i--) {
1994 ConstString typeCS(typeA);
1997 result.
AppendError(
"empty category name not allowed");
2017 "Provide a list of all existing categories.",
2038 std::unique_ptr<RegularExpression> regex;
2042 regex = std::make_unique<RegularExpression>(arg);
2043 if (!regex->IsValid()) {
2045 "syntax error in category regular expression '%s'", arg);
2048 }
else if (argc != 0) {
2058 if (regex->GetText() == category_sp->GetName()) {
2060 }
else if (regex->Execute(category_sp->GetName())) {
2069 "Category: %s\n", category_sp->GetDescription().c_str());
2085 "Show a list of current filters.") {}
2095 interpreter,
"type synthetic list",
2096 "Show a list of current synthetic providers.") {}
2127 "type filter clear",
2128 "Delete all existing filter.") {}
2138 "Delete all existing synthetic providers.") {}
2143 auto options = std::make_unique<SynthAddOptions>(
2148 for (
auto &entry : command.
entries()) {
2149 if (entry.ref().empty()) {
2150 result.
AppendError(
"empty typenames not allowed");
2154 options->m_target_types << std::string(entry.ref());
2178 "directly input Python code.\n",
2185 ScriptedSyntheticChildren *impl =
new ScriptedSyntheticChildren(
2186 SyntheticChildren::Flags()
2188 .SetFrontEndWantsDereference(
m_options.m_wants_deref)
2189 .SetSkipPointers(
m_options.m_skip_pointers)
2190 .SetSkipReferences(
m_options.m_skip_references),
2200 "The provided class '{0}' does not exist - please define it "
2201 "before attempting to use this synthetic provider",
2202 llvm::StringRef(python_class_name));
2208 ConstString(
m_options.m_category.c_str()), category);
2212 for (
auto &arg_entry : command.
entries()) {
2213 if (arg_entry.ref().empty()) {
2214 result.
AppendError(
"empty typenames not allowed");
2218 ConstString typeCS(arg_entry.ref());
2233 "Add a new synthetic provider for a type.", nullptr),
2241 std::string category_name,
2265 "cannot add synthetic for type %s when "
2266 "filter is defined in same category!",
2274 if (!typeRX.IsValid()) {
2276 *
error = Status::FromErrorString(
2277 "regex format error (maybe this is not really a regex?)");
2283 const char *function_name = type_name.
AsCString();
2287 "The provided recognizer function \"%s\" does not exist - "
2288 "please define it before attempting to use this summary.\n",
2294 category->AddTypeSynthetic(type_name.
GetStringRef(), match_type, entry);
2298#define LLDB_OPTIONS_type_filter_add
2299#include "CommandOptions.inc"
2317 switch (short_option) {
2322 "invalid value for cascade: %s", option_arg.str().c_str());
2341 llvm_unreachable(
"Unimplemented option");
2358 return llvm::ArrayRef(g_type_filter_add_options);
2407 "cannot add filter for type %s when "
2408 "synthetic is defined in same "
2419 if (!typeRX.IsValid()) {
2421 *
error = Status::FromErrorString(
2422 "regex format error (maybe this is not really a regex?)");
2426 category->AddTypeFilter(type_name.
GetStringRef(), match_type, entry);
2433 "Add a new filter for a type.", nullptr) {
2438The following examples of 'type filter add' refer to this code snippet for context:
2453Adding a simple filter:
2455(lldb) type filter add --child a --child g Foo
2456(lldb) frame variable my_foo
2459 "Produces output where only a and g are displayed. Other children of my_foo \
2460(b, c, d, e, f, h and i) are available by asking for them explicitly:"
2463(lldb) frame variable my_foo.b my_foo.c my_foo.i
2466 "The formatting option --raw on frame variable bypasses the filter, showing \
2467all children of my_foo as if no filter was defined:"
2470(lldb) frame variable my_foo --raw)");
2492 SyntheticChildren::Flags()
2502 entry->AddExpressionPath(*begin);
2514 for (
auto &arg_entry : command.
entries()) {
2515 if (arg_entry.ref().empty()) {
2516 result.
AppendError(
"empty typenames not allowed");
2534#define LLDB_OPTIONS_type_lookup
2535#include "CommandOptions.inc"
2566 return llvm::ArrayRef(g_type_lookup_options);
2573 const int short_option = g_type_lookup_options[option_idx].short_option;
2575 switch (short_option) {
2585 llvm_unreachable(
"Unimplemented option");
2608 "Lookup types and declarations in the current target, "
2609 "following language-specific naming conventions.",
2610 "type lookup <type-specifier>",
2611 eCommandRequiresTarget) {
2624 StreamString stream;
2627 stream.
Printf(
"%s\n", help);
2628 return IterationAction::Continue;
2635 void DoExecute(llvm::StringRef raw_command_line,
2636 CommandReturnObject &result)
override {
2637 if (raw_command_line.empty()) {
2639 "type lookup cannot be invoked without a type name as argument");
2646 OptionsWithRaw args(raw_command_line);
2647 const char *name_of_type = args.GetRawPart().c_str();
2654 ExecutionContextScope *best_scope = exe_ctx.GetBestExecutionContextScope();
2656 bool any_found =
false;
2658 std::vector<Language *> languages;
2660 bool is_global_search =
false;
2663 if ((is_global_search =
2666 languages.push_back(lang);
2667 return IterationAction::Continue;
2680 languages.begin(), languages.end(),
2682 if (!lang1 || !lang2)
2684 LanguageType lt1 = lang1->GetLanguageType();
2685 LanguageType lt2 = lang2->GetLanguageType();
2688 if (lt1 == guessed_language)
2690 if (lt2 == guessed_language)
2697 bool is_first_language =
true;
2703 if (
auto scavenger = language->GetTypeScavenger()) {
2705 if (scavenger->Find(best_scope, name_of_type, search_results) > 0) {
2706 for (
const auto &search_result : search_results) {
2707 if (search_result && search_result->IsValid()) {
2710 this->m_command_options.m_show_help);
2716 if (any_found && is_global_search)
2718 else if (is_first_language && is_global_search &&
2720 is_first_language =
false;
2722 "no type was found in the current language %s matching '%s'; "
2723 "performing a global search across all languages\n",
2737template <
typename FormatterType>
2740 typedef std::function<
typename FormatterType::SharedPointer(ValueObject &)>
2743 const char *formatter_name,
2749 name.
Printf(
"type %s info", formatter_name);
2752 help.
Printf(
"This command evaluates the provided expression and shows "
2753 "which %s is applied to the resulting value (if any).",
2757 syntax.
Printf(
"type %s info <expr>", formatter_name);
2778 command, frame_sp.get(), result_valobj_sp, options);
2781 result_valobj_sp->GetQualifiedRepresentationIfAvailable(
2782 target_sp->GetPreferDynamicValue(),
2783 target_sp->GetEnableSyntheticValue());
2784 typename FormatterType::SharedPointer formatter_sp =
2787 std::string description(formatter_sp->GetDescription());
2790 << result_valobj_sp->GetDisplayTypeName().AsCString(
"<unknown>")
2791 <<
") " << command <<
" is: " << description <<
"\n";
2796 << result_valobj_sp->GetDisplayTypeName().AsCString(
"<unknown>")
2797 <<
") " << command <<
"\n";
2801 result.
AppendError(
"failed to evaluate expression");
2814 interpreter,
"type format",
2815 "Commands for customizing value display formats.",
2816 "type format [<sub-command-options>] ") {
2827 interpreter,
"format",
2840 interpreter,
"type synthetic",
2841 "Commands for operating on synthetic type representations.",
2842 "type synthetic [<sub-command-options>] ") {
2854 interpreter,
"synthetic",
2867 "Commands for operating on type filters.",
2868 "type filter [<sub-command-options>] ") {
2886 "Commands for operating on type categories.",
2887 "type category [<sub-command-options>] ") {
2911 interpreter,
"type summary",
2912 "Commands for editing variable summary display options.",
2913 "type summary [<sub-command-options>] ") {
2915 "add",
CommandObjectSP(
new CommandObjectTypeSummaryAdd(interpreter)));
2921 "list",
CommandObjectSP(
new CommandObjectTypeSummaryList(interpreter)));
2923 "info",
CommandObjectSP(
new CommandObjectFormatterInfo<TypeSummaryImpl>(
2924 interpreter,
"summary",
2937 "Commands for operating on the type system.",
2938 "type [<sub-command-options>]") {
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
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
Options * GetOptions() override
CommandObjectTypeFilterAdd(CommandInterpreter &interpreter)
bool AddFilter(ConstString type_name, TypeFilterImplSP entry, FilterFormatType type, std::string category_name, Status *error)
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
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
uint32_t m_ptr_match_depth
~CommandObjectTypeSummaryAdd() override=default
Options * GetOptions() override
bool Execute_ScriptSummary(Args &command, CommandReturnObject &result)
void DoExecute(Args &command, CommandReturnObject &result) override
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(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
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 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
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() const
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)
virtual void SetHelp(llvm::StringRef str)
void void AppendError(llvm::StringRef in_string)
void AppendWarningWithFormat(const char *format,...) __attribute__((format(printf
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)
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.
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/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.
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)
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
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
std::shared_ptr< lldb_private::Target > TargetSP
static bool ToBoolean(llvm::StringRef s, bool fail_value, bool *success_ptr)
lldb::LanguageType AsLanguageType() const