summaryrefslogtreecommitdiffstats
path: root/lldb/scripts/Python/python-wrapper.swig
diff options
context:
space:
mode:
authorJohnny Chen <johnny.chen@apple.com>2012-08-09 23:09:42 +0000
committerJohnny Chen <johnny.chen@apple.com>2012-08-09 23:09:42 +0000
commite9a5627e7ae21d10049352e196ff7469a40c6d06 (patch)
tree97ada238546a6071edbdf67f1ba78bc41ca7f6f0 /lldb/scripts/Python/python-wrapper.swig
parent637ff0cc0fc79bdd6ccea856835f278e89f79b67 (diff)
downloadbcm5719-llvm-e9a5627e7ae21d10049352e196ff7469a40c6d06.tar.gz
bcm5719-llvm-e9a5627e7ae21d10049352e196ff7469a40c6d06.zip
rdar://problem/11457143 [ER] need "watchpoint command ..."
Add 'watchpoint command add/delete/list' to lldb, plus two .py test files. llvm-svn: 161638
Diffstat (limited to 'lldb/scripts/Python/python-wrapper.swig')
-rw-r--r--lldb/scripts/Python/python-wrapper.swig79
1 files changed, 79 insertions, 0 deletions
diff --git a/lldb/scripts/Python/python-wrapper.swig b/lldb/scripts/Python/python-wrapper.swig
index 1442608d6bb..73bad8d11d2 100644
--- a/lldb/scripts/Python/python-wrapper.swig
+++ b/lldb/scripts/Python/python-wrapper.swig
@@ -176,6 +176,85 @@ LLDBSwigPythonBreakpointCallbackFunction
return stop_at_breakpoint;
}
+// This function is called by lldb_private::ScriptInterpreterPython::WatchpointCallbackFunction(...)
+// and is used when a script command is attached to a watchpoint for execution.
+
+SWIGEXPORT bool
+LLDBSwigPythonWatchpointCallbackFunction
+(
+ const char *python_function_name,
+ const char *session_dictionary_name,
+ const lldb::StackFrameSP& frame_sp,
+ const lldb::WatchpointSP& wp_sp
+)
+{
+ lldb::SBFrame sb_frame (frame_sp);
+ lldb::SBWatchpoint sb_wp(wp_sp);
+
+ bool stop_at_watchpoint = true;
+ PyObject *Frame_PyObj = SWIG_NewPointerObj((void *) &sb_frame, SWIGTYPE_p_lldb__SBFrame, 0);
+ PyObject *Wp_PyObj = SWIG_NewPointerObj ((void *) &sb_wp, SWIGTYPE_p_lldb__SBWatchpoint, 0);
+
+ if (Frame_PyObj == NULL || Wp_PyObj == NULL)
+ return stop_at_watchpoint;
+
+ if (!python_function_name || !session_dictionary_name)
+ return stop_at_watchpoint;
+
+ 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 (pfunc != NULL)
+ {
+ // Set up the arguments and call the function.
+
+ if (PyCallable_Check (pfunc))
+ {
+ pargs = PyTuple_New (3);
+ if (pargs == NULL)
+ {
+ if (PyErr_Occurred())
+ PyErr_Clear();
+ return stop_at_watchpoint;
+ }
+
+ PyTuple_SetItem (pargs, 0, Frame_PyObj); // This "steals" a reference to Frame_PyObj
+ PyTuple_SetItem (pargs, 1, Wp_PyObj); // This "steals" a reference to Wp_PyObj
+ PyTuple_SetItem (pargs, 2, session_dict); // This "steals" a reference to session_dict
+ pvalue = PyObject_CallObject (pfunc, pargs);
+ Py_DECREF (pargs);
+
+ if (pvalue != NULL)
+ {
+ Py_DECREF (pvalue);
+ }
+ else if (PyErr_Occurred ())
+ {
+ PyErr_Clear();
+ }
+ Py_INCREF (session_dict);
+ }
+ else if (PyErr_Occurred())
+ {
+ PyErr_Clear();
+ }
+ }
+ else if (PyErr_Occurred())
+ {
+ PyErr_Clear();
+ }
+ }
+ else if (PyErr_Occurred ())
+ {
+ PyErr_Clear ();
+ }
+ return stop_at_watchpoint;
+}
+
SWIGEXPORT bool
LLDBSwigPythonCallTypeScript
(
OpenPOWER on IntegriCloud