diff options
author | Greg Clayton <gclayton@apple.com> | 2012-02-29 04:21:24 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2012-02-29 04:21:24 +0000 |
commit | a9f7b79dfe69d6cc94fc209a97c077d0d8953a2a (patch) | |
tree | c16f44ce84a4b49103b5ef252b60358e511c67ba /lldb/source/Interpreter/CommandInterpreter.cpp | |
parent | e4f22dfa95be88c79b4a19eb63bfd289930822d2 (diff) | |
download | bcm5719-llvm-a9f7b79dfe69d6cc94fc209a97c077d0d8953a2a.tar.gz bcm5719-llvm-a9f7b79dfe69d6cc94fc209a97c077d0d8953a2a.zip |
<rdar://problem/10605072>
Added the ability to override command line commands. In some cases GUI interfaces
might want to intercept commands like "quit" or "process launch" (which might cause
the process to re-run). They can now do so by overriding/intercepting commands
by using functions added to SBCommandInterpreter using a callback function. If the
callback function returns true, the command is assumed to be handled. If false
is returned the command should be evaluated normally.
Adopted this up in the Driver.cpp for intercepting the "quit" command.
llvm-svn: 151708
Diffstat (limited to 'lldb/source/Interpreter/CommandInterpreter.cpp')
-rw-r--r-- | lldb/source/Interpreter/CommandInterpreter.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 8b4dc81561b..8c3d2d37d75 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -1511,12 +1511,33 @@ CommandInterpreter::HandleCommand (const char *command_line, 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) - cmd_obj->ExecuteRawCommandString (remainder.c_str(), result); + { + 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()); - cmd_obj->ExecuteWithOptions (cmd_args, result); + 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); } } else |