[Lldb-commits] [lldb] r366561 - [lldb][NFC] Tablegenify target

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Fri Jul 19 03:23:22 PDT 2019


Author: teemperor
Date: Fri Jul 19 03:23:22 2019
New Revision: 366561

URL: http://llvm.org/viewvc/llvm-project?rev=366561&view=rev
Log:
[lldb][NFC] Tablegenify target

Modified:
    lldb/trunk/source/Commands/CommandObjectTarget.cpp
    lldb/trunk/source/Commands/Options.td
    lldb/trunk/source/Commands/OptionsBase.td

Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=366561&r1=366560&r2=366561&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Fri Jul 19 03:23:22 2019
@@ -145,12 +145,9 @@ static constexpr OptionEnumValueElement
      "Load dependents, even if the target is not an executable."}};
 
 static constexpr OptionDefinition g_dependents_options[] = {
-    {LLDB_OPT_SET_1, false, "no-dependents", 'd',
-     OptionParser::eOptionalArgument, nullptr,
-     OptionEnumValues(g_dependents_enumaration), 0, eArgTypeValue,
-     "Whether or not to load dependents when creating a target. If the option "
-     "is not specified, the value is implicitly 'default'. If the option is "
-     "specified but without a value, the value is implicitly 'true'."}};
+#define LLDB_OPTIONS_target_dependents
+#include "CommandOptions.inc"
+};
 
 class OptionGroupDependents : public OptionGroup {
 public:
@@ -2455,16 +2452,8 @@ protected:
 
     llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
       static constexpr OptionDefinition g_options[] = {
-          {LLDB_OPT_SET_ALL,
-           false,
-           "verbose",
-           'v',
-           OptionParser::eNoArgument,
-           nullptr,
-           {},
-           0,
-           eArgTypeNone,
-           "Enable verbose dump."},
+#define LLDB_OPTIONS_target_modules_dump
+#include "CommandOptions.inc"
       };
       return llvm::makeArrayRef(g_options);
     }
@@ -2970,23 +2959,8 @@ protected:
 // List images with associated information
 
 static constexpr OptionDefinition g_target_modules_list_options[] = {
-    // clang-format off
-  { LLDB_OPT_SET_1, false, "address",        'a', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeAddressOrExpression, "Display the image at this address." },
-  { LLDB_OPT_SET_1, false, "arch",           'A', OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeWidth,               "Display the architecture when listing images." },
-  { LLDB_OPT_SET_1, false, "triple",         't', OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeWidth,               "Display the triple when listing images." },
-  { LLDB_OPT_SET_1, false, "header",         'h', OptionParser::eNoArgument,       nullptr, {}, 0, eArgTypeNone,                "Display the image base address as a load address if debugging, a file address otherwise." },
-  { LLDB_OPT_SET_1, false, "offset",         'o', OptionParser::eNoArgument,       nullptr, {}, 0, eArgTypeNone,                "Display the image load address offset from the base file address (the slide amount)." },
-  { LLDB_OPT_SET_1, false, "uuid",           'u', OptionParser::eNoArgument,       nullptr, {}, 0, eArgTypeNone,                "Display the UUID when listing images." },
-  { LLDB_OPT_SET_1, false, "fullpath",       'f', OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeWidth,               "Display the fullpath to the image object file." },
-  { LLDB_OPT_SET_1, false, "directory",      'd', OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeWidth,               "Display the directory with optional width for the image object file." },
-  { LLDB_OPT_SET_1, false, "basename",       'b', OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeWidth,               "Display the basename with optional width for the image object file." },
-  { LLDB_OPT_SET_1, false, "symfile",        's', OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeWidth,               "Display the fullpath to the image symbol file with optional width." },
-  { LLDB_OPT_SET_1, false, "symfile-unique", 'S', OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeWidth,               "Display the symbol file with optional width only if it is different from the executable object file." },
-  { LLDB_OPT_SET_1, false, "mod-time",       'm', OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeWidth,               "Display the modification time with optional width of the module." },
-  { LLDB_OPT_SET_1, false, "ref-count",      'r', OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeWidth,               "Display the reference count if the module is still in the shared module cache." },
-  { LLDB_OPT_SET_1, false, "pointer",        'p', OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeNone,                "Display the module pointer." },
-  { LLDB_OPT_SET_1, false, "global",         'g', OptionParser::eNoArgument,       nullptr, {}, 0, eArgTypeNone,                "Display the modules from the global module list, not just the current target." }
-    // clang-format on
+#define LLDB_OPTIONS_target_modules_list
+#include "CommandOptions.inc"
 };
 
 class CommandObjectTargetModulesList : public CommandObjectParsed {
@@ -3334,10 +3308,8 @@ protected:
 // Lookup unwind information in images
 
 static constexpr OptionDefinition g_target_modules_show_unwind_options[] = {
-    // clang-format off
-  { LLDB_OPT_SET_1, false, "name",    'n', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeFunctionName,        "Show unwind instructions for a function or symbol name." },
-  { LLDB_OPT_SET_2, false, "address", 'a', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeAddressOrExpression, "Show unwind instructions for a function or symbol containing an address" }
-    // clang-format on
+#define LLDB_OPTIONS_target_modules_show_unwind
+#include "CommandOptions.inc"
 };
 
 class CommandObjectTargetModulesShowUnwind : public CommandObjectParsed {
@@ -3645,21 +3617,8 @@ protected:
 // Lookup information in images
 
 static constexpr OptionDefinition g_target_modules_lookup_options[] = {
-    // clang-format off
-  { LLDB_OPT_SET_1,                                  true,  "address",    'a', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeAddressOrExpression, "Lookup an address in one or more target modules." },
-  { LLDB_OPT_SET_1,                                  false, "offset",     'o', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeOffset,              "When looking up an address subtract <offset> from any addresses before doing the lookup." },
-  /* FIXME: re-enable regex for types when the LookupTypeInModule actually uses the regex option: | LLDB_OPT_SET_6 */
-  { LLDB_OPT_SET_2 | LLDB_OPT_SET_4 | LLDB_OPT_SET_5, false, "regex",      'r', OptionParser::eNoArgument,      nullptr, {}, 0, eArgTypeNone,                "The <name> argument for name lookups are regular expressions." },
-  { LLDB_OPT_SET_2,                                  true,  "symbol",     's', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeSymbol,              "Lookup a symbol by name in the symbol tables in one or more target modules." },
-  { LLDB_OPT_SET_3,                                  true,  "file",       'f', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeFilename,            "Lookup a file by fullpath or basename in one or more target modules." },
-  { LLDB_OPT_SET_3,                                  false, "line",       'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLineNum,             "Lookup a line number in a file (must be used in conjunction with --file)." },
-  { LLDB_OPT_SET_FROM_TO(3,5),                       false, "no-inlines", 'i', OptionParser::eNoArgument,       nullptr, {}, 0, eArgTypeNone,                "Ignore inline entries (must be used in conjunction with --file or --function)." },
-  { LLDB_OPT_SET_4,                                  true,  "function",   'F', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeFunctionName,        "Lookup a function by name in the debug symbols in one or more target modules." },
-  { LLDB_OPT_SET_5,                                  true,  "name",       'n', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeFunctionOrSymbol,    "Lookup a function or symbol by name in one or more target modules." },
-  { LLDB_OPT_SET_6,                                  true,  "type",       't', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeName,                "Lookup a type by name in the debug symbols in one or more target modules." },
-  { LLDB_OPT_SET_ALL,                                false, "verbose",    'v', OptionParser::eNoArgument,       nullptr, {}, 0, eArgTypeNone,                "Enable verbose lookup information." },
-  { LLDB_OPT_SET_ALL,                                false, "all",        'A', OptionParser::eNoArgument,       nullptr, {}, 0, eArgTypeNone,                "Print all matches, not just the best match, if a best match is available." },
-    // clang-format on
+#define LLDB_OPTIONS_target_modules_lookup
+#include "CommandOptions.inc"
 };
 
 class CommandObjectTargetModulesLookup : public CommandObjectParsed {
@@ -4513,20 +4472,8 @@ private:
 // CommandObjectTargetStopHookAdd
 
 static constexpr OptionDefinition g_target_stop_hook_add_options[] = {
-    // clang-format off
-  { LLDB_OPT_SET_ALL, false, "one-liner",    'o', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeOneLiner,                                         "Add a command for the stop hook.  Can be specified more than once, and commands will be run in the order they appear." },
-  { LLDB_OPT_SET_ALL, false, "shlib",        's', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eModuleCompletion, eArgTypeShlibName,    "Set the module within which the stop-hook is to be run." },
-  { LLDB_OPT_SET_ALL, false, "thread-index", 'x', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeThreadIndex,                                      "The stop hook is run only for the thread whose index matches this argument." },
-  { LLDB_OPT_SET_ALL, false, "thread-id",    't', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeThreadID,                                         "The stop hook is run only for the thread whose TID matches this argument." },
-  { LLDB_OPT_SET_ALL, false, "thread-name",  'T', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeThreadName,                                       "The stop hook is run only for the thread whose thread name matches this argument." },
-  { LLDB_OPT_SET_ALL, false, "queue-name",   'q', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeQueueName,                                        "The stop hook is run only for threads in the queue whose name is given by this argument." },
-  { LLDB_OPT_SET_1,   false, "file",         'f', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eSourceFileCompletion, eArgTypeFilename, "Specify the source file within which the stop-hook is to be run." },
-  { LLDB_OPT_SET_1,   false, "start-line",   'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLineNum,                                          "Set the start of the line range for which the stop-hook is to be run." },
-  { LLDB_OPT_SET_1,   false, "end-line",     'e', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLineNum,                                          "Set the end of the line range for which the stop-hook is to be run." },
-  { LLDB_OPT_SET_2,   false, "classname",    'c', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeClassName,                                        "Specify the class within which the stop-hook is to be run." },
-  { LLDB_OPT_SET_3,   false, "name",         'n', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName, "Set the function name within which the stop hook will be run." },
-  { LLDB_OPT_SET_ALL, false, "auto-continue",'G', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean,     "The breakpoint will auto-continue after running its commands." },
-    // clang-format on
+#define LLDB_OPTIONS_target_stop_hook_add
+#include "CommandOptions.inc"
 };
 
 class CommandObjectTargetStopHookAdd : public CommandObjectParsed,

Modified: lldb/trunk/source/Commands/Options.td
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/Options.td?rev=366561&r1=366560&r2=366561&view=diff
==============================================================================
--- lldb/trunk/source/Commands/Options.td (original)
+++ lldb/trunk/source/Commands/Options.td Fri Jul 19 03:23:22 2019
@@ -109,6 +109,150 @@ let Command = "script add" in {
     "LLDB event system.">;
 }
 
+let Command = "target dependents" in {
+  def dependents_no_dependents : Option<"no-dependents", "d">, Group<1>,
+    OptionalEnumArg<"Value", "OptionEnumValues(g_dependents_enumaration)">,
+    Desc<"Whether or not to load dependents when creating a target. If the "
+         "option is not specified, the value is implicitly 'default'. If the "
+         "option is specified but without a value, the value is implicitly "
+         "'true'.">;
+}
+
+let Command = "target modules dump" in {
+  def target_modules_dump_verbose : Option<"verbose", "v">,
+    Desc<"Enable verbose dump.">;
+}
+
+let Command = "target modules list" in {
+  def target_modules_list_address : Option<"address", "a">, Group<1>,
+    Arg<"AddressOrExpression">, Desc<"Display the image at this address.">;
+  def target_modules_list_arch : Option<"arch", "A">, Group<1>,
+    OptionalArg<"Width">, Desc<"Display the architecture when listing images.">;
+  def target_modules_list_triple : Option<"triple", "t">, Group<1>,
+    OptionalArg<"Width">, Desc<"Display the triple when listing images.">;
+  def target_modules_list_header : Option<"header", "h">, Group<1>,
+    Desc<"Display the image base address as a load address if debugging, a file"
+    " address otherwise.">;
+  def target_modules_list_offset : Option<"offset", "o">, Group<1>,
+    Desc<"Display the image load address offset from the base file address "
+    "(the slide amount).">;
+  def target_modules_list_uuid : Option<"uuid", "u">, Group<1>,
+    Desc<"Display the UUID when listing images.">;
+  def target_modules_list_fullpath : Option<"fullpath", "f">, Group<1>,
+    OptionalArg<"Width">,
+    Desc<"Display the fullpath to the image object file.">;
+  def target_modules_list_directory : Option<"directory", "d">, Group<1>,
+    OptionalArg<"Width">, Desc<"Display the directory with optional width for "
+    "the image object file.">;
+  def target_modules_list_basename : Option<"basename", "b">, Group<1>,
+    OptionalArg<"Width">, Desc<"Display the basename with optional width for "
+    "the image object file.">;
+  def target_modules_list_symfile : Option<"symfile", "s">, Group<1>,
+    OptionalArg<"Width">, Desc<"Display the fullpath to the image symbol file "
+    "with optional width.">;
+  def target_modules_list_symfile_unique : Option<"symfile-unique", "S">,
+    Group<1>, OptionalArg<"Width">, Desc<"Display the symbol file with optional"
+    " width only if it is different from the executable object file.">;
+  def target_modules_list_mod_time : Option<"mod-time", "m">, Group<1>,
+    OptionalArg<"Width">, Desc<"Display the modification time with optional "
+    "width of the module.">;
+  def target_modules_list_ref_count : Option<"ref-count", "r">, Group<1>,
+    OptionalArg<"Width">, Desc<"Display the reference count if the module is "
+    "still in the shared module cache.">;
+  def target_modules_list_pointer : Option<"pointer", "p">, Group<1>,
+    OptionalArg<"None">, Desc<"Display the module pointer.">;
+  def target_modules_list_global : Option<"global", "g">, Group<1>,
+    Desc<"Display the modules from the global module list, not just the "
+    "current target.">;
+}
+
+let Command = "target modules show unwind" in {
+  def target_modules_show_unwind_name : Option<"name", "n">, Group<1>,
+    Arg<"FunctionName">,
+    Desc<"Show unwind instructions for a function or symbol name.">;
+  def target_modules_show_unwind_address : Option<"address", "a">, Group<2>,
+    Arg<"AddressOrExpression">, Desc<"Show unwind instructions for a function "
+    "or symbol containing an address">;
+}
+
+let Command = "target modules lookup" in {
+  def target_modules_lookup_address : Option<"address", "a">, Group<1>,
+    Arg<"AddressOrExpression">, Required, Desc<"Lookup an address in one or "
+    "more target modules.">;
+  def target_modules_lookup_offset : Option<"offset", "o">, Group<1>,
+    Arg<"Offset">, Desc<"When looking up an address subtract <offset> from any "
+    "addresses before doing the lookup.">;
+  // FIXME: re-enable regex for types when the LookupTypeInModule actually uses
+  // the regex option by adding to group 6.
+  def target_modules_lookup_regex : Option<"regex", "r">, Groups<[2,4,5]>,
+    Desc<"The <name> argument for name lookups are regular expressions.">;
+  def target_modules_lookup_symbol : Option<"symbol", "s">, Group<2>,
+    Arg<"Symbol">, Required, Desc<"Lookup a symbol by name in the symbol tables"
+    " in one or more target modules.">;
+  def target_modules_lookup_file : Option<"file", "f">, Group<3>,
+    Arg<"Filename">, Required, Desc<"Lookup a file by fullpath or basename in "
+    "one or more target modules.">;
+  def target_modules_lookup_line : Option<"line", "l">, Group<3>,
+    Arg<"LineNum">, Desc<"Lookup a line number in a file (must be used in "
+    "conjunction with --file).">;
+  def target_modules_lookup_no_inlines : Option<"no-inlines", "i">,
+    GroupRange<3,5>,
+    Desc<"Ignore inline entries (must be used in conjunction with --file or "
+    "--function).">;
+  def target_modules_lookup_function : Option<"function", "F">, Group<4>,
+    Arg<"FunctionName">, Required, Desc<"Lookup a function by name in the debug"
+    " symbols in one or more target modules.">;
+  def target_modules_lookup_name : Option<"name", "n">, Group<5>,
+    Arg<"FunctionOrSymbol">, Required, Desc<"Lookup a function or symbol by "
+    "name in one or more target modules.">;
+  def target_modules_lookup_type : Option<"type", "t">, Group<6>, Arg<"Name">,
+    Required, Desc<"Lookup a type by name in the debug symbols in one or more "
+    "target modules.">;
+  def target_modules_lookup_verbose : Option<"verbose", "v">,
+    Desc<"Enable verbose lookup information.">;
+  def target_modules_lookup_all : Option<"all", "A">, Desc<"Print all matches, "
+    "not just the best match, if a best match is available.">;
+}
+
+let Command = "target stop hook add" in {
+  def target_stop_hook_add_one_liner : Option<"one-liner", "o">,
+    Arg<"OneLiner">, Desc<"Add a command for the stop hook.  Can be specified "
+    "more than once, and commands will be run in the order they appear.">;
+  def target_stop_hook_add_shlib : Option<"shlib", "s">, Arg<"ShlibName">,
+    Completion<"Module">,
+    Desc<"Set the module within which the stop-hook is to be run.">;
+  def target_stop_hook_add_thread_index : Option<"thread-index", "x">,
+    Arg<"ThreadIndex">, Desc<"The stop hook is run only for the thread whose "
+    "index matches this argument.">;
+  def target_stop_hook_add_thread_id : Option<"thread-id", "t">,
+    Arg<"ThreadID">, Desc<"The stop hook is run only for the thread whose TID "
+    "matches this argument.">;
+  def target_stop_hook_add_thread_name : Option<"thread-name", "T">,
+    Arg<"ThreadName">, Desc<"The stop hook is run only for the thread whose "
+    "thread name matches this argument.">;
+  def target_stop_hook_add_queue_name : Option<"queue-name", "q">,
+    Arg<"QueueName">, Desc<"The stop hook is run only for threads in the queue "
+    "whose name is given by this argument.">;
+  def target_stop_hook_add_file : Option<"file", "f">, Group<1>,
+    Arg<"Filename">, Desc<"Specify the source file within which the stop-hook "
+    "is to be run.">, Completion<"SourceFile">;
+  def target_stop_hook_add_start_line : Option<"start-line", "l">, Group<1>,
+    Arg<"LineNum">, Desc<"Set the start of the line range for which the "
+    "stop-hook is to be run.">;
+  def target_stop_hook_add_end_line : Option<"end-line", "e">, Group<1>,
+    Arg<"LineNum">, Desc<"Set the end of the line range for which the stop-hook"
+    " is to be run.">;
+  def target_stop_hook_add_classname : Option<"classname", "c">, Group<2>,
+    Arg<"ClassName">,
+    Desc<"Specify the class within which the stop-hook is to be run.">;
+  def target_stop_hook_add_name : Option<"name", "n">, Group<3>,
+    Arg<"FunctionName">, Desc<"Set the function name within which the stop hook"
+    " will be run.">, Completion<"Symbol">;
+  def target_stop_hook_add_auto_continue : Option<"auto-continue", "G">,
+    Arg<"Boolean">, Desc<"The breakpoint will auto-continue after running its"
+    " commands.">;
+}
+
 let Command = "thread backtrace" in {
   def thread_backtrace_count : Option<"count", "c">, Group<1>, Arg<"Count">,
   Desc<"How many frames to display (-1 for all)">;

Modified: lldb/trunk/source/Commands/OptionsBase.td
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/OptionsBase.td?rev=366561&r1=366560&r2=366561&view=diff
==============================================================================
--- lldb/trunk/source/Commands/OptionsBase.td (original)
+++ lldb/trunk/source/Commands/OptionsBase.td Fri Jul 19 03:23:22 2019
@@ -41,6 +41,7 @@
 //  - `OptionalArg`: Sets the argument type and marks it as optional.
 //  - `Arg`: Sets the argument type and marks it as required.
 //  - `EnumArg`: Sets the argument type to an enum and marks it as required.
+//  - `OptionalEnumArg`: Same as EnumArg but marks it as optional.
 // See argument_type field for more info.
 ////////////////////////////////////////////////////////////////////////////////
 // Field: validator
@@ -50,6 +51,7 @@
 // Field: enum_values
 // Default value: {} (No enum associated with this option)
 // Set by:
+//  - `OptionalEnumArg`:
 //  - `EnumArg`: Sets the argument type and assigns it a enum holding the valid
 //               values. The enum needs to be a variable in the including code.
 //               Marks the option as required (see option_has_arg).
@@ -82,12 +84,14 @@
 //           Example: def foo : Option<"foo", "f">, Arg<"Pid">;
 //                    Sets the argument type to eArgTypePid and marks option as
 //                    required (see option_has_arg).
+//  - `OptionalEnumArg`:
 //  - `EnumArg`: Sets the argument type and assigns it a enum holding the valid
 //               values. The enum needs to be a variable in the including code.
 //               Marks the option as required (see option_has_arg).
 //               Example: def foo : Option<"foo", "f">,
 //                          EnumArg<"SortOrder",
 //                          "OptionEnumValues(g_sort_option_enumeration)">;
+//               Use `OptionalEnumArg` for having an option enum argument.
 ////////////////////////////////////////////////////////////////////////////////
 // Field: usage_text
 // Default value: ""
@@ -150,6 +154,13 @@ class EnumArg<string type, string enum>
   string ArgEnum = enum;
 }
 
+// Gives the option an required argument.
+class OptionalEnumArg<string type, string enum> {
+  string ArgType = type;
+  string ArgEnum = enum;
+  bit OptionalArg = 1;
+}
+
 // Sets the available completions for the given option.
 class Completions<list<string> completions> {
   list<string> Completions = completions;




More information about the lldb-commits mailing list