Decoupled Options from CommandInterpreter.
Options used to store a reference to the CommandInterpreter instance
in the base Options class. This made it impossible to parse options
independent of a CommandInterpreter.
This change removes the reference from the base class. Instead, it
modifies the options-parsing-related methods to take an
ExecutionContext pointer, which the options may inspect if they need
to do so.
Closes https://reviews.llvm.org/D23416
Reviewers: clayborg, jingham
llvm-svn: 278440
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index 53ac2a6..98efe52 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -492,15 +492,16 @@
class CommandOptions : public Options
{
public:
- CommandOptions (CommandInterpreter &interpreter) :
- Options(interpreter),
+ CommandOptions() :
+ Options(),
m_verbose(false,false)
{}
~CommandOptions() override = default;
Error
- SetOptionValue(uint32_t option_idx, const char *option_arg) override
+ SetOptionValue(uint32_t option_idx, const char *option_arg,
+ ExecutionContext *execution_context) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -520,7 +521,7 @@
}
void
- OptionParsingStarting() override
+ OptionParsingStarting(ExecutionContext *execution_context) override
{
m_verbose.Clear();
}
@@ -543,7 +544,7 @@
eCommandRequiresProcess |
eCommandProcessMustBeLaunched |
eCommandProcessMustBePaused ),
- m_options(interpreter)
+ m_options()
{
CommandArgumentEntry arg;
CommandArgumentData index_arg;
diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
index ad1fe3d..5299169 100644
--- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -3659,7 +3659,7 @@
"Sets a breakpoint on a renderscript kernel.",
"renderscript kernel breakpoint set <kernel_name> [-c x,y,z]",
eCommandRequiresProcess | eCommandProcessMustBeLaunched | eCommandProcessMustBePaused),
- m_options(interpreter)
+ m_options()
{
}
@@ -3674,12 +3674,13 @@
class CommandOptions : public Options
{
public:
- CommandOptions(CommandInterpreter &interpreter) : Options(interpreter) {}
+ CommandOptions() : Options() {}
~CommandOptions() override = default;
Error
- SetOptionValue(uint32_t option_idx, const char *option_arg) override
+ SetOptionValue(uint32_t option_idx, const char *option_arg,
+ ExecutionContext *execution_context) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -3726,7 +3727,7 @@
}
void
- OptionParsingStarting() override
+ OptionParsingStarting(ExecutionContext *execution_context) override
{
// -1 means the -c option hasn't been set
m_coord[0] = -1;
@@ -3950,7 +3951,7 @@
: CommandObjectParsed(interpreter, "renderscript allocation dump",
"Displays the contents of a particular allocation", "renderscript allocation dump <ID>",
eCommandRequiresProcess | eCommandProcessMustBeLaunched),
- m_options(interpreter)
+ m_options()
{
}
@@ -3965,12 +3966,13 @@
class CommandOptions : public Options
{
public:
- CommandOptions(CommandInterpreter &interpreter) : Options(interpreter) {}
+ CommandOptions() : Options() {}
~CommandOptions() override = default;
Error
- SetOptionValue(uint32_t option_idx, const char *option_arg) override
+ SetOptionValue(uint32_t option_idx, const char *option_arg,
+ ExecutionContext *execution_context) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -3993,7 +3995,7 @@
}
void
- OptionParsingStarting() override
+ OptionParsingStarting(ExecutionContext *execution_context) override
{
m_outfile.Clear();
}
@@ -4084,7 +4086,7 @@
: CommandObjectParsed(interpreter, "renderscript allocation list",
"List renderscript allocations and their information.", "renderscript allocation list",
eCommandRequiresProcess | eCommandProcessMustBeLaunched),
- m_options(interpreter)
+ m_options()
{
}
@@ -4099,12 +4101,13 @@
class CommandOptions : public Options
{
public:
- CommandOptions(CommandInterpreter &interpreter) : Options(interpreter), m_id(0) {}
+ CommandOptions() : Options(), m_id(0) {}
~CommandOptions() override = default;
Error
- SetOptionValue(uint32_t option_idx, const char *option_arg) override
+ SetOptionValue(uint32_t option_idx, const char *option_arg,
+ ExecutionContext *execution_context) override
{
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -4125,7 +4128,7 @@
}
void
- OptionParsingStarting() override
+ OptionParsingStarting(ExecutionContext *execution_context) override
{
m_id = 0;
}
diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index d00cb81..967f4dd 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -75,7 +75,7 @@
auto iter = m_options.find(&interpreter), end = m_options.end();
if (iter == end)
{
- std::unique_ptr<lldb_private::OptionGroupOptions> options(new OptionGroupOptions(interpreter));
+ std::unique_ptr<lldb_private::OptionGroupOptions> options(new OptionGroupOptions());
options->Append(m_option_group_platform_rsync.get());
options->Append(m_option_group_platform_ssh.get());
options->Append(m_option_group_platform_caching.get());
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
index 3c333f0..8da3774 100644
--- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
@@ -1050,7 +1050,7 @@
"process plugin packet send",
"Send a custom packet through the KDP protocol by specifying the command byte and the packet payload data. A packet will be sent with a correct header and payload, and the raw result bytes will be displayed as a string value. ",
NULL),
- m_option_group (interpreter),
+ m_option_group(),
m_command_byte(LLDB_OPT_SET_1, true , "command", 'c', 0, eArgTypeNone, "Specify the command byte to use when sending the KDP request packet.", 0),
m_packet_data (LLDB_OPT_SET_1, false, "payload", 'p', 0, eArgTypeNone, "Specify packet payload bytes as a hex ASCII string with no spaces or hex prefixes.", NULL)
{
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 352d87e..07ec61f 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -5215,7 +5215,7 @@
"process plugin packet speed-test",
"Tests packet speeds of various sizes to determine the performance characteristics of the GDB remote connection. ",
NULL),
- m_option_group (interpreter),
+ m_option_group (),
m_num_packets (LLDB_OPT_SET_1, false, "count", 'c', 0, eArgTypeCount, "The number of packets to send of each varying size (default is 1000).", 1000),
m_max_send (LLDB_OPT_SET_1, false, "max-send", 's', 0, eArgTypeCount, "The maximum number of bytes to send in a packet. Sizes increase in powers of 2 while the size is less than or equal to this option value. (default 1024).", 1024),
m_max_recv (LLDB_OPT_SET_1, false, "max-receive", 'r', 0, eArgTypeCount, "The maximum number of bytes to receive in a packet. Sizes increase in powers of 2 while the size is less than or equal to this option value. (default 1024).", 1024),