diff options
| author | Jeffrey Tan <jeffreytan@fb.com> | 2023-02-03 17:09:09 -0800 |
|---|---|---|
| committer | Jeffrey Tan <jeffreytan@fb.com> | 2023-03-07 14:48:15 -0800 |
| commit | b461398f1ce307ec80708b7eb50f3bc82b76ed3f (patch) | |
| tree | ad2231b14096485f58091b68490b4436615f32af /lldb/bindings/python/python-typemaps.swig | |
| parent | 6e2ade23c7944a09241d6cafe559f05b39cb17e8 (diff) | |
Add a new SBDebugger::SetDestroyCallback() API
Adding a new SBDebugger::SetDestroyCallback() API.
This API can be used by any client to query for statistics/metrics before
exiting debug sessions.
Differential Revision: https://reviews.llvm.org/D143520
Diffstat (limited to 'lldb/bindings/python/python-typemaps.swig')
| -rw-r--r-- | lldb/bindings/python/python-typemaps.swig | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lldb/bindings/python/python-typemaps.swig b/lldb/bindings/python/python-typemaps.swig index 1b1f2e1fe266..b3e7dd4ee265 100644 --- a/lldb/bindings/python/python-typemaps.swig +++ b/lldb/bindings/python/python-typemaps.swig @@ -384,6 +384,29 @@ template <> bool SetNumberFromPyObject<double>(double &number, PyObject *obj) { $1 = $1 || PyCallable_Check(reinterpret_cast<PyObject *>($input)); } +// For lldb::SBDebuggerDestroyCallback +%typemap(in) (lldb::SBDebuggerDestroyCallback destroy_callback, void *baton) { + if (!($input == Py_None || + PyCallable_Check(reinterpret_cast<PyObject *>($input)))) { + PyErr_SetString(PyExc_TypeError, "Need a callable object or None!"); + SWIG_fail; + } + + // FIXME (filcab): We can't currently check if our callback is already + // LLDBSwigPythonCallPythonSBDebuggerTerminateCallback (to DECREF the previous + // baton) nor can we just remove all traces of a callback, if we want to + // revert to a file logging mechanism. + + // Don't lose the callback reference + Py_INCREF($input); + $1 = LLDBSwigPythonCallPythonSBDebuggerTerminateCallback; + $2 = $input; +} + +%typemap(typecheck) (lldb::SBDebuggerDestroyCallback destroy_callback, void *baton) { + $1 = $input == Py_None; + $1 = $1 || PyCallable_Check(reinterpret_cast<PyObject *>($input)); +} %typemap(in) lldb::FileSP { PythonFile py_file(PyRefType::Borrowed, $input); |
