diff options
Diffstat (limited to 'lldb/source/Interpreter')
-rw-r--r-- | lldb/source/Interpreter/CommandInterpreter.cpp | 30 | ||||
-rw-r--r-- | lldb/source/Interpreter/CommandObject.cpp | 88 | ||||
-rw-r--r-- | lldb/source/Interpreter/CommandObjectRegexCommand.cpp | 15 | ||||
-rw-r--r-- | lldb/source/Interpreter/CommandObjectScript.cpp | 28 | ||||
-rw-r--r-- | lldb/source/Interpreter/CommandObjectScript.h | 12 |
5 files changed, 73 insertions, 100 deletions
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 3a5b98e0f89..e18f8293a00 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -1562,35 +1562,7 @@ CommandInterpreter::HandleCommand (const char *command_line, if (log) log->Printf ("HandleCommand, command line after removing command name(s): '%s'", remainder.c_str()); - - CommandOverrideCallback command_callback = cmd_obj->GetOverrideCallback(); - bool handled = false; - if (wants_raw_input) - { - if (command_callback) - { - std::string full_command (cmd_obj->GetCommandName ()); - full_command += ' '; - full_command += remainder; - const char *argv[2] = { NULL, NULL }; - argv[0] = full_command.c_str(); - handled = command_callback (cmd_obj->GetOverrideCallbackBaton(), argv); - } - if (!handled) - cmd_obj->ExecuteRawCommandString (remainder.c_str(), result); - } - else - { - Args cmd_args (remainder.c_str()); - if (command_callback) - { - Args full_args (cmd_obj->GetCommandName ()); - full_args.AppendArguments(cmd_args); - handled = command_callback (cmd_obj->GetOverrideCallbackBaton(), full_args.GetConstArgumentVector()); - } - if (!handled) - cmd_obj->ExecuteWithOptions (cmd_args, result); - } + cmd_obj->Execute (remainder.c_str(), result); } else { diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp index dbbd0936aa0..85b21f5b0ed 100644 --- a/lldb/source/Interpreter/CommandObject.cpp +++ b/lldb/source/Interpreter/CommandObject.cpp @@ -153,18 +153,6 @@ CommandObject::GetOptions () return NULL; } -Flags& -CommandObject::GetFlags() -{ - return m_flags; -} - -const Flags& -CommandObject::GetFlags() const -{ - return m_flags; -} - bool CommandObject::ParseOptions ( @@ -214,16 +202,12 @@ CommandObject::ParseOptions } return true; } + + + bool -CommandObject::ExecuteWithOptions (Args& args, CommandReturnObject &result) +CommandObject::CheckFlags (CommandReturnObject &result) { - for (size_t i = 0; i < args.GetArgumentCount(); ++i) - { - const char *tmp_str = args.GetArgumentAtIndex (i); - if (tmp_str[0] == '`') // back-quote - args.ReplaceArgumentAtIndex (i, m_interpreter.ProcessEmbeddedScriptCommands (tmp_str)); - } - if (GetFlags().AnySet (CommandObject::eFlagProcessMustBeLaunched | CommandObject::eFlagProcessMustBePaused)) { Process *process = m_interpreter.GetExecutionContext().GetProcessPtr(); @@ -274,12 +258,7 @@ CommandObject::ExecuteWithOptions (Args& args, CommandReturnObject &result) } } } - - if (!ParseOptions (args, result)) - return false; - - // Call the command-specific version of 'Execute', passing it the already processed arguments. - return Execute (args, result); + return true; } class CommandDictCommandPartialMatch @@ -846,6 +825,63 @@ CommandObject::GetArgumentDescriptionAsCString (const lldb::CommandArgumentType return NULL; } +bool +CommandObjectParsed::Execute (const char *args_string, CommandReturnObject &result) +{ + CommandOverrideCallback command_callback = GetOverrideCallback(); + bool handled = false; + Args cmd_args (args_string); + if (command_callback) + { + Args full_args (GetCommandName ()); + full_args.AppendArguments(cmd_args); + handled = command_callback (GetOverrideCallbackBaton(), full_args.GetConstArgumentVector()); + } + if (!handled) + { + for (size_t i = 0; i < cmd_args.GetArgumentCount(); ++i) + { + const char *tmp_str = cmd_args.GetArgumentAtIndex (i); + if (tmp_str[0] == '`') // back-quote + cmd_args.ReplaceArgumentAtIndex (i, m_interpreter.ProcessEmbeddedScriptCommands (tmp_str)); + } + + if (!CheckFlags(result)) + return false; + + if (!ParseOptions (cmd_args, result)) + return false; + + // Call the command-specific version of 'Execute', passing it the already processed arguments. + handled = DoExecute (cmd_args, result); + } + return handled; +} + +bool +CommandObjectRaw::Execute (const char *args_string, CommandReturnObject &result) +{ + CommandOverrideCallback command_callback = GetOverrideCallback(); + bool handled = false; + if (command_callback) + { + std::string full_command (GetCommandName ()); + full_command += ' '; + full_command += args_string; + const char *argv[2] = { NULL, NULL }; + argv[0] = full_command.c_str(); + handled = command_callback (GetOverrideCallbackBaton(), argv); + } + if (!handled) + { + if (!CheckFlags(result)) + return false; + else + handled = DoExecute (args_string, result); + } + return handled; +} + static const char *arch_helper() { diff --git a/lldb/source/Interpreter/CommandObjectRegexCommand.cpp b/lldb/source/Interpreter/CommandObjectRegexCommand.cpp index 871922c6222..de6faba4d87 100644 --- a/lldb/source/Interpreter/CommandObjectRegexCommand.cpp +++ b/lldb/source/Interpreter/CommandObjectRegexCommand.cpp @@ -30,7 +30,7 @@ CommandObjectRegexCommand::CommandObjectRegexCommand const char *syntax, uint32_t max_matches ) : - CommandObject (interpreter, name, help, syntax), + CommandObjectRaw (interpreter, name, help, syntax), m_max_matches (max_matches), m_entries () { @@ -45,18 +45,7 @@ CommandObjectRegexCommand::~CommandObjectRegexCommand() bool -CommandObjectRegexCommand::Execute -( - Args& command, - CommandReturnObject &result -) -{ - return false; -} - - -bool -CommandObjectRegexCommand::ExecuteRawCommandString +CommandObjectRegexCommand::DoExecute ( const char *command, CommandReturnObject &result diff --git a/lldb/source/Interpreter/CommandObjectScript.cpp b/lldb/source/Interpreter/CommandObjectScript.cpp index 5ade400d463..76bfe6e9928 100644 --- a/lldb/source/Interpreter/CommandObjectScript.cpp +++ b/lldb/source/Interpreter/CommandObjectScript.cpp @@ -30,10 +30,10 @@ using namespace lldb_private; //------------------------------------------------------------------------- CommandObjectScript::CommandObjectScript (CommandInterpreter &interpreter, ScriptLanguage script_lang) : - CommandObject (interpreter, - "script", - "Pass an expression to the script interpreter for evaluation and return the results. Drop into the interactive interpreter if no expression is given.", - "script [<script-expression-for-evaluation>]"), + CommandObjectRaw (interpreter, + "script", + "Pass an expression to the script interpreter for evaluation and return the results. Drop into the interactive interpreter if no expression is given.", + "script [<script-expression-for-evaluation>]"), m_script_lang (script_lang) { } @@ -43,7 +43,7 @@ CommandObjectScript::~CommandObjectScript () } bool -CommandObjectScript::ExecuteRawCommandString +CommandObjectScript::DoExecute ( const char *command, CommandReturnObject &result @@ -74,21 +74,3 @@ CommandObjectScript::ExecuteRawCommandString return result.Succeeded(); } - -bool -CommandObjectScript::WantsRawCommandString() -{ - return true; -} - -bool -CommandObjectScript::Execute -( - Args& command, - CommandReturnObject &result -) -{ - // everything should be handled in ExecuteRawCommandString - return false; -} - diff --git a/lldb/source/Interpreter/CommandObjectScript.h b/lldb/source/Interpreter/CommandObjectScript.h index b9fa759bb7b..c812539e9ef 100644 --- a/lldb/source/Interpreter/CommandObjectScript.h +++ b/lldb/source/Interpreter/CommandObjectScript.h @@ -22,7 +22,7 @@ namespace lldb_private { // CommandObjectScript //------------------------------------------------------------------------- -class CommandObjectScript : public CommandObject +class CommandObjectScript : public CommandObjectRaw { public: @@ -32,15 +32,9 @@ public: virtual ~CommandObjectScript (); - bool WantsRawCommandString(); - - virtual bool - ExecuteRawCommandString (const char *command, - CommandReturnObject &result); - +protected: virtual bool - Execute (Args& command, - CommandReturnObject &result); + DoExecute (const char *command, CommandReturnObject &result); private: lldb::ScriptLanguage m_script_lang; |