JDevlieghere created this revision.
JDevlieghere added a reviewer: jingham.
Herald added a project: All.
JDevlieghere requested review of this revision.
Refactor command option enum values so that there's a table that connects the
CommandArgumentType enumeration with the corresponding enum values. This has
two benefits:
- We guarantee that two options that use the same argument type have the same
accepted values.
- We can print the enum values and their description in the help output (not
part of this patch).
https://reviews.llvm.org/D129703
Files:
lldb/include/lldb/Interpreter/CommandObject.h
lldb/include/lldb/Interpreter/CommandOptionEnumValues.h
lldb/include/lldb/Target/Target.h
lldb/include/lldb/lldb-enumerations.h
lldb/include/lldb/lldb-private-enumerations.h
lldb/source/Commands/CommandObjectBreakpoint.cpp
lldb/source/Commands/CommandObjectBreakpointCommand.cpp
lldb/source/Commands/CommandObjectCommands.cpp
lldb/source/Commands/CommandObjectDisassemble.cpp
lldb/source/Commands/CommandObjectExpression.cpp
lldb/source/Commands/CommandObjectFrame.cpp
lldb/source/Commands/CommandObjectGUI.cpp
lldb/source/Commands/CommandObjectHelp.cpp
lldb/source/Commands/CommandObjectLog.cpp
lldb/source/Commands/CommandObjectMemory.cpp
lldb/source/Commands/CommandObjectMemoryTag.cpp
lldb/source/Commands/CommandObjectPlatform.cpp
lldb/source/Commands/CommandObjectProcess.cpp
lldb/source/Commands/CommandObjectRegister.cpp
lldb/source/Commands/CommandObjectReproducer.cpp
lldb/source/Commands/CommandObjectScript.cpp
lldb/source/Commands/CommandObjectSession.cpp
lldb/source/Commands/CommandObjectSettings.cpp
lldb/source/Commands/CommandObjectSource.cpp
lldb/source/Commands/CommandObjectStats.cpp
lldb/source/Commands/CommandObjectTarget.cpp
lldb/source/Commands/CommandObjectThread.cpp
lldb/source/Commands/CommandObjectTrace.cpp
lldb/source/Commands/CommandObjectType.cpp
lldb/source/Commands/CommandObjectWatchpoint.cpp
lldb/source/Commands/CommandObjectWatchpointCommand.cpp
lldb/source/Commands/CommandOptionsProcessLaunch.cpp
lldb/source/Commands/Options.td
lldb/source/Commands/OptionsBase.td
lldb/source/Interpreter/CommandObject.cpp
lldb/source/Plugins/TraceExporter/ctf/CommandObjectThreadTraceExportCTF.cpp
lldb/utils/TableGen/LLDBOptionDefEmitter.cpp
Index: lldb/utils/TableGen/LLDBOptionDefEmitter.cpp
===================================================================
--- lldb/utils/TableGen/LLDBOptionDefEmitter.cpp
+++ lldb/utils/TableGen/LLDBOptionDefEmitter.cpp
@@ -31,7 +31,6 @@
std::string ArgType;
bool OptionalArg = false;
std::string Validator;
- std::string ArgEnum;
std::vector<StringRef> Completions;
std::string Description;
@@ -65,9 +64,6 @@
if (Option->getValue("Validator"))
Validator = std::string(Option->getValueAsString("Validator"));
- if (Option->getValue("ArgEnum"))
- ArgEnum = std::string(Option->getValueAsString("ArgEnum"));
-
if (Option->getValue("Completions"))
Completions = Option->getValueAsListOfStrings("Completions");
@@ -114,8 +110,9 @@
OS << "nullptr";
OS << ", ";
- if (!O.ArgEnum.empty())
- OS << O.ArgEnum;
+ if (!O.ArgType.empty())
+ OS << "g_argument_type_enum_values[eArgType" << O.ArgType
+ << "].enum_values";
else
OS << "{}";
OS << ", ";
Index: lldb/source/Plugins/TraceExporter/ctf/CommandObjectThreadTraceExportCTF.cpp
===================================================================
--- lldb/source/Plugins/TraceExporter/ctf/CommandObjectThreadTraceExportCTF.cpp
+++ lldb/source/Plugins/TraceExporter/ctf/CommandObjectThreadTraceExportCTF.cpp
@@ -10,6 +10,7 @@
#include "../common/TraceHTR.h"
#include "lldb/Host/OptionParser.h"
+#include "lldb/Interpreter/CommandOptionEnumValues.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Trace.h"
Index: lldb/source/Interpreter/CommandObject.cpp
===================================================================
--- lldb/source/Interpreter/CommandObject.cpp
+++ lldb/source/Interpreter/CommandObject.cpp
@@ -1056,13 +1056,14 @@
{ eArgTypeClassName, "class-name", CommandCompletions::eNoCompletion, { nullptr, false }, "Then name of a class from the debug information in the program." },
{ eArgTypeCommandName, "cmd-name", CommandCompletions::eNoCompletion, { nullptr, false }, "A debugger command (may be multiple words), without any options or arguments." },
{ eArgTypeCount, "count", CommandCompletions::eNoCompletion, { nullptr, false }, "An unsigned integer." },
+ { eArgTypeDescriptionVerbosity, "description-verbosity", CommandCompletions::eNoCompletion, { nullptr, false }, "How verbose the output of 'po' should be." },
{ eArgTypeDirectoryName, "directory", CommandCompletions::eDiskDirectoryCompletion, { nullptr, false }, "A directory name." },
{ eArgTypeDisassemblyFlavor, "disassembly-flavor", CommandCompletions::eDisassemblyFlavorCompletion, { nullptr, false }, "A disassembly flavor recognized by your disassembly plugin. Currently the only valid options are \"att\" and \"intel\" for Intel targets" },
- { eArgTypeDescriptionVerbosity, "description-verbosity", CommandCompletions::eNoCompletion, { nullptr, false }, "How verbose the output of 'po' should be." },
{ eArgTypeEndAddress, "end-address", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
{ eArgTypeExpression, "expr", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
{ eArgTypeExpressionPath, "expr-path", CommandCompletions::eNoCompletion, { ExprPathHelpTextCallback, true }, nullptr },
{ eArgTypeExprFormat, "expression-format", CommandCompletions::eNoCompletion, { nullptr, false }, "[ [bool|b] | [bin] | [char|c] | [oct|o] | [dec|i|d|u] | [hex|x] | [float|f] | [cstr|s] ]" },
+ { eArgTypeFileLineColumn, "linespec", CommandCompletions::eNoCompletion, { nullptr, false }, "A source specifier in the form file:line[:column]" },
{ eArgTypeFilename, "filename", CommandCompletions::eDiskFileCompletion, { nullptr, false }, "The name of a file (can include path)." },
{ eArgTypeFormat, "format", CommandCompletions::eNoCompletion, { FormatHelpTextCallback, true }, nullptr },
{ eArgTypeFrameIndex, "frame-index", CommandCompletions::eFrameIndexCompletion, { nullptr, false }, "Index into a thread's list of frames." },
@@ -1074,7 +1075,6 @@
{ eArgTypeIndex, "index", CommandCompletions::eNoCompletion, { nullptr, false }, "An index into a list." },
{ eArgTypeLanguage, "source-language", CommandCompletions::eTypeLanguageCompletion, { LanguageTypeHelpTextCallback, true }, nullptr },
{ eArgTypeLineNum, "linenum", CommandCompletions::eNoCompletion, { nullptr, false }, "Line number in a source file." },
- { eArgTypeFileLineColumn, "linespec", CommandCompletions::eNoCompletion, { nullptr, false }, "A source specifier in the form file:line[:column]" },
{ eArgTypeLogCategory, "log-category", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a category within a log channel, e.g. all (try \"log list\" to see a list of all channels and their categories." },
{ eArgTypeLogChannel, "log-channel", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a log channel, e.g. process.gdb-remote (try \"log list\" to see a list of all channels and their categories)." },
{ eArgTypeMethod, "method", CommandCompletions::eNoCompletion, { nullptr, false }, "A C++ method name." },
@@ -1137,7 +1137,9 @@
{ eArgTypeRecognizerID, "frame-recognizer-id", CommandCompletions::eNoCompletion, { nullptr, false }, "The ID for a stack frame recognizer." },
{ eArgTypeConnectURL, "process-connect-url", CommandCompletions::eNoCompletion, { nullptr, false }, "A URL-style specification for a remote connection." },
{ eArgTypeTargetID, "target-id", CommandCompletions::eNoCompletion, { nullptr, false }, "The index ID for an lldb Target." },
- { eArgTypeStopHookID, "stop-hook-id", CommandCompletions::eNoCompletion, { nullptr, false }, "The ID you receive when you create a stop-hook." }
+ { eArgTypeStopHookID, "stop-hook-id", CommandCompletions::eNoCompletion, { nullptr, false }, "The ID you receive when you create a stop-hook." },
+ { eArgTypeReproducerProvider, "reproducer-provider", CommandCompletions::eNoCompletion, { nullptr, false }, "The reproducer provider." },
+ { eArgTypeReproducerSignal, "reproducer-signal", CommandCompletions::eNoCompletion, { nullptr, false }, "The signal used to emulate a reproducer crash." },
// clang-format on
};
Index: lldb/source/Commands/OptionsBase.td
===================================================================
--- lldb/source/Commands/OptionsBase.td
+++ lldb/source/Commands/OptionsBase.td
@@ -151,15 +151,13 @@
}
// Gives the option an required argument.
-class EnumArg<string type, string enum> {
+class EnumArg<string type> {
string ArgType = type;
- string ArgEnum = enum;
}
// Gives the option an required argument.
-class OptionalEnumArg<string type, string enum> {
+class OptionalEnumArg<string type> {
string ArgType = type;
- string ArgEnum = enum;
bit OptionalArg = 1;
}
Index: lldb/source/Commands/Options.td
===================================================================
--- lldb/source/Commands/Options.td
+++ lldb/source/Commands/Options.td
@@ -3,7 +3,7 @@
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)">;
+ EnumArg<"SortOrder">;
def tm_smn : Option<"show-mangled-names", "m">, Group<1>,
Desc<"Do not demangle symbol names before showing them.">;
}
@@ -282,7 +282,7 @@
Arg<"Boolean">, Desc<"Specify whether breakpoint command execution should "
"terminate on error.">;
def breakpoint_add_script_type : Option<"script-type", "s">,
- EnumArg<"None", "ScriptOptionEnum()">,
+ EnumArg<"ScriptLang">,
Desc<"Specify the language for the commands - if none is specified, the "
"lldb command interpreter will be used.">;
def breakpoint_add_dummy_breakpoints : Option<"dummy-breakpoints", "D">,
@@ -370,7 +370,7 @@
"automatically applied to the expression.">;
def expression_options_description_verbosity :
Option<"description-verbosity", "v">, Group<1>,
- OptionalEnumArg<"DescriptionVerbosity", "DescriptionVerbosityTypes()">,
+ OptionalEnumArg<"DescriptionVerbosity">,
Desc<"How verbose should the output of this expression be, if the object "
"description is asked for.">;
def expression_options_top_level : Option<"top-level", "p">, Groups<[1,2]>,
@@ -437,7 +437,7 @@
def log_file : Option<"file", "f">, Group<1>, Arg<"Filename">,
Desc<"Set the destination file to log to.">;
def log_handler : Option<"log-handler", "h">, Group<1>,
- EnumArg<"LogHandler", "LogHandlerType()">, Desc<"Specify a log handler which determines where log messages are written.">;
+ EnumArg<"LogHandler">, Desc<"Specify a log handler which determines where log messages are written.">;
def log_buffer_size : Option<"buffer", "b">, Group<1>, Arg<"UnsignedInteger">,
Desc<"Set the log to be buffered, using the specified buffer size, if supported by the log handler.">;
def log_verbose : Option<"verbose", "v">, Group<1>,
@@ -468,7 +468,7 @@
let Command = "reproducer dump" in {
def reproducer_provider : Option<"provider", "p">, Group<1>,
- EnumArg<"None", "ReproducerProviderType()">,
+ EnumArg<"ReproducerProvider">,
Required, Desc<"The reproducer provider to dump.">;
def reproducer_file : Option<"file", "f">, Group<1>, Arg<"Filename">,
Desc<"The reproducer path. If a reproducer is replayed and no path is "
@@ -483,7 +483,7 @@
let Command = "reproducer xcrash" in {
def reproducer_signal : Option<"signal", "s">, Group<1>,
- EnumArg<"None", "ReproducerSignalType()">,
+ EnumArg<"ReproducerSignal">,
Required, Desc<"The signal to crash the debugger.">;
}
@@ -781,7 +781,7 @@
let Command = "process save_core" in {
def process_save_core_style : Option<"style", "s">, Group<1>,
- EnumArg<"SaveCoreStyle", "SaveCoreStyles()">, Desc<"Request a specific style "
+ EnumArg<"SaveCoreStyle">, Desc<"Request a specific style "
"of corefile to be saved.">;
def process_save_core_plugin_name : Option<"plugin-name", "p">,
OptionalArg<"Plugin">, Desc<"Specify a plugin name to create the core file."
@@ -820,7 +820,7 @@
def script_add_overwrite : Option<"overwrite", "o">, Groups<[1,2]>,
Desc<"Overwrite an existing command at this node.">;
def script_add_synchronicity : Option<"synchronicity", "s">,
- EnumArg<"ScriptedCommandSynchronicity", "ScriptSynchroType()">,
+ EnumArg<"ScriptedCommandSynchronicity">,
Desc<"Set the synchronicity of this command's executions with regard to "
"LLDB event system.">;
}
@@ -836,7 +836,7 @@
let Command = "script" in {
def script_language : Option<"language", "l">,
- EnumArg<"ScriptLang", "ScriptOptionEnum()">, Desc<"Specify the scripting "
+ EnumArg<"ScriptLang">, Desc<"Specify the scripting "
" language. If none is specific the default scripting language is used.">;
}
@@ -889,7 +889,7 @@
let Command = "target dependents" in {
def dependents_no_dependents : Option<"no-dependents", "d">, Group<1>,
- OptionalEnumArg<"Value", "OptionEnumValues(g_dependents_enumeration)">,
+ OptionalEnumArg<"Value">,
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 "
@@ -1062,7 +1062,7 @@
" block. This is particularly use in conjunction with --step-target to"
" step through a complex calling sequence.">;
def thread_step_scope_run_mode : Option<"run-mode", "m">, Group<1>,
- EnumArg<"RunMode", "TriRunningModes()">, Desc<"Determine how to run other "
+ EnumArg<"RunMode">, Desc<"Determine how to run other "
"threads while stepping the current thread.">;
def thread_step_scope_step_over_regexp : Option<"step-over-regexp", "r">,
Group<1>, Arg<"RegularExpression">, Desc<"A regular expression that defines "
@@ -1078,7 +1078,7 @@
def thread_until_thread : Option<"thread", "t">, Group<1>, Arg<"ThreadIndex">,
Desc<"Thread index for the thread for until operation">;
def thread_until_run_mode : Option<"run-mode", "m">, Group<1>,
- EnumArg<"RunMode", "DuoRunningModes()">, Desc<"Determine how to run other "
+ EnumArg<"RunMode">, Desc<"Determine how to run other "
"threads while stepping this one">;
def thread_until_address : Option<"address", "a">, Group<1>,
Arg<"AddressOrExpression">, Desc<"Run until we reach the specified address, "
@@ -1339,7 +1339,7 @@
Arg<"Boolean">, Desc<"Specify whether watchpoint command execution should "
"terminate on error.">;
def watchpoint_command_add_script_type : Option<"script-type", "s">,
- EnumArg<"None", "ScriptOptionEnum()">, Desc<"Specify the language for the"
+ EnumArg<"ScriptLang">, Desc<"Specify the language for the"
" commands - if none is specified, the lldb command interpreter will be "
"used.">;
def watchpoint_command_add_python_function : Option<"python-function", "F">,
Index: lldb/source/Commands/CommandOptionsProcessLaunch.cpp
===================================================================
--- lldb/source/Commands/CommandOptionsProcessLaunch.cpp
+++ lldb/source/Commands/CommandOptionsProcessLaunch.cpp
@@ -12,6 +12,8 @@
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandCompletions.h"
+#include "lldb/Interpreter/CommandObject.h"
+#include "lldb/Interpreter/CommandOptionEnumValues.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Platform.h"
Index: lldb/source/Commands/CommandObjectWatchpointCommand.cpp
===================================================================
--- lldb/source/Commands/CommandObjectWatchpointCommand.cpp
+++ lldb/source/Commands/CommandObjectWatchpointCommand.cpp
@@ -15,6 +15,7 @@
#include "lldb/Core/IOHandler.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/CommandOptionEnumValues.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Target/Target.h"
@@ -22,36 +23,6 @@
using namespace lldb;
using namespace lldb_private;
-// FIXME: "script-type" needs to have its contents determined dynamically, so
-// somebody can add a new scripting language to lldb and have it pickable here
-// without having to change this enumeration by hand and rebuild lldb proper.
-static constexpr OptionEnumValueElement g_script_option_enumeration[] = {
- {
- eScriptLanguageNone,
- "command",
- "Commands are in the lldb command interpreter language",
- },
- {
- eScriptLanguagePython,
- "python",
- "Commands are in the Python language.",
- },
- {
- eScriptLanguageLua,
- "lua",
- "Commands are in the Lua language.",
- },
- {
- eSortOrderByName,
- "default-script",
- "Commands are in the default scripting language.",
- },
-};
-
-static constexpr OptionEnumValues ScriptOptionEnum() {
- return OptionEnumValues(g_script_option_enumeration);
-}
-
#define LLDB_OPTIONS_watchpoint_command_add
#include "CommandOptions.inc"
Index: lldb/source/Commands/CommandObjectWatchpoint.cpp
===================================================================
--- lldb/source/Commands/CommandObjectWatchpoint.cpp
+++ lldb/source/Commands/CommandObjectWatchpoint.cpp
@@ -18,6 +18,7 @@
#include "lldb/Core/ValueObject.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/CommandOptionEnumValues.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Symbol/Variable.h"
#include "lldb/Symbol/VariableList.h"
Index: lldb/source/Commands/CommandObjectType.cpp
===================================================================
--- lldb/source/Commands/CommandObjectType.cpp
+++ lldb/source/Commands/CommandObjectType.cpp
@@ -15,6 +15,7 @@
#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandObject.h"
+#include "lldb/Interpreter/CommandOptionEnumValues.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/OptionGroupFormat.h"
Index: lldb/source/Commands/CommandObjectTrace.cpp
===================================================================
--- lldb/source/Commands/CommandObjectTrace.cpp
+++ lldb/source/Commands/CommandObjectTrace.cpp
@@ -16,6 +16,7 @@
#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandObject.h"
+#include "lldb/Interpreter/CommandOptionEnumValues.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/OptionGroupFormat.h"
Index: lldb/source/Commands/CommandObjectThread.cpp
===================================================================
--- lldb/source/Commands/CommandObjectThread.cpp
+++ lldb/source/Commands/CommandObjectThread.cpp
@@ -17,6 +17,7 @@
#include "lldb/Core/ValueObject.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/CommandOptionEnumValues.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/OptionGroupPythonClassWithDict.h"
@@ -239,16 +240,6 @@
enum StepScope { eStepScopeSource, eStepScopeInstruction };
-static constexpr OptionEnumValueElement g_tri_running_mode[] = {
- {eOnlyThisThread, "this-thread", "Run only this thread"},
- {eAllThreads, "all-threads", "Run all threads"},
- {eOnlyDuringStepping, "while-stepping",
- "Run only this thread while stepping"}};
-
-static constexpr OptionEnumValues TriRunningModes() {
- return OptionEnumValues(g_tri_running_mode);
-}
-
#define LLDB_OPTIONS_thread_step_scope
#include "CommandOptions.inc"
@@ -813,14 +804,6 @@
// CommandObjectThreadUntil
-static constexpr OptionEnumValueElement g_duo_running_mode[] = {
- {eOnlyThisThread, "this-thread", "Run only this thread"},
- {eAllThreads, "all-threads", "Run all threads"}};
-
-static constexpr OptionEnumValues DuoRunningModes() {
- return OptionEnumValues(g_duo_running_mode);
-}
-
#define LLDB_OPTIONS_thread_until
#include "CommandOptions.inc"
Index: lldb/source/Commands/CommandObjectTarget.cpp
===================================================================
--- lldb/source/Commands/CommandObjectTarget.cpp
+++ lldb/source/Commands/CommandObjectTarget.cpp
@@ -17,6 +17,7 @@
#include "lldb/DataFormatters/ValueObjectPrinter.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/CommandOptionEnumValues.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/OptionGroupArchitecture.h"
@@ -136,26 +137,6 @@
return num_targets;
}
-// Note that the negation in the argument name causes a slightly confusing
-// mapping of the enum values.
-static constexpr OptionEnumValueElement g_dependents_enumeration[] = {
- {
- eLoadDependentsDefault,
- "default",
- "Only load dependents when the target is an executable.",
- },
- {
- eLoadDependentsNo,
- "true",
- "Don't load dependents, even if the target is an executable.",
- },
- {
- eLoadDependentsYes,
- "false",
- "Load dependents, even if the target is not an executable.",
- },
-};
-
#define LLDB_OPTIONS_target_dependents
#include "CommandOptions.inc"
@@ -1917,26 +1898,6 @@
}
};
-#pragma mark CommandObjectTargetModulesDumpSymtab
-
-static constexpr OptionEnumValueElement g_sort_option_enumeration[] = {
- {
- eSortOrderNone,
- "none",
- "No sorting, use the original symbol table order.",
- },
- {
- eSortOrderByAddress,
- "address",
- "Sort output by symbol address.",
- },
- {
- eSortOrderByName,
- "name",
- "Sort output by symbol name.",
- },
-};
-
#define LLDB_OPTIONS_target_modules_dump_symtab
#include "CommandOptions.inc"
Index: lldb/source/Commands/CommandObjectStats.cpp
===================================================================
--- lldb/source/Commands/CommandObjectStats.cpp
+++ lldb/source/Commands/CommandObjectStats.cpp
@@ -9,6 +9,7 @@
#include "CommandObjectStats.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Host/OptionParser.h"
+#include "lldb/Interpreter/CommandOptionEnumValues.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Target/Target.h"
Index: lldb/source/Commands/CommandObjectSource.cpp
===================================================================
--- lldb/source/Commands/CommandObjectSource.cpp
+++ lldb/source/Commands/CommandObjectSource.cpp
@@ -14,6 +14,7 @@
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/SourceManager.h"
#include "lldb/Host/OptionParser.h"
+#include "lldb/Interpreter/CommandOptionEnumValues.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/OptionValueFileColonLine.h"
Index: lldb/source/Commands/CommandObjectSettings.cpp
===================================================================
--- lldb/source/Commands/CommandObjectSettings.cpp
+++ lldb/source/Commands/CommandObjectSettings.cpp
@@ -13,6 +13,7 @@
#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandCompletions.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/CommandOptionEnumValues.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionValueProperties.h"
Index: lldb/source/Commands/CommandObjectSession.cpp
===================================================================
--- lldb/source/Commands/CommandObjectSession.cpp
+++ lldb/source/Commands/CommandObjectSession.cpp
@@ -1,6 +1,7 @@
#include "CommandObjectSession.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/CommandOptionEnumValues.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/OptionValue.h"
Index: lldb/source/Commands/CommandObjectScript.cpp
===================================================================
--- lldb/source/Commands/CommandObjectScript.cpp
+++ lldb/source/Commands/CommandObjectScript.cpp
@@ -12,6 +12,7 @@
#include "lldb/Host/Config.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/CommandOptionEnumValues.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
@@ -20,28 +21,6 @@
using namespace lldb;
using namespace lldb_private;
-static constexpr OptionEnumValueElement g_script_option_enumeration[] = {
- {
- eScriptLanguagePython,
- "python",
- "Python",
- },
- {
- eScriptLanguageLua,
- "lua",
- "Lua",
- },
- {
- eScriptLanguageNone,
- "default",
- "The default scripting language.",
- },
-};
-
-static constexpr OptionEnumValues ScriptOptionEnum() {
- return OptionEnumValues(g_script_option_enumeration);
-}
-
#define LLDB_OPTIONS_script
#include "CommandOptions.inc"
Index: lldb/source/Commands/CommandObjectReproducer.cpp
===================================================================
--- lldb/source/Commands/CommandObjectReproducer.cpp
+++ lldb/source/Commands/CommandObjectReproducer.cpp
@@ -11,6 +11,7 @@
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/CommandOptionEnumValues.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Utility/GDBRemote.h"
@@ -24,95 +25,9 @@
using namespace lldb_private;
using namespace lldb_private::repro;
-enum ReproducerProvider {
- eReproducerProviderCommands,
- eReproducerProviderFiles,
- eReproducerProviderSymbolFiles,
- eReproducerProviderGDB,
- eReproducerProviderProcessInfo,
- eReproducerProviderVersion,
- eReproducerProviderWorkingDirectory,
- eReproducerProviderHomeDirectory,
- eReproducerProviderNone
-};
-
-static constexpr OptionEnumValueElement g_reproducer_provider_type[] = {
- {
- eReproducerProviderCommands,
- "commands",
- "Command Interpreter Commands",
- },
- {
- eReproducerProviderFiles,
- "files",
- "Files",
- },
- {
- eReproducerProviderSymbolFiles,
- "symbol-files",
- "Symbol Files",
- },
- {
- eReproducerProviderGDB,
- "gdb",
- "GDB Remote Packets",
- },
- {
- eReproducerProviderProcessInfo,
- "processes",
- "Process Info",
- },
- {
- eReproducerProviderVersion,
- "version",
- "Version",
- },
- {
- eReproducerProviderWorkingDirectory,
- "cwd",
- "Working Directory",
- },
- {
- eReproducerProviderHomeDirectory,
- "home",
- "Home Directory",
- },
- {
- eReproducerProviderNone,
- "none",
- "None",
- },
-};
-
-static constexpr OptionEnumValues ReproducerProviderType() {
- return OptionEnumValues(g_reproducer_provider_type);
-}
-
#define LLDB_OPTIONS_reproducer_dump
#include "CommandOptions.inc"
-enum ReproducerCrashSignal {
- eReproducerCrashSigill,
- eReproducerCrashSigsegv,
-};
-
-static constexpr OptionEnumValueElement g_reproducer_signaltype[] = {
- {
- eReproducerCrashSigill,
- "SIGILL",
- "Illegal instruction",
- },
- {
- eReproducerCrashSigsegv,
- "SIGSEGV",
- "Segmentation fault",
- },
-};
-
-static constexpr OptionEnumValues ReproducerSignalType() {
- return OptionEnumValues(g_reproducer_signaltype);
-}
-
#define LLDB_OPTIONS_reproducer_xcrash
#include "CommandOptions.inc"
Index: lldb/source/Commands/CommandObjectRegister.cpp
===================================================================
--- lldb/source/Commands/CommandObjectRegister.cpp
+++ lldb/source/Commands/CommandObjectRegister.cpp
@@ -10,6 +10,7 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/DumpRegisterValue.h"
#include "lldb/Host/OptionParser.h"
+#include "lldb/Interpreter/CommandOptionEnumValues.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionGroupFormat.h"
#include "lldb/Interpreter/OptionValueArray.h"
Index: lldb/source/Commands/CommandObjectProcess.cpp
===================================================================
--- lldb/source/Commands/CommandObjectProcess.cpp
+++ lldb/source/Commands/CommandObjectProcess.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "CommandObjectProcess.h"
-#include "CommandObjectTrace.h"
#include "CommandObjectBreakpoint.h"
+#include "CommandObjectTrace.h"
#include "CommandOptionsProcessLaunch.h"
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointIDList.h"
@@ -19,6 +19,7 @@
#include "lldb/Core/PluginManager.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/CommandOptionEnumValues.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/OptionGroupPythonClassWithDict.h"
@@ -1332,20 +1333,6 @@
}
};
-// CommandObjectProcessSaveCore
-#pragma mark CommandObjectProcessSaveCore
-
-static constexpr OptionEnumValueElement g_corefile_save_style[] = {
- {eSaveCoreFull, "full", "Create a core file with all memory saved"},
- {eSaveCoreDirtyOnly, "modified-memory",
- "Create a corefile with only modified memory saved"},
- {eSaveCoreStackOnly, "stack",
- "Create a corefile with only stack memory saved"}};
-
-static constexpr OptionEnumValues SaveCoreStyles() {
- return OptionEnumValues(g_corefile_save_style);
-}
-
#define LLDB_OPTIONS_process_save_core
#include "CommandOptions.inc"
Index: lldb/source/Commands/CommandObjectPlatform.cpp
===================================================================
--- lldb/source/Commands/CommandObjectPlatform.cpp
+++ lldb/source/Commands/CommandObjectPlatform.cpp
@@ -13,6 +13,7 @@
#include "lldb/Core/PluginManager.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/CommandOptionEnumValues.h"
#include "lldb/Interpreter/CommandOptionValidators.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionGroupFile.h"
Index: lldb/source/Commands/CommandObjectMemoryTag.cpp
===================================================================
--- lldb/source/Commands/CommandObjectMemoryTag.cpp
+++ lldb/source/Commands/CommandObjectMemoryTag.cpp
@@ -8,6 +8,7 @@
#include "CommandObjectMemoryTag.h"
#include "lldb/Host/OptionParser.h"
+#include "lldb/Interpreter/CommandOptionEnumValues.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/OptionGroupFormat.h"
Index: lldb/source/Commands/CommandObjectMemory.cpp
===================================================================
--- lldb/source/Commands/CommandObjectMemory.cpp
+++ lldb/source/Commands/CommandObjectMemory.cpp
@@ -13,6 +13,7 @@
#include "lldb/Core/ValueObjectMemory.h"
#include "lldb/Expression/ExpressionVariable.h"
#include "lldb/Host/OptionParser.h"
+#include "lldb/Interpreter/CommandOptionEnumValues.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/OptionGroupFormat.h"
Index: lldb/source/Commands/CommandObjectLog.cpp
===================================================================
--- lldb/source/Commands/CommandObjectLog.cpp
+++ lldb/source/Commands/CommandObjectLog.cpp
@@ -9,6 +9,7 @@
#include "CommandObjectLog.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Host/OptionParser.h"
+#include "lldb/Interpreter/CommandOptionEnumValues.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/OptionValueEnumeration.h"
@@ -23,36 +24,6 @@
using namespace lldb;
using namespace lldb_private;
-static constexpr OptionEnumValueElement g_log_handler_type[] = {
- {
- eLogHandlerDefault,
- "default",
- "Use the default (stream) log handler",
- },
- {
- eLogHandlerStream,
- "stream",
- "Write log messages to the debugger output stream or to a file if one "
- "is specified. A buffer size (in bytes) can be specified with -b. If "
- "no buffer size is specified the output is unbuffered.",
- },
- {
- eLogHandlerCircular,
- "circular",
- "Write log messages to a fixed size circular buffer. A buffer size "
- "(number of messages) must be specified with -b.",
- },
- {
- eLogHandlerSystem,
- "os",
- "Write log messages to the operating system log.",
- },
-};
-
-static constexpr OptionEnumValues LogHandlerType() {
- return OptionEnumValues(g_log_handler_type);
-}
-
#define LLDB_OPTIONS_log_enable
#include "CommandOptions.inc"
Index: lldb/source/Commands/CommandObjectHelp.cpp
===================================================================
--- lldb/source/Commands/CommandObjectHelp.cpp
+++ lldb/source/Commands/CommandObjectHelp.cpp
@@ -8,6 +8,7 @@
#include "CommandObjectHelp.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/CommandOptionEnumValues.h"
#include "lldb/Interpreter/CommandReturnObject.h"
using namespace lldb;
Index: lldb/source/Commands/CommandObjectGUI.cpp
===================================================================
--- lldb/source/Commands/CommandObjectGUI.cpp
+++ lldb/source/Commands/CommandObjectGUI.cpp
@@ -11,6 +11,7 @@
#include "lldb/Core/IOHandlerCursesGUI.h"
#include "lldb/Host/Config.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/CommandOptionEnumValues.h"
#include "lldb/Interpreter/CommandReturnObject.h"
using namespace lldb;
Index: lldb/source/Commands/CommandObjectFrame.cpp
===================================================================
--- lldb/source/Commands/CommandObjectFrame.cpp
+++ lldb/source/Commands/CommandObjectFrame.cpp
@@ -13,6 +13,7 @@
#include "lldb/Host/Config.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/CommandOptionEnumValues.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/OptionGroupFormat.h"
Index: lldb/source/Commands/CommandObjectExpression.cpp
===================================================================
--- lldb/source/Commands/CommandObjectExpression.cpp
+++ lldb/source/Commands/CommandObjectExpression.cpp
@@ -14,6 +14,7 @@
#include "lldb/Expression/UserExpression.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/CommandOptionEnumValues.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Target/Language.h"
@@ -28,23 +29,6 @@
CommandObjectExpression::CommandOptions::~CommandOptions() = default;
-static constexpr OptionEnumValueElement g_description_verbosity_type[] = {
- {
- eLanguageRuntimeDescriptionDisplayVerbosityCompact,
- "compact",
- "Only show the description string",
- },
- {
- eLanguageRuntimeDescriptionDisplayVerbosityFull,
- "full",
- "Show the full output, including persistent variable's name and type",
- },
-};
-
-static constexpr OptionEnumValues DescriptionVerbosityTypes() {
- return OptionEnumValues(g_description_verbosity_type);
-}
-
#define LLDB_OPTIONS_expression
#include "CommandOptions.inc"
Index: lldb/source/Commands/CommandObjectDisassemble.cpp
===================================================================
--- lldb/source/Commands/CommandObjectDisassemble.cpp
+++ lldb/source/Commands/CommandObjectDisassemble.cpp
@@ -12,6 +12,7 @@
#include "lldb/Core/Module.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/CommandOptionEnumValues.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/Options.h"
Index: lldb/source/Commands/CommandObjectCommands.cpp
===================================================================
--- lldb/source/Commands/CommandObjectCommands.cpp
+++ lldb/source/Commands/CommandObjectCommands.cpp
@@ -13,6 +13,7 @@
#include "lldb/Core/IOHandler.h"
#include "lldb/Interpreter/CommandHistory.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/CommandOptionEnumValues.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/OptionValueBoolean.h"
@@ -1354,29 +1355,6 @@
CommandOptions m_options;
};
-// CommandObjectCommandsScriptAdd
-static constexpr OptionEnumValueElement g_script_synchro_type[] = {
- {
- eScriptedCommandSynchronicitySynchronous,
- "synchronous",
- "Run synchronous",
- },
- {
- eScriptedCommandSynchronicityAsynchronous,
- "asynchronous",
- "Run asynchronous",
- },
- {
- eScriptedCommandSynchronicityCurrentValue,
- "current",
- "Do not alter current setting",
- },
-};
-
-static constexpr OptionEnumValues ScriptSynchroType() {
- return OptionEnumValues(g_script_synchro_type);
-}
-
#define LLDB_OPTIONS_script_add
#include "CommandOptions.inc"
Index: lldb/source/Commands/CommandObjectBreakpointCommand.cpp
===================================================================
--- lldb/source/Commands/CommandObjectBreakpointCommand.cpp
+++ lldb/source/Commands/CommandObjectBreakpointCommand.cpp
@@ -14,6 +14,7 @@
#include "lldb/Core/IOHandler.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/CommandOptionEnumValues.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/OptionGroupPythonClassWithDict.h"
@@ -22,36 +23,6 @@
using namespace lldb;
using namespace lldb_private;
-// FIXME: "script-type" needs to have its contents determined dynamically, so
-// somebody can add a new scripting language to lldb and have it pickable here
-// without having to change this enumeration by hand and rebuild lldb proper.
-static constexpr OptionEnumValueElement g_script_option_enumeration[] = {
- {
- eScriptLanguageNone,
- "command",
- "Commands are in the lldb command interpreter language",
- },
- {
- eScriptLanguagePython,
- "python",
- "Commands are in the Python language.",
- },
- {
- eScriptLanguageLua,
- "lua",
- "Commands are in the Lua language.",
- },
- {
- eScriptLanguageDefault,
- "default-script",
- "Commands are in the default scripting language.",
- },
-};
-
-static constexpr OptionEnumValues ScriptOptionEnum() {
- return OptionEnumValues(g_script_option_enumeration);
-}
-
#define LLDB_OPTIONS_breakpoint_command_add
#include "CommandOptions.inc"
Index: lldb/source/Commands/CommandObjectBreakpoint.cpp
===================================================================
--- lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -13,6 +13,7 @@
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/CommandOptionEnumValues.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/OptionGroupPythonClassWithDict.h"
Index: lldb/include/lldb/lldb-private-enumerations.h
===================================================================
--- lldb/include/lldb/lldb-private-enumerations.h
+++ lldb/include/lldb/lldb-private-enumerations.h
@@ -231,6 +231,29 @@
eLogHandlerDefault = eLogHandlerStream,
};
+enum ReproducerProvider {
+ eReproducerProviderCommands,
+ eReproducerProviderFiles,
+ eReproducerProviderSymbolFiles,
+ eReproducerProviderGDB,
+ eReproducerProviderProcessInfo,
+ eReproducerProviderVersion,
+ eReproducerProviderWorkingDirectory,
+ eReproducerProviderHomeDirectory,
+ eReproducerProviderNone,
+};
+
+enum ReproducerCrashSignal {
+ eReproducerCrashSigill,
+ eReproducerCrashSigsegv,
+};
+
+enum LoadDependentFiles {
+ eLoadDependentsDefault,
+ eLoadDependentsYes,
+ eLoadDependentsNo,
+};
+
inline std::string GetStatDescription(lldb_private::StatisticKind K) {
switch (K) {
case StatisticKind::ExpressionSuccessful:
Index: lldb/include/lldb/lldb-enumerations.h
===================================================================
--- lldb/include/lldb/lldb-enumerations.h
+++ lldb/include/lldb/lldb-enumerations.h
@@ -608,6 +608,8 @@
eArgTypeConnectURL,
eArgTypeTargetID,
eArgTypeStopHookID,
+ eArgTypeReproducerProvider,
+ eArgTypeReproducerSignal,
eArgTypeLastArg // Always keep this entry as the last entry in this
// enumeration!!
};
Index: lldb/include/lldb/Target/Target.h
===================================================================
--- lldb/include/lldb/Target/Target.h
+++ lldb/include/lldb/Target/Target.h
@@ -59,12 +59,6 @@
eLoadCWDlldbinitWarn
};
-enum LoadDependentFiles {
- eLoadDependentsDefault,
- eLoadDependentsYes,
- eLoadDependentsNo,
-};
-
enum ImportStdModule {
eImportStdModuleFalse,
eImportStdModuleFallback,
Index: lldb/include/lldb/Interpreter/CommandOptionEnumValues.h
===================================================================
--- /dev/null
+++ lldb/include/lldb/Interpreter/CommandOptionEnumValues.h
@@ -0,0 +1,324 @@
+//===-- CommandOptionEnumValues.h -------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_INTERPRETER_COMMANDOPTIONENUMVALUES_H
+#define LLDB_INTERPRETER_COMMANDOPTIONENUMVALUES_H
+
+#include "lldb/Interpreter/CommandObject.h"
+
+namespace lldb_private {
+
+static constexpr OptionEnumValueElement g_corefile_save_style[] = {
+ {lldb::eSaveCoreFull, "full", "Create a core file with all memory saved"},
+ {lldb::eSaveCoreDirtyOnly, "modified-memory",
+ "Create a corefile with only modified memory saved"},
+ {lldb::eSaveCoreStackOnly, "stack",
+ "Create a corefile with only stack memory saved"},
+};
+
+static constexpr OptionEnumValueElement g_description_verbosity_type[] = {
+ {
+ eLanguageRuntimeDescriptionDisplayVerbosityCompact,
+ "compact",
+ "Only show the description string",
+ },
+ {
+ eLanguageRuntimeDescriptionDisplayVerbosityFull,
+ "full",
+ "Show the full output, including persistent variable's name and type",
+ },
+};
+
+static constexpr OptionEnumValueElement g_sort_option_enumeration[] = {
+ {
+ eSortOrderNone,
+ "none",
+ "No sorting, use the original symbol table order.",
+ },
+ {
+ eSortOrderByAddress,
+ "address",
+ "Sort output by symbol address.",
+ },
+ {
+ eSortOrderByName,
+ "name",
+ "Sort output by symbol name.",
+ },
+};
+
+// Note that the negation in the argument name causes a slightly confusing
+// mapping of the enum values.
+static constexpr OptionEnumValueElement g_dependents_enumeration[] = {
+ {
+ eLoadDependentsDefault,
+ "default",
+ "Only load dependents when the target is an executable.",
+ },
+ {
+ eLoadDependentsNo,
+ "true",
+ "Don't load dependents, even if the target is an executable.",
+ },
+ {
+ eLoadDependentsYes,
+ "false",
+ "Load dependents, even if the target is not an executable.",
+ },
+};
+
+// FIXME: "script-type" needs to have its contents determined dynamically, so
+// somebody can add a new scripting language to lldb and have it pickable here
+// without having to change this enumeration by hand and rebuild lldb proper.
+static constexpr OptionEnumValueElement g_script_option_enumeration[] = {
+ {
+ lldb::eScriptLanguageNone,
+ "command",
+ "Commands are in the lldb command interpreter language",
+ },
+ {
+ lldb::eScriptLanguagePython,
+ "python",
+ "Commands are in the Python language.",
+ },
+ {
+ lldb::eScriptLanguageLua,
+ "lua",
+ "Commands are in the Lua language.",
+ },
+ {
+ lldb::eScriptLanguageNone,
+ "default",
+ "Commands are in the default scripting language.",
+ },
+};
+
+static constexpr OptionEnumValueElement g_log_handler_type[] = {
+ {
+ eLogHandlerDefault,
+ "default",
+ "Use the default (stream) log handler",
+ },
+ {
+ eLogHandlerStream,
+ "stream",
+ "Write log messages to the debugger output stream or to a file if one "
+ "is specified. A buffer size (in bytes) can be specified with -b. If "
+ "no buffer size is specified the output is unbuffered.",
+ },
+ {
+ eLogHandlerCircular,
+ "circular",
+ "Write log messages to a fixed size circular buffer. A buffer size "
+ "(number of messages) must be specified with -b.",
+ },
+ {
+ eLogHandlerSystem,
+ "os",
+ "Write log messages to the operating system log.",
+ },
+};
+
+static constexpr OptionEnumValueElement g_reproducer_provider_type[] = {
+ {
+ eReproducerProviderCommands,
+ "commands",
+ "Command Interpreter Commands",
+ },
+ {
+ eReproducerProviderFiles,
+ "files",
+ "Files",
+ },
+ {
+ eReproducerProviderSymbolFiles,
+ "symbol-files",
+ "Symbol Files",
+ },
+ {
+ eReproducerProviderGDB,
+ "gdb",
+ "GDB Remote Packets",
+ },
+ {
+ eReproducerProviderProcessInfo,
+ "processes",
+ "Process Info",
+ },
+ {
+ eReproducerProviderVersion,
+ "version",
+ "Version",
+ },
+ {
+ eReproducerProviderWorkingDirectory,
+ "cwd",
+ "Working Directory",
+ },
+ {
+ eReproducerProviderHomeDirectory,
+ "home",
+ "Home Directory",
+ },
+ {
+ eReproducerProviderNone,
+ "none",
+ "None",
+ },
+};
+
+static constexpr OptionEnumValueElement g_reproducer_signaltype[] = {
+ {
+ eReproducerCrashSigill,
+ "SIGILL",
+ "Illegal instruction",
+ },
+ {
+ eReproducerCrashSigsegv,
+ "SIGSEGV",
+ "Segmentation fault",
+ },
+};
+
+static constexpr OptionEnumValueElement g_script_synchro_type[] = {
+ {
+ eScriptedCommandSynchronicitySynchronous,
+ "synchronous",
+ "Run synchronous",
+ },
+ {
+ eScriptedCommandSynchronicityAsynchronous,
+ "asynchronous",
+ "Run asynchronous",
+ },
+ {
+ eScriptedCommandSynchronicityCurrentValue,
+ "current",
+ "Do not alter current setting",
+ },
+};
+
+static constexpr OptionEnumValueElement g_running_mode[] = {
+ {lldb::eOnlyThisThread, "this-thread", "Run only this thread"},
+ {lldb::eAllThreads, "all-threads", "Run all threads"},
+ {lldb::eOnlyDuringStepping, "while-stepping",
+ "Run only this thread while stepping"},
+};
+
+static constexpr CommandObject::ArgumentTypeEnumValues
+ g_argument_type_enum_values[] = {
+ // clang-format off
+ { lldb::eArgTypeAddress, {} },
+ { lldb::eArgTypeAddressOrExpression, {} },
+ { lldb::eArgTypeAliasName, {} },
+ { lldb::eArgTypeAliasOptions, {} },
+ { lldb::eArgTypeArchitecture, {} },
+ { lldb::eArgTypeBoolean, {} },
+ { lldb::eArgTypeBreakpointID, {} },
+ { lldb::eArgTypeBreakpointIDRange, {} },
+ { lldb::eArgTypeBreakpointName, {} },
+ { lldb::eArgTypeByteSize, {} },
+ { lldb::eArgTypeClassName, {} },
+ { lldb::eArgTypeCommandName, {} },
+ { lldb::eArgTypeCount, {} },
+ { lldb::eArgTypeDescriptionVerbosity, g_description_verbosity_type},
+ { lldb::eArgTypeDirectoryName, {} },
+ { lldb::eArgTypeDisassemblyFlavor, {} },
+ { lldb::eArgTypeEndAddress, {} },
+ { lldb::eArgTypeExpression, {} },
+ { lldb::eArgTypeExpressionPath, {} },
+ { lldb::eArgTypeExprFormat, {} },
+ { lldb::eArgTypeFileLineColumn, {} },
+ { lldb::eArgTypeFilename, {} },
+ { lldb::eArgTypeFormat, {} },
+ { lldb::eArgTypeFrameIndex, {} },
+ { lldb::eArgTypeFullName, {} },
+ { lldb::eArgTypeFunctionName, {} },
+ { lldb::eArgTypeFunctionOrSymbol, {} },
+ { lldb::eArgTypeGDBFormat, {} },
+ { lldb::eArgTypeHelpText, {} },
+ { lldb::eArgTypeIndex, {} },
+ { lldb::eArgTypeLanguage, {} },
+ { lldb::eArgTypeLineNum, {} },
+ { lldb::eArgTypeLogCategory, {} },
+ { lldb::eArgTypeLogChannel, {} },
+ { lldb::eArgTypeMethod, {} },
+ { lldb::eArgTypeName, {} },
+ { lldb::eArgTypeNewPathPrefix, {} },
+ { lldb::eArgTypeNumLines, {} },
+ { lldb::eArgTypeNumberPerLine, {} },
+ { lldb::eArgTypeOffset, {} },
+ { lldb::eArgTypeOldPathPrefix, {} },
+ { lldb::eArgTypeOneLiner, {} },
+ { lldb::eArgTypePath, {} },
+ { lldb::eArgTypePermissionsNumber, {} },
+ { lldb::eArgTypePermissionsString, {} },
+ { lldb::eArgTypePid, {} },
+ { lldb::eArgTypePlugin, {} },
+ { lldb::eArgTypeProcessName, {} },
+ { lldb::eArgTypePythonClass, {} },
+ { lldb::eArgTypePythonFunction, {} },
+ { lldb::eArgTypePythonScript, {} },
+ { lldb::eArgTypeQueueName, {} },
+ { lldb::eArgTypeRegisterName, {} },
+ { lldb::eArgTypeRegularExpression, {} },
+ { lldb::eArgTypeRunArgs, {} },
+ { lldb::eArgTypeRunMode, g_running_mode},
+ { lldb::eArgTypeScriptedCommandSynchronicity, g_script_synchro_type},
+ { lldb::eArgTypeScriptLang, g_script_option_enumeration},
+ { lldb::eArgTypeSearchWord, {} },
+ { lldb::eArgTypeSelector, {} },
+ { lldb::eArgTypeSettingIndex, {} },
+ { lldb::eArgTypeSettingKey, {} },
+ { lldb::eArgTypeSettingPrefix, {} },
+ { lldb::eArgTypeSettingVariableName, {} },
+ { lldb::eArgTypeShlibName, {} },
+ { lldb::eArgTypeSourceFile, {} },
+ { lldb::eArgTypeSortOrder, g_sort_option_enumeration},
+ { lldb::eArgTypeStartAddress, {} },
+ { lldb::eArgTypeSummaryString, {} },
+ { lldb::eArgTypeSymbol, {} },
+ { lldb::eArgTypeThreadID, {} },
+ { lldb::eArgTypeThreadIndex, {} },
+ { lldb::eArgTypeThreadName, {} },
+ { lldb::eArgTypeTypeName, {} },
+ { lldb::eArgTypeUnsignedInteger, {} },
+ { lldb::eArgTypeUnixSignal, {} },
+ { lldb::eArgTypeVarName, {} },
+ { lldb::eArgTypeValue, g_dependents_enumeration},
+ { lldb::eArgTypeWidth, {} },
+ { lldb::eArgTypeNone, {} },
+ { lldb::eArgTypePlatform, {} },
+ { lldb::eArgTypeWatchpointID, {} },
+ { lldb::eArgTypeWatchpointIDRange, {} },
+ { lldb::eArgTypeWatchType, {} },
+ { lldb::eArgRawInput, {} },
+ { lldb::eArgTypeCommand, {} },
+ { lldb::eArgTypeColumnNum, {} },
+ { lldb::eArgTypeModuleUUID, {} },
+ { lldb::eArgTypeSaveCoreStyle, g_corefile_save_style},
+ { lldb::eArgTypeLogHandler, g_log_handler_type},
+ { lldb::eArgTypeSEDStylePair, {} },
+ { lldb::eArgTypeRecognizerID, {} },
+ { lldb::eArgTypeConnectURL, {} },
+ { lldb::eArgTypeTargetID, {} },
+ { lldb::eArgTypeStopHookID, {} },
+ { lldb::eArgTypeReproducerProvider, g_reproducer_provider_type},
+ { lldb::eArgTypeReproducerSignal, g_reproducer_signaltype},
+ // clang-format on
+};
+
+static_assert((sizeof(g_argument_type_enum_values) /
+ sizeof(CommandObject::ArgumentTypeEnumValues)) ==
+ lldb::eArgTypeLastArg,
+ "g_argument_type_enum_values out of sync with "
+ "CommandArgumentType enumeration");
+
+} // namespace lldb_private
+
+#endif // LLDB_INTERPRETER_COMMANDOPTIONENUMVALUES_H
Index: lldb/include/lldb/Interpreter/CommandObject.h
===================================================================
--- lldb/include/lldb/Interpreter/CommandObject.h
+++ lldb/include/lldb/Interpreter/CommandObject.h
@@ -77,8 +77,8 @@
explicit operator bool() const { return (help_callback != nullptr); }
};
- struct ArgumentTableEntry // Entries in the main argument information table
- {
+ /// Entries in the main argument information table.
+ struct ArgumentTableEntry {
lldb::CommandArgumentType arg_type;
const char *arg_name;
CommandCompletions::CommonCompletionTypes completion_type;
@@ -86,8 +86,14 @@
const char *help_text;
};
- struct CommandArgumentData // Used to build individual command argument lists
- {
+ /// Entries in the table mapping arguments types to enum values.
+ struct ArgumentTypeEnumValues {
+ lldb::CommandArgumentType arg_type;
+ OptionEnumValues enum_values;
+ };
+
+ /// Used to build individual command argument lists.
+ struct CommandArgumentData {
lldb::CommandArgumentType arg_type;
ArgumentRepetitionType arg_repetition;
/// This arg might be associated only with some particular option set(s). By
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits