summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter/CommandObject.cpp
diff options
context:
space:
mode:
authorJim Ingham <jingham@apple.com>2012-06-08 21:56:10 +0000
committerJim Ingham <jingham@apple.com>2012-06-08 21:56:10 +0000
commit5a988416736b906931cf6076d38f5b960110ed81 (patch)
treebbd923b8bcc49eb2e456290706df5452f4bcd250 /lldb/source/Interpreter/CommandObject.cpp
parentc5adccab1ae914f439593f8588a6a95669783bad (diff)
downloadbcm5719-llvm-5a988416736b906931cf6076d38f5b960110ed81.tar.gz
bcm5719-llvm-5a988416736b906931cf6076d38f5b960110ed81.zip
Make raw & parsed commands subclasses of CommandObject rather than having the raw version implement an
Execute which was never going to get run and another ExecuteRawCommandString. Took the knowledge of how to prepare raw & parsed commands out of CommandInterpreter and put it in CommandObject where it belongs. Also took all the cases where there were the subcommands of Multiword commands declared in the .h file for the overall command and moved them into the .cpp file. Made the CommandObject flags work for raw as well as parsed commands. Made "expr" use the flags so that it requires you to be paused to run "expr". llvm-svn: 158235
Diffstat (limited to 'lldb/source/Interpreter/CommandObject.cpp')
-rw-r--r--lldb/source/Interpreter/CommandObject.cpp88
1 files changed, 62 insertions, 26 deletions
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()
{
OpenPOWER on IntegriCloud