Skip to content

Commit 64becc1

Browse files
committed
[lldb][NFC] Tablegenify alias/regex/history/source/script
(Converting these commands together as they are all simple commands that share the same file). llvm-svn: 366440
1 parent 6d3bb71 commit 64becc1

File tree

2 files changed

+69
-28
lines changed

2 files changed

+69
-28
lines changed

lldb/source/Commands/CommandObjectCommands.cpp

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,8 @@ using namespace lldb_private;
3232
// CommandObjectCommandsSource
3333

3434
static constexpr OptionDefinition g_history_options[] = {
35-
// clang-format off
36-
{ LLDB_OPT_SET_1, false, "count", 'c', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeUnsignedInteger, "How many history commands to print." },
37-
{ LLDB_OPT_SET_1, false, "start-index", 's', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeUnsignedInteger, "Index at which to start printing history commands (or end to mean tail mode)." },
38-
{ LLDB_OPT_SET_1, false, "end-index", 'e', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeUnsignedInteger, "Index at which to stop printing history commands." },
39-
{ LLDB_OPT_SET_2, false, "clear", 'C', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeBoolean, "Clears the current command history." },
40-
// clang-format on
35+
#define LLDB_OPTIONS_history
36+
#include "CommandOptions.inc"
4137
};
4238

4339
class CommandObjectCommandsHistory : public CommandObjectParsed {
@@ -189,11 +185,8 @@ class CommandObjectCommandsHistory : public CommandObjectParsed {
189185
// CommandObjectCommandsSource
190186

191187
static constexpr OptionDefinition g_source_options[] = {
192-
// clang-format off
193-
{ LLDB_OPT_SET_ALL, false, "stop-on-error", 'e', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "If true, stop executing commands on error." },
194-
{ LLDB_OPT_SET_ALL, false, "stop-on-continue", 'c', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "If true, stop executing commands on continue." },
195-
{ LLDB_OPT_SET_ALL, false, "silent-run", 's', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "If true don't echo commands while executing." },
196-
// clang-format on
188+
#define LLDB_OPTIONS_source
189+
#include "CommandOptions.inc"
197190
};
198191

199192
class CommandObjectCommandsSource : public CommandObjectParsed {
@@ -344,10 +337,8 @@ class CommandObjectCommandsSource : public CommandObjectParsed {
344337
// CommandObjectCommandsAlias
345338

346339
static constexpr OptionDefinition g_alias_options[] = {
347-
// clang-format off
348-
{ LLDB_OPT_SET_ALL, false, "help", 'h', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeHelpText, "Help text for this command" },
349-
{ LLDB_OPT_SET_ALL, false, "long-help", 'H', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeHelpText, "Long help text for this command" },
350-
// clang-format on
340+
#define LLDB_OPTIONS_alias
341+
#include "CommandOptions.inc"
351342
};
352343

353344
static const char *g_python_command_instructions =
@@ -912,10 +903,8 @@ class CommandObjectCommandsDelete : public CommandObjectParsed {
912903
// CommandObjectCommandsAddRegex
913904

914905
static constexpr OptionDefinition g_regex_options[] = {
915-
// clang-format off
916-
{ LLDB_OPT_SET_1, false, "help" , 'h', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeNone, "The help text to display for this command." },
917-
{ LLDB_OPT_SET_1, false, "syntax", 's', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeNone, "A syntax string showing the typical usage syntax." },
918-
// clang-format on
906+
#define LLDB_OPTIONS_regex
907+
#include "CommandOptions.inc"
919908
};
920909

921910
#pragma mark CommandObjectCommandsAddRegex
@@ -1387,9 +1376,8 @@ class CommandObjectScriptingObject : public CommandObjectRaw {
13871376
// CommandObjectCommandsScriptImport
13881377

13891378
static constexpr OptionDefinition g_script_import_options[] = {
1390-
// clang-format off
1391-
{ LLDB_OPT_SET_1, false, "allow-reload", 'r', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Allow the script to be loaded even if it was already loaded before. This argument exists for backwards compatibility, but reloading is always allowed, whether you specify it or not." },
1392-
// clang-format on
1379+
#define LLDB_OPTIONS_script_import
1380+
#include "CommandOptions.inc"
13931381
};
13941382

13951383
class CommandObjectCommandsScriptImport : public CommandObjectParsed {
@@ -1521,12 +1509,8 @@ static constexpr OptionEnumValues ScriptSynchroType() {
15211509
}
15221510

15231511
static constexpr OptionDefinition g_script_add_options[] = {
1524-
// clang-format off
1525-
{ LLDB_OPT_SET_1, false, "function", 'f', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePythonFunction, "Name of the Python function to bind to this command name." },
1526-
{ LLDB_OPT_SET_2, false, "class", 'c', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePythonClass, "Name of the Python class to bind to this command name." },
1527-
{ LLDB_OPT_SET_1, false, "help" , 'h', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeHelpText, "The help text to display for this command." },
1528-
{ LLDB_OPT_SET_ALL, false, "synchronicity", 's', OptionParser::eRequiredArgument, nullptr, ScriptSynchroType(), 0, eArgTypeScriptedCommandSynchronicity, "Set the synchronicity of this command's executions with regard to LLDB event system." },
1529-
// clang-format on
1512+
#define LLDB_OPTIONS_script_add
1513+
#include "CommandOptions.inc"
15301514
};
15311515

15321516
class CommandObjectCommandsScriptAdd : public CommandObjectParsed,

lldb/source/Commands/Options.td

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,63 @@ let Command = "breakpoint list" in {
5252
"provided, which prime new targets.">;
5353
}
5454

55+
let Command = "history" in {
56+
def history_count : Option<"count", "c">, Group<1>, Arg<"UnsignedInteger">,
57+
Desc<"How many history commands to print.">;
58+
def history_start_index : Option<"start-index", "s">, Group<1>,
59+
Arg<"UnsignedInteger">, Desc<"Index at which to start printing history "
60+
"commands (or end to mean tail mode).">;
61+
def history_end_index : Option<"end-index", "e">, Group<1>,
62+
Arg<"UnsignedInteger">,
63+
Desc<"Index at which to stop printing history commands.">;
64+
def history_clear : Option<"clear", "C">, Group<2>,
65+
Desc<"Clears the current command history.">;
66+
}
67+
68+
let Command = "source" in {
69+
def source_stop_on_error : Option<"stop-on-error", "e">, Arg<"Boolean">,
70+
Desc<"If true, stop executing commands on error.">;
71+
def source_stop_on_continue : Option<"stop-on-continue", "c">, Arg<"Boolean">,
72+
Desc<"If true, stop executing commands on continue.">;
73+
def source_silent_run : Option<"silent-run", "s">, Arg<"Boolean">,
74+
Desc<"If true don't echo commands while executing.">;
75+
}
76+
77+
let Command = "alias" in {
78+
def alias_help : Option<"help", "h">, Arg<"HelpText">,
79+
Desc<"Help text for this command">;
80+
def alias_long_help : Option<"long-help", "H">, Arg<"HelpText">,
81+
Desc<"Long help text for this command">;
82+
}
83+
84+
let Command = "regex" in {
85+
def regex_help : Option<"help", "h">, Group<1>, Arg<"None">,
86+
Desc<"The help text to display for this command.">;
87+
def regex_syntax : Option<"syntax", "s">, Group<1>, Arg<"None">,
88+
Desc<"A syntax string showing the typical usage syntax.">;
89+
}
90+
91+
let Command = "script import" in {
92+
def script_import_allow_reload : Option<"allow-reload", "r">, Group<1>,
93+
Desc<"Allow the script to be loaded even if it was already loaded before. "
94+
"This argument exists for backwards compatibility, but reloading is always "
95+
"allowed, whether you specify it or not.">;
96+
}
97+
98+
let Command = "script add" in {
99+
def script_add_function : Option<"function", "f">, Group<1>,
100+
Arg<"PythonFunction">,
101+
Desc<"Name of the Python function to bind to this command name.">;
102+
def script_add_class : Option<"class", "c">, Group<2>, Arg<"PythonClass">,
103+
Desc<"Name of the Python class to bind to this command name.">;
104+
def script_add_help : Option<"help", "h">, Group<1>, Arg<"HelpText">,
105+
Desc<"The help text to display for this command.">;
106+
def script_add_synchronicity : Option<"synchronicity", "s">,
107+
EnumArg<"ScriptedCommandSynchronicity", "ScriptSynchroType()">,
108+
Desc<"Set the synchronicity of this command's executions with regard to "
109+
"LLDB event system.">;
110+
}
111+
55112
let Command = "thread backtrace" in {
56113
def thread_backtrace_count : Option<"count", "c">, Group<1>, Arg<"Count">,
57114
Desc<"How many frames to display (-1 for all)">;

0 commit comments

Comments
 (0)