[Lldb-commits] [lldb] r214938 - Add a variant of the CommandOverrideCallback that takes a
Jim Ingham
jingham at apple.com
Tue Aug 5 17:10:13 PDT 2014
Author: jingham
Date: Tue Aug 5 19:10:12 2014
New Revision: 214938
URL: http://llvm.org/viewvc/llvm-project?rev=214938&view=rev
Log:
Add a variant of the CommandOverrideCallback that takes a
CommandReturnObject. Otherwise, all the overridden command
can do is say it overrode the command, not say what it did...
Also removed the duplicate definition of CommandOverrideCallback
from the private interfaces.
Now to figure out how to get this through the SB API's...
<rdar://problem/17911629>
Modified:
lldb/trunk/include/lldb/Interpreter/CommandObject.h
lldb/trunk/include/lldb/lldb-private-interfaces.h
lldb/trunk/include/lldb/lldb-types.h
lldb/trunk/source/Interpreter/CommandObject.cpp
Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObject.h?rev=214938&r1=214937&r2=214938&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/CommandObject.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandObject.h Tue Aug 5 19:10:12 2014
@@ -460,25 +460,37 @@ public:
return NULL;
}
- CommandOverrideCallback
- GetOverrideCallback () const
+ bool
+ HasOverrideCallback () const
{
- return m_command_override_callback;
+ return m_command_override_callback || m_deprecated_command_override_callback;
}
- void *
- GetOverrideCallbackBaton () const
+ void
+ SetOverrideCallback (lldb::CommandOverrideCallback callback, void *baton)
{
- return m_command_override_baton;
+ m_deprecated_command_override_callback = callback;
+ m_command_override_baton = baton;
}
-
+
void
- SetOverrideCallback (CommandOverrideCallback callback, void *baton)
+ SetOverrideCallback (lldb::CommandOverrideCallbackWithResult callback, void *baton)
{
m_command_override_callback = callback;
m_command_override_baton = baton;
}
+ bool
+ InvokeOverrideCallback (const char **argv, CommandReturnObject &result)
+ {
+ if (m_command_override_callback)
+ return m_command_override_callback(m_command_override_baton, argv, result);
+ else if (m_deprecated_command_override_callback)
+ return m_deprecated_command_override_callback(m_command_override_baton, argv);
+ else
+ return false;
+ }
+
virtual bool
Execute (const char *args_string, CommandReturnObject &result) = 0;
@@ -540,7 +552,8 @@ protected:
bool m_is_alias;
Flags m_flags;
std::vector<CommandArgumentEntry> m_arguments;
- CommandOverrideCallback m_command_override_callback;
+ lldb::CommandOverrideCallback m_deprecated_command_override_callback;
+ lldb::CommandOverrideCallbackWithResult m_command_override_callback;
void * m_command_override_baton;
// Helper function to populate IDs or ID ranges as the command argument data
Modified: lldb/trunk/include/lldb/lldb-private-interfaces.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-interfaces.h?rev=214938&r1=214937&r2=214938&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-private-interfaces.h (original)
+++ lldb/trunk/include/lldb/lldb-private-interfaces.h Tue Aug 5 19:10:12 2014
@@ -40,7 +40,6 @@ namespace lldb_private
typedef lldb::ThreadPlanSP (*ThreadPlanStepFromHereCallback) (ThreadPlan *current_plan, Flags &flags, lldb::FrameComparison operation, void *baton);
typedef UnwindAssembly* (*UnwindAssemblyCreateInstance) (const ArchSpec &arch);
typedef int (*ComparisonFunction)(const void *, const void *);
- typedef bool (*CommandOverrideCallback)(void *baton, const char **argv);
typedef void (*DebuggerInitializeCallback)(Debugger &debugger);
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/lldb-types.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-types.h?rev=214938&r1=214937&r2=214938&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-types.h (original)
+++ lldb/trunk/include/lldb/lldb-types.h Tue Aug 5 19:10:12 2014
@@ -81,6 +81,9 @@ namespace lldb
{
typedef void (*LogOutputCallback) (const char *, void *baton);
typedef bool (*CommandOverrideCallback)(void *baton, const char **argv);
+ typedef bool (*CommandOverrideCallbackWithResult)(void *baton,
+ const char **argv,
+ lldb_private::CommandReturnObject &result);
typedef bool (*ExpressionCancelCallback) (ExpressionEvaluationPhase phase, void *baton);
}
Modified: lldb/trunk/source/Interpreter/CommandObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=214938&r1=214937&r2=214938&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandObject.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandObject.cpp Tue Aug 5 19:10:12 2014
@@ -1005,14 +1005,13 @@ CommandObject::GetArgumentDescriptionAsC
bool
CommandObjectParsed::Execute (const char *args_string, CommandReturnObject &result)
{
- CommandOverrideCallback command_callback = GetOverrideCallback();
bool handled = false;
Args cmd_args (args_string);
- if (command_callback)
+ if (HasOverrideCallback())
{
Args full_args (GetCommandName ());
full_args.AppendArguments(cmd_args);
- handled = command_callback (GetOverrideCallbackBaton(), full_args.GetConstArgumentVector());
+ handled = InvokeOverrideCallback (full_args.GetConstArgumentVector(), result);
}
if (!handled)
{
@@ -1040,16 +1039,15 @@ CommandObjectParsed::Execute (const char
bool
CommandObjectRaw::Execute (const char *args_string, CommandReturnObject &result)
{
- CommandOverrideCallback command_callback = GetOverrideCallback();
bool handled = false;
- if (command_callback)
+ if (HasOverrideCallback())
{
std::string full_command (GetCommandName ());
full_command += ' ';
full_command += args_string;
const char *argv[2] = { nullptr, nullptr };
argv[0] = full_command.c_str();
- handled = command_callback (GetOverrideCallbackBaton(), argv);
+ handled = InvokeOverrideCallback (argv, result);
}
if (!handled)
{
More information about the lldb-commits
mailing list