15#include "lldb/Host/Config.h"
38#include "llvm/ADT/STLExtras.h"
89 for (
auto entry : llvm::enumerate(command.
entries().drop_back())) {
90 if (entry.value().ref() !=
"unsigned")
92 auto next = command.
entries()[entry.index() + 1].ref();
93 if (next ==
"int" || next ==
"short" || next ==
"char" || next ==
"long") {
95 "unsigned {0} being treated as two types. if you meant the combined "
96 "type name use quotes, as in \"unsigned {0}\"",
112 return "synthetic child provider";
117 llvm_unreachable(
"Fully covered switch above!");
120#define LLDB_OPTIONS_type_summary_add
121#include "CommandOptions.inc"
138 return llvm::ArrayRef(g_type_summary_add_options);
168 static const char *g_summary_addreader_instructions =
169 "Enter your Python command(s). Type 'DONE' to end.\n"
170 "def function (valobj,internal_dict):\n"
171 " \"\"\"valobj: an SBValue which you want to provide a summary "
173 " internal_dict: an LLDB support object not to be used\"\"\"\n";
178 locked_stream.
PutCString(g_summary_addreader_instructions);
184 std::string &data)
override {
187#if LLDB_ENABLE_PYTHON
202 std::string funct_name_str;
205 if (funct_name_str.empty()) {
208 "unable to obtain a valid function name from "
209 "the script interpreter.\n");
215 script_format = std::make_shared<ScriptSummaryFormat>(
216 options->m_flags, funct_name_str.c_str(),
217 lines.
CopyList(
" ").c_str(), options->m_ptr_match_depth);
221 for (
const std::string &type_name : options->m_target_types) {
223 options->m_match_type, options->m_category,
227 locked_stream.
Printf(
"error: %s",
error.AsCString());
231 if (options->m_name) {
233 options->m_name, script_format, &
error);
236 options->m_name, script_format, &
error);
239 locked_stream.
Printf(
"error: %s",
error.AsCString());
243 locked_stream.
Printf(
"error: %s",
error.AsCString());
246 if (
error.AsCString()) {
248 locked_stream.
Printf(
"error: %s",
error.AsCString());
254 locked_stream.
Printf(
"error: unable to generate a function.\n");
258 locked_stream.
Printf(
"error: no script interpreter.\n");
262 locked_stream.
Printf(
"error: internal synchronization information "
263 "missing or invalid.\n");
268 "error: empty function, didn't add python command.\n");
273 "error: script interpreter missing, didn't add python command.\n");
291 "Enter your Python command(s). Type 'DONE' to end.\n"
292 "You must define a Python class with these methods:\n"
293 " def __init__(self, valobj: lldb.SBValue, internal_dict):\n"
294 " def num_children(self) -> int:\n"
295 " def get_child_at_index(self, index: int) -> lldb.SBValue | None:\n"
296 " def get_child_index(self, name: str) -> int:\n"
297 " def update(self) -> bool:\n"
299 "class synthProvider:\n";
301#define LLDB_OPTIONS_type_synth_add
302#include "CommandOptions.inc"
319 switch (short_option) {
324 "invalid value for cascade: %s", option_arg.str().c_str());
330 "invalid value for wants-dereference: %s",
331 option_arg.str().c_str());
352 "can't use --regex and --recognizer-function at the same time");
359 "can't use --regex and --recognizer-function at the same time");
364 llvm_unreachable(
"Unimplemented option");
383 return llvm::ArrayRef(g_type_synth_add_options);
417 result.
AppendError(
"must either provide a children list, a Python class "
418 "name, or use -P and type a Python class "
433 std::string &data)
override {
436#if LLDB_ENABLE_PYTHON
451 std::string class_name_str;
453 if (class_name_str.empty()) {
457 "error: unable to obtain a proper name for the class.\n");
463 synth_provider = std::make_shared<ScriptedSyntheticChildren>(
465 .SetCascades(options->m_cascade)
469 class_name_str.c_str());
473 ConstString(options->m_category.c_str()), category);
477 for (
const std::string &type_name : options->m_target_types) {
478 if (!type_name.empty()) {
480 options->m_match_type, options->m_category,
483 locked_stream.
Printf(
"error: %s\n",
error.AsCString());
488 locked_stream.
Printf(
"error: invalid type name.\n");
495 locked_stream.
Printf(
"error: unable to generate a class.\n");
499 locked_stream.
Printf(
"error: no script interpreter.\n");
504 "error: internal synchronization data missing.\n");
509 "error: empty function, didn't add python command.\n");
514 "error: script interpreter missing, didn't add python command.\n");
533#define LLDB_OPTIONS_type_format_add
534#include "CommandOptions.inc"
545 return llvm::ArrayRef(g_type_format_add_options);
560 const int short_option =
561 g_type_format_add_options[option_idx].short_option;
564 switch (short_option) {
569 "invalid value for cascade: %s", option_value.str().c_str());
587 llvm_unreachable(
"Unimplemented option");
612 "Add a new formatting style for a type.", nullptr),
618The following examples of 'type format add' refer to this code snippet for context:
621 typedef float Afloat;
623 typedef Afloat Bfloat;
631Adding default formatting:
633(lldb) type format add -f hex AInt
634(lldb) frame variable iy
637 " Produces hexadecimal display of iy, because no formatter is available for Bint and \
638the one for Aint is used instead."
641To prevent this use the cascade option '-C no' to prevent evaluation of typedef chains:
644(lldb) type format add -f hex -C no AInt
646Similar reasoning applies to this:
648(lldb) type format add -f hex -C no float -p
651 " All float values and float references are now formatted as hexadecimal, but not \
652pointers to floats. Nor will it change the default display for Afloat and Bfloat objects.");
685 entry = std::make_shared<TypeFormatImpl_Format>(
686 format, TypeFormatImpl::Flags()
691 entry = std::make_shared<TypeFormatImpl_EnumType>(
693 TypeFormatImpl::Flags()
708 for (
auto &arg_entry : command.
entries()) {
709 if (arg_entry.ref().empty()) {
718 if (!typeRX.IsValid()) {
720 "regex format error (maybe this is not really a regex?)");
724 category_sp->AddTypeFormat(arg_entry.ref(), match_type, entry);
731#define LLDB_OPTIONS_type_formatter_delete
732#include "CommandOptions.inc"
747 switch (short_option) {
758 llvm_unreachable(
"Unimplemented option");
771 return llvm::ArrayRef(g_type_formatter_delete_options);
787 "Delete an existing %s for a type.";
790 "Delete an existing %s for a type. Unless you specify a "
791 "specific category or all categories, only the "
792 "'default' category is searched. The names must be exactly as "
793 "shown in the 'type %s list' output";
813 s.
Printf(
"type %s delete", short_kind);
861 bool delete_category =
false;
862 bool extra_deletion =
false;
880 if (delete_category || extra_deletion) {
888#define LLDB_OPTIONS_type_formatter_clear
889#include "CommandOptions.inc"
904 switch (short_option) {
909 llvm_unreachable(
"Unimplemented option");
920 return llvm::ArrayRef(g_type_formatter_clear_options);
935 const char *name,
const char *help)
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)
1069 return regex ==
nullptr || s == regex->
GetText() || regex->
Execute(s);
1075 std::unique_ptr<RegularExpression> category_regex;
1076 std::unique_ptr<RegularExpression> formatter_regex;
1078 if (
m_options.m_category_regex.OptionWasSet()) {
1079 category_regex = std::make_unique<RegularExpression>(
1080 m_options.m_category_regex.GetCurrentValueAsRef());
1081 if (!category_regex->IsValid()) {
1083 "syntax error in category regular expression '%s'",
1084 m_options.m_category_regex.GetCurrentValueAsRef().str().c_str());
1091 formatter_regex = std::make_unique<RegularExpression>(arg);
1092 if (!formatter_regex->IsValid()) {
1099 bool any_printed =
false;
1101 auto category_closure =
1102 [&result, &formatter_regex,
1105 "-----------------------\nCategory: %s%s\n-----------------------\n",
1106 category->GetName(), category->IsEnabled() ?
"" :
" (disabled)");
1109 [&result, &formatter_regex,
1113 formatter_regex.get())) {
1116 "%s: %s\n", type_matcher.GetMatchString().GetCString(),
1117 format_sp->GetDescription().c_str());
1121 category->ForEach(print_formatter);
1124 if (
m_options.m_category_language.OptionWasSet()) {
1127 m_options.m_category_language.GetCurrentValue(), category_sp);
1129 category_closure(category_sp);
1132 [&category_regex, &category_closure](
1135 category_closure(category);
1159 "Show a list of current formats.") {}
1163 uint32_t option_idx, llvm::StringRef option_arg,
1169 switch (short_option) {
1174 option_arg.str().c_str());
1177 m_flags.SetDontShowChildren(
false);
1180 m_flags.SetHideEmptyAggregates(
true);
1183 m_flags.SetDontShowValue(
true);
1186 m_flags.SetShowMembersOneLiner(
true);
1192 m_flags.SetSkipPointers(
true);
1197 "invalid integer value for option '%c': %s", short_option,
1202 m_flags.SetSkipReferences(
true);
1207 "can't use --regex and --recognizer-function at the same time");
1214 "can't use --regex and --recognizer-function at the same time");
1219 m_name.SetString(option_arg);
1236 m_flags.SetHideItemNames(
true);
1239 llvm_unreachable(
"Unimplemented option");
1247 m_flags.Clear().SetCascades().SetDontShowChildren().SetDontShowValue(
false);
1248 m_flags.SetShowMembersOneLiner(
false)
1249 .SetSkipPointers(
false)
1250 .SetSkipReferences(
false)
1251 .SetHideItemNames(
false);
1262#if LLDB_ENABLE_PYTHON
1280 if (!funct_name || !funct_name[0]) {
1286 (
" " +
m_options.m_python_function +
"(valobj,internal_dict)");
1288 script_format = std::make_shared<ScriptSummaryFormat>(
1289 m_options.m_flags, funct_name, code.c_str(),
1296 "the provided function \"{0}\" does not exist - "
1297 "please define it before attempting to use this summary",
1304 result.
AppendError(
"script interpreter missing - unable to generate "
1305 "function wrapper.\n");
1308 StringList funct_sl;
1309 funct_sl <<
m_options.m_python_script.c_str();
1310 std::string funct_name_str;
1312 result.
AppendError(
"unable to generate function wrapper.\n");
1315 if (funct_name_str.empty()) {
1317 "script interpreter failed to generate a valid function name.\n");
1321 std::string code =
" " +
m_options.m_python_script;
1323 script_format = std::make_shared<ScriptSummaryFormat>(
1324 m_options.m_flags, funct_name_str.c_str(), code.c_str(),
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");
1389 if (!
m_options.m_flags.GetShowMembersOneLiner() &&
1391 result.
AppendError(
"empty summary strings not allowed");
1395 const char *format_cstr = (
m_options.m_flags.GetShowMembersOneLiner()
1400 if (strcmp(format_cstr,
"${var%S}") == 0) {
1401 result.
AppendError(
"recursive summary not allowed");
1407 if (!string_format) {
1411 if (string_format->m_error.Fail()) {
1413 string_format->m_error.AsCString(
"<unknown>"));
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),
1458The following examples of 'type summary add' refer to this code snippet for context:
1464 JustADemo(int p = 1, float v = 0.1) : ptr(new int(p)), value(v) {}
1466 JustADemo demo_instance(42, 3.14);
1468 typedef JustADemo NewDemo;
1469 NewDemo new_demo_instance(42, 3.14);
1471(lldb) type summary add --summary-string "the answer is ${*var.ptr}" JustADemo
1473 Subsequently displaying demo_instance with 'frame variable' or 'expression' will display "the answer is 42"
1475(lldb) type summary add --summary-string "the answer is ${*var.ptr}, and the question is ${var.value}" JustADemo
1477 Subsequently displaying demo_instance with 'frame variable' or 'expression' will display "the answer is 42 and the question is 3.14"
1480 "Alternatively, you could define formatting for all pointers to integers and \
1481rely on that when formatting JustADemo to obtain the same result:"
1484(lldb) type summary add --summary-string "${var%V} -> ${*var}" "int *"
1485(lldb) type summary add --summary-string "the answer is ${var.ptr}, and the question is ${var.value}" JustADemo
1488 "Type summaries are automatically applied to derived typedefs, so the examples \
1489above apply to both JustADemo and NewDemo. The cascade option can be used to \
1490suppress this behavior:"
1493(lldb) type summary add --summary-string "${var.ptr}, ${var.value},{${var.byte}}" JustADemo -C no
1495 The summary will now be used for values of JustADemo but not NewDemo.
1498 "By default summaries are shown for pointers and references to values of the \
1499specified type. To suppress formatting for pointers use the -p option, or apply \
1500the corresponding -r option to suppress formatting for references:"
1503(lldb) type summary add -p -r --summary-string "${var.ptr}, ${var.value},{${var.byte}}" JustADemo
1506 "One-line summaries including all fields in a type can be inferred without supplying an \
1507explicit summary string by passing the -c option:"
1510(lldb) type summary add -c JustADemo
1511(lldb) frame variable demo_instance
1512(ptr=<address>, value=3.14)
1515 "Type summaries normally suppress the nested display of individual fields. To \
1516supply a summary to supplement the default structure add the -e option:"
1519(lldb) type summary add -e --summary-string "*ptr = ${*var.ptr}" JustADemo
1522 "Now when displaying JustADemo values the int* is displayed, followed by the \
1523standard LLDB sequence of children, one per line:"
1532 "You can also add summaries written in Python. These scripts use lldb public API to \
1533gather information from your variables and produce a meaningful summary. To start a \
1534multi-line script use the -P option. The function declaration will be displayed along with \
1535a comment describing the two arguments. End your script with the word 'DONE' on a line by \
1539(lldb) type summary add JustADemo -P
1540def function (valobj,internal_dict):
"""valobj: an SBValue which you want to provide a summary for
1541internal_dict: an LLDB support object not to be used"""
1542 value = valobj.GetChildMemberWithName('value');
1543 return 'My value is ' + value.GetValue();
1546Alternatively, the -o option can be used when providing a simple one-line Python script:
1548(lldb) type summary add JustADemo -o "value = valobj.GetChildMemberWithName('value'); return 'My value is ' + value.GetValue();")");
1556#if LLDB_ENABLE_PYTHON
1570 if (type_name_ref.ends_with(
"[]")) {
1571 std::string type_name_str(type_name.
GetCString());
1572 type_name_str.resize(type_name_str.length() - 2);
1573 if (type_name_str.back() !=
' ')
1574 type_name_str.append(
" ?\\[[0-9]+\\]");
1576 type_name_str.append(
"\\[[0-9]+\\]");
1594 std::string category_name,
1608 if (!typeRX.IsValid()) {
1611 "regex format error (maybe this is not really a regex?)");
1617 const char *function_name = type_name.
AsCString(
nullptr);
1620 *
error = Status::FromErrorStringWithFormat(
1621 "The provided recognizer function \"%s\" does not exist - "
1622 "please define it before attempting to use this summary.\n",
1627 category->AddTypeSummary(type_name.
GetStringRef(), match_type, entry);
1653 "type summary clear",
1654 "Delete all existing summaries.") {}
1669 "Show a list of current summaries.") {}
1680 summary_sp->GetDescription().c_str());
1690#define LLDB_OPTIONS_type_category_define
1691#include "CommandOptions.inc"
1703 ExecutionContext *execution_context)
override {
1707 switch (short_option) {
1715 llvm_unreachable(
"Unimplemented option");
1727 return llvm::ArrayRef(g_type_category_define_options);
1743 "Define a new category as a source of formatters.",
1760 for (
auto &entry : command.
entries()) {
1765 category_sp->AddLanguage(
m_options.m_cate_language.GetCurrentValue());
1766 if (
m_options.m_define_enabled.GetCurrentValue())
1777#define LLDB_OPTIONS_type_category_enable
1778#include "CommandOptions.inc"
1788 ExecutionContext *execution_context)
override {
1792 switch (short_option) {
1794 if (!option_arg.empty()) {
1797 error = Status::FromErrorStringWithFormat(
1798 "unrecognized language '%s'", option_arg.str().c_str());
1802 llvm_unreachable(
"Unimplemented option");
1813 return llvm::ArrayRef(g_type_category_enable_options);
1828 "Enable a category as a source of formatters.",
1836 void DoExecute(Args &command, CommandReturnObject &result)
override {
1847 }
else if (argc > 0) {
1848 for (
int i = argc - 1; i >= 0; i--) {
1850 ConstString typeCS(typeA);
1853 result.
AppendError(
"empty category name not allowed");
1859 if (cate->GetCount() == 0) {
1879 "Delete a category and all associated formatters.",
1896 bool success =
true;
1899 for (
int i = argc - 1; i >= 0; i--) {
1904 result.
AppendError(
"empty category name not allowed");
1919#define LLDB_OPTIONS_type_category_disable
1920#include "CommandOptions.inc"
1930 ExecutionContext *execution_context)
override {
1934 switch (short_option) {
1936 if (!option_arg.empty()) {
1939 error = Status::FromErrorStringWithFormat(
1940 "unrecognized language '%s'", option_arg.str().c_str());
1944 llvm_unreachable(
"Unimplemented option");
1955 return llvm::ArrayRef(g_type_category_disable_options);
1970 "Disable a category as a source of formatters.",
1989 }
else if (argc > 0) {
1991 for (
int i = argc - 1; i >= 0; i--) {
1993 ConstString typeCS(typeA);
1996 result.
AppendError(
"empty category name not allowed");
2016 "Provide a list of all existing categories.",
2037 std::unique_ptr<RegularExpression> regex;
2041 regex = std::make_unique<RegularExpression>(arg);
2042 if (!regex->IsValid()) {
2044 "syntax error in category regular expression '%s'", arg);
2047 }
else if (argc != 0) {
2057 if (regex->GetText() == category_sp->GetName()) {
2059 }
else if (regex->Execute(category_sp->GetName())) {
2068 "Category: %s\n", category_sp->GetDescription().c_str());
2084 "Show a list of current filters.") {}
2094 interpreter,
"type synthetic list",
2095 "Show a list of current synthetic providers.") {}
2126 "type filter clear",
2127 "Delete all existing filter.") {}
2137 "Delete all existing synthetic providers.") {}
2142 auto options = std::make_unique<SynthAddOptions>(
2147 for (
auto &entry : command.
entries()) {
2148 if (entry.ref().empty()) {
2149 result.
AppendError(
"empty typenames not allowed");
2153 options->m_target_types << std::string(entry.ref());
2177 "directly input Python code.\n",
2184 ScriptedSyntheticChildren *impl =
new ScriptedSyntheticChildren(
2185 SyntheticChildren::Flags()
2187 .SetFrontEndWantsDereference(
m_options.m_wants_deref)
2188 .SetSkipPointers(
m_options.m_skip_pointers)
2189 .SetSkipReferences(
m_options.m_skip_references),
2199 "the provided class '{0}' does not exist - please define it "
2200 "before attempting to use this synthetic provider",
2201 llvm::StringRef(python_class_name));
2207 ConstString(
m_options.m_category.c_str()), category);
2211 for (
auto &arg_entry : command.
entries()) {
2212 if (arg_entry.ref().empty()) {
2213 result.
AppendError(
"empty typenames not allowed");
2217 ConstString typeCS(arg_entry.ref());
2232 "Add a new synthetic provider for a type.", nullptr),
2240 std::string category_name,
2264 "cannot add synthetic for type {0} when "
2265 "filter is defined in same category!",
2273 if (!typeRX.IsValid()) {
2275 *
error = Status::FromErrorString(
2276 "regex format error (maybe this is not really a regex?)");
2282 const char *function_name = type_name.
AsCString(
nullptr);
2286 "The provided recognizer function \"%s\" does not exist - "
2287 "please define it before attempting to use this summary.\n",
2293 category->AddTypeSynthetic(type_name.
GetStringRef(), match_type, entry);
2297#define LLDB_OPTIONS_type_filter_add
2298#include "CommandOptions.inc"
2316 switch (short_option) {
2321 "invalid value for cascade: %s", option_arg.str().c_str());
2340 llvm_unreachable(
"Unimplemented option");
2357 return llvm::ArrayRef(g_type_filter_add_options);
2406 "cannot add filter for type {0} when "
2407 "synthetic is defined in same "
2418 if (!typeRX.IsValid()) {
2420 *
error = Status::FromErrorString(
2421 "regex format error (maybe this is not really a regex?)");
2425 category->AddTypeFilter(type_name.
GetStringRef(), match_type, entry);
2432 "Add a new filter for a type.", nullptr) {
2437The following examples of 'type filter add' refer to this code snippet for context:
2452Adding a simple filter:
2454(lldb) type filter add --child a --child g Foo
2455(lldb) frame variable my_foo
2458 "Produces output where only a and g are displayed. Other children of my_foo \
2459(b, c, d, e, f, h and i) are available by asking for them explicitly:"
2462(lldb) frame variable my_foo.b my_foo.c my_foo.i
2465 "The formatting option --raw on frame variable bypasses the filter, showing \
2466all children of my_foo as if no filter was defined:"
2469(lldb) frame variable my_foo --raw)");
2491 SyntheticChildren::Flags()
2501 entry->AddExpressionPath(*begin);
2513 for (
auto &arg_entry : command.
entries()) {
2514 if (arg_entry.ref().empty()) {
2515 result.
AppendError(
"empty typenames not allowed");
2533#define LLDB_OPTIONS_type_lookup
2534#include "CommandOptions.inc"
2565 return llvm::ArrayRef(g_type_lookup_options);
2572 const int short_option = g_type_lookup_options[option_idx].short_option;
2574 switch (short_option) {
2584 llvm_unreachable(
"Unimplemented option");
2607 "Lookup types and declarations in the current target, "
2608 "following language-specific naming conventions.",
2609 "type lookup <type-specifier>",
2610 eCommandRequiresTarget) {
2623 StreamString stream;
2626 stream.
Printf(
"%s\n", help);
2627 return IterationAction::Continue;
2634 void DoExecute(llvm::StringRef raw_command_line,
2635 CommandReturnObject &result)
override {
2636 if (raw_command_line.empty()) {
2638 "type lookup cannot be invoked without a type name as argument");
2645 OptionsWithRaw args(raw_command_line);
2646 const char *name_of_type = args.GetRawPart().c_str();
2653 ExecutionContextScope *best_scope = exe_ctx.GetBestExecutionContextScope();
2655 bool any_found =
false;
2657 std::vector<Language *> languages;
2659 bool is_global_search =
false;
2662 if ((is_global_search =
2665 languages.push_back(lang);
2666 return IterationAction::Continue;
2679 languages.begin(), languages.end(),
2681 if (!lang1 || !lang2)
2683 LanguageType lt1 = lang1->GetLanguageType();
2684 LanguageType lt2 = lang2->GetLanguageType();
2687 if (lt1 == guessed_language)
2689 if (lt2 == guessed_language)
2696 bool is_first_language =
true;
2702 if (
auto scavenger = language->GetTypeScavenger()) {
2704 if (scavenger->Find(best_scope, name_of_type, search_results) > 0) {
2705 for (
const auto &search_result : search_results) {
2706 if (search_result && search_result->IsValid()) {
2709 this->m_command_options.m_show_help);
2715 if (any_found && is_global_search)
2717 else if (is_first_language && is_global_search &&
2719 is_first_language =
false;
2721 "no type was found in the current language %s matching '%s'; "
2722 "performing a global search across all languages\n",
2736template <
typename FormatterType>
2739 typedef std::function<
typename FormatterType::SharedPointer(ValueObject &)>
2742 const char *formatter_name,
2748 name.
Printf(
"type %s info", formatter_name);
2751 help.
Printf(
"This command evaluates the provided expression and shows "
2752 "which %s is applied to the resulting value (if any).",
2756 syntax.
Printf(
"type %s info <expr>", formatter_name);
2777 command, frame_sp.get(), result_valobj_sp, options);
2780 result_valobj_sp->GetQualifiedRepresentationIfAvailable(
2781 target_sp->GetPreferDynamicValue(),
2782 target_sp->GetEnableSyntheticValue());
2783 typename FormatterType::SharedPointer formatter_sp =
2786 std::string description(formatter_sp->GetDescription());
2789 << result_valobj_sp->GetDisplayTypeName().AsCString(
"<unknown>")
2790 <<
") " << command <<
" is: " << description <<
"\n";
2795 << result_valobj_sp->GetDisplayTypeName().AsCString(
"<unknown>")
2796 <<
") " << command <<
"\n";
2800 result.
AppendError(
"failed to evaluate expression");
2813 interpreter,
"type format",
2814 "Commands for customizing value display formats.",
2815 "type format [<sub-command-options>] ") {
2826 interpreter,
"format",
2839 interpreter,
"type synthetic",
2840 "Commands for operating on synthetic type representations.",
2841 "type synthetic [<sub-command-options>] ") {
2853 interpreter,
"synthetic",
2866 "Commands for operating on type filters.",
2867 "type filter [<sub-command-options>] ") {
2885 "Commands for operating on type categories.",
2886 "type category [<sub-command-options>] ") {
2910 interpreter,
"type summary",
2911 "Commands for editing variable summary display options.",
2912 "type summary [<sub-command-options>] ") {
2914 "add",
CommandObjectSP(
new CommandObjectTypeSummaryAdd(interpreter)));
2920 "list",
CommandObjectSP(
new CommandObjectTypeSummaryList(interpreter)));
2922 "info",
CommandObjectSP(
new CommandObjectFormatterInfo<TypeSummaryImpl>(
2923 interpreter,
"summary",
2936 "Commands for operating on the type system.",
2937 "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 AppendError(llvm::StringRef in_string)
void AppendWarningWithFormatv(const char *format, Args &&...args)
void SetStatus(lldb::ReturnStatus status)
void AppendErrorWithFormat(const char *format,...) __attribute__((format(printf
void void AppendMessageWithFormatv(const char *format, Args &&...args)
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.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
const char * GetCString() const
Get the string value as a C string.
const char * AsCString(const char *value_if_empty) 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)
static Status static Status FromErrorStringWithFormatv(const char *format, Args &&...args)
const char * GetData() const
llvm::StringRef GetString() const
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
std::string CopyList(const char *item_preamble=nullptr, const char *items_sep="\n") const
size_t SplitIntoLines(const std::string &lines)
Symbol * symbol
The Symbol for a given query.
Flags & SetSkipReferences(bool value=true)
Flags & SetFrontEndWantsDereference(bool value=true)
Flags & SetSkipPointers(bool value=true)
std::shared_ptr< SyntheticChildren > SharedPointer
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