diff options
author | Todd Fiala <todd.fiala@gmail.com> | 2016-08-11 23:51:28 +0000 |
---|---|---|
committer | Todd Fiala <todd.fiala@gmail.com> | 2016-08-11 23:51:28 +0000 |
commit | e1cfbc79420fee0b71bad62f8d413b68a0eca91e (patch) | |
tree | ab91f6f91be4051731e37ed69ca9ff8c7bdad1ff /lldb/source/Commands | |
parent | 1602421c852d9d7fddbe8c5f014d7861a7848865 (diff) | |
download | bcm5719-llvm-e1cfbc79420fee0b71bad62f8d413b68a0eca91e.tar.gz bcm5719-llvm-e1cfbc79420fee0b71bad62f8d413b68a0eca91e.zip |
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
Diffstat (limited to 'lldb/source/Commands')
26 files changed, 589 insertions, 464 deletions
diff --git a/lldb/source/Commands/CommandObjectArgs.cpp b/lldb/source/Commands/CommandObjectArgs.cpp index 206a26f45e4..303563c6a91 100644 --- a/lldb/source/Commands/CommandObjectArgs.cpp +++ b/lldb/source/Commands/CommandObjectArgs.cpp @@ -37,16 +37,18 @@ using namespace lldb_private; // CommandObjectArgs::CommandOptions::CommandOptions (CommandInterpreter &interpreter) : - Options(interpreter) + Options() { // Keep only one place to reset the values to their defaults - OptionParsingStarting(); + OptionParsingStarting(nullptr); } CommandObjectArgs::CommandOptions::~CommandOptions() = default; Error -CommandObjectArgs::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg) +CommandObjectArgs::CommandOptions::SetOptionValue(uint32_t option_idx, + const char *option_arg, + ExecutionContext *execution_context) { Error error; @@ -57,7 +59,8 @@ CommandObjectArgs::CommandOptions::SetOptionValue (uint32_t option_idx, const ch } void -CommandObjectArgs::CommandOptions::OptionParsingStarting () +CommandObjectArgs::CommandOptions::OptionParsingStarting( + ExecutionContext *execution_context) { } diff --git a/lldb/source/Commands/CommandObjectArgs.h b/lldb/source/Commands/CommandObjectArgs.h index 4a4e1c35cf3..90b2f504ca1 100644 --- a/lldb/source/Commands/CommandObjectArgs.h +++ b/lldb/source/Commands/CommandObjectArgs.h @@ -32,10 +32,11 @@ namespace lldb_private { ~CommandOptions() override; Error - SetOptionValue(uint32_t option_idx, const char *option_arg) override; + SetOptionValue(uint32_t option_idx, const char *option_arg, + ExecutionContext *execution_context) override; void - OptionParsingStarting() override; + OptionParsingStarting(ExecutionContext *execution_context) override; const OptionDefinition* GetDefinitions() override; diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index 6a71389a3f6..15819675ec2 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -69,7 +69,7 @@ public: "breakpoint set", "Sets a breakpoint or set of breakpoints in the executable.", "breakpoint set <cmd-options>"), - m_options (interpreter) + m_options () { } @@ -84,8 +84,8 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter), + CommandOptions () : + Options (), m_condition (), m_filenames (), m_line_num (0), @@ -116,7 +116,8 @@ public: ~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; @@ -125,8 +126,9 @@ public: { case 'a': { - ExecutionContext exe_ctx (m_interpreter.GetExecutionContext()); - m_load_addr = Args::StringToAddress(&exe_ctx, option_arg, LLDB_INVALID_ADDRESS, &error); + m_load_addr = + Args::StringToAddress(execution_context, option_arg, + LLDB_INVALID_ADDRESS, &error); } break; @@ -279,9 +281,10 @@ public: case 'R': { - ExecutionContext exe_ctx (m_interpreter.GetExecutionContext()); lldb::addr_t tmp_offset_addr; - tmp_offset_addr = Args::StringToAddress(&exe_ctx, option_arg, 0, &error); + tmp_offset_addr = + Args::StringToAddress(execution_context, option_arg, + 0, &error); if (error.Success()) m_offset_addr = tmp_offset_addr; } @@ -355,7 +358,7 @@ public: } void - OptionParsingStarting () override + OptionParsingStarting (ExecutionContext *execution_context) override { m_condition.clear(); m_filenames.Clear(); @@ -892,7 +895,7 @@ public: "If no breakpoint is specified, acts on the last created breakpoint. " "With the exception of -e, -d and -i, passing an empty argument clears the modification.", nullptr), - m_options (interpreter) + m_options () { CommandArgumentEntry arg; CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange); @@ -911,8 +914,8 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter), + CommandOptions () : + Options (), m_ignore_count (0), m_thread_id(LLDB_INVALID_THREAD_ID), m_thread_id_passed(false), @@ -935,7 +938,8 @@ public: ~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; @@ -1031,7 +1035,7 @@ public: } void - OptionParsingStarting () override + OptionParsingStarting (ExecutionContext *execution_context) override { m_ignore_count = 0; m_thread_id = LLDB_INVALID_THREAD_ID; @@ -1418,7 +1422,7 @@ public: "breakpoint list", "List some or all breakpoints at configurable levels of detail.", nullptr), - m_options (interpreter) + m_options () { CommandArgumentEntry arg; CommandArgumentData bp_id_arg; @@ -1445,8 +1449,8 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter), + CommandOptions () : + Options (), m_level (lldb::eDescriptionLevelBrief), m_use_dummy(false) { @@ -1455,7 +1459,8 @@ public: ~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; @@ -1486,7 +1491,7 @@ public: } void - OptionParsingStarting () override + OptionParsingStarting (ExecutionContext *execution_context) override { m_level = lldb::eDescriptionLevelFull; m_internal = false; @@ -1622,7 +1627,7 @@ public: : CommandObjectParsed(interpreter, "breakpoint clear", "Delete or disable breakpoints matching the specified source file and line.", "breakpoint clear <cmd-options>"), - m_options(interpreter) + m_options() { } @@ -1637,8 +1642,8 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter), + CommandOptions () : + Options (), m_filename (), m_line_num (0) { @@ -1647,7 +1652,8 @@ public: ~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; @@ -1671,7 +1677,7 @@ public: } void - OptionParsingStarting () override + OptionParsingStarting (ExecutionContext *execution_context) override { m_filename.clear(); m_line_num = 0; @@ -1815,7 +1821,7 @@ public: "breakpoint delete", "Delete the specified breakpoint(s). If no breakpoints are specified, delete them all.", nullptr), - m_options (interpreter) + m_options() { CommandArgumentEntry arg; CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange); @@ -1834,8 +1840,8 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter), + CommandOptions () : + Options (), m_use_dummy (false), m_force (false) { @@ -1844,7 +1850,8 @@ public: ~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; @@ -1868,7 +1875,7 @@ public: } void - OptionParsingStarting () override + OptionParsingStarting (ExecutionContext *execution_context) override { m_use_dummy = false; m_force = false; @@ -2025,9 +2032,9 @@ public: } Error - SetOptionValue (CommandInterpreter &interpreter, - uint32_t option_idx, - const char *option_value) override + SetOptionValue (uint32_t option_idx, + const char *option_value, + ExecutionContext *execution_context) override { Error error; const int short_option = g_breakpoint_name_options[option_idx].short_option; @@ -2056,7 +2063,7 @@ public: } void - OptionParsingStarting (CommandInterpreter &interpreter) override + OptionParsingStarting (ExecutionContext *execution_context) override { m_name.Clear(); m_breakpoint.Clear(); @@ -2078,7 +2085,7 @@ public: "Add a name to the breakpoints provided.", "breakpoint name add <command-options> <breakpoint-id-list>"), m_name_options(), - m_option_group(interpreter) + m_option_group() { // Create the first variant for the first (and only) argument for this command. CommandArgumentEntry arg1; @@ -2171,7 +2178,7 @@ public: "Delete a name from the breakpoints provided.", "breakpoint name delete <command-options> <breakpoint-id-list>"), m_name_options(), - m_option_group(interpreter) + m_option_group() { // Create the first variant for the first (and only) argument for this command. CommandArgumentEntry arg1; @@ -2263,7 +2270,7 @@ public: "List either the names for a breakpoint or the breakpoints for a given name.", "breakpoint name list <command-options>"), m_name_options(), - m_option_group(interpreter) + m_option_group() { m_option_group.Append (&m_name_options); m_option_group.Finalize(); diff --git a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp index 57572c8ef14..15c9fee8d43 100644 --- a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp +++ b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp @@ -42,7 +42,7 @@ public: " If no breakpoint is specified, adds the commands to the last created breakpoint.", nullptr), IOHandlerDelegateMultiline("DONE", IOHandlerDelegate::Completion::LLDBCommand), - m_options(interpreter) + m_options() { SetHelpLong ( R"( @@ -295,8 +295,8 @@ are no syntax errors may indicate that a function was declared but never called. class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter), + CommandOptions () : + Options (), m_use_commands (false), m_use_script_language (false), m_script_language (eScriptLanguageNone), @@ -309,7 +309,8 @@ are no syntax errors may indicate that a function was declared but never called. ~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; @@ -363,7 +364,7 @@ are no syntax errors may indicate that a function was declared but never called. } void - OptionParsingStarting () override + OptionParsingStarting (ExecutionContext *execution_context) override { m_use_commands = true; m_use_script_language = false; @@ -566,7 +567,7 @@ public: "delete", "Delete the set of commands from a breakpoint.", nullptr), - m_options (interpreter) + m_options() { CommandArgumentEntry arg; CommandArgumentData bp_id_arg; @@ -593,16 +594,17 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter), - m_use_dummy (false) + CommandOptions() : + Options(), + m_use_dummy(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; @@ -622,7 +624,7 @@ public: } void - OptionParsingStarting () override + OptionParsingStarting (ExecutionContext *execution_context) override { m_use_dummy = false; } diff --git a/lldb/source/Commands/CommandObjectBugreport.cpp b/lldb/source/Commands/CommandObjectBugreport.cpp index db8c06c0e9e..7dd19792ba3 100644 --- a/lldb/source/Commands/CommandObjectBugreport.cpp +++ b/lldb/source/Commands/CommandObjectBugreport.cpp @@ -36,7 +36,7 @@ public: "bugreport unwind", "Create a bugreport for a bug in the stack unwinding code.", nullptr), - m_option_group(interpreter), + m_option_group(), m_outfile_options() { m_option_group.Append (&m_outfile_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1 | LLDB_OPT_SET_2 | LLDB_OPT_SET_3); diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index dd2fd9a0efc..0cba318a266 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -44,7 +44,7 @@ public: "command history", "Dump the history of commands in this session.", nullptr), - m_options (interpreter) + m_options() { } @@ -60,8 +60,8 @@ protected: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter), + CommandOptions() : + Options(), m_start_idx(0), m_stop_idx(0), m_count(0), @@ -72,7 +72,8 @@ protected: ~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; @@ -107,7 +108,7 @@ protected: } void - OptionParsingStarting () override + OptionParsingStarting (ExecutionContext *execution_context) override { m_start_idx.Clear(); m_stop_idx.Clear(); @@ -238,7 +239,7 @@ public: CommandObjectCommandsSource(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "command source", "Read and execute LLDB commands from the file <filename>.", nullptr), - m_options(interpreter) + m_options() { CommandArgumentEntry arg; CommandArgumentData file_arg; @@ -274,8 +275,8 @@ public: { std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); - - CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + + CommandCompletions::InvokeCommonCompletionCallbacks(GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion, completion_str.c_str(), match_start_point, @@ -296,8 +297,8 @@ protected: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter), + CommandOptions() : + Options(), m_stop_on_error (true), m_silent_run (false), m_stop_on_continue (true) @@ -307,7 +308,8 @@ protected: ~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; @@ -335,7 +337,7 @@ protected: } void - OptionParsingStarting () override + OptionParsingStarting (ExecutionContext *execution_context) override { m_stop_on_error.Clear(); m_silent_run.Clear(); @@ -454,9 +456,9 @@ protected: } Error - SetOptionValue (CommandInterpreter &interpreter, - uint32_t option_idx, - const char *option_value) override + SetOptionValue (uint32_t option_idx, + const char *option_value, + ExecutionContext *execution_context) override { Error error; @@ -483,7 +485,7 @@ protected: } void - OptionParsingStarting (CommandInterpreter &interpreter) override + OptionParsingStarting (ExecutionContext *execution_context) override { m_help.Clear(); m_long_help.Clear(); @@ -509,7 +511,7 @@ public: CommandObjectCommandsAlias(CommandInterpreter &interpreter) : CommandObjectRaw(interpreter, "command alias", "Define a custom command in terms of an existing command.", nullptr), - m_option_group(interpreter), + m_option_group(), m_command_options() { m_option_group.Append(&m_command_options); @@ -630,8 +632,9 @@ protected: result.AppendError ("'command alias' requires at least two arguments"); return false; } - - m_option_group.NotifyOptionParsingStarting(); + + ExecutionContext exe_ctx = GetCommandInterpreter().GetExecutionContext(); + m_option_group.NotifyOptionParsingStarting(&exe_ctx); const char * remainder = nullptr; @@ -663,7 +666,7 @@ protected: if (!ParseOptions (args, result)) return false; - Error error (m_option_group.NotifyOptionParsingFinished()); + Error error (m_option_group.NotifyOptionParsingFinished(&exe_ctx)); if (error.Fail()) { result.AppendError (error.AsCString()); @@ -1092,7 +1095,7 @@ public: "Define a custom command in terms of existing commands by matching regular expressions.", "command regex <cmd-name> [s/<regex>/<subst>/ ...]"), IOHandlerDelegateMultiline("", IOHandlerDelegate::Completion::LLDBCommand), - m_options(interpreter) + m_options() { SetHelpLong(R"( )" "This command allows the user to create powerful regular expression commands \ @@ -1359,15 +1362,16 @@ private: 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; @@ -1389,7 +1393,7 @@ private: } void - OptionParsingStarting () override + OptionParsingStarting (ExecutionContext *execution_context) override { m_help.clear(); m_syntax.clear(); @@ -1676,7 +1680,7 @@ public: "command script import", "Import a scripting module in LLDB.", nullptr), - m_options(interpreter) + m_options() { CommandArgumentEntry arg1; CommandArgumentData cmd_arg; @@ -1706,8 +1710,8 @@ public: { std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); - - CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + + CommandCompletions::InvokeCommonCompletionCallbacks(GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion, completion_str.c_str(), match_start_point, @@ -1728,15 +1732,16 @@ protected: 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; @@ -1755,7 +1760,7 @@ protected: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_allow_reload = true; } @@ -1850,7 +1855,7 @@ public: "Add a scripted function as an LLDB command.", nullptr), IOHandlerDelegateMultiline ("DONE"), - m_options (interpreter) + m_options() { CommandArgumentEntry arg1; CommandArgumentData cmd_arg; @@ -1878,8 +1883,8 @@ protected: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter), + CommandOptions() : + Options(), m_class_name(), m_funct_name(), m_short_help(), @@ -1890,7 +1895,8 @@ protected: ~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; @@ -1923,7 +1929,7 @@ protected: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_class_name.clear(); m_funct_name.clear(); diff --git a/lldb/source/Commands/CommandObjectDisassemble.cpp b/lldb/source/Commands/CommandObjectDisassemble.cpp index 07a847aaeba..6f5287626f5 100644 --- a/lldb/source/Commands/CommandObjectDisassemble.cpp +++ b/lldb/source/Commands/CommandObjectDisassemble.cpp @@ -34,8 +34,8 @@ using namespace lldb; using namespace lldb_private; -CommandObjectDisassemble::CommandOptions::CommandOptions (CommandInterpreter &interpreter) : - Options(interpreter), +CommandObjectDisassemble::CommandOptions::CommandOptions() : + Options(), num_lines_context(0), num_instructions (0), func_name(), @@ -50,13 +50,15 @@ CommandObjectDisassemble::CommandOptions::CommandOptions (CommandInterpreter &in some_location_specified (false), symbol_containing_addr () { - OptionParsingStarting(); + OptionParsingStarting(nullptr); } CommandObjectDisassemble::CommandOptions::~CommandOptions() = default; Error -CommandObjectDisassemble::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg) +CommandObjectDisassemble::CommandOptions::SetOptionValue(uint32_t option_idx, + const char *option_arg, + ExecutionContext *execution_context) { Error error; @@ -88,16 +90,16 @@ CommandObjectDisassemble::CommandOptions::SetOptionValue (uint32_t option_idx, c case 's': { - ExecutionContext exe_ctx (m_interpreter.GetExecutionContext()); - start_addr = Args::StringToAddress(&exe_ctx, option_arg, LLDB_INVALID_ADDRESS, &error); + start_addr = Args::StringToAddress(execution_context, option_arg, + LLDB_INVALID_ADDRESS, &error); if (start_addr != LLDB_INVALID_ADDRESS) some_location_specified = true; } break; case 'e': { - ExecutionContext exe_ctx (m_interpreter.GetExecutionContext()); - end_addr = Args::StringToAddress(&exe_ctx, option_arg, LLDB_INVALID_ADDRESS, &error); + end_addr = Args::StringToAddress(execution_context, option_arg, + LLDB_INVALID_ADDRESS, &error); if (end_addr != LLDB_INVALID_ADDRESS) some_location_specified = true; } @@ -127,9 +129,11 @@ CommandObjectDisassemble::CommandOptions::SetOptionValue (uint32_t option_idx, c case 'F': { - Target *target = m_interpreter.GetExecutionContext().GetTargetPtr(); - if (target->GetArchitecture().GetTriple().getArch() == llvm::Triple::x86 - || target->GetArchitecture().GetTriple().getArch() == llvm::Triple::x86_64) + TargetSP target_sp = execution_context ? + execution_context->GetTargetSP() : TargetSP(); + if (target_sp && + (target_sp->GetArchitecture().GetTriple().getArch() == llvm::Triple::x86 + || target_sp->GetArchitecture().GetTriple().getArch() == llvm::Triple::x86_64)) { flavor_string.assign (option_arg); } @@ -148,14 +152,22 @@ CommandObjectDisassemble::CommandOptions::SetOptionValue (uint32_t option_idx, c break; case 'A': - if (!arch.SetTriple (option_arg, m_interpreter.GetPlatform (true).get())) - arch.SetTriple (option_arg); + if (execution_context) + { + auto target_sp = execution_context ? + execution_context->GetTargetSP() : TargetSP(); + auto platform_sp = + target_sp ? target_sp->GetPlatform() : PlatformSP(); + if (!arch.SetTriple (option_arg, platform_sp.get())) + arch.SetTriple (option_arg); + } break; case 'a': { - ExecutionContext exe_ctx (m_interpreter.GetExecutionContext()); - symbol_containing_addr = Args::StringToAddress(&exe_ctx, option_arg, LLDB_INVALID_ADDRESS, &error); + symbol_containing_addr = + Args::StringToAddress(execution_context,option_arg, + LLDB_INVALID_ADDRESS, &error); if (symbol_containing_addr != LLDB_INVALID_ADDRESS) { some_location_specified = true; @@ -172,7 +184,8 @@ CommandObjectDisassemble::CommandOptions::SetOptionValue (uint32_t option_idx, c } void -CommandObjectDisassemble::CommandOptions::OptionParsingStarting () +CommandObjectDisassemble::CommandOptions::OptionParsingStarting( + ExecutionContext *execution_context) { show_mixed = false; show_bytes = false; @@ -188,7 +201,8 @@ CommandObjectDisassemble::CommandOptions::OptionParsingStarting () raw = false; plugin_name.clear(); - Target *target = m_interpreter.GetExecutionContext().GetTargetPtr(); + Target *target = + execution_context ? execution_context->GetTargetPtr() : nullptr; // This is a hack till we get the ability to specify features based on architecture. For now GetDisassemblyFlavor // is really only valid for x86 (and for the llvm assembler plugin, but I'm papering over that since that is the @@ -212,7 +226,8 @@ CommandObjectDisassemble::CommandOptions::OptionParsingStarting () } Error -CommandObjectDisassemble::CommandOptions::OptionParsingFinished () +CommandObjectDisassemble::CommandOptions::OptionParsingFinished( + ExecutionContext *execution_context) { if (!some_location_specified) current_function = true; @@ -262,7 +277,7 @@ CommandObjectDisassemble::CommandObjectDisassemble(CommandInterpreter &interpret "Defaults to the current function for the current thread and " "stack frame.", "disassemble [<cmd-options>]"), - m_options(interpreter) + m_options() { } @@ -315,7 +330,10 @@ CommandObjectDisassemble::DoExecute (Args& command, CommandReturnObject &result) if (command.GetArgumentCount() != 0) { result.AppendErrorWithFormat ("\"disassemble\" arguments are specified as options.\n"); - GetOptions()->GenerateOptionUsage (result.GetErrorStream(), this); + const int terminal_width = + GetCommandInterpreter().GetDebugger().GetTerminalWidth(); + GetOptions()->GenerateOptionUsage(result.GetErrorStream(), this, + terminal_width); result.SetStatus (eReturnStatusFailed); return false; } diff --git a/lldb/source/Commands/CommandObjectDisassemble.h b/lldb/source/Commands/CommandObjectDisassemble.h index ef19b3cf316..fa951227c99 100644 --- a/lldb/source/Commands/CommandObjectDisassemble.h +++ b/lldb/source/Commands/CommandObjectDisassemble.h @@ -30,15 +30,16 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter); + CommandOptions(); ~CommandOptions() override; Error - SetOptionValue(uint32_t option_idx, const char *option_arg) override; + SetOptionValue(uint32_t option_idx, const char *option_arg, + ExecutionContext *execution_context) override; void - OptionParsingStarting() override; + OptionParsingStarting(ExecutionContext *execution_context) override; const OptionDefinition* GetDefinitions() override; @@ -58,7 +59,7 @@ public: } Error - OptionParsingFinished() override; + OptionParsingFinished(ExecutionContext *execution_context) override; bool show_mixed; // Show mixed source/assembly bool show_bytes; diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index f2bd3ed367c..78483ed3f59 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -74,9 +74,9 @@ CommandObjectExpression::CommandOptions::GetNumDefinitions () } Error -CommandObjectExpression::CommandOptions::SetOptionValue (CommandInterpreter &interpreter, - uint32_t option_idx, - const char *option_arg) +CommandObjectExpression::CommandOptions::SetOptionValue (uint32_t option_idx, + const char *option_arg, + ExecutionContext *execution_context) { Error error; @@ -188,13 +188,15 @@ CommandObjectExpression::CommandOptions::SetOptionValue (CommandInterpreter &int } void -CommandObjectExpression::CommandOptions::OptionParsingStarting (CommandInterpreter &interpreter) +CommandObjectExpression::CommandOptions::OptionParsingStarting( + ExecutionContext *execution_context) { - Process *process = interpreter.GetExecutionContext().GetProcessPtr(); - if (process != nullptr) + auto process_sp = + execution_context ? execution_context->GetProcessSP() : ProcessSP(); + if (process_sp) { - ignore_breakpoints = process->GetIgnoreBreakpointsInExpressions(); - unwind_on_error = process->GetUnwindOnErrorInExpressions(); + ignore_breakpoints = process_sp->GetIgnoreBreakpointsInExpressions(); + unwind_on_error = process_sp->GetUnwindOnErrorInExpressions(); } else { @@ -225,7 +227,7 @@ CommandObjectExpression::CommandObjectExpression(CommandInterpreter &interpreter "Evaluate an expression on the current thread. Displays any returned value with LLDB's default formatting.", nullptr, eCommandProcessMustBePaused | eCommandTryTargetAPILock), IOHandlerDelegate(IOHandlerDelegate::Completion::Expression), - m_option_group(interpreter), + m_option_group(), m_format_options(eFormatDefault), m_repl_option(LLDB_OPT_SET_1, false, "repl", 'r', "Drop into REPL", false, true), m_command_options(), @@ -517,7 +519,8 @@ CommandObjectExpression::DoExecute(const char *command, CommandReturnObject &result) { m_fixed_expression.clear(); - m_option_group.NotifyOptionParsingStarting(); + auto exe_ctx = GetCommandInterpreter().GetExecutionContext(); + m_option_group.NotifyOptionParsingStarting(&exe_ctx); const char * expr = nullptr; @@ -555,7 +558,7 @@ CommandObjectExpression::DoExecute(const char *command, if (!ParseOptions (args, result)) return false; - Error error (m_option_group.NotifyOptionParsingFinished()); + Error error (m_option_group.NotifyOptionParsingFinished(&exe_ctx)); if (error.Fail()) { result.AppendError (error.AsCString()); diff --git a/lldb/source/Commands/CommandObjectExpression.h b/lldb/source/Commands/CommandObjectExpression.h index 3445aef2766..9e6278351d1 100644 --- a/lldb/source/Commands/CommandObjectExpression.h +++ b/lldb/source/Commands/CommandObjectExpression.h @@ -44,12 +44,12 @@ public: GetDefinitions() override; Error - SetOptionValue(CommandInterpreter &interpreter, - uint32_t option_idx, - const char *option_value) override; + SetOptionValue(uint32_t option_idx, + const char *option_value, + ExecutionContext *execution_context) override; void - OptionParsingStarting(CommandInterpreter &interpreter) override; + OptionParsingStarting(ExecutionContext *execution_context) override; // Options table: Required for subclasses of Options. diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp index cd436dfdb97..9af89656af6 100644 --- a/lldb/source/Commands/CommandObjectFrame.cpp +++ b/lldb/source/Commands/CommandObjectFrame.cpp @@ -90,16 +90,17 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options(interpreter) + CommandOptions() : + Options() { - OptionParsingStarting (); + OptionParsingStarting(nullptr); } ~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; bool success = false; @@ -121,7 +122,7 @@ public: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { relative_frame_offset = INT32_MIN; } @@ -144,7 +145,7 @@ public: "Select the current stack frame by index from within the current thread (see 'thread backtrace'.)", nullptr, eCommandRequiresThread | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched | eCommandProcessMustBePaused), - m_options(interpreter) + m_options() { CommandArgumentEntry arg; CommandArgumentData index_arg; @@ -247,7 +248,10 @@ protected: { result.AppendErrorWithFormat ("too many arguments; expected frame-index, saw '%s'.\n", command.GetArgumentAtIndex(0)); - m_options.GenerateOptionUsage (result.GetErrorStream(), this); + m_options.GenerateOptionUsage(result.GetErrorStream(), this, + GetCommandInterpreter() + .GetDebugger() + .GetTerminalWidth()); return false; } } @@ -294,7 +298,7 @@ public: "'var->child.x'.", nullptr, eCommandRequiresFrame | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched | eCommandProcessMustBePaused | eCommandRequiresProcess), - m_option_group(interpreter), + m_option_group(), m_option_variable(true), // Include the frame specific options by passing "true" m_option_format(eFormatDefault), m_varobj_options() @@ -339,8 +343,8 @@ public: // Arguments are the standard source file completer. std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); - - CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + + CommandCompletions::InvokeCommonCompletionCallbacks(GetCommandInterpreter(), CommandCompletions::eVariablePathCompletion, completion_str.c_str(), match_start_point, diff --git a/lldb/source/Commands/CommandObjectHelp.cpp b/lldb/source/Commands/CommandObjectHelp.cpp index 4cf74885e99..56c940ed384 100644 --- a/lldb/source/Commands/CommandObjectHelp.cpp +++ b/lldb/source/Commands/CommandObjectHelp.cpp @@ -53,7 +53,7 @@ CommandObjectHelp::CommandObjectHelp(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "help", "Show a list of all debugger commands, or give details about a specific command.", "help [<cmd-name>]"), - m_options(interpreter) + m_options() { CommandArgumentEntry arg; CommandArgumentData command_arg; diff --git a/lldb/source/Commands/CommandObjectHelp.h b/lldb/source/Commands/CommandObjectHelp.h index a374a10e3e7..6114aa16f07 100644 --- a/lldb/source/Commands/CommandObjectHelp.h +++ b/lldb/source/Commands/CommandObjectHelp.h @@ -52,15 +52,16 @@ public: { public: - CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter) + CommandOptions() : + Options() { } ~CommandOptions() override {} 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; @@ -85,7 +86,7 @@ public: } void - OptionParsingStarting() override + OptionParsingStarting(ExecutionContext *execution_context) override { m_show_aliases = true; m_show_user_defined = true; diff --git a/lldb/source/Commands/CommandObjectLog.cpp b/lldb/source/Commands/CommandObjectLog.cpp index ca6b39c0ebf..79560bb2a97 100644 --- a/lldb/source/Commands/CommandObjectLog.cpp +++ b/lldb/source/Commands/CommandObjectLog.cpp @@ -47,7 +47,7 @@ public: "log enable", "Enable logging for a single log channel.", nullptr), - m_options (interpreter) + m_options() { CommandArgumentEntry arg1; CommandArgumentEntry arg2; @@ -104,17 +104,18 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter), - log_file (), - log_options (0) + CommandOptions() : + Options(), + log_file(), + log_options(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; @@ -140,7 +141,7 @@ public: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { log_file.Clear(); log_options = 0; diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index 7065e65ac96..0d735f9eb38 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -86,9 +86,9 @@ public: } Error - SetOptionValue (CommandInterpreter &interpreter, - 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 = g_option_table[option_idx].short_option; @@ -125,7 +125,7 @@ public: } void - OptionParsingStarting (CommandInterpreter &interpreter) override + OptionParsingStarting(ExecutionContext *execution_context) override { m_num_per_line.Clear(); m_output_as_binary = false; @@ -323,7 +323,7 @@ public: CommandObjectMemoryRead(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "memory read", "Read from the memory of the current target process.", nullptr, eCommandRequiresTarget | eCommandProcessMustBePaused), - m_option_group(interpreter), + m_option_group(), m_format_options(eFormatBytesWithASCII, 1, 8), m_memory_options(), m_outfile_options(), @@ -993,9 +993,9 @@ public: } Error - SetOptionValue (CommandInterpreter &interpreter, - 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 = g_memory_find_option_table[option_idx].short_option; @@ -1028,7 +1028,7 @@ public: } void - OptionParsingStarting (CommandInterpreter &interpreter) override + OptionParsingStarting(ExecutionContext *execution_context) override { m_expr.Clear(); m_string.Clear(); @@ -1044,7 +1044,7 @@ public: CommandObjectMemoryFind(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "memory find", "Find a value in the memory of the current target process.", nullptr, eCommandRequiresProcess | eCommandProcessMustBeLaunched), - m_option_group(interpreter), + m_option_group(), m_memory_options() { CommandArgumentEntry arg1; @@ -1274,9 +1274,9 @@ public: } Error - SetOptionValue (CommandInterpreter &interpreter, - 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 = g_memory_write_option_table[option_idx].short_option; @@ -1311,7 +1311,7 @@ public: } void - OptionParsingStarting (CommandInterpreter &interpreter) override + OptionParsingStarting(ExecutionContext *execution_context) override { m_infile.Clear(); m_infile_offset = 0; @@ -1324,7 +1324,7 @@ public: CommandObjectMemoryWrite(CommandInterpreter &interpreter) : CommandObjectParsed(interpreter, "memory write", "Write to the memory of the current target process.", nullptr, eCommandRequiresProcess | eCommandProcessMustBeLaunched), - m_option_group(interpreter), + m_option_group(), m_format_options(eFormatBytes, 1, UINT64_MAX), m_memory_options() { diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp index 99bd63b6bdb..581b3dc1ad1 100644 --- a/lldb/source/Commands/CommandObjectPlatform.cpp +++ b/lldb/source/Commands/CommandObjectPlatform.cpp @@ -89,9 +89,9 @@ public: ~OptionPermissions() override = default; lldb_private::Error - SetOptionValue (CommandInterpreter &interpreter, - uint32_t option_idx, - const char *option_arg) override + SetOptionValue(uint32_t option_idx, + const char *option_arg, + ExecutionContext *execution_context) override { Error error; char short_option = (char) GetDefinitions()[option_idx].short_option; @@ -152,7 +152,7 @@ public: } void - OptionParsingStarting (CommandInterpreter &interpreter) override + OptionParsingStarting(ExecutionContext *execution_context) override { m_permissions = 0; } @@ -189,7 +189,7 @@ public: "Create a platform if needed and select it as the current platform.", "platform select <platform-name>", 0), - m_option_group (interpreter), + m_option_group (), m_platform_options (false) // Don't include the "--platform" option by passing false { m_option_group.Append (&m_platform_options, LLDB_OPT_SET_ALL, 1); @@ -210,7 +210,7 @@ public: std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); - CommandCompletions::PlatformPluginNames(m_interpreter, + CommandCompletions::PlatformPluginNames(GetCommandInterpreter(), completion_str.c_str(), match_start_point, max_return_elements, @@ -517,7 +517,7 @@ public: "Set settings for the current target's platform, or for a platform by name.", "platform settings", 0), - m_options (interpreter), + m_options(), m_option_working_dir (LLDB_OPT_SET_1, false, "working-dir", 'w', 0, eArgTypePath, "The working directory for the platform.") { m_options.Append (&m_option_working_dir, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); @@ -568,7 +568,7 @@ public: "Make a new directory on the remote end.", nullptr, 0), - m_options(interpreter) + m_options() { } @@ -633,7 +633,7 @@ public: "Open a file on the remote end.", nullptr, 0), - m_options(interpreter) + m_options() { } @@ -752,7 +752,7 @@ public: "Read data from a file on the remote end.", nullptr, 0), - m_options (interpreter) + m_options() { } @@ -792,15 +792,16 @@ protected: 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; char short_option = (char) m_getopt_table[option_idx].val; @@ -827,7 +828,7 @@ protected: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_offset = 0; m_count = 1; @@ -872,7 +873,7 @@ public: "Write data to a file on the remote end.", nullptr, 0), - m_options (interpreter) + m_options() { } @@ -914,15 +915,16 @@ protected: 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; char short_option = (char) m_getopt_table[option_idx].val; @@ -947,7 +949,7 @@ protected: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_offset = 0; m_data.clear(); @@ -1220,7 +1222,7 @@ public: "Launch a new process on a remote platform.", "platform process launch program", eCommandRequiresTarget | eCommandTryTargetAPILock), - m_options (interpreter) + m_options() { } @@ -1332,7 +1334,7 @@ public: "List processes on a remote platform by name, pid, or many other matching attributes.", "platform process list", 0), - m_options (interpreter) + m_options() { } @@ -1451,8 +1453,8 @@ protected: class CommandOptions : public Options { public: - CommandOptions(CommandInterpreter &interpreter) : - Options(interpreter), + CommandOptions() : + Options(), match_info(), show_args(false), verbose(false) @@ -1480,7 +1482,8 @@ protected: ~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; @@ -1525,7 +1528,18 @@ protected: break; case 'a': - match_info.GetProcessInfo().GetArchitecture().SetTriple (option_arg, m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform().get()); + { + TargetSP target_sp = execution_context ? + execution_context->GetTargetSP() : TargetSP(); + DebuggerSP debugger_sp = target_sp ? + target_sp->GetDebugger().shared_from_this() : + DebuggerSP(); + PlatformSP platform_sp = debugger_sp ? + debugger_sp->GetPlatformList().GetSelectedPlatform() : + PlatformSP(); + match_info.GetProcessInfo().GetArchitecture().SetTriple( + option_arg, platform_sp.get()); + } break; case 'n': @@ -1570,7 +1584,7 @@ protected: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { match_info.Clear(); show_args = false; @@ -1727,17 +1741,18 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options(interpreter) + CommandOptions() : + Options() { // Keep default values of all options in one place: OptionParsingStarting () - OptionParsingStarting (); + OptionParsingStarting(nullptr); } ~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; char short_option = (char) m_getopt_table[option_idx].val; @@ -1778,7 +1793,7 @@ public: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { attach_info.Clear(); } @@ -1797,6 +1812,7 @@ public: int opt_element_index, int match_start_point, int max_return_elements, + CommandInterpreter &interpreter, bool &word_complete, StringList &matches) override { @@ -1816,7 +1832,7 @@ public: const char *partial_name = nullptr; partial_name = input.GetArgumentAtIndex(opt_arg_pos); - PlatformSP platform_sp (m_interpreter.GetPlatform (true)); + PlatformSP platform_sp(interpreter.GetPlatform(true)); if (platform_sp) { ProcessInstanceInfoList process_infos; @@ -1856,7 +1872,7 @@ public: "platform process attach", "Attach to a process.", "platform process attach <cmd-options>"), - m_options (interpreter) + m_options() { } @@ -1948,8 +1964,8 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options(interpreter), + CommandOptions() : + Options(), timeout(10) { } @@ -1970,7 +1986,8 @@ public: Error SetOptionValue (uint32_t option_idx, - const char *option_value) override + const char *option_value, + ExecutionContext *execution_context) override { Error error; @@ -1995,7 +2012,7 @@ public: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { } @@ -2008,7 +2025,7 @@ public: CommandObjectPlatformShell(CommandInterpreter &interpreter) : CommandObjectRaw(interpreter, "platform shell", "Run a shell command on the current platform.", "platform shell <shell-command>", 0), - m_options(interpreter) + m_options() { } @@ -2023,7 +2040,9 @@ public: bool DoExecute (const char *raw_command_line, CommandReturnObject &result) override { - m_options.NotifyOptionParsingStarting(); + ExecutionContext exe_ctx = + GetCommandInterpreter().GetExecutionContext(); + m_options.NotifyOptionParsingStarting(&exe_ctx); const char* expr = nullptr; diff --git a/lldb/source/Commands/CommandObjectPlugin.cpp b/lldb/source/Commands/CommandObjectPlugin.cpp index 221c9a67d84..8d1a5a5d462 100644 --- a/lldb/source/Commands/CommandObjectPlugin.cpp +++ b/lldb/source/Commands/CommandObjectPlugin.cpp @@ -56,8 +56,8 @@ public: { std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); - - CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + + CommandCompletions::InvokeCommonCompletionCallbacks(GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion, completion_str.c_str(), match_start_point, diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index 106e2d86b18..1da33bb50cb 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -126,7 +126,7 @@ public: nullptr, eCommandRequiresTarget, "restart"), - m_options (interpreter) + m_options() { CommandArgumentEntry arg; CommandArgumentData run_args_arg; @@ -156,8 +156,8 @@ public: { std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); - - CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + + CommandCompletions::InvokeCommonCompletionCallbacks(GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion, completion_str.c_str(), match_start_point, @@ -328,17 +328,18 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options(interpreter) + CommandOptions() : + Options() { // Keep default values of all options in one place: OptionParsingStarting () - OptionParsingStarting (); + OptionParsingStarting(nullptr); } ~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; @@ -387,7 +388,7 @@ public: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { attach_info.Clear(); } @@ -406,6 +407,7 @@ public: int opt_element_index, int match_start_point, int max_return_elements, + CommandInterpreter &interpreter, bool &word_complete, StringList &matches) override { @@ -425,7 +427,7 @@ public: const char *partial_name = nullptr; partial_name = input.GetArgumentAtIndex(opt_arg_pos); - PlatformSP platform_sp (m_interpreter.GetPlatform (true)); + PlatformSP platform_sp(interpreter.GetPlatform(true)); if (platform_sp) { ProcessInstanceInfoList process_infos; @@ -467,7 +469,7 @@ public: "process attach <cmd-options>", 0, "attach"), - m_options (interpreter) + m_options() { } @@ -632,7 +634,7 @@ public: eCommandTryTargetAPILock | eCommandProcessMustBeLaunched | eCommandProcessMustBePaused ), - m_options(interpreter) + m_options() { } @@ -642,17 +644,18 @@ protected: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options(interpreter) + CommandOptions() : + Options() { // Keep default values of all options in one place: OptionParsingStarting () - OptionParsingStarting (); + OptionParsingStarting(nullptr); } ~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; @@ -673,7 +676,7 @@ protected: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_ignore = 0; } @@ -818,16 +821,17 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter) + CommandOptions() : + Options() { - OptionParsingStarting (); + OptionParsingStarting(nullptr); } ~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; @@ -856,7 +860,7 @@ public: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_keep_stopped = eLazyBoolCalculate; } @@ -879,7 +883,7 @@ public: : CommandObjectParsed(interpreter, "process detach", "Detach from the current target process.", "process detach", eCommandRequiresProcess | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched), - m_options(interpreter) + m_options() { } @@ -943,17 +947,18 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options(interpreter) + CommandOptions() : + Options() { // Keep default values of all options in one place: OptionParsingStarting () - OptionParsingStarting (); + OptionParsingStarting(nullptr); } ~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; @@ -972,7 +977,7 @@ public: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { plugin_name.clear(); } @@ -998,7 +1003,7 @@ public: "Connect to a remote debug service.", "process connect <remote-url>", 0), - m_options (interpreter) + m_options() { } @@ -1100,17 +1105,18 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options(interpreter) + CommandOptions() : + Options() { // Keep default values of all options in one place: OptionParsingStarting () - OptionParsingStarting (); + OptionParsingStarting(nullptr); } ~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; @@ -1129,7 +1135,7 @@ public: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { do_install = false; install_path.Clear(); @@ -1158,7 +1164,7 @@ public: eCommandTryTargetAPILock | eCommandProcessMustBeLaunched | eCommandProcessMustBePaused ), - m_options (interpreter) + m_options() { } @@ -1577,16 +1583,17 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter) + CommandOptions() : + Options() { - OptionParsingStarting (); + OptionParsingStarting(nullptr); } ~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; @@ -1610,7 +1617,7 @@ public: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { stop.clear(); notify.clear(); @@ -1639,7 +1646,7 @@ public: interpreter, "process handle", "Manage LLDB handling of OS signals for the current target process. Defaults to showing current policy.", nullptr), - m_options(interpreter) + m_options() { SetHelpLong ("\nIf no signals are specified, update them all. If no update " "option is specified, list the current values."); diff --git a/lldb/source/Commands/CommandObjectRegister.cpp b/lldb/source/Commands/CommandObjectRegister.cpp index ff8df2a6aca..00b60fb2c65 100644 --- a/lldb/source/Commands/CommandObjectRegister.cpp +++ b/lldb/source/Commands/CommandObjectRegister.cpp @@ -50,7 +50,7 @@ public: eCommandRequiresRegContext | eCommandProcessMustBeLaunched | eCommandProcessMustBePaused ), - m_option_group (interpreter), + m_option_group(), m_format_options (eFormatDefault), m_command_options () { @@ -279,7 +279,7 @@ protected: } void - OptionParsingStarting (CommandInterpreter &interpreter) override + OptionParsingStarting(ExecutionContext *execution_context) override { set_indexes.Clear(); dump_all_sets.Clear(); @@ -287,9 +287,9 @@ protected: } Error - SetOptionValue (CommandInterpreter &interpreter, - uint32_t option_idx, - const char *option_value) override + SetOptionValue (uint32_t option_idx, + const char *option_value, + ExecutionContext *execution_context) override { Error error; const int short_option = g_option_table[option_idx].short_option; diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp index b76af207525..3fcca55c021 100644 --- a/lldb/source/Commands/CommandObjectSettings.cpp +++ b/lldb/source/Commands/CommandObjectSettings.cpp @@ -32,7 +32,7 @@ class CommandObjectSettingsSet : public CommandObjectRaw public: CommandObjectSettingsSet(CommandInterpreter &interpreter) : CommandObjectRaw(interpreter, "settings set", "Set the value of the specified debugger setting.", nullptr), - m_options(interpreter) + m_options() { CommandArgumentEntry arg1; CommandArgumentEntry arg2; @@ -95,16 +95,17 @@ insert-before or insert-after." class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter), - m_global (false) + CommandOptions() : + Options(), + m_global(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; @@ -123,7 +124,7 @@ insert-before or insert-after." } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_global = false; } @@ -168,7 +169,7 @@ insert-before or insert-after." if (cursor_index == setting_var_idx) { // Attempting to complete setting variable name - CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks(GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, completion_str.c_str(), match_start_point, @@ -328,7 +329,7 @@ public: { std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position); - CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks(GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, completion_str.c_str(), match_start_point, @@ -418,7 +419,7 @@ public: { std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position); - CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks(GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, completion_str.c_str(), match_start_point, @@ -524,7 +525,7 @@ public: // Attempting to complete variable name if (cursor_index < 2) - CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks(GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, completion_str.c_str(), match_start_point, @@ -532,7 +533,6 @@ public: nullptr, word_complete, matches); - return matches.GetSize(); } @@ -655,7 +655,7 @@ public: // Attempting to complete variable name if (cursor_index < 2) - CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks(GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, completion_str.c_str(), match_start_point, @@ -774,7 +774,7 @@ public: // Attempting to complete variable name if (cursor_index < 2) - CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks(GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, completion_str.c_str(), match_start_point, @@ -896,7 +896,7 @@ public: // Attempting to complete variable name if (cursor_index < 2) - CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks(GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, completion_str.c_str(), match_start_point, @@ -1007,7 +1007,7 @@ public: // Attempting to complete variable name if (cursor_index < 2) - CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks(GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, completion_str.c_str(), match_start_point, @@ -1106,7 +1106,7 @@ public: // Attempting to complete variable name if (cursor_index < 2) - CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks(GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, completion_str.c_str(), match_start_point, diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp index cef9d09d0e5..e87169d9953 100644 --- a/lldb/source/Commands/CommandObjectSource.cpp +++ b/lldb/source/Commands/CommandObjectSource.cpp @@ -45,12 +45,13 @@ class CommandObjectSourceInfo : public CommandObjectParsed 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 = g_option_table[option_idx].short_option; @@ -84,8 +85,10 @@ class CommandObjectSourceInfo : public CommandObjectParsed case 'a': { - ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); - address = Args::StringToAddress(&exe_ctx, option_arg, LLDB_INVALID_ADDRESS, &error); + address = Args::StringToAddress(execution_context, + option_arg, + LLDB_INVALID_ADDRESS, + &error); } break; case 's': @@ -100,7 +103,7 @@ class CommandObjectSourceInfo : public CommandObjectParsed } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { file_spec.Clear(); file_name.clear(); @@ -137,7 +140,7 @@ public: "process. Defaults to instruction pointer in current stack " "frame.", nullptr, eCommandRequiresTarget), - m_options(interpreter) + m_options() { } @@ -728,15 +731,16 @@ class CommandObjectSourceList : public CommandObjectParsed 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 = g_option_table[option_idx].short_option; @@ -764,8 +768,10 @@ class CommandObjectSourceList : public CommandObjectParsed case 'a': { - ExecutionContext exe_ctx (m_interpreter.GetExecutionContext()); - address = Args::StringToAddress(&exe_ctx, option_arg, LLDB_INVALID_ADDRESS, &error); + address = Args::StringToAddress(execution_context, + option_arg, + LLDB_INVALID_ADDRESS, + &error); } break; case 's': @@ -787,7 +793,7 @@ class CommandObjectSourceList : public CommandObjectParsed } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { file_spec.Clear(); file_name.clear(); @@ -825,7 +831,7 @@ public: : CommandObjectParsed(interpreter, "source list", "Display source code for the current target process as specified by options.", nullptr, eCommandRequiresTarget), - m_options(interpreter) + m_options() { } diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index d6cf0e346a9..5193da10d13 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -157,7 +157,7 @@ public: "target create", "Create a target using the argument as the main executable.", nullptr), - m_option_group (interpreter), + m_option_group (), m_arch_option (), m_core_file (LLDB_OPT_SET_1, false, "core", 'c', 0, eArgTypeFilename, "Fullpath to a core file to use for this target."), m_platform_path (LLDB_OPT_SET_1, false, "platform-path", 'P', 0, eArgTypePath, "Path to the remote file to use for this target."), @@ -208,7 +208,7 @@ public: std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); - CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks(GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion, completion_str.c_str(), match_start_point, @@ -594,7 +594,7 @@ public: "target delete", "Delete one or more targets by target index.", nullptr), - m_option_group(interpreter), + m_option_group(), m_all_option(LLDB_OPT_SET_1, false, "all", 'a', "Delete all targets.", false, true), m_cleanup_option( LLDB_OPT_SET_1, @@ -728,7 +728,7 @@ public: : CommandObjectParsed(interpreter, "target variable", "Read global variables for the current target, before or while running a process.", nullptr, eCommandRequiresTarget), - m_option_group(interpreter), + m_option_group(), m_option_variable(false), // Don't include frame options m_option_format(eFormatDefault), m_option_compile_units(LLDB_OPT_SET_1, false, "file", SHORT_OPTION_FILE, 0, eArgTypeFilename, @@ -2068,7 +2068,7 @@ public: std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); - CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks(GetCommandInterpreter(), CommandCompletions::eModuleCompletion, completion_str.c_str(), match_start_point, @@ -2127,7 +2127,7 @@ public: std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); - CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks(GetCommandInterpreter(), CommandCompletions::eSourceFileCompletion, completion_str.c_str(), match_start_point, @@ -2220,7 +2220,7 @@ public: "target modules dump symtab", "Dump the symbol table from one or more target modules.", nullptr), - m_options(interpreter) + m_options() { } @@ -2235,16 +2235,17 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options(interpreter), - m_sort_order (eSortOrderNone) + CommandOptions() : + Options(), + m_sort_order(eSortOrderNone) { } ~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; @@ -2266,7 +2267,7 @@ public: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_sort_order = eSortOrderNone; } @@ -2704,7 +2705,7 @@ public: "target modules add", "Add a new module to the current target's modules.", "target modules add [<module>]"), - m_option_group (interpreter), + m_option_group(), m_symbol_file (LLDB_OPT_SET_1, false, "symfile", 's', 0, eArgTypeFilename, "Fullpath to a stand alone debug symbols file for when debug symbols are not in the executable.") { m_option_group.Append (&m_uuid_option_group, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); @@ -2733,7 +2734,7 @@ public: std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); - CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks(GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion, completion_str.c_str(), match_start_point, @@ -2900,7 +2901,7 @@ public: "target modules load", "Set the load addresses for one or more sections in a target module.", "target modules load [--file <module> --uuid <uuid>] <sect-name> <address> [<sect-name> <address> ....]"), - m_option_group (interpreter), + m_option_group(), m_file_option (LLDB_OPT_SET_1, false, "file", 'f', 0, eArgTypeName, "Fullpath or basename for module to load.", ""), m_slide_option(LLDB_OPT_SET_1, false, "slide", 's', 0, eArgTypeOffset, "Set the load address for all sections to be the virtual address in the file plus the offset.", 0) { @@ -3155,8 +3156,8 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options(interpreter), + CommandOptions() : + Options(), m_format_array(), m_use_global_module_list (false), m_module_addr (LLDB_INVALID_ADDRESS) @@ -3166,7 +3167,8 @@ public: ~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; @@ -3177,8 +3179,10 @@ public: } else if (short_option == 'a') { - ExecutionContext exe_ctx (m_interpreter.GetExecutionContext()); - m_module_addr = Args::StringToAddress(&exe_ctx, option_arg, LLDB_INVALID_ADDRESS, &error); + m_module_addr = Args::StringToAddress(execution_context, + option_arg, + LLDB_INVALID_ADDRESS, + &error); } else { @@ -3191,7 +3195,7 @@ public: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_format_array.clear(); m_use_global_module_list = false; @@ -3220,7 +3224,7 @@ public: "target modules list", "List current executable and dependent shared library images.", "target modules list [<cmd-options>]"), - m_options (interpreter) + m_options() { } @@ -3594,8 +3598,8 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options(interpreter), + CommandOptions() : + Options(), m_type(eLookupTypeInvalid), m_str(), m_addr(LLDB_INVALID_ADDRESS) @@ -3605,7 +3609,8 @@ public: ~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; @@ -3615,10 +3620,12 @@ public: { case 'a': { - ExecutionContext exe_ctx (m_interpreter.GetExecutionContext()); m_str = option_arg; m_type = eLookupTypeAddress; - m_addr = Args::StringToAddress(&exe_ctx, option_arg, LLDB_INVALID_ADDRESS, &error); + m_addr = Args::StringToAddress(execution_context, + option_arg, + LLDB_INVALID_ADDRESS, + &error); if (m_addr == LLDB_INVALID_ADDRESS) error.SetErrorStringWithFormat ("invalid address string '%s'", option_arg); break; @@ -3638,7 +3645,7 @@ public: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_type = eLookupTypeInvalid; m_str.clear(); @@ -3671,7 +3678,7 @@ public: eCommandRequiresProcess | eCommandProcessMustBeLaunched | eCommandProcessMustBePaused ), - m_options (interpreter) + m_options() { } @@ -3900,16 +3907,17 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options(interpreter) + CommandOptions() : + Options() { - OptionParsingStarting(); + OptionParsingStarting(nullptr); } ~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; @@ -3920,8 +3928,10 @@ public: case 'a': { m_type = eLookupTypeAddress; - ExecutionContext exe_ctx (m_interpreter.GetExecutionContext()); - m_addr = Args::StringToAddress(&exe_ctx, option_arg, LLDB_INVALID_ADDRESS, &error); + m_addr = Args::StringToAddress(execution_context, + option_arg, + LLDB_INVALID_ADDRESS, + &error); } break; @@ -3986,7 +3996,7 @@ public: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_type = eLookupTypeInvalid; m_str.clear(); @@ -4027,7 +4037,7 @@ public: "Look up information within executable and dependent shared library images.", nullptr, eCommandRequiresTarget), - m_options (interpreter) + m_options() { CommandArgumentEntry arg; CommandArgumentData file_arg; @@ -4190,7 +4200,10 @@ public: break; default: - m_options.GenerateOptionUsage (result.GetErrorStream(), this); + m_options.GenerateOptionUsage(result.GetErrorStream(), this, + GetCommandInterpreter() + .GetDebugger() + .GetTerminalWidth()); syntax_error = true; break; } @@ -4392,7 +4405,7 @@ public: "target symbols add", "Add a debug symbol file to one of the target's current modules by specifying a path to a debug symbols file, or using the options to specify a module to download symbols for.", "target symbols add [<symfile>]", eCommandRequiresTarget), - m_option_group (interpreter), + m_option_group(), m_file_option (LLDB_OPT_SET_1, false, "shlib", 's', CommandCompletions::eModuleCompletion, eArgTypeShlibName, "Fullpath or basename for module to find debug symbols for."), m_current_frame_option (LLDB_OPT_SET_2, false, "frame", 'F', "Locate the debug symbols the currently selected frame.", false, true) @@ -4418,7 +4431,7 @@ public: std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); - CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks(GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion, completion_str.c_str(), match_start_point, @@ -4847,8 +4860,8 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options(interpreter), + CommandOptions() : + Options(), m_line_start(0), m_line_end (UINT_MAX), m_func_name_type_mask (eFunctionNameTypeAuto), @@ -4868,7 +4881,8 @@ public: } 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; @@ -4958,7 +4972,7 @@ public: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_class_name.clear(); m_function_name.clear(); @@ -5007,7 +5021,7 @@ public: "Add a hook to be executed when the target stops.", "target stop-hook add"), IOHandlerDelegateMultiline ("DONE", IOHandlerDelegate::Completion::LLDBCommand), - m_options (interpreter) + m_options() { } diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index 9e4bffdeb6a..2c74bf88b1a 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -153,17 +153,18 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options(interpreter) + CommandOptions() : + Options() { // Keep default values of all options in one place: OptionParsingStarting () - OptionParsingStarting (); + OptionParsingStarting(nullptr); } ~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; @@ -206,7 +207,7 @@ public: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_count = UINT32_MAX; m_start = 0; @@ -236,7 +237,7 @@ public: "to see all threads.", nullptr, eCommandRequiresProcess | eCommandRequiresThread | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched | eCommandProcessMustBePaused), - m_options(interpreter) + m_options() { } @@ -334,17 +335,18 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter) + CommandOptions() : + Options() { // Keep default values of all options in one place: OptionParsingStarting () - OptionParsingStarting (); + OptionParsingStarting(nullptr); } ~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; @@ -429,14 +431,16 @@ public: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_step_in_avoid_no_debug = eLazyBoolCalculate; m_step_out_avoid_no_debug = eLazyBoolCalculate; m_run_mode = eOnlyDuringStepping; // Check if we are in Non-Stop mode - lldb::TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget(); + TargetSP target_sp = + execution_context ? execution_context->GetTargetSP() : + TargetSP(); if (target_sp && target_sp->GetNonStopModeEnabled()) m_run_mode = eOnlyThisThread; @@ -484,7 +488,7 @@ public: eCommandProcessMustBePaused ), m_step_type (step_type), m_step_scope (step_scope), - m_options (interpreter) + m_options() { CommandArgumentEntry arg; CommandArgumentData thread_id_arg; @@ -1007,19 +1011,20 @@ public: uint32_t m_thread_idx; uint32_t m_frame_idx; - CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter), + CommandOptions() : + Options(), m_thread_idx(LLDB_INVALID_THREAD_ID), m_frame_idx(LLDB_INVALID_FRAME_ID) { // Keep default values of all options in one place: OptionParsingStarting () - OptionParsingStarting (); + OptionParsingStarting(nullptr); } ~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; @@ -1028,8 +1033,9 @@ public: { case 'a': { - ExecutionContext exe_ctx (m_interpreter.GetExecutionContext()); - lldb::addr_t tmp_addr = Args::StringToAddress(&exe_ctx, option_arg, LLDB_INVALID_ADDRESS, &error); + lldb::addr_t tmp_addr = + Args::StringToAddress(execution_context, option_arg, + LLDB_INVALID_ADDRESS, &error); if (error.Success()) m_until_addrs.push_back(tmp_addr); } @@ -1070,7 +1076,7 @@ public: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_thread_idx = LLDB_INVALID_THREAD_ID; m_frame_idx = 0; @@ -1101,7 +1107,7 @@ public: "the current function as a safety measure.", nullptr, eCommandRequiresThread | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched | eCommandProcessMustBePaused), - m_options(interpreter) + m_options() { CommandArgumentEntry arg; CommandArgumentData line_num_arg; @@ -1461,23 +1467,24 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter) + CommandOptions() : + Options() { - OptionParsingStarting (); + OptionParsingStarting(nullptr); } ~CommandOptions() override = default; void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_json_thread = false; m_json_stopinfo = false; } Error - SetOptionValue (uint32_t option_idx, const char *option_arg) override + SetOptionValue(uint32_t option_idx, const char *option_arg, + ExecutionContext *execution_context) override { const int short_option = m_getopt_table[option_idx].val; Error error; @@ -1516,7 +1523,7 @@ public: "Show an extended summary of one or more threads. Defaults to the current thread.", "thread info", eCommandRequiresProcess | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched | eCommandProcessMustBePaused), - m_options(interpreter) + m_options() { m_add_return = false; } @@ -1574,18 +1581,19 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter), - m_from_expression (false) + CommandOptions() : + Options(), + m_from_expression(false) { // Keep default values of all options in one place: OptionParsingStarting () - OptionParsingStarting (); + OptionParsingStarting(nullptr); } ~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; @@ -1612,7 +1620,7 @@ public: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_from_expression = false; } @@ -1639,7 +1647,7 @@ public: "frame.", "thread return", eCommandRequiresFrame | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched | eCommandProcessMustBePaused), - m_options(interpreter) + m_options() { CommandArgumentEntry arg; CommandArgumentData expression_arg; @@ -1770,16 +1778,16 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter) + CommandOptions() : + Options() { - OptionParsingStarting (); + OptionParsingStarting(nullptr); } ~CommandOptions() override = default; void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_filenames.Clear(); m_line_num = 0; @@ -1789,7 +1797,8 @@ public: } Error - SetOptionValue (uint32_t option_idx, const char *option_arg) override + SetOptionValue(uint32_t option_idx, const char *option_arg, + ExecutionContext *execution_context) override { bool success; const int short_option = m_getopt_table[option_idx].val; @@ -1813,10 +1822,10 @@ public: return Error("invalid line offset: '%s'.", option_arg); break; case 'a': - { - ExecutionContext exe_ctx (m_interpreter.GetExecutionContext()); - m_load_addr = Args::StringToAddress(&exe_ctx, option_arg, LLDB_INVALID_ADDRESS, &error); - } + m_load_addr = Args::StringToAddress(execution_context, + option_arg, + LLDB_INVALID_ADDRESS, + &error); break; case 'r': m_force = true; @@ -1851,7 +1860,7 @@ public: eCommandTryTargetAPILock | eCommandProcessMustBeLaunched | eCommandProcessMustBePaused ), - m_options (interpreter) + m_options() { } @@ -1967,17 +1976,18 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options(interpreter) + CommandOptions() : + Options() { // Keep default values of all options in one place: OptionParsingStarting () - OptionParsingStarting (); + OptionParsingStarting(nullptr); } ~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; @@ -1998,7 +2008,7 @@ public: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_verbose = false; m_internal = false; @@ -2026,7 +2036,7 @@ public: "current thread. Use the thread-index \"all\" to see all threads.", nullptr, eCommandRequiresProcess | eCommandRequiresThread | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched | eCommandProcessMustBePaused), - m_options(interpreter) + m_options() { } diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp index 9b5ae4f65d3..36a1131434c 100644 --- a/lldb/source/Commands/CommandObjectType.cpp +++ b/lldb/source/Commands/CommandObjectType.cpp @@ -131,17 +131,18 @@ private: { public: CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter) + 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; void - OptionParsingStarting () override; + OptionParsingStarting(ExecutionContext *execution_context) override; const OptionDefinition* GetDefinitions () override @@ -361,15 +362,16 @@ private: 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; @@ -410,7 +412,7 @@ private: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_cascade = true; m_class_name = ""; @@ -639,7 +641,7 @@ private: } void - OptionParsingStarting (CommandInterpreter &interpreter) override + OptionParsingStarting(ExecutionContext *execution_context) override { m_cascade = true; m_skip_pointers = false; @@ -650,9 +652,9 @@ private: } Error - SetOptionValue (CommandInterpreter &interpreter, - uint32_t option_idx, - const char *option_value) override + SetOptionValue(uint32_t option_idx, + const char *option_value, + ExecutionContext *execution_context) override { Error error; const int short_option = g_option_table[option_idx].short_option; @@ -718,9 +720,9 @@ public: "type format add", "Add a new formatting style for a type.", nullptr), - m_option_group (interpreter), - m_format_options (eFormatInvalid), - m_command_options () + m_option_group(), + m_format_options(eFormatInvalid), + m_command_options() { CommandArgumentEntry type_arg; CommandArgumentData type_style_arg; @@ -877,15 +879,16 @@ protected: 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; @@ -910,7 +913,7 @@ protected: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_delete_all = false; m_category = "default"; @@ -952,7 +955,7 @@ public: name, help, nullptr), - m_options(interpreter), + m_options(), m_formatter_kind_mask(formatter_kind_mask) { CommandArgumentEntry type_arg; @@ -1056,15 +1059,16 @@ private: 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; @@ -1083,7 +1087,7 @@ private: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_delete_all = false; } @@ -1120,7 +1124,7 @@ public: name, help, nullptr), - m_options(interpreter), + m_options(), m_formatter_kind_mask(formatter_kind_mask) { } @@ -1215,8 +1219,8 @@ class CommandObjectTypeFormatterList : public CommandObjectParsed class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter), + CommandOptions() : + Options(), m_category_regex("",""), m_category_language(lldb::eLanguageTypeUnknown, lldb::eLanguageTypeUnknown) { @@ -1225,7 +1229,8 @@ class CommandObjectTypeFormatterList : public CommandObjectParsed ~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; @@ -1250,7 +1255,7 @@ class CommandObjectTypeFormatterList : public CommandObjectParsed } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_category_regex.Clear(); m_category_language.Clear(); @@ -1295,7 +1300,7 @@ public: name, help, nullptr), - m_options(interpreter) + m_options() { CommandArgumentEntry type_arg; CommandArgumentData type_style_arg; @@ -1473,7 +1478,11 @@ public: #endif // LLDB_DISABLE_PYTHON Error -CommandObjectTypeSummaryAdd::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg) +CommandObjectTypeSummaryAdd::CommandOptions::SetOptionValue(uint32_t option_idx, + const char + *option_arg, + ExecutionContext + *execution_context) { Error error; const int short_option = m_getopt_table[option_idx].val; @@ -1539,7 +1548,8 @@ CommandObjectTypeSummaryAdd::CommandOptions::SetOptionValue (uint32_t option_idx } void -CommandObjectTypeSummaryAdd::CommandOptions::OptionParsingStarting () +CommandObjectTypeSummaryAdd::CommandOptions::OptionParsingStarting( + ExecutionContext *execution_context) { m_flags.Clear().SetCascades().SetDontShowChildren().SetDontShowValue(false); m_flags.SetShowMembersOneLiner(false).SetSkipPointers(false).SetSkipReferences(false).SetHideItemNames(false); @@ -2069,8 +2079,8 @@ class CommandObjectTypeCategoryDefine : public CommandObjectParsed class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter), + CommandOptions() : + Options(), m_define_enabled(false,false), m_cate_language(eLanguageTypeUnknown,eLanguageTypeUnknown) { @@ -2079,7 +2089,8 @@ class CommandObjectTypeCategoryDefine : public CommandObjectParsed ~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; @@ -2101,7 +2112,7 @@ class CommandObjectTypeCategoryDefine : public CommandObjectParsed } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_define_enabled.Clear(); m_cate_language.Clear(); @@ -2137,7 +2148,7 @@ public: "type category define", "Define a new category as a source of formatters.", nullptr), - m_options(interpreter) + m_options() { CommandArgumentEntry type_arg; CommandArgumentData type_style_arg; @@ -2199,15 +2210,16 @@ class CommandObjectTypeCategoryEnable : public CommandObjectParsed 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; @@ -2231,7 +2243,7 @@ class CommandObjectTypeCategoryEnable : public CommandObjectParsed } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_language = lldb::eLanguageTypeUnknown; } @@ -2266,7 +2278,7 @@ public: "type category enable", "Enable a category as a source of formatters.", nullptr), - m_options(interpreter) + m_options() { CommandArgumentEntry type_arg; CommandArgumentData type_style_arg; @@ -2419,15 +2431,16 @@ class CommandObjectTypeCategoryDisable : public CommandObjectParsed 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; @@ -2451,7 +2464,7 @@ class CommandObjectTypeCategoryDisable : public CommandObjectParsed } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_language = lldb::eLanguageTypeUnknown; } @@ -2485,7 +2498,7 @@ public: "type category disable", "Disable a category as a source of formatters.", nullptr), - m_options(interpreter) + m_options() { CommandArgumentEntry type_arg; CommandArgumentData type_style_arg; @@ -2845,7 +2858,7 @@ CommandObjectTypeSynthAdd::CommandObjectTypeSynthAdd (CommandInterpreter &interp "Add a new synthetic provider for a type.", nullptr), IOHandlerDelegateMultiline ("DONE"), - m_options (interpreter) + m_options() { CommandArgumentEntry type_arg; CommandArgumentData type_style_arg; @@ -2928,15 +2941,16 @@ private: typedef std::vector<std::string> option_vector; 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; @@ -2974,7 +2988,7 @@ private: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_cascade = true; m_skip_pointers = false; @@ -3076,7 +3090,7 @@ public: "type filter add", "Add a new filter for a type.", nullptr), - m_options (interpreter) + m_options() { CommandArgumentEntry type_arg; CommandArgumentData type_style_arg; @@ -3257,9 +3271,9 @@ protected: } Error - SetOptionValue (CommandInterpreter &interpreter, - uint32_t option_idx, - const char *option_value) override + SetOptionValue (uint32_t option_idx, + const char *option_value, + ExecutionContext *execution_context) override { Error error; @@ -3284,7 +3298,7 @@ protected: } void - OptionParsingStarting (CommandInterpreter &interpreter) override + OptionParsingStarting(ExecutionContext *execution_context) override { m_show_help = false; m_language = eLanguageTypeUnknown; @@ -3307,7 +3321,7 @@ public: "Lookup types and declarations in the current target, following language-specific naming conventions.", "type lookup <type-specifier>", eCommandRequiresTarget), - m_option_group(interpreter), + m_option_group(), m_command_options() { m_option_group.Append(&m_command_options); @@ -3356,8 +3370,9 @@ public: result.SetError("type lookup cannot be invoked without a type name as argument"); return false; } - - m_option_group.NotifyOptionParsingStarting(); + + auto exe_ctx = GetCommandInterpreter().GetExecutionContext(); + m_option_group.NotifyOptionParsingStarting(&exe_ctx); const char * name_of_type = nullptr; @@ -3389,7 +3404,8 @@ public: if (!ParseOptions (args, result)) return false; - Error error (m_option_group.NotifyOptionParsingFinished()); + Error error(m_option_group.NotifyOptionParsingFinished( + &exe_ctx)); if (error.Fail()) { result.AppendError (error.AsCString()); @@ -3401,9 +3417,9 @@ public: if (nullptr == name_of_type) name_of_type = raw_command_line; - TargetSP target_sp(GetCommandInterpreter().GetDebugger().GetSelectedTarget()); - const bool fill_all_in = true; - ExecutionContext exe_ctx(target_sp.get(), fill_all_in); + // TargetSP target_sp(GetCommandInterpreter().GetDebugger().GetSelectedTarget()); + // const bool fill_all_in = true; + // ExecutionContext exe_ctx(target_sp.get(), fill_all_in); ExecutionContextScope *best_scope = exe_ctx.GetBestExecutionContextScope(); bool any_found = false; diff --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp b/lldb/source/Commands/CommandObjectWatchpoint.cpp index 977b6bb3743..f232311fcf3 100644 --- a/lldb/source/Commands/CommandObjectWatchpoint.cpp +++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp @@ -170,7 +170,7 @@ public: "watchpoint list", "List all watchpoints at configurable levels of detail.", nullptr), - m_options(interpreter) + m_options() { CommandArgumentEntry arg; CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange); @@ -189,8 +189,8 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options(interpreter), + CommandOptions() : + Options(), m_level(lldb::eDescriptionLevelBrief) // Watchpoint List defaults to brief descriptions { } @@ -198,7 +198,8 @@ public: ~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; @@ -223,7 +224,7 @@ public: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_level = lldb::eDescriptionLevelFull; } @@ -589,7 +590,7 @@ public: "watchpoint ignore", "Set ignore count on the specified watchpoint(s). If no watchpoints are specified, set them all.", nullptr), - m_options (interpreter) + m_options() { CommandArgumentEntry arg; CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange); @@ -608,8 +609,8 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter), + CommandOptions() : + Options(), m_ignore_count (0) { } @@ -617,7 +618,8 @@ public: ~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; @@ -638,7 +640,7 @@ public: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_ignore_count = 0; } @@ -738,7 +740,7 @@ public: "If no watchpoint is specified, act on the last created watchpoint. " "Passing an empty argument clears the modification.", nullptr), - m_options (interpreter) + m_options() { CommandArgumentEntry arg; CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange); @@ -757,8 +759,8 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter), + CommandOptions() : + Options(), m_condition (), m_condition_passed (false) { @@ -767,7 +769,8 @@ public: ~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; @@ -790,7 +793,7 @@ public: } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_condition.clear(); m_condition_passed = false; @@ -907,7 +910,7 @@ public: eCommandTryTargetAPILock | eCommandProcessMustBeLaunched | eCommandProcessMustBePaused ), - m_option_group (interpreter), + m_option_group(), m_option_watchpoint () { SetHelpLong( @@ -1116,7 +1119,7 @@ public: eCommandTryTargetAPILock | eCommandProcessMustBeLaunched | eCommandProcessMustBePaused ), - m_option_group (interpreter), + m_option_group(), m_option_watchpoint () { SetHelpLong( @@ -1162,7 +1165,8 @@ protected: bool DoExecute (const char *raw_command, CommandReturnObject &result) override { - m_option_group.NotifyOptionParsingStarting(); // This is a raw command, so notify the option group + auto exe_ctx = GetCommandInterpreter().GetExecutionContext(); + m_option_group.NotifyOptionParsingStarting(&exe_ctx); // This is a raw command, so notify the option group Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); StackFrame *frame = m_exe_ctx.GetFramePtr(); @@ -1197,7 +1201,8 @@ protected: if (!ParseOptions (args, result)) return false; - Error error (m_option_group.NotifyOptionParsingFinished()); + Error error(m_option_group.NotifyOptionParsingFinished( + &exe_ctx)); if (error.Fail()) { result.AppendError (error.AsCString()); diff --git a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp index 0ae1850b5e2..82046d7f972 100644 --- a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp +++ b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp @@ -41,7 +41,7 @@ public: interpreter, "add", "Add a set of LLDB commands to a watchpoint, to be executed whenever the watchpoint is hit.", nullptr), IOHandlerDelegateMultiline("DONE", IOHandlerDelegate::Completion::LLDBCommand), - m_options(interpreter) + m_options() { SetHelpLong ( R"( @@ -280,8 +280,8 @@ are no syntax errors may indicate that a function was declared but never called. class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : - Options (interpreter), + CommandOptions() : + Options(), m_use_commands (false), m_use_script_language (false), m_script_language (eScriptLanguageNone), @@ -294,7 +294,8 @@ are no syntax errors may indicate that a function was declared but never called. ~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; @@ -338,7 +339,7 @@ are no syntax errors may indicate that a function was declared but never called. } void - OptionParsingStarting () override + OptionParsingStarting(ExecutionContext *execution_context) override { m_use_commands = true; m_use_script_language = false; |