summaryrefslogtreecommitdiffstats
path: root/lldb/source
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/Commands/CMakeLists.txt6
-rw-r--r--lldb/source/Commands/CommandObjectBreakpoint.cpp13
-rw-r--r--lldb/source/Commands/CommandObjectHelp.cpp7
-rw-r--r--lldb/source/Commands/CommandObjectSettings.cpp17
-rw-r--r--lldb/source/Commands/CommandObjectTarget.cpp5
-rw-r--r--lldb/source/Commands/Options.td53
-rw-r--r--lldb/source/Commands/OptionsBase.td62
7 files changed, 135 insertions, 28 deletions
diff --git a/lldb/source/Commands/CMakeLists.txt b/lldb/source/Commands/CMakeLists.txt
index d7fd47af026..f3f96af7dab 100644
--- a/lldb/source/Commands/CMakeLists.txt
+++ b/lldb/source/Commands/CMakeLists.txt
@@ -1,3 +1,7 @@
+lldb_tablegen(Options.inc -gen-lldb-option-defs
+ SOURCE Options.td
+ TARGET LLDBOptionsGen)
+
add_lldb_library(lldbCommands
CommandCompletions.cpp
CommandObjectApropos.cpp
@@ -45,3 +49,5 @@ add_lldb_library(lldbCommands
LINK_COMPONENTS
Support
)
+
+add_dependencies(lldbCommands LLDBOptionsGen)
diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp
index a4f558e7f81..a661ffc6251 100644
--- a/lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -1246,15 +1246,10 @@ protected:
#pragma mark List::CommandOptions
static constexpr OptionDefinition g_breakpoint_list_options[] = {
- // clang-format off
- { LLDB_OPT_SET_ALL, false, "internal", 'i', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Show debugger internal breakpoints" },
- { LLDB_OPT_SET_1, false, "brief", 'b', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Give a brief description of the breakpoint (no location info)." },
- // FIXME: We need to add an "internal" command, and then add this sort of thing to it.
- // But I need to see it for now, and don't want to wait.
- { LLDB_OPT_SET_2, false, "full", 'f', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Give a full description of the breakpoint and its locations." },
- { LLDB_OPT_SET_3, false, "verbose", 'v', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Explain everything we know about the breakpoint (for debugging debugger bugs)." },
- { LLDB_OPT_SET_ALL, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "List Dummy breakpoints - i.e. breakpoints set before a file is provided, which prime new targets." },
- // clang-format on
+ // FIXME: We need to add an "internal" command, and then add this sort of
+ // thing to it. But I need to see it for now, and don't want to wait.
+#define LLDB_OPTIONS_breakpoint_list
+#include "Options.inc"
};
#pragma mark List
diff --git a/lldb/source/Commands/CommandObjectHelp.cpp b/lldb/source/Commands/CommandObjectHelp.cpp
index 4e663c797eb..ad53e03121f 100644
--- a/lldb/source/Commands/CommandObjectHelp.cpp
+++ b/lldb/source/Commands/CommandObjectHelp.cpp
@@ -66,11 +66,8 @@ CommandObjectHelp::CommandObjectHelp(CommandInterpreter &interpreter)
CommandObjectHelp::~CommandObjectHelp() = default;
static constexpr OptionDefinition g_help_options[] = {
- // clang-format off
- {LLDB_OPT_SET_ALL, false, "hide-aliases", 'a', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Hide aliases in the command list."},
- {LLDB_OPT_SET_ALL, false, "hide-user-commands", 'u', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Hide user-defined commands from the list."},
- {LLDB_OPT_SET_ALL, false, "show-hidden-commands", 'h', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Include commands prefixed with an underscore."},
- // clang-format on
+#define LLDB_OPTIONS_help
+#include "Options.inc"
};
llvm::ArrayRef<OptionDefinition>
diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp
index e7e72de5a7e..057c5de619c 100644
--- a/lldb/source/Commands/CommandObjectSettings.cpp
+++ b/lldb/source/Commands/CommandObjectSettings.cpp
@@ -22,10 +22,8 @@ using namespace lldb_private;
// CommandObjectSettingsSet
static constexpr OptionDefinition g_settings_set_options[] = {
- // clang-format off
- { LLDB_OPT_SET_2, false, "global", 'g', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Apply the new value to the global default value." },
- { LLDB_OPT_SET_2, false, "force", 'f', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Force an empty value to be accepted as the default." }
- // clang-format on
+#define LLDB_OPTIONS_settings_set
+#include "Options.inc"
};
class CommandObjectSettingsSet : public CommandObjectRaw {
@@ -313,10 +311,8 @@ protected:
// CommandObjectSettingsWrite -- Write settings to file
static constexpr OptionDefinition g_settings_write_options[] = {
- // clang-format off
- { LLDB_OPT_SET_ALL, true, "file", 'f', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eDiskFileCompletion, eArgTypeFilename, "The file into which to write the settings." },
- { LLDB_OPT_SET_ALL, false, "append",'a', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Append to saved settings file if it exists."},
- // clang-format on
+#define LLDB_OPTIONS_settings_write
+#include "Options.inc"
};
class CommandObjectSettingsWrite : public CommandObjectParsed {
@@ -438,9 +434,8 @@ private:
// CommandObjectSettingsRead -- Read settings from file
static constexpr OptionDefinition g_settings_read_options[] = {
- // clang-format off
- {LLDB_OPT_SET_ALL, true, "file",'f', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eDiskFileCompletion, eArgTypeFilename, "The file from which to read the breakpoints." },
- // clang-format on
+#define LLDB_OPTIONS_settings_read
+#include "Options.inc"
};
class CommandObjectSettingsRead : public CommandObjectParsed {
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index 764461ee92b..e8720157ab4 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -1967,9 +1967,8 @@ static constexpr OptionEnumValueElement g_sort_option_enumeration[] = {
{eSortOrderByName, "name", "Sort output by symbol name."} };
static constexpr OptionDefinition g_target_modules_dump_symtab_options[] = {
- // clang-format off
- { LLDB_OPT_SET_1, false, "sort", 's', OptionParser::eRequiredArgument, nullptr, OptionEnumValues(g_sort_option_enumeration), 0, eArgTypeSortOrder, "Supply a sort order when dumping the symbol table." }
- // clang-format on
+#define LLDB_OPTIONS_target_modules_dump_symtab
+#include "Options.inc"
};
class CommandObjectTargetModulesDumpSymtab
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
new file mode 100644
index 00000000000..1f4c09c3860
--- /dev/null
+++ b/lldb/source/Commands/Options.td
@@ -0,0 +1,53 @@
+include "OptionsBase.td"
+
+let Command = "target modules dump symtab" in {
+ def tm_sort : Option<"sort", "s">, Group<1>,
+ Desc<"Supply a sort order when dumping the symbol table.">,
+ EnumArg<"SortOrder", "OptionEnumValues(g_sort_option_enumeration)">;
+}
+
+let Command = "help" in {
+ def help_hide_aliases : Option<"hide-aliases", "a">,
+ Desc<"Hide aliases in the command list.">;
+ def help_hide_user : Option<"hide-user-commands", "u">,
+ Desc<"Hide user-defined commands from the list.">;
+ def help_show_hidden : Option<"show-hidden-commands", "h">,
+ Desc<"Include commands prefixed with an underscore.">;
+}
+
+let Command = "settings set" in {
+ def setset_global : Option<"global", "g">, Arg<"Filename">,
+ Completion<"DiskFile">,
+ Desc<"Apply the new value to the global default value.">;
+ def setset_force : Option<"force", "f">,
+ Desc<"Force an empty value to be accepted as the default.">;
+}
+
+let Command = "settings write" in {
+ def setwrite_file : Option<"file", "f">, Required, Arg<"Filename">,
+ Completion<"DiskFile">,
+ Desc<"The file into which to write the settings.">;
+ def setwrite_append : Option<"append", "a">,
+ Desc<"Append to saved settings file if it exists.">;
+}
+
+let Command = "settings read" in {
+ def setread_file : Option<"file", "f">, Required, Arg<"Filename">,
+ Completion<"DiskFile">,
+ Desc<"The file from which to read the settings.">;
+}
+
+let Command = "breakpoint list" in {
+ def blist_internal : Option<"internal", "i">,
+ Desc<"Show debugger internal breakpoints">;
+ def blist_brief : Option<"brief", "b">, Group<1>,
+ Desc<"Give a brief description of the breakpoint (no location info).">;
+ def blist_full : Option<"full", "f">, Group<2>,
+ Desc<"Give a full description of the breakpoint and its locations.">;
+ def blist_verbose : Option<"verbose", "v">, Group<3>,
+ Desc<"Explain everything we know about the breakpoint (for debugging "
+ "debugger bugs).">;
+ def blist_dummy_bp : Option<"dummy-breakpoints", "D">,
+ Desc<"List Dummy breakpoints - i.e. breakpoints set before a file is "
+ "provided, which prime new targets.">;
+}
diff --git a/lldb/source/Commands/OptionsBase.td b/lldb/source/Commands/OptionsBase.td
new file mode 100644
index 00000000000..c4a326fbaf5
--- /dev/null
+++ b/lldb/source/Commands/OptionsBase.td
@@ -0,0 +1,62 @@
+// Base class for all options.
+class Option<string fullname, string shortname> {
+ string FullName = fullname;
+ string ShortName = shortname;
+ // The full associated command/subcommand such as "settings set".
+ string Command;
+}
+
+// Moves the option into a list of option groups.
+class Groups<list<int> groups> {
+ list<int> Groups = groups;
+}
+
+// Moves the option in all option groups in a range.
+// Start and end values are inclusive.
+class GroupRange<int start, int end> {
+ int GroupStart = start;
+ int GroupEnd = end;
+}
+// Moves the option in a single option group.
+class Group<int group> {
+ int GroupStart = group;
+ int GroupEnd = group;
+}
+
+// Sets the description for the option that should be
+// displayed to the user.
+class Desc<string description> {
+ string Description = description;
+}
+
+// Marks the option as required when calling the
+// associated command.
+class Required {
+ bit Required = 1;
+}
+
+// Gives the option an optional argument.
+class OptionalArg<string type> {
+ string ArgType = type;
+ bit OptionalArg = 1;
+}
+
+// Gives the option an required argument.
+class Arg<string type> {
+ string ArgType = type;
+}
+
+// Gives the option an required argument.
+class EnumArg<string type, string enum> {
+ string ArgType = type;
+ string ArgEnum = enum;
+}
+
+// Sets the available completions for the given option.
+class Completions<list<string> completions> {
+ list<string> Completions = completions;
+}
+// Sets a single completion for the given option.
+class Completion<string completion> {
+ list<string> Completions = [completion];
+}
OpenPOWER on IntegriCloud