summaryrefslogtreecommitdiffstats
path: root/lldb/scripts/Python/python-wrapper.swig
diff options
context:
space:
mode:
authorKuba Mracek <mracek@apple.com>2018-10-31 00:21:03 +0000
committerKuba Mracek <mracek@apple.com>2018-10-31 00:21:03 +0000
commitac0ba8c52493012daabb73512a5739394c37a2dc (patch)
tree60ae5cde6970cb9d828e8ca3c7bcdf2e4095b4c5 /lldb/scripts/Python/python-wrapper.swig
parent1079d7ccfeccf8344eb799bef392a875693ab353 (diff)
downloadbcm5719-llvm-ac0ba8c52493012daabb73512a5739394c37a2dc.tar.gz
bcm5719-llvm-ac0ba8c52493012daabb73512a5739394c37a2dc.zip
[lldb] Introduce StackFrameRecognizer
This patch introduces a concept of "frame recognizer" and "recognized frame". This should be an extensible mechanism that retrieves information about special frames based on ABI, arguments or other special properties of that frame, even without source code. A few examples where that could be useful could be 1) objc_exception_throw, where we'd like to get the current exception, 2) terminate_with_reason and extracting the current terminate string, 3) recognizing Objective-C frames and automatically extracting the receiver+selector, or perhaps all arguments (based on selector). Differential Revision: https://reviews.llvm.org/D44603 llvm-svn: 345678
Diffstat (limited to 'lldb/scripts/Python/python-wrapper.swig')
-rw-r--r--lldb/scripts/Python/python-wrapper.swig46
1 files changed, 46 insertions, 0 deletions
diff --git a/lldb/scripts/Python/python-wrapper.swig b/lldb/scripts/Python/python-wrapper.swig
index 1679d895e4a..e6a6b7afb8e 100644
--- a/lldb/scripts/Python/python-wrapper.swig
+++ b/lldb/scripts/Python/python-wrapper.swig
@@ -785,6 +785,52 @@ LLDBSWIGPythonCreateOSPlugin
}
SWIGEXPORT void*
+LLDBSWIGPython_CreateFrameRecognizer
+(
+ const char *python_class_name,
+ const char *session_dictionary_name
+)
+{
+ using namespace lldb_private;
+
+ if (python_class_name == NULL || python_class_name[0] == '\0' || !session_dictionary_name)
+ Py_RETURN_NONE;
+
+ PyErr_Cleaner py_err_cleaner(true);
+
+ auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(session_dictionary_name);
+ auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(python_class_name, dict);
+
+ if (!pfunc.IsAllocated())
+ Py_RETURN_NONE;
+
+ auto result = pfunc();
+
+ if (result.IsAllocated())
+ return result.release();
+
+ Py_RETURN_NONE;
+}
+
+SWIGEXPORT PyObject*
+LLDBSwigPython_GetRecognizedArguments
+(
+ PyObject *implementor,
+ const lldb::StackFrameSP& frame_sp
+)
+{
+ using namespace lldb_private;
+
+ static char callee_name[] = "get_recognized_arguments";
+
+ lldb::SBFrame frame_sb(frame_sp);
+ PyObject *arg = SBTypeToSWIGWrapper(frame_sb);
+
+ PyObject* result = PyObject_CallMethodObjArgs(implementor, PyString_FromString(callee_name), arg, NULL);
+ return result;
+}
+
+SWIGEXPORT void*
LLDBSWIGPython_GetDynamicSetting (void* module, const char* setting, const lldb::TargetSP& target_sp)
{
using namespace lldb_private;
OpenPOWER on IntegriCloud