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/Interpreter | |
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/Interpreter')
19 files changed, 160 insertions, 97 deletions
diff --git a/lldb/source/Interpreter/Args.cpp b/lldb/source/Interpreter/Args.cpp index d90ef1d256a..3e5b55a482a 100644 --- a/lldb/source/Interpreter/Args.cpp +++ b/lldb/source/Interpreter/Args.cpp @@ -550,7 +550,8 @@ Args::SetArguments (const char **argv) Error -Args::ParseOptions (Options &options) +Args::ParseOptions (Options &options, ExecutionContext *execution_context, + PlatformSP platform_sp, bool require_validation) { StreamString sstr; Error error; @@ -622,17 +623,47 @@ Args::ParseOptions (Options &options) if (long_options_index >= 0 && long_options[long_options_index].definition) { const OptionDefinition *def = long_options[long_options_index].definition; - CommandInterpreter &interpreter = options.GetInterpreter(); + + if (!platform_sp) + { + // User did not pass in an explicit platform. Try to grab + // from the execution context. + TargetSP target_sp = execution_context ? + execution_context->GetTargetSP() : TargetSP(); + platform_sp = target_sp ? + target_sp->GetPlatform() : PlatformSP(); + } OptionValidator *validator = def->validator; - if (validator && !validator->IsValid(*interpreter.GetPlatform(true), interpreter.GetExecutionContext())) + + if (!platform_sp && require_validation) { - error.SetErrorStringWithFormat("Option \"%s\" invalid. %s", def->long_option, def->validator->LongConditionString()); + // Caller requires validation but we cannot validate as we + // don't have the mandatory platform against which to + // validate. + error.SetErrorString("cannot validate options: " + "no platform available"); + return error; } - else + + bool validation_failed = false; + if (platform_sp) { - error = options.SetOptionValue(long_options_index, - (def->option_has_arg == OptionParser::eNoArgument) ? nullptr : OptionParser::GetOptionArgument()); + // Ensure we have an execution context, empty or not. + ExecutionContext dummy_context; + ExecutionContext *exe_ctx_p = + execution_context ? execution_context : &dummy_context; + if (validator && !validator->IsValid(*platform_sp, *exe_ctx_p)) + { + validation_failed = true; + error.SetErrorStringWithFormat("Option \"%s\" invalid. %s", def->long_option, def->validator->LongConditionString()); + } } + + // As long as validation didn't fail, we set the option value. + if (!validation_failed) + error = options.SetOptionValue(long_options_index, + (def->option_has_arg == OptionParser::eNoArgument) ? nullptr : OptionParser::GetOptionArgument(), + execution_context); } else { diff --git a/lldb/source/Interpreter/CommandAlias.cpp b/lldb/source/Interpreter/CommandAlias.cpp index a915d63e654..e796f292726 100644 --- a/lldb/source/Interpreter/CommandAlias.cpp +++ b/lldb/source/Interpreter/CommandAlias.cpp @@ -12,6 +12,7 @@ #include "llvm/Support/ErrorHandling.h" #include "lldb/Core/StreamString.h" +#include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandObject.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Interpreter/Options.h" @@ -38,7 +39,9 @@ ProcessAliasOptionsArgs (lldb::CommandObjectSP &cmd_obj_sp, if (options) { // See if any options were specified as part of the alias; if so, handle them appropriately. - options->NotifyOptionParsingStarting (); + ExecutionContext exe_ctx = + cmd_obj_sp->GetCommandInterpreter().GetExecutionContext(); + options->NotifyOptionParsingStarting(&exe_ctx); args.Unshift ("dummy_arg"); args.ParseAliasOptions (*options, result, option_arg_vector, options_string); args.Shift (); diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp index 75e42925406..3fd2d375357 100644 --- a/lldb/source/Interpreter/CommandObject.cpp +++ b/lldb/source/Interpreter/CommandObject.cpp @@ -159,18 +159,23 @@ CommandObject::ParseOptions if (options != nullptr) { Error error; - options->NotifyOptionParsingStarting(); + + auto exe_ctx = GetCommandInterpreter().GetExecutionContext(); + options->NotifyOptionParsingStarting(&exe_ctx); // ParseOptions calls getopt_long_only, which always skips the zero'th item in the array and starts at position 1, // so we need to push a dummy value into position zero. args.Unshift("dummy_string"); - error = args.ParseOptions (*options); + const bool require_validation = true; + error = args.ParseOptions(*options, &exe_ctx, + GetCommandInterpreter().GetPlatform(true), + require_validation); // The "dummy_string" will have already been removed by ParseOptions, // so no need to remove it. if (error.Success()) - error = options->NotifyOptionParsingFinished(); + error = options->NotifyOptionParsingFinished(&exe_ctx); if (error.Success()) { @@ -188,7 +193,10 @@ CommandObject::ParseOptions else { // No error string, output the usage information into result - options->GenerateOptionUsage (result.GetErrorStream(), this); + options->GenerateOptionUsage(result.GetErrorStream(), this, + GetCommandInterpreter() + .GetDebugger() + .GetTerminalWidth()); } } result.SetStatus (eReturnStatusFailed); @@ -393,6 +401,7 @@ CommandObject::HandleCompletion cursor_char_position, match_start_point, max_return_elements, + GetCommandInterpreter(), word_complete, matches); if (handled_by_options) @@ -438,7 +447,9 @@ CommandObject::HelpTextContainsWord (const char *search_word, && GetOptions() != nullptr) { StreamString usage_help; - GetOptions()->GenerateOptionUsage (usage_help, this); + GetOptions()->GenerateOptionUsage(usage_help, this, + GetCommandInterpreter() + .GetDebugger().GetTerminalWidth()); if (usage_help.GetSize() > 0) { const char *usage_text = usage_help.GetData(); @@ -929,7 +940,9 @@ CommandObject::GenerateHelpText (Stream &output_strm) Options *options = GetOptions(); if (options != nullptr) { - options->GenerateOptionUsage(output_strm, this); + options->GenerateOptionUsage(output_strm, this, + GetCommandInterpreter() + .GetDebugger().GetTerminalWidth()); } const char *long_help = GetHelpLong(); if ((long_help != nullptr) && (strlen(long_help) > 0)) diff --git a/lldb/source/Interpreter/CommandObjectRegexCommand.cpp b/lldb/source/Interpreter/CommandObjectRegexCommand.cpp index 1c3c3cdd5fd..12de6d0dc73 100644 --- a/lldb/source/Interpreter/CommandObjectRegexCommand.cpp +++ b/lldb/source/Interpreter/CommandObjectRegexCommand.cpp @@ -131,7 +131,7 @@ CommandObjectRegexCommand::HandleCompletion (Args &input, if (m_completion_type_mask) { std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position); - CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks (GetCommandInterpreter(), m_completion_type_mask, completion_str.c_str(), match_start_point, diff --git a/lldb/source/Interpreter/OptionGroupArchitecture.cpp b/lldb/source/Interpreter/OptionGroupArchitecture.cpp index 3a454093ab2..063466a99c4 100644 --- a/lldb/source/Interpreter/OptionGroupArchitecture.cpp +++ b/lldb/source/Interpreter/OptionGroupArchitecture.cpp @@ -57,9 +57,9 @@ OptionGroupArchitecture::GetArchitecture (Platform *platform, ArchSpec &arch) Error -OptionGroupArchitecture::SetOptionValue (CommandInterpreter &interpreter, - uint32_t option_idx, - const char *option_arg) +OptionGroupArchitecture::SetOptionValue(uint32_t option_idx, + const char *option_arg, + ExecutionContext *execution_context) { Error error; const int short_option = g_option_table[option_idx].short_option; @@ -79,7 +79,8 @@ OptionGroupArchitecture::SetOptionValue (CommandInterpreter &interpreter, } void -OptionGroupArchitecture::OptionParsingStarting (CommandInterpreter &interpreter) +OptionGroupArchitecture::OptionParsingStarting( + ExecutionContext *execution_context) { m_arch_str.clear(); } diff --git a/lldb/source/Interpreter/OptionGroupBoolean.cpp b/lldb/source/Interpreter/OptionGroupBoolean.cpp index 6bd2743a668..f21c3adacf1 100644 --- a/lldb/source/Interpreter/OptionGroupBoolean.cpp +++ b/lldb/source/Interpreter/OptionGroupBoolean.cpp @@ -43,9 +43,9 @@ OptionGroupBoolean::~OptionGroupBoolean () } Error -OptionGroupBoolean::SetOptionValue (CommandInterpreter &interpreter, - uint32_t option_idx, - const char *option_arg) +OptionGroupBoolean::SetOptionValue(uint32_t option_idx, + const char *option_arg, + ExecutionContext *execution_context) { Error error; if (m_option_definition.option_has_arg == OptionParser::eNoArgument) @@ -62,7 +62,7 @@ OptionGroupBoolean::SetOptionValue (CommandInterpreter &interpreter, } void -OptionGroupBoolean::OptionParsingStarting (CommandInterpreter &interpreter) +OptionGroupBoolean::OptionParsingStarting(ExecutionContext *execution_context) { m_value.Clear(); } diff --git a/lldb/source/Interpreter/OptionGroupFile.cpp b/lldb/source/Interpreter/OptionGroupFile.cpp index a4b56409698..1f82e579191 100644 --- a/lldb/source/Interpreter/OptionGroupFile.cpp +++ b/lldb/source/Interpreter/OptionGroupFile.cpp @@ -43,16 +43,16 @@ OptionGroupFile::~OptionGroupFile () } Error -OptionGroupFile::SetOptionValue (CommandInterpreter &interpreter, - uint32_t option_idx, - const char *option_arg) +OptionGroupFile::SetOptionValue(uint32_t option_idx, + const char *option_arg, + ExecutionContext *execution_context) { Error error (m_file.SetValueFromString (option_arg)); return error; } void -OptionGroupFile::OptionParsingStarting (CommandInterpreter &interpreter) +OptionGroupFile::OptionParsingStarting(ExecutionContext *execution_context) { m_file.Clear(); } @@ -84,16 +84,16 @@ OptionGroupFileList::~OptionGroupFileList () } Error -OptionGroupFileList::SetOptionValue (CommandInterpreter &interpreter, - uint32_t option_idx, - const char *option_arg) +OptionGroupFileList::SetOptionValue(uint32_t option_idx, + const char *option_arg, + ExecutionContext *execution_context) { Error error (m_file_list.SetValueFromString (option_arg)); return error; } void -OptionGroupFileList::OptionParsingStarting (CommandInterpreter &interpreter) +OptionGroupFileList::OptionParsingStarting(ExecutionContext *execution_context) { m_file_list.Clear(); } diff --git a/lldb/source/Interpreter/OptionGroupFormat.cpp b/lldb/source/Interpreter/OptionGroupFormat.cpp index 3ca216afee0..1a1e060f7e6 100644 --- a/lldb/source/Interpreter/OptionGroupFormat.cpp +++ b/lldb/source/Interpreter/OptionGroupFormat.cpp @@ -66,9 +66,9 @@ OptionGroupFormat::GetDefinitions () } Error -OptionGroupFormat::SetOptionValue (CommandInterpreter &interpreter, - uint32_t option_idx, - const char *option_arg) +OptionGroupFormat::SetOptionValue(uint32_t option_idx, + const char *option_arg, + ExecutionContext *execution_context) { Error error; const int short_option = g_option_table[option_idx].short_option; @@ -123,7 +123,9 @@ OptionGroupFormat::SetOptionValue (CommandInterpreter &interpreter, Format format = eFormatDefault; uint32_t byte_size = 0; - while (ParserGDBFormatLetter (interpreter, gdb_format_cstr[0], format, byte_size)) + while (ParserGDBFormatLetter (execution_context, + gdb_format_cstr[0], format, + byte_size)) { ++gdb_format_cstr; } @@ -143,7 +145,8 @@ OptionGroupFormat::SetOptionValue (CommandInterpreter &interpreter, // Anything that wasn't set correctly should be set to the // previous default if (format == eFormatInvalid) - ParserGDBFormatLetter (interpreter, m_prev_gdb_format, format, byte_size); + ParserGDBFormatLetter (execution_context, m_prev_gdb_format, + format, byte_size); const bool byte_size_enabled = m_byte_size.GetDefaultValue() < UINT64_MAX; const bool count_enabled = m_count.GetDefaultValue() < UINT64_MAX; @@ -151,7 +154,7 @@ OptionGroupFormat::SetOptionValue (CommandInterpreter &interpreter, { // Byte size is enabled if (byte_size == 0) - ParserGDBFormatLetter (interpreter, m_prev_gdb_size, format, byte_size); + ParserGDBFormatLetter (execution_context, m_prev_gdb_size, format, byte_size); } else { @@ -205,7 +208,9 @@ OptionGroupFormat::SetOptionValue (CommandInterpreter &interpreter, } bool -OptionGroupFormat::ParserGDBFormatLetter (CommandInterpreter &interpreter, char format_letter, Format &format, uint32_t &byte_size) +OptionGroupFormat::ParserGDBFormatLetter(ExecutionContext *execution_context, + char format_letter, Format &format, + uint32_t &byte_size) { m_has_gdb_format = true; switch (format_letter) @@ -218,10 +223,10 @@ OptionGroupFormat::ParserGDBFormatLetter (CommandInterpreter &interpreter, char case 'f': format = eFormatFloat; m_prev_gdb_format = format_letter; return true; case 'a': format = eFormatAddressInfo; { - ExecutionContext exe_ctx(interpreter.GetExecutionContext()); - Target *target = exe_ctx.GetTargetPtr(); - if (target) - byte_size = target->GetArchitecture().GetAddressByteSize(); + TargetSP target_sp = execution_context ? + execution_context->GetTargetSP() : TargetSP(); + if (target_sp) + byte_size = target_sp->GetArchitecture().GetAddressByteSize(); m_prev_gdb_format = format_letter; return true; } @@ -258,7 +263,7 @@ OptionGroupFormat::ParserGDBFormatLetter (CommandInterpreter &interpreter, char } void -OptionGroupFormat::OptionParsingStarting (CommandInterpreter &interpreter) +OptionGroupFormat::OptionParsingStarting(ExecutionContext *execution_context) { m_format.Clear(); m_byte_size.Clear(); diff --git a/lldb/source/Interpreter/OptionGroupOutputFile.cpp b/lldb/source/Interpreter/OptionGroupOutputFile.cpp index e95cd35976e..857d21e53f4 100644 --- a/lldb/source/Interpreter/OptionGroupOutputFile.cpp +++ b/lldb/source/Interpreter/OptionGroupOutputFile.cpp @@ -52,9 +52,9 @@ OptionGroupOutputFile::GetDefinitions () } Error -OptionGroupOutputFile::SetOptionValue (CommandInterpreter &interpreter, - uint32_t option_idx, - const char *option_arg) +OptionGroupOutputFile::SetOptionValue(uint32_t option_idx, + const char *option_arg, + ExecutionContext *execution_context) { Error error; const int short_option = g_option_table[option_idx].short_option; @@ -78,7 +78,8 @@ OptionGroupOutputFile::SetOptionValue (CommandInterpreter &interpreter, } void -OptionGroupOutputFile::OptionParsingStarting (CommandInterpreter &interpreter) +OptionGroupOutputFile::OptionParsingStarting( + ExecutionContext *execution_context) { m_file.Clear(); m_append.Clear(); diff --git a/lldb/source/Interpreter/OptionGroupPlatform.cpp b/lldb/source/Interpreter/OptionGroupPlatform.cpp index 6fa06d1eb8e..f5ea857fb7d 100644 --- a/lldb/source/Interpreter/OptionGroupPlatform.cpp +++ b/lldb/source/Interpreter/OptionGroupPlatform.cpp @@ -70,7 +70,7 @@ OptionGroupPlatform::CreatePlatformWithOptions (CommandInterpreter &interpreter, } void -OptionGroupPlatform::OptionParsingStarting (CommandInterpreter &interpreter) +OptionGroupPlatform::OptionParsingStarting(ExecutionContext *execution_context) { m_platform_name.clear(); m_sdk_sysroot.Clear(); @@ -107,9 +107,9 @@ OptionGroupPlatform::GetNumDefinitions () Error -OptionGroupPlatform::SetOptionValue (CommandInterpreter &interpreter, - uint32_t option_idx, - const char *option_arg) +OptionGroupPlatform::SetOptionValue(uint32_t option_idx, + const char *option_arg, + ExecutionContext *execution_context) { Error error; if (!m_include_platform_option) diff --git a/lldb/source/Interpreter/OptionGroupString.cpp b/lldb/source/Interpreter/OptionGroupString.cpp index e0291b154be..1f45844e543 100644 --- a/lldb/source/Interpreter/OptionGroupString.cpp +++ b/lldb/source/Interpreter/OptionGroupString.cpp @@ -44,16 +44,16 @@ OptionGroupString::~OptionGroupString () } Error -OptionGroupString::SetOptionValue (CommandInterpreter &interpreter, - uint32_t option_idx, - const char *option_arg) +OptionGroupString::SetOptionValue(uint32_t option_idx, + const char *option_arg, + ExecutionContext *execution_context) { Error error (m_value.SetValueFromString (option_arg)); return error; } void -OptionGroupString::OptionParsingStarting (CommandInterpreter &interpreter) +OptionGroupString::OptionParsingStarting(ExecutionContext *execution_context) { m_value.Clear(); } diff --git a/lldb/source/Interpreter/OptionGroupUInt64.cpp b/lldb/source/Interpreter/OptionGroupUInt64.cpp index a922ab25596..5cc0d5deb20 100644 --- a/lldb/source/Interpreter/OptionGroupUInt64.cpp +++ b/lldb/source/Interpreter/OptionGroupUInt64.cpp @@ -44,16 +44,16 @@ OptionGroupUInt64::~OptionGroupUInt64 () } Error -OptionGroupUInt64::SetOptionValue (CommandInterpreter &interpreter, - uint32_t option_idx, - const char *option_arg) +OptionGroupUInt64::SetOptionValue(uint32_t option_idx, + const char *option_arg, + ExecutionContext *execution_context) { Error error (m_value.SetValueFromString (option_arg)); return error; } void -OptionGroupUInt64::OptionParsingStarting (CommandInterpreter &interpreter) +OptionGroupUInt64::OptionParsingStarting(ExecutionContext *execution_context) { m_value.Clear(); } diff --git a/lldb/source/Interpreter/OptionGroupUUID.cpp b/lldb/source/Interpreter/OptionGroupUUID.cpp index 609967a83e7..0873dba1f58 100644 --- a/lldb/source/Interpreter/OptionGroupUUID.cpp +++ b/lldb/source/Interpreter/OptionGroupUUID.cpp @@ -46,9 +46,9 @@ OptionGroupUUID::GetDefinitions () } Error -OptionGroupUUID::SetOptionValue (CommandInterpreter &interpreter, - uint32_t option_idx, - const char *option_arg) +OptionGroupUUID::SetOptionValue(uint32_t option_idx, + const char *option_arg, + ExecutionContext *execution_context) { Error error; const int short_option = g_option_table[option_idx].short_option; @@ -70,7 +70,7 @@ OptionGroupUUID::SetOptionValue (CommandInterpreter &interpreter, } void -OptionGroupUUID::OptionParsingStarting (CommandInterpreter &interpreter) +OptionGroupUUID::OptionParsingStarting(ExecutionContext *execution_context) { m_uuid.Clear(); } diff --git a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp index c30a978d957..718ddc77f82 100644 --- a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp +++ b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp @@ -63,9 +63,10 @@ OptionGroupValueObjectDisplay::GetDefinitions () Error -OptionGroupValueObjectDisplay::SetOptionValue (CommandInterpreter &interpreter, - uint32_t option_idx, - const char *option_arg) +OptionGroupValueObjectDisplay::SetOptionValue(uint32_t option_idx, + const char *option_arg, + ExecutionContext + *execution_context) { Error error; const int short_option = g_option_table[option_idx].short_option; @@ -138,7 +139,8 @@ OptionGroupValueObjectDisplay::SetOptionValue (CommandInterpreter &interpreter, } void -OptionGroupValueObjectDisplay::OptionParsingStarting (CommandInterpreter &interpreter) +OptionGroupValueObjectDisplay::OptionParsingStarting(ExecutionContext + *execution_context) { // If these defaults change, be sure to modify AnyOptionWasSet(). show_types = false; @@ -153,10 +155,11 @@ OptionGroupValueObjectDisplay::OptionParsingStarting (CommandInterpreter &interp be_raw = false; ignore_cap = false; run_validator = false; - - Target *target = interpreter.GetExecutionContext().GetTargetPtr(); - if (target != nullptr) - use_dynamic = target->GetPreferDynamicValue(); + + TargetSP target_sp = + execution_context ? execution_context->GetTargetSP() : TargetSP(); + if (target_sp) + use_dynamic = target_sp->GetPreferDynamicValue(); else { // If we don't have any targets, then dynamic values won't do us much good. diff --git a/lldb/source/Interpreter/OptionGroupVariable.cpp b/lldb/source/Interpreter/OptionGroupVariable.cpp index 092d60af9eb..6ee71aed800 100644 --- a/lldb/source/Interpreter/OptionGroupVariable.cpp +++ b/lldb/source/Interpreter/OptionGroupVariable.cpp @@ -68,9 +68,9 @@ OptionGroupVariable::~OptionGroupVariable () } Error -OptionGroupVariable::SetOptionValue (CommandInterpreter &interpreter, - uint32_t option_idx, - const char *option_arg) +OptionGroupVariable::SetOptionValue(uint32_t option_idx, + const char *option_arg, + ExecutionContext *execution_context) { Error error; if (!include_frame_options) @@ -101,7 +101,7 @@ OptionGroupVariable::SetOptionValue (CommandInterpreter &interpreter, } void -OptionGroupVariable::OptionParsingStarting (CommandInterpreter &interpreter) +OptionGroupVariable::OptionParsingStarting(ExecutionContext *execution_context) { show_args = true; // Frame option only show_locals = true; // Frame option only diff --git a/lldb/source/Interpreter/OptionGroupWatchpoint.cpp b/lldb/source/Interpreter/OptionGroupWatchpoint.cpp index c6f4b8f8c8e..82d0fa99742 100644 --- a/lldb/source/Interpreter/OptionGroupWatchpoint.cpp +++ b/lldb/source/Interpreter/OptionGroupWatchpoint.cpp @@ -68,9 +68,9 @@ OptionGroupWatchpoint::~OptionGroupWatchpoint () } Error -OptionGroupWatchpoint::SetOptionValue (CommandInterpreter &interpreter, - uint32_t option_idx, - const char *option_arg) +OptionGroupWatchpoint::SetOptionValue(uint32_t option_idx, + const char *option_arg, + ExecutionContext *execution_context) { Error error; const int short_option = g_option_table[option_idx].short_option; @@ -100,7 +100,8 @@ OptionGroupWatchpoint::SetOptionValue (CommandInterpreter &interpreter, } void -OptionGroupWatchpoint::OptionParsingStarting (CommandInterpreter &interpreter) +OptionGroupWatchpoint::OptionParsingStarting(ExecutionContext + *execution_context) { watch_type_specified = false; watch_type = eWatchInvalid; diff --git a/lldb/source/Interpreter/OptionValueArch.cpp b/lldb/source/Interpreter/OptionValueArch.cpp index 0e1ca07afd2..06973f8b644 100644 --- a/lldb/source/Interpreter/OptionValueArch.cpp +++ b/lldb/source/Interpreter/OptionValueArch.cpp @@ -17,6 +17,7 @@ #include "lldb/DataFormatters/FormatManager.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandCompletions.h" +#include "lldb/Interpreter/CommandInterpreter.h" using namespace lldb; using namespace lldb_private; diff --git a/lldb/source/Interpreter/OptionValueFileSpec.cpp b/lldb/source/Interpreter/OptionValueFileSpec.cpp index 3a282f177fe..2b0af02e96a 100644 --- a/lldb/source/Interpreter/OptionValueFileSpec.cpp +++ b/lldb/source/Interpreter/OptionValueFileSpec.cpp @@ -17,6 +17,7 @@ #include "lldb/DataFormatters/FormatManager.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandCompletions.h" +#include "lldb/Interpreter/CommandInterpreter.h" using namespace lldb; using namespace lldb_private; diff --git a/lldb/source/Interpreter/Options.cpp b/lldb/source/Interpreter/Options.cpp index 70f532ed75d..a868b251c55 100644 --- a/lldb/source/Interpreter/Options.cpp +++ b/lldb/source/Interpreter/Options.cpp @@ -31,8 +31,7 @@ using namespace lldb_private; //------------------------------------------------------------------------- // Options //------------------------------------------------------------------------- -Options::Options (CommandInterpreter &interpreter) : - m_interpreter (interpreter), +Options::Options () : m_getopt_table () { BuildValidOptionSets(); @@ -43,17 +42,17 @@ Options::~Options () } void -Options::NotifyOptionParsingStarting () +Options::NotifyOptionParsingStarting(ExecutionContext *execution_context) { m_seen_options.clear(); // Let the subclass reset its option values - OptionParsingStarting (); + OptionParsingStarting(execution_context); } Error -Options::NotifyOptionParsingFinished () +Options::NotifyOptionParsingFinished(ExecutionContext *execution_context) { - return OptionParsingFinished (); + return OptionParsingFinished(execution_context); } void @@ -475,11 +474,11 @@ void Options::GenerateOptionUsage ( Stream &strm, - CommandObject *cmd + CommandObject *cmd, + uint32_t screen_width ) { const bool only_print_args = cmd->IsDashDashCommand(); - const uint32_t screen_width = m_interpreter.GetDebugger().GetTerminalWidth(); const OptionDefinition *opt_defs = GetDefinitions(); const uint32_t save_indent_level = strm.GetIndentLevel(); @@ -760,6 +759,7 @@ Options::HandleOptionCompletion int char_pos, int match_start_point, int max_return_elements, + CommandInterpreter &interpreter, bool &word_complete, lldb_private::StringList &matches ) @@ -882,6 +882,7 @@ Options::HandleOptionCompletion i, match_start_point, max_return_elements, + interpreter, word_complete, matches); return true; @@ -912,6 +913,7 @@ Options::HandleOptionArgumentCompletion int opt_element_index, int match_start_point, int max_return_elements, + CommandInterpreter &interpreter, bool &word_complete, lldb_private::StringList &matches ) @@ -982,7 +984,7 @@ Options::HandleOptionArgumentCompletion if (module_name) { FileSpec module_spec(module_name, false); - lldb::TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget(); + lldb::TargetSP target_sp = interpreter.GetDebugger().GetSelectedTarget(); // Search filters require a target... if (target_sp) filter_ap.reset (new SearchFilterByModule (target_sp, module_spec)); @@ -992,7 +994,7 @@ Options::HandleOptionArgumentCompletion } } - return CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, + return CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, completion_mask, input.GetArgumentAtIndex (opt_arg_pos), match_start_point, @@ -1056,7 +1058,8 @@ OptionGroupOptions::Finalize () Error OptionGroupOptions::SetOptionValue (uint32_t option_idx, - const char *option_value) + const char *option_value, + ExecutionContext *execution_context) { // After calling OptionGroupOptions::Append(...), you must finalize the groups // by calling OptionGroupOptions::Finlize() @@ -1065,9 +1068,9 @@ OptionGroupOptions::SetOptionValue (uint32_t option_idx, Error error; if (option_idx < m_option_infos.size()) { - error = m_option_infos[option_idx].option_group->SetOptionValue (m_interpreter, - m_option_infos[option_idx].option_index, - option_value); + error = m_option_infos[option_idx].option_group->SetOptionValue (m_option_infos[option_idx].option_index, + option_value, + execution_context); } else @@ -1078,7 +1081,7 @@ OptionGroupOptions::SetOptionValue (uint32_t option_idx, } void -OptionGroupOptions::OptionParsingStarting () +OptionGroupOptions::OptionParsingStarting (ExecutionContext *execution_context) { std::set<OptionGroup*> group_set; OptionInfos::iterator pos, end = m_option_infos.end(); @@ -1087,13 +1090,13 @@ OptionGroupOptions::OptionParsingStarting () OptionGroup* group = pos->option_group; if (group_set.find(group) == group_set.end()) { - group->OptionParsingStarting (m_interpreter); + group->OptionParsingStarting(execution_context); group_set.insert(group); } } } Error -OptionGroupOptions::OptionParsingFinished () +OptionGroupOptions::OptionParsingFinished (ExecutionContext *execution_context) { std::set<OptionGroup*> group_set; Error error; @@ -1103,7 +1106,7 @@ OptionGroupOptions::OptionParsingFinished () OptionGroup* group = pos->option_group; if (group_set.find(group) == group_set.end()) { - error = group->OptionParsingFinished (m_interpreter); + error = group->OptionParsingFinished (execution_context); group_set.insert(group); if (error.Fail()) return error; |