From 9fe00e52d3dc12e80428648d84542f800c362163 Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Fri, 13 Mar 2015 02:20:41 +0000 Subject: Bulk of the infrastructure work to allow script commands to be backed by object instances in addition to free functions This works by creating a command backed by a class whose interface should - at least - include def __init__(self, debugger, session_dict) def __call__(self, args, return_obj, exe_ctx) What works: - adding a command via command script add --class - calling a thusly created command What is missing: - support for custom help - test cases The missing parts will follow over the next couple of days This is an improvement over the existing system as: a) it provides an obvious location for commands to provide help strings (i.e. methods) b) it allows commands to store state in an obvious fashion c) it allows us to easily add features to script commands over time (option parsing and subcommands registration, I am looking at you :-) llvm-svn: 232136 --- lldb/source/API/SBCommandInterpreter.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lldb/source/API/SBCommandInterpreter.cpp') diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/source/API/SBCommandInterpreter.cpp index 5f2ccdc6c79..a2afd5361f7 100644 --- a/lldb/source/API/SBCommandInterpreter.cpp +++ b/lldb/source/API/SBCommandInterpreter.cpp @@ -603,6 +603,10 @@ LLDBSwigPythonCreateSyntheticProvider (const char *python_class_name, const char *session_dictionary_name, const lldb::ValueObjectSP& valobj_sp); +extern "C" void* +LLDBSwigPythonCreateCommandObject (const char *python_class_name, + const char *session_dictionary_name, + const lldb::DebuggerSP debugger_sp); extern "C" void* LLDBSwigPythonCreateScriptedThreadPlan (const char *python_class_name, @@ -647,6 +651,13 @@ LLDBSwigPythonCallCommand (const char *python_function_name, lldb_private::CommandReturnObject &cmd_retobj, lldb::ExecutionContextRefSP exe_ctx_ref_sp); +extern "C" bool +LLDBSwigPythonCallCommandObject (void *implementor, + lldb::DebuggerSP& debugger, + const char* args, + lldb_private::CommandReturnObject& cmd_retobj, + lldb::ExecutionContextRefSP exe_ctx_ref_sp); + extern "C" bool LLDBSwigPythonCallModuleInit (const char *python_module_name, const char *session_dictionary_name, @@ -708,6 +719,7 @@ SBCommandInterpreter::InitializeSWIG () LLDBSwigPythonWatchpointCallbackFunction, LLDBSwigPythonCallTypeScript, LLDBSwigPythonCreateSyntheticProvider, + LLDBSwigPythonCreateCommandObject, LLDBSwigPython_CalculateNumChildren, LLDBSwigPython_GetChildAtIndex, LLDBSwigPython_GetIndexOfChildWithName, @@ -717,6 +729,7 @@ SBCommandInterpreter::InitializeSWIG () LLDBSwigPython_MightHaveChildrenSynthProviderInstance, LLDBSwigPython_GetValueSynthProviderInstance, LLDBSwigPythonCallCommand, + LLDBSwigPythonCallCommandObject, LLDBSwigPythonCallModuleInit, LLDBSWIGPythonCreateOSPlugin, LLDBSWIGPythonRunScriptKeywordProcess, -- cgit v1.2.3