Index: include/lldb/Interpreter/Args.h =================================================================== --- include/lldb/Interpreter/Args.h +++ include/lldb/Interpreter/Args.h @@ -314,10 +314,22 @@ /// get processed start at the second argument. The first argument /// is assumed to be the command and will not be touched. /// + /// param[in] platform_sp + /// The platform used for option validation. This is necessary + /// because an empty execution_context is not enough to get us + /// to a reasonable platform. If the platform isn't given, + /// we'll try to get it from the execution context. If we can't + /// get it from the execution context, we'll skip validation. + /// + /// param[in] require_validation + /// When true, it will fail option parsing if validation could + /// not occur due to not having a platform. + /// /// @see class Options //------------------------------------------------------------------ Error - ParseOptions (Options &options); + ParseOptions (Options &options, ExecutionContext *execution_context, + lldb::PlatformSP platform_sp, bool require_validation); size_t FindArgumentIndexForOption (Option *long_options, int long_options_index); Index: include/lldb/Interpreter/OptionGroupArchitecture.h =================================================================== --- include/lldb/Interpreter/OptionGroupArchitecture.h +++ include/lldb/Interpreter/OptionGroupArchitecture.h @@ -37,12 +37,12 @@ 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; bool GetArchitecture (Platform *platform, ArchSpec &arch); Index: include/lldb/Interpreter/OptionGroupBoolean.h =================================================================== --- include/lldb/Interpreter/OptionGroupBoolean.h +++ include/lldb/Interpreter/OptionGroupBoolean.h @@ -51,12 +51,12 @@ } 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; OptionValueBoolean & GetOptionValue () Index: include/lldb/Interpreter/OptionGroupFile.h =================================================================== --- include/lldb/Interpreter/OptionGroupFile.h +++ include/lldb/Interpreter/OptionGroupFile.h @@ -50,12 +50,12 @@ } 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; OptionValueFileSpec & GetOptionValue () @@ -105,12 +105,12 @@ } 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; OptionValueFileSpecList & GetOptionValue () Index: include/lldb/Interpreter/OptionGroupFormat.h =================================================================== --- include/lldb/Interpreter/OptionGroupFormat.h +++ include/lldb/Interpreter/OptionGroupFormat.h @@ -46,12 +46,12 @@ 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; lldb::Format GetFormat () const @@ -111,7 +111,7 @@ protected: bool - ParserGDBFormatLetter (CommandInterpreter &interpreter, + ParserGDBFormatLetter (ExecutionContext *execution_context, char format_letter, lldb::Format &format, uint32_t &byte_size); Index: include/lldb/Interpreter/OptionGroupOutputFile.h =================================================================== --- include/lldb/Interpreter/OptionGroupOutputFile.h +++ include/lldb/Interpreter/OptionGroupOutputFile.h @@ -37,12 +37,12 @@ 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; const OptionValueFileSpec & GetFile () Index: include/lldb/Interpreter/OptionGroupPlatform.h =================================================================== --- include/lldb/Interpreter/OptionGroupPlatform.h +++ include/lldb/Interpreter/OptionGroupPlatform.h @@ -47,12 +47,12 @@ 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; lldb::PlatformSP CreatePlatformWithOptions (CommandInterpreter &interpreter, Index: include/lldb/Interpreter/OptionGroupString.h =================================================================== --- include/lldb/Interpreter/OptionGroupString.h +++ include/lldb/Interpreter/OptionGroupString.h @@ -49,12 +49,12 @@ } 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; OptionValueString & GetOptionValue () Index: include/lldb/Interpreter/OptionGroupUInt64.h =================================================================== --- include/lldb/Interpreter/OptionGroupUInt64.h +++ include/lldb/Interpreter/OptionGroupUInt64.h @@ -50,12 +50,12 @@ } 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; OptionValueUInt64 & GetOptionValue () Index: include/lldb/Interpreter/OptionGroupUUID.h =================================================================== --- include/lldb/Interpreter/OptionGroupUUID.h +++ include/lldb/Interpreter/OptionGroupUUID.h @@ -37,12 +37,12 @@ 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; const OptionValueUUID & GetOptionValue () const Index: include/lldb/Interpreter/OptionGroupValueObjectDisplay.h =================================================================== --- include/lldb/Interpreter/OptionGroupValueObjectDisplay.h +++ include/lldb/Interpreter/OptionGroupValueObjectDisplay.h @@ -37,12 +37,12 @@ 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; bool AnyOptionWasSet () const Index: include/lldb/Interpreter/OptionGroupVariable.h =================================================================== --- include/lldb/Interpreter/OptionGroupVariable.h +++ include/lldb/Interpreter/OptionGroupVariable.h @@ -37,12 +37,12 @@ GetDefinitions() override; 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; void - OptionParsingStarting(CommandInterpreter &interpreter) override; + OptionParsingStarting(ExecutionContext *execution_context) override; bool include_frame_options:1, show_args:1, // Frame option only (include_frame_options == true) Index: include/lldb/Interpreter/OptionGroupWatchpoint.h =================================================================== --- include/lldb/Interpreter/OptionGroupWatchpoint.h +++ include/lldb/Interpreter/OptionGroupWatchpoint.h @@ -39,12 +39,12 @@ GetDefinitions() override; 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; void - OptionParsingStarting(CommandInterpreter &interpreter) override; + OptionParsingStarting(ExecutionContext *execution_context) override; // Note: // eWatchRead == LLDB_WATCH_TYPE_READ; and Index: include/lldb/Interpreter/Options.h =================================================================== --- include/lldb/Interpreter/Options.h +++ include/lldb/Interpreter/Options.h @@ -117,7 +117,7 @@ class Options { public: - Options (CommandInterpreter &interpreter); + Options (); virtual ~Options (); @@ -160,7 +160,8 @@ void GenerateOptionUsage (Stream &strm, - CommandObject *cmd); + CommandObject *cmd, + uint32_t screen_width); bool SupportsLongOption (const char *long_option); @@ -180,10 +181,10 @@ // Option::OptionParsingStarting() like they did before. This was error // prone and subclasses shouldn't have to do it. void - NotifyOptionParsingStarting (); + NotifyOptionParsingStarting (ExecutionContext *execution_context); Error - NotifyOptionParsingFinished (); + NotifyOptionParsingFinished (ExecutionContext *execution_context); //------------------------------------------------------------------ /// Set the value of an option. @@ -196,12 +197,17 @@ /// The argument value for the option that the user entered, or /// nullptr if there is no argument for the current option. /// + /// @param[in] execution_context + /// The execution context to use for evaluating the option. + /// May be nullptr if the option is to be evaluated outside any + /// particular context. /// /// @see Args::ParseOptions (Options&) /// @see man getopt_long_only //------------------------------------------------------------------ virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) = 0; + SetOptionValue (uint32_t option_idx, const char *option_arg, + ExecutionContext *execution_context) = 0; //------------------------------------------------------------------ /// Handles the generic bits of figuring out whether we are in an @@ -245,6 +251,7 @@ int char_pos, int match_start_point, int max_return_elements, + CommandInterpreter &interpreter, bool &word_complete, lldb_private::StringList &matches); @@ -276,6 +283,9 @@ /// See CommandObject::HandleCompletions for a description of /// how these work. /// + /// @param[in] interpreter + /// The command interpreter in which we're doing completion. + /// /// @param[out] word_complete /// \btrue if this is a complete option value (a space will /// be inserted after the completion.) \bfalse otherwise. @@ -298,21 +308,15 @@ int opt_element_index, int match_start_point, int max_return_elements, + CommandInterpreter &interpreter, bool &word_complete, StringList &matches); - CommandInterpreter& - GetInterpreter() - { - return m_interpreter; - } - protected: // This is a set of options expressed as indexes into the options table for this Option. typedef std::set OptionSet; typedef std::vector OptionSetVector; - CommandInterpreter &m_interpreter; std::vector