15#include "lldb/Host/Config.h" 
   38#include "llvm/ADT/STLExtras.h" 
   87  for (
auto entry : llvm::enumerate(command.
entries().drop_back())) {
 
   88    if (entry.value().ref() != 
"unsigned")
 
   90    auto next = command.
entries()[entry.index() + 1].ref();
 
   91    if (next == 
"int" || next == 
"short" || next == 
"char" || next == 
"long") {
 
   93          "unsigned %s being treated as two types. if you meant the combined " 
   95          "name use  quotes, as in \"unsigned %s\"\n",
 
   96          next.str().c_str(), next.str().c_str());
 
 
  111      return "synthetic child provider";
 
  116  llvm_unreachable(
"Fully covered switch above!");
 
 
  119#define LLDB_OPTIONS_type_summary_add 
  120#include "CommandOptions.inc" 
  137      return llvm::ArrayRef(g_type_summary_add_options);
 
 
 
  167    static const char *g_summary_addreader_instructions =
 
  168        "Enter your Python command(s). Type 'DONE' to end.\n" 
  169        "def function (valobj,internal_dict):\n" 
  170        "     \"\"\"valobj: an SBValue which you want to provide a summary " 
  172        "        internal_dict: an LLDB support object not to be used\"\"\"\n";
 
  177        locked_stream.
PutCString(g_summary_addreader_instructions);
 
 
  183                              std::string &data)
 override {
 
  186#if LLDB_ENABLE_PYTHON 
  201            std::string funct_name_str;
 
  204              if (funct_name_str.empty()) {
 
  207                    "unable to obtain a valid function name from " 
  208                    "the script interpreter.\n");
 
  214                script_format = std::make_shared<ScriptSummaryFormat>(
 
  215                    options->m_flags, funct_name_str.c_str(),
 
  216                    lines.
CopyList(
"    ").c_str(), options->m_ptr_match_depth);
 
  220                for (
const std::string &type_name : options->m_target_types) {
 
  222                             options->m_match_type, options->m_category,
 
  226                    locked_stream.
Printf(
"error: %s", 
error.AsCString());
 
  230                if (options->m_name) {
 
  232                      options->m_name, script_format, &
error);
 
  235                        options->m_name, script_format, &
error);
 
  238                      locked_stream.
Printf(
"error: %s", 
error.AsCString());
 
  242                    locked_stream.
Printf(
"error: %s", 
error.AsCString());
 
  245                  if (
error.AsCString()) {
 
  247                    locked_stream.
Printf(
"error: %s", 
error.AsCString());
 
  253              locked_stream.
Printf(
"error: unable to generate a function.\n");
 
  257            locked_stream.
Printf(
"error: no script interpreter.\n");
 
  261          locked_stream.
Printf(
"error: internal synchronization information " 
  262                               "missing or invalid.\n");
 
  267            "error: empty function, didn't add python command.\n");
 
  272          "error: script interpreter missing, didn't add python command.\n");
 
 
 
  290    "Enter your Python command(s). Type 'DONE' to end.\n" 
  291    "You must define a Python class with these methods:\n" 
  292    "    def __init__(self, valobj, internal_dict):\n" 
  293    "    def num_children(self):\n" 
  294    "    def get_child_at_index(self, index):\n" 
  295    "    def get_child_index(self, name):\n" 
  296    "    def update(self):\n" 
  298    "class synthProvider:\n";
 
  300#define LLDB_OPTIONS_type_synth_add 
  301#include "CommandOptions.inc" 
  318      switch (short_option) {
 
  323              "invalid value for cascade: %s", option_arg.str().c_str());
 
  344              "can't use --regex and --recognizer-function at the same time");
 
  351              "can't use --regex and --recognizer-function at the same time");
 
  356        llvm_unreachable(
"Unimplemented option");
 
 
  374      return llvm::ArrayRef(g_type_synth_add_options);
 
 
 
  407      result.
AppendError(
"must either provide a children list, a Python class " 
  408                         "name, or use -P and type a Python class " 
 
  423                              std::string &data)
 override {
 
  426#if LLDB_ENABLE_PYTHON 
  441            std::string class_name_str;
 
  443              if (class_name_str.empty()) {
 
  447                    "error: unable to obtain a proper name for the class.\n");
 
  453                synth_provider = std::make_shared<ScriptedSyntheticChildren>(
 
  455                        .SetCascades(options->m_cascade)
 
  458                    class_name_str.c_str());
 
  462                    ConstString(options->m_category.c_str()), category);
 
  466                for (
const std::string &type_name : options->m_target_types) {
 
  467                  if (!type_name.empty()) {
 
  469                                 options->m_match_type, options->m_category,
 
  472                      locked_stream.
Printf(
"error: %s\n", 
error.AsCString());
 
  477                    locked_stream.
Printf(
"error: invalid type name.\n");
 
  484              locked_stream.
Printf(
"error: unable to generate a class.\n");
 
  488            locked_stream.
Printf(
"error: no script interpreter.\n");
 
  493              "error: internal synchronization data missing.\n");
 
  498            "error: empty function, didn't add python command.\n");
 
  503          "error: script interpreter missing, didn't add python command.\n");
 
 
 
  522#define LLDB_OPTIONS_type_format_add 
  523#include "CommandOptions.inc" 
  534      return llvm::ArrayRef(g_type_format_add_options);
 
 
  549      const int short_option =
 
  550          g_type_format_add_options[option_idx].short_option;
 
  553      switch (short_option) {
 
  558              "invalid value for cascade: %s", option_value.str().c_str());
 
  576        llvm_unreachable(
"Unimplemented option");
 
 
 
  601                            "Add a new formatting style for a type.", nullptr),
 
  607The following examples of 'type format add' refer to this code snippet for context: 
  610    typedef float Afloat; 
  612    typedef Afloat Bfloat; 
 
  620Adding default formatting: 
  622(lldb) type format add -f hex AInt 
  623(lldb) frame variable iy 
  626        "    Produces hexadecimal display of iy, because no formatter is available for Bint and \ 
  627the one for Aint is used instead." 
  630To prevent this use the cascade option '-C no' to prevent evaluation of typedef chains: 
  633(lldb) type format add -f hex -C no AInt 
  635Similar reasoning applies to this: 
  637(lldb) type format add -f hex -C no float -p 
  640        "    All float values and float references are now formatted as hexadecimal, but not \ 
  641pointers to floats.  Nor will it change the default display for Afloat and Bfloat objects.");
 
  674      entry = std::make_shared<TypeFormatImpl_Format>(
 
  675          format, TypeFormatImpl::Flags()
 
  680      entry = std::make_shared<TypeFormatImpl_EnumType>(
 
  682          TypeFormatImpl::Flags()
 
 
  697    for (
auto &arg_entry : command.
entries()) {
 
  698      if (arg_entry.ref().empty()) {
 
  707        if (!typeRX.IsValid()) {
 
  709              "regex format error (maybe this is not really a regex?)");
 
  713      category_sp->AddTypeFormat(arg_entry.ref(), match_type, entry);
 
 
  720#define LLDB_OPTIONS_type_formatter_delete 
  721#include "CommandOptions.inc" 
  736      switch (short_option) {
 
  747        llvm_unreachable(
"Unimplemented option");
 
 
  760      return llvm::ArrayRef(g_type_formatter_delete_options);
 
 
 
  776      "Delete an existing %s for a type.";
 
  779      "Delete an existing %s for a type.  Unless you specify a " 
  780      "specific category or all categories, only the " 
  781      "'default' category is searched.  The names must be exactly as " 
  782      "shown in the 'type %s list' output";
 
  802    s.
Printf(
"type %s delete", short_kind);
 
 
  850    bool delete_category = 
false;
 
  851    bool extra_deletion = 
false;
 
  869    if (delete_category || extra_deletion) {
 
 
 
  877#define LLDB_OPTIONS_type_formatter_clear 
  878#include "CommandOptions.inc" 
  893      switch (short_option) {
 
  898        llvm_unreachable(
"Unimplemented option");
 
 
  909      return llvm::ArrayRef(g_type_formatter_clear_options);
 
 
 
  924                                  const char *name, 
const char *help)
 
 
 
  979                                        "Delete all existing format styles.") {}
 
 
 
  982#define LLDB_OPTIONS_type_formatter_list 
  983#include "CommandOptions.inc" 
  985template <
typename FormatterType>
 
 1002      switch (short_option) {
 
 1009        if (
error.Success())
 
 1013        llvm_unreachable(
"Unimplemented option");
 
 
 1025      return llvm::ArrayRef(g_type_formatter_list_options);
 
 
 
 1040                                 const char *name, 
const char *help)
 
 
 1058    return regex == 
nullptr || s == regex->
GetText() || regex->
Execute(s);
 
 
 1064    std::unique_ptr<RegularExpression> category_regex;
 
 1065    std::unique_ptr<RegularExpression> formatter_regex;
 
 1067    if (
m_options.m_category_regex.OptionWasSet()) {
 
 1068      category_regex = std::make_unique<RegularExpression>(
 
 1069          m_options.m_category_regex.GetCurrentValueAsRef());
 
 1070      if (!category_regex->IsValid()) {
 
 1072            "syntax error in category regular expression '%s'",
 
 1073            m_options.m_category_regex.GetCurrentValueAsRef().str().c_str());
 
 1080      formatter_regex = std::make_unique<RegularExpression>(arg);
 
 1081      if (!formatter_regex->IsValid()) {
 
 1088    bool any_printed = 
false;
 
 1090    auto category_closure =
 
 1091        [&result, &formatter_regex,
 
 1094          "-----------------------\nCategory: %s%s\n-----------------------\n",
 
 1095          category->GetName(), category->IsEnabled() ? 
"" : 
" (disabled)");
 
 1098          [&result, &formatter_regex,
 
 1102                           formatter_regex.get())) {
 
 1105              "%s: %s\n", type_matcher.GetMatchString().GetCString(),
 
 1106              format_sp->GetDescription().c_str());
 
 1110      category->ForEach(print_formatter);
 
 1113    if (
m_options.m_category_language.OptionWasSet()) {
 
 1116          m_options.m_category_language.GetCurrentValue(), category_sp);
 
 1118        category_closure(category_sp);
 
 1121          [&category_regex, &category_closure](
 
 1124              category_closure(category);
 
 
 
 1148                                       "Show a list of current formats.") {}
 
 
 
 1152    uint32_t option_idx, llvm::StringRef option_arg,
 
 1158  switch (short_option) {
 
 1163                                                option_arg.str().c_str());
 
 1166    m_flags.SetDontShowChildren(
false);
 
 1169    m_flags.SetHideEmptyAggregates(
true);
 
 1172    m_flags.SetDontShowValue(
true);
 
 1175    m_flags.SetShowMembersOneLiner(
true);
 
 1181    m_flags.SetSkipPointers(
true);
 
 1186          "invalid integer value for option '%c': %s", short_option,
 
 1191    m_flags.SetSkipReferences(
true);
 
 1196          "can't use --regex and --recognizer-function at the same time");
 
 1203          "can't use --regex and --recognizer-function at the same time");
 
 1208    m_name.SetString(option_arg);
 
 1225    m_flags.SetHideItemNames(
true);
 
 1228    llvm_unreachable(
"Unimplemented option");
 
 
 1236  m_flags.Clear().SetCascades().SetDontShowChildren().SetDontShowValue(
false);
 
 1237  m_flags.SetShowMembersOneLiner(
false)
 
 1238      .SetSkipPointers(
false)
 
 1239      .SetSkipReferences(
false)
 
 1240      .SetHideItemNames(
false);
 
 
 1251#if LLDB_ENABLE_PYTHON 
 1269    if (!funct_name || !funct_name[0]) {
 
 1275        (
"    " + 
m_options.m_python_function + 
"(valobj,internal_dict)");
 
 1277    script_format = std::make_shared<ScriptSummaryFormat>(
 
 1278        m_options.m_flags, funct_name, code.c_str(),
 
 1285          "The provided function \"%s\" does not exist - " 
 1286          "please define it before attempting to use this summary.\n",
 
 1293      result.
AppendError(
"script interpreter missing - unable to generate " 
 1294                         "function wrapper.\n");
 
 1297    StringList funct_sl;
 
 1298    funct_sl << 
m_options.m_python_script.c_str();
 
 1299    std::string funct_name_str;
 
 1301      result.
AppendError(
"unable to generate function wrapper.\n");
 
 1304    if (funct_name_str.empty()) {
 
 1306          "script interpreter failed to generate a valid function name.\n");
 
 1310    std::string code = 
"    " + 
m_options.m_python_script;
 
 1312    script_format = std::make_shared<ScriptSummaryFormat>(
 
 1313        m_options.m_flags, funct_name_str.c_str(), code.c_str(),
 
 1317    auto options = std::make_unique<ScriptAddOptions>(
 
 1321    for (
auto &entry : command.
entries()) {
 
 1322      if (entry.ref().empty()) {
 
 1323        result.
AppendError(
"empty typenames not allowed");
 
 1327      options->m_target_types << std::string(entry.ref());
 
 1345  for (
auto &entry : command.
entries()) {
 
 1358      result.
AppendError(
"added to types, but not given a name");
 
 1378  if (!
m_options.m_flags.GetShowMembersOneLiner() &&
 
 1380    result.
AppendError(
"empty summary strings not allowed");
 
 1384  const char *format_cstr = (
m_options.m_flags.GetShowMembersOneLiner()
 
 1389  if (strcmp(format_cstr, 
"${var%S}") == 0) {
 
 1390    result.
AppendError(
"recursive summary not allowed");
 
 1396  if (!string_format) {
 
 1400  if (string_format->m_error.Fail()) {
 
 1402                                 string_format->m_error.AsCString(
"<unknown>"));
 
 1409  for (
auto &arg_entry : command.
entries()) {
 
 1410    if (arg_entry.ref().empty()) {
 
 1411      result.
AppendError(
"empty typenames not allowed");
 
 1429      result.
AppendError(
"added to types, but not given a name");
 
 
 1441                          "Add a new summary style for a type.", nullptr),
 
 1447The following examples of 'type summary add' refer to this code snippet for context: 
 1453        JustADemo(int p = 1, float v = 0.1) : ptr(new int(p)), value(v) {} 
 1455    JustADemo demo_instance(42, 3.14); 
 1457    typedef JustADemo NewDemo; 
 1458    NewDemo new_demo_instance(42, 3.14); 
 1460(lldb) type summary add --summary-string "the answer is ${*var.ptr}" JustADemo 
 1462    Subsequently displaying demo_instance with 'frame variable' or 'expression' will display "the answer is 42" 
 1464(lldb) type summary add --summary-string "the answer is ${*var.ptr}, and the question is ${var.value}" JustADemo 
 1466    Subsequently displaying demo_instance with 'frame variable' or 'expression' will display "the answer is 42 and the question is 3.14" 
 1469      "Alternatively, you could define formatting for all pointers to integers and \ 
 1470rely on that when formatting JustADemo to obtain the same result:" 
 1473(lldb) type summary add --summary-string "${var%V} -> ${*var}" "int *" 
 
 1474(lldb) type summary add --summary-string "the answer is ${var.ptr}, and the question is ${var.value}" JustADemo 
 1477      "Type summaries are automatically applied to derived typedefs, so the examples \ 
 1478above apply to both JustADemo and NewDemo.  The cascade option can be used to \ 
 1479suppress this behavior:" 
 1482(lldb) type summary add --summary-string "${var.ptr}, ${var.value},{${var.byte}}" JustADemo -C no 
 1484    The summary will now be used for values of JustADemo but not NewDemo. 
 1487      "By default summaries are shown for pointers and references to values of the \ 
 1488specified type.  To suppress formatting for pointers use the -p option, or apply \ 
 1489the corresponding -r option to suppress formatting for references:" 
 
 1492(lldb) type summary add -p -r --summary-string "${var.ptr}, ${var.value},{${var.byte}}" JustADemo 
 1495      "One-line summaries including all fields in a type can be inferred without supplying an \ 
 1496explicit summary string by passing the -c option:" 
 1499(lldb) type summary add -c JustADemo 
 1500(lldb) frame variable demo_instance 
 1501(ptr=<address>, value=3.14) 
 1504      "Type summaries normally suppress the nested display of individual fields.  To \ 
 1505supply a summary to supplement the default structure add the -e option:" 
 
 1508(lldb) type summary add -e --summary-string "*ptr = ${*var.ptr}" JustADemo 
 1511      "Now when displaying JustADemo values the int* is displayed, followed by the \ 
 1512standard LLDB sequence of children, one per line:" 
 
 1521      "You can also add summaries written in Python.  These scripts use lldb public API to \ 
 1522gather information from your variables and produce a meaningful summary.  To start a \ 
 1523multi-line script use the -P option.  The function declaration will be displayed along with \ 
 1524a comment describing the two arguments.  End your script with the  word 'DONE' on a line by \ 
 1528(lldb) type summary add JustADemo -P 
 1529def function (valobj,internal_dict):
"""valobj: an SBValue which you want to provide a summary for 
 1530internal_dict: an LLDB support object not to be used""" 
 1531    value = valobj.GetChildMemberWithName('value'); 
 1532    return 'My value is ' + value.GetValue(); 
 1535Alternatively, the -o option can be used when providing a simple one-line Python script: 
 1537(lldb) type summary add JustADemo -o "value = valobj.GetChildMemberWithName('value'); return 'My value is ' + value.GetValue();")"); 
 1545#if LLDB_ENABLE_PYTHON 
 
 1559  if (type_name_ref.ends_with(
"[]")) {
 
 1560    std::string type_name_str(type_name.
GetCString());
 
 1561    type_name_str.resize(type_name_str.length() - 2);
 
 
 1562    if (type_name_str.back() != 
' ')
 
 1563      type_name_str.append(
" ?\\[[0-9]+\\]");
 
 1565      type_name_str.append(
"\\[[0-9]+\\]");
 
 
 1583                                             std::string category_name,
 
 
 
 1597    if (!typeRX.IsValid()) {
 
 1600            "regex format error (maybe this is not really a regex?)");
 
 1606    const char *function_name = type_name.
AsCString();
 
 1609      *
error = Status::FromErrorStringWithFormat(
 
 1610          "The provided recognizer function \"%s\" does not exist - " 
 
 1611          "please define it before attempting to use this summary.\n",
 
 
 1616  category->AddTypeSummary(type_name.
GetStringRef(), match_type, entry);
 
 1642                                        "type summary clear",
 
 1643                                        "Delete all existing summaries.") {}
 
 
 1658                                       "Show a list of current summaries.") {}
 
 
 1669                summary_sp->GetDescription().c_str());
 
 
 1679#define LLDB_OPTIONS_type_category_define 
 1680#include "CommandOptions.inc" 
 1692                          ExecutionContext *execution_context)
 override {
 
 1696      switch (short_option) {
 
 
 
 1704        llvm_unreachable(
"Unimplemented option");
 
 1716      return llvm::ArrayRef(g_type_category_define_options);
 
 
 1732                            "Define a new category as a source of formatters.",
 
 
 
 1749    for (
auto &entry : command.
entries()) {
 
 1754        category_sp->AddLanguage(
m_options.m_cate_language.GetCurrentValue());
 
 1755        if (
m_options.m_define_enabled.GetCurrentValue())
 
 
 1766#define LLDB_OPTIONS_type_category_enable 
 1767#include "CommandOptions.inc" 
 1777                          ExecutionContext *execution_context)
 override {
 
 1781      switch (short_option) {
 
 1783        if (!option_arg.empty()) {
 
 1786            error = Status::FromErrorStringWithFormat(
 
 1787                "unrecognized language '%s'", option_arg.str().c_str());
 
 1791        llvm_unreachable(
"Unimplemented option");
 
 
 
 1802      return llvm::ArrayRef(g_type_category_enable_options);
 
 
 1817                            "Enable a category as a source of formatters.",
 
 1825  void DoExecute(Args &command, CommandReturnObject &result)
 override {
 
 1836    } 
else if (argc > 0) {
 
 1837      for (
int i = argc - 1; i >= 0; i--) {
 
 1839        ConstString typeCS(typeA);
 
 
 
 1842          result.
AppendError(
"empty category name not allowed");
 
 1848          if (cate->GetCount() == 0) {
 
 1868                            "Delete a category and all associated formatters.",
 
 
 1885    bool success = 
true;
 
 
 1888    for (
int i = argc - 1; i >= 0; i--) {
 
 1893        result.
AppendError(
"empty category name not allowed");
 
 
 1908#define LLDB_OPTIONS_type_category_disable 
 1909#include "CommandOptions.inc" 
 1919                          ExecutionContext *execution_context)
 override {
 
 1923      switch (short_option) {
 
 1925        if (!option_arg.empty()) {
 
 1928            error = Status::FromErrorStringWithFormat(
 
 1929                "unrecognized language '%s'", option_arg.str().c_str());
 
 
 
 1933        llvm_unreachable(
"Unimplemented option");
 
 1944      return llvm::ArrayRef(g_type_category_disable_options);
 
 1959                            "Disable a category as a source of formatters.",
 
 1978    } 
else if (argc > 0) {
 
 1980      for (
int i = argc - 1; i >= 0; i--) {
 
 1982        ConstString typeCS(typeA);
 
 1985          result.
AppendError(
"empty category name not allowed");
 
 
 
 2005                            "Provide a list of all existing categories.",
 
 
 2026    std::unique_ptr<RegularExpression> regex;
 
 
 2030      regex = std::make_unique<RegularExpression>(arg);
 
 2031      if (!regex->IsValid()) {
 
 
 2033            "syntax error in category regular expression '%s'", arg);
 
 2036    } 
else if (argc != 0) {
 
 
 2046            if (regex->GetText() == category_sp->GetName()) {
 
 2048            } 
else if (regex->Execute(category_sp->GetName())) {
 
 
 
 2057              "Category: %s\n", category_sp->GetDescription().c_str());
 
 
 2073                                       "Show a list of current filters.") {}
 
 2083            interpreter, 
"type synthetic list",
 
 2084            "Show a list of current synthetic providers.") {}
 
 
 2115                                        "type filter clear",
 
 2116                                        "Delete all existing filter.") {}
 
 2126            "Delete all existing synthetic providers.") {}
 
 2131  auto options = std::make_unique<SynthAddOptions>(
 
 2135  for (
auto &entry : command.
entries()) {
 
 2136    if (entry.ref().empty()) {
 
 2137      result.
AppendError(
"empty typenames not allowed");
 
 2141    options->m_target_types << std::string(entry.ref());
 
 
 2165                                 "directly input Python code.\n",
 
 2172  ScriptedSyntheticChildren *impl = 
new ScriptedSyntheticChildren(
 
 2173      SyntheticChildren::Flags()
 
 2175          .SetSkipPointers(
m_options.m_skip_pointers)
 
 2176          .SetSkipReferences(
m_options.m_skip_references),
 
 2185    result.
AppendWarning(
"The provided class does not exist - please define it " 
 2186                         "before attempting to use this synthetic provider");
 
 2192      ConstString(
m_options.m_category.c_str()), category);
 
 2196  for (
auto &arg_entry : command.
entries()) {
 
 2197    if (arg_entry.ref().empty()) {
 
 2198      result.
AppendError(
"empty typenames not allowed");
 
 2202    ConstString typeCS(arg_entry.ref());
 
 
 2217                          "Add a new synthetic provider for a type.", nullptr),
 
 2225                                         std::string category_name,
 
 2249            "cannot add synthetic for type %s when " 
 2250            "filter is defined in same category!",
 
 2258    if (!typeRX.IsValid()) {
 
 2260        *
error = Status::FromErrorString(
 
 2261            "regex format error (maybe this is not really a regex?)");
 
 
 2267    const char *function_name = type_name.
AsCString();
 
 2271          "The provided recognizer function \"%s\" does not exist - " 
 2272          "please define it before attempting to use this summary.\n",
 
 
 2278  category->AddTypeSynthetic(type_name.
GetStringRef(), match_type, entry);
 
 
 2282#define LLDB_OPTIONS_type_filter_add 
 2283#include "CommandOptions.inc" 
 
 2301      switch (short_option) {
 
 2306              "invalid value for cascade: %s", option_arg.str().c_str());
 
 2325        llvm_unreachable(
"Unimplemented option");
 
 2342      return llvm::ArrayRef(g_type_filter_add_options);
 
 
 2391              "cannot add filter for type %s when " 
 2392              "synthetic is defined in same " 
 2403      if (!typeRX.IsValid()) {
 
 2405          *
error = Status::FromErrorString(
 
 2406              "regex format error (maybe this is not really a regex?)");
 
 2410    category->AddTypeFilter(type_name.
GetStringRef(), match_type, entry);
 
 2417                            "Add a new filter for a type.", nullptr) {
 
 2422The following examples of 'type filter add' refer to this code snippet for context: 
 
 2437Adding a simple filter: 
 2439(lldb) type filter add --child a --child g Foo 
 2440(lldb) frame variable my_foo 
 2443        "Produces output where only a and g are displayed.  Other children of my_foo \ 
 2444(b, c, d, e, f, h and i) are available by asking for them explicitly:" 
 2447(lldb) frame variable my_foo.b my_foo.c my_foo.i 
 2450        "The formatting option --raw on frame variable bypasses the filter, showing \ 
 
 2451all children of my_foo as if no filter was defined:" 
 2454(lldb) frame variable my_foo --raw)"); 
 2476        SyntheticChildren::Flags()
 
 
 2486      entry->AddExpressionPath(*begin);
 
 
 2498    for (
auto &arg_entry : command.
entries()) {
 
 2499      if (arg_entry.ref().empty()) {
 
 2500        result.
AppendError(
"empty typenames not allowed");
 
 
 2518#define LLDB_OPTIONS_type_lookup 
 2519#include "CommandOptions.inc" 
 
 2550      return llvm::ArrayRef(g_type_lookup_options);
 
 
 2557      const int short_option = g_type_lookup_options[option_idx].short_option;
 
 2559      switch (short_option) {
 
 2569        llvm_unreachable(
"Unimplemented option");
 
 2592                         "Lookup types and declarations in the current target, " 
 2593                         "following language-specific naming conventions.",
 
 2594                         "type lookup <type-specifier>",
 
 2595                         eCommandRequiresTarget) {
 
 2608    StreamString stream;
 
 2611        stream.
Printf(
"%s\n", help);
 
 2612      return IterationAction::Continue;
 
 2619  void DoExecute(llvm::StringRef raw_command_line,
 
 2620                 CommandReturnObject &result)
 override {
 
 2621    if (raw_command_line.empty()) {
 
 2623          "type lookup cannot be invoked without a type name as argument");
 
 2630    OptionsWithRaw args(raw_command_line);
 
 2631    const char *name_of_type = args.GetRawPart().c_str();
 
 2638    ExecutionContextScope *best_scope = exe_ctx.GetBestExecutionContextScope();
 
 2640    bool any_found = 
false;
 
 2642    std::vector<Language *> languages;
 
 2644    bool is_global_search = 
false;
 
 2647    if ((is_global_search =
 
 2650        languages.push_back(lang);
 
 2651        return IterationAction::Continue;
 
 
 
 2664            languages.begin(), languages.end(),
 
 2666              if (!lang1 || !lang2)
 
 2668              LanguageType lt1 = lang1->GetLanguageType();
 
 2669              LanguageType lt2 = lang2->GetLanguageType();
 
 2672              if (lt1 == guessed_language)
 
 2674              if (lt2 == guessed_language)
 
 
 2681    bool is_first_language = 
true;
 
 2687      if (
auto scavenger = language->GetTypeScavenger()) {
 
 2689        if (scavenger->Find(best_scope, name_of_type, search_results) > 0) {
 
 2690          for (
const auto &search_result : search_results) {
 
 2691            if (search_result && search_result->IsValid()) {
 
 2694                                          this->m_command_options.m_show_help);
 
 2700      if (any_found && is_global_search)
 
 2702      else if (is_first_language && is_global_search &&
 
 2704        is_first_language = 
false;
 
 2706            "no type was found in the current language %s matching '%s'; " 
 2707            "performing a global search across all languages\n",
 
 2721template <
typename FormatterType>
 
 
 2724  typedef std::function<
typename FormatterType::SharedPointer(ValueObject &)>
 
 2727                             const char *formatter_name,
 
 
 2733    name.
Printf(
"type %s info", formatter_name);
 
 2736    help.
Printf(
"This command evaluates the provided expression and shows " 
 2737                "which %s is applied to the resulting value (if any).",
 
 2741    syntax.
Printf(
"type %s info <expr>", formatter_name);
 
 
 
 2762        command, frame_sp.get(), result_valobj_sp, options);
 
 2765          result_valobj_sp->GetQualifiedRepresentationIfAvailable(
 
 2766              target_sp->GetPreferDynamicValue(),
 
 2767              target_sp->GetEnableSyntheticValue());
 
 2768      typename FormatterType::SharedPointer formatter_sp =
 
 2771        std::string description(formatter_sp->GetDescription());
 
 2774            << result_valobj_sp->GetDisplayTypeName().AsCString(
"<unknown>")
 
 2775            << 
") " << command << 
" is: " << description << 
"\n";
 
 
 2780            << result_valobj_sp->GetDisplayTypeName().AsCString(
"<unknown>")
 
 
 2781            << 
") " << command << 
"\n";
 
 2785      result.
AppendError(
"failed to evaluate expression");
 
 
 2798            interpreter, 
"type format",
 
 2799            "Commands for customizing value display formats.",
 
 
 2800            "type format [<sub-command-options>] ") {
 
 2811                    interpreter, 
"format",
 
 
 2824            interpreter, 
"type synthetic",
 
 
 2825            "Commands for operating on synthetic type representations.",
 
 2826            "type synthetic [<sub-command-options>] ") {
 
 2838            interpreter, 
"synthetic",
 
 
 
 2851                               "Commands for operating on type filters.",
 
 2852                               "type filter [<sub-command-options>] ") {
 
 2870                               "Commands for operating on type categories.",
 
 
 2871                               "type category [<sub-command-options>] ") {
 
 2895            interpreter, 
"type summary",
 
 2896            "Commands for editing variable summary display options.",
 
 2897            "type summary [<sub-command-options>] ") {
 
 2899        "add", 
CommandObjectSP(
new CommandObjectTypeSummaryAdd(interpreter)));
 
 2905        "list", 
CommandObjectSP(
new CommandObjectTypeSummaryList(interpreter)));
 
 2907        "info", 
CommandObjectSP(
new CommandObjectFormatterInfo<TypeSummaryImpl>(
 
 2908                    interpreter, 
"summary",
 
 2921                             "Commands for operating on the type system.",
 
 2922                             "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
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)
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 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.
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.
SourceLanguage GuessLanguage()
Similar to GetLanguage(), but is allowed to take a potentially incorrect guess if exact information i...
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 & 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