summaryrefslogtreecommitdiffstats
path: root/lldb/scripts/Python/python-wrapper.swig
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2013-06-20 23:40:21 +0000
committerEnrico Granata <egranata@apple.com>2013-06-20 23:40:21 +0000
commitaad8e480549bc3e23b172534c2b6b8ffcf0425a2 (patch)
treec27d6eec9d63c1fca281cb65811823c00f3da114 /lldb/scripts/Python/python-wrapper.swig
parentd6c62b66b5eefc61d8891332b549cd2983ebfc13 (diff)
downloadbcm5719-llvm-aad8e480549bc3e23b172534c2b6b8ffcf0425a2.tar.gz
bcm5719-llvm-aad8e480549bc3e23b172534c2b6b8ffcf0425a2.zip
In thread and frame format strings, it is now allowed to use Python functions to generate part or all of the output text
Specifically, the ${target ${process ${thread and ${frame specifiers have been extended to allow a subkeyword .script:<fctName> (e.g. ${frame.script:FooFunction}) The functions are prototyped as def FooFunction(Object,unused) where object is of the respective SB-type (SBTarget for target.script, ... and so on) This has not been implemented for ${var because it would be akin to a Python summary which is already well-defined in LLDB llvm-svn: 184500
Diffstat (limited to 'lldb/scripts/Python/python-wrapper.swig')
-rw-r--r--lldb/scripts/Python/python-wrapper.swig344
1 files changed, 344 insertions, 0 deletions
diff --git a/lldb/scripts/Python/python-wrapper.swig b/lldb/scripts/Python/python-wrapper.swig
index d10102a6443..8c1c5051cbd 100644
--- a/lldb/scripts/Python/python-wrapper.swig
+++ b/lldb/scripts/Python/python-wrapper.swig
@@ -895,6 +895,350 @@ LLDBSWIGPythonCreateOSPlugin
}
SWIGEXPORT bool
+LLDBSWIGPythonRunScriptKeywordProcess
+(const char* python_function_name,
+const char* session_dictionary_name,
+lldb::ProcessSP& process,
+std::string& output)
+
+{
+ bool retval = false;
+
+ if (python_function_name == NULL || python_function_name[0] == '\0' || !session_dictionary_name)
+ return retval;
+
+ lldb::SBProcess process_sb(process);
+ PyObject *ProcessObj_PyObj = SWIG_NewPointerObj((void *) &process_sb, SWIGTYPE_p_lldb__SBProcess, 0);
+
+ if (ProcessObj_PyObj == NULL)
+ return retval;
+
+ PyObject *session_dict, *pfunc;
+ PyObject *pargs, *pvalue;
+
+ session_dict = FindSessionDictionary (session_dictionary_name);
+
+ if (session_dict != NULL)
+ {
+ pfunc = ResolvePythonName (python_function_name, session_dict);
+
+ if (PyErr_Occurred()) // this might not exist.. let's make sure we handle that
+ {
+ PyErr_Clear();
+ return true;
+ }
+
+ if (pfunc == NULL)
+ return true;
+ else
+ {
+ // Set up the arguments and call the function.
+
+ if (PyCallable_Check (pfunc))
+ {
+ pargs = PyTuple_New (2);
+ if (pargs == NULL)
+ {
+ if (PyErr_Occurred())
+ PyErr_Clear();
+ return retval;
+ }
+
+ PyTuple_SetItem (pargs, 0, ProcessObj_PyObj); // This "steals" a reference to ProcessObj_PyObj
+ PyTuple_SetItem (pargs, 1, session_dict); // This "steals" a reference to session_dict
+ pvalue = PyObject_CallObject (pfunc, pargs);
+ Py_XDECREF (pargs);
+
+ if (PyErr_Occurred ())
+ {
+ PyErr_Print();
+ PyErr_Clear();
+ }
+ else
+ {
+ if (PyString_Check(pvalue))
+ {
+ output.assign(PyString_AsString(pvalue));
+ retval = true;
+ }
+ else
+ {
+ output.clear();
+ retval = false;
+ }
+ Py_XDECREF (pvalue);
+ }
+ Py_INCREF (session_dict);
+ }
+ else if (PyErr_Occurred())
+ {
+ PyErr_Print();
+ PyErr_Clear();
+ }
+ }
+ }
+ return retval;
+}
+
+SWIGEXPORT bool
+LLDBSWIGPythonRunScriptKeywordThread
+(const char* python_function_name,
+const char* session_dictionary_name,
+lldb::ThreadSP& thread,
+std::string& output)
+
+{
+ bool retval = false;
+
+ if (python_function_name == NULL || python_function_name[0] == '\0' || !session_dictionary_name)
+ return retval;
+
+ lldb::SBThread thread_sb(thread);
+ PyObject *ThreadObj_PyObj = SWIG_NewPointerObj((void *) &thread_sb, SWIGTYPE_p_lldb__SBThread, 0);
+
+ if (ThreadObj_PyObj == NULL)
+ return retval;
+
+ PyObject *session_dict, *pfunc;
+ PyObject *pargs, *pvalue;
+
+ session_dict = FindSessionDictionary (session_dictionary_name);
+
+ if (session_dict != NULL)
+ {
+ pfunc = ResolvePythonName (python_function_name, session_dict);
+
+ if (PyErr_Occurred()) // this might not exist.. let's make sure we handle that
+ {
+ PyErr_Clear();
+ return true;
+ }
+
+ if (pfunc == NULL)
+ return true;
+ else
+ {
+ // Set up the arguments and call the function.
+
+ if (PyCallable_Check (pfunc))
+ {
+ pargs = PyTuple_New (2);
+ if (pargs == NULL)
+ {
+ if (PyErr_Occurred())
+ PyErr_Clear();
+ return retval;
+ }
+
+ PyTuple_SetItem (pargs, 0, ThreadObj_PyObj); // This "steals" a reference to ThreadObj_PyObj
+ PyTuple_SetItem (pargs, 1, session_dict); // This "steals" a reference to session_dict
+ pvalue = PyObject_CallObject (pfunc, pargs);
+ Py_XDECREF (pargs);
+
+ if (PyErr_Occurred ())
+ {
+ PyErr_Print();
+ PyErr_Clear();
+ }
+ else
+ {
+ if (PyString_Check(pvalue))
+ {
+ output.assign(PyString_AsString(pvalue));
+ retval = true;
+ }
+ else
+ {
+ output.clear();
+ retval = false;
+ }
+ Py_XDECREF (pvalue);
+ }
+ Py_INCREF (session_dict);
+ }
+ else if (PyErr_Occurred())
+ {
+ PyErr_Print();
+ PyErr_Clear();
+ }
+ }
+ }
+ return retval;
+}
+
+SWIGEXPORT bool
+LLDBSWIGPythonRunScriptKeywordTarget
+(const char* python_function_name,
+const char* session_dictionary_name,
+lldb::TargetSP& target,
+std::string& output)
+
+{
+ bool retval = false;
+
+ if (python_function_name == NULL || python_function_name[0] == '\0' || !session_dictionary_name)
+ return retval;
+
+ lldb::SBTarget target_sb(target);
+ PyObject *TargetObj_PyObj = SWIG_NewPointerObj((void *) &target_sb, SWIGTYPE_p_lldb__SBTarget, 0);
+
+ if (TargetObj_PyObj == NULL)
+ return retval;
+
+ PyObject *session_dict, *pfunc;
+ PyObject *pargs, *pvalue;
+
+ session_dict = FindSessionDictionary (session_dictionary_name);
+
+ if (session_dict != NULL)
+ {
+ pfunc = ResolvePythonName (python_function_name, session_dict);
+
+ if (PyErr_Occurred()) // this might not exist.. let's make sure we handle that
+ {
+ PyErr_Clear();
+ return true;
+ }
+
+ if (pfunc == NULL)
+ return true;
+ else
+ {
+ // Set up the arguments and call the function.
+
+ if (PyCallable_Check (pfunc))
+ {
+ pargs = PyTuple_New (2);
+ if (pargs == NULL)
+ {
+ if (PyErr_Occurred())
+ PyErr_Clear();
+ return retval;
+ }
+
+ PyTuple_SetItem (pargs, 0, TargetObj_PyObj); // This "steals" a reference to TargetObj_PyObj
+ PyTuple_SetItem (pargs, 1, session_dict); // This "steals" a reference to session_dict
+ pvalue = PyObject_CallObject (pfunc, pargs);
+ Py_XDECREF (pargs);
+
+ if (PyErr_Occurred ())
+ {
+ PyErr_Print();
+ PyErr_Clear();
+ }
+ else
+ {
+ if (PyString_Check(pvalue))
+ {
+ output.assign(PyString_AsString(pvalue));
+ retval = true;
+ }
+ else
+ {
+ output.clear();
+ retval = false;
+ }
+ Py_XDECREF (pvalue);
+ }
+ Py_INCREF (session_dict);
+ }
+ else if (PyErr_Occurred())
+ {
+ PyErr_Print();
+ PyErr_Clear();
+ }
+ }
+ }
+ return retval;
+}
+
+SWIGEXPORT bool
+LLDBSWIGPythonRunScriptKeywordFrame
+(const char* python_function_name,
+const char* session_dictionary_name,
+lldb::StackFrameSP& frame,
+std::string& output)
+
+{
+ bool retval = false;
+
+ if (python_function_name == NULL || python_function_name[0] == '\0' || !session_dictionary_name)
+ return retval;
+
+ lldb::SBFrame frame_sb(frame);
+ PyObject *FrameObj_PyObj = SWIG_NewPointerObj((void *) &frame_sb, SWIGTYPE_p_lldb__SBFrame, 0);
+
+ if (FrameObj_PyObj == NULL)
+ return retval;
+
+ PyObject *session_dict, *pfunc;
+ PyObject *pargs, *pvalue;
+
+ session_dict = FindSessionDictionary (session_dictionary_name);
+
+ if (session_dict != NULL)
+ {
+ pfunc = ResolvePythonName (python_function_name, session_dict);
+
+ if (PyErr_Occurred()) // this might not exist.. let's make sure we handle that
+ {
+ PyErr_Clear();
+ return true;
+ }
+
+ if (pfunc == NULL)
+ return true;
+ else
+ {
+ // Set up the arguments and call the function.
+
+ if (PyCallable_Check (pfunc))
+ {
+ pargs = PyTuple_New (2);
+ if (pargs == NULL)
+ {
+ if (PyErr_Occurred())
+ PyErr_Clear();
+ return retval;
+ }
+
+ PyTuple_SetItem (pargs, 0, FrameObj_PyObj); // This "steals" a reference to FrameObj_PyObj
+ PyTuple_SetItem (pargs, 1, session_dict); // This "steals" a reference to session_dict
+ pvalue = PyObject_CallObject (pfunc, pargs);
+ Py_XDECREF (pargs);
+
+ if (PyErr_Occurred ())
+ {
+ PyErr_Print();
+ PyErr_Clear();
+ }
+ else
+ {
+ if (PyString_Check(pvalue))
+ {
+ output.assign(PyString_AsString(pvalue));
+ retval = true;
+ }
+ else
+ {
+ output.clear();
+ retval = false;
+ }
+ Py_XDECREF (pvalue);
+ }
+ Py_INCREF (session_dict);
+ }
+ else if (PyErr_Occurred())
+ {
+ PyErr_Print();
+ PyErr_Clear();
+ }
+ }
+ }
+ return retval;
+}
+
+SWIGEXPORT bool
LLDBSwigPythonCallModuleInit
(
const char *python_module_name,
OpenPOWER on IntegriCloud