diff options
Diffstat (limited to 'gdb/python/python-utils.c')
-rw-r--r-- | gdb/python/python-utils.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gdb/python/python-utils.c b/gdb/python/python-utils.c index 912845f..8db81ec 100644 --- a/gdb/python/python-utils.c +++ b/gdb/python/python-utils.c @@ -46,6 +46,23 @@ make_cleanup_py_decref (PyObject *py) return make_cleanup (py_decref, (void *) py); } +/* A cleanup function to restore the thread state. */ + +static void +py_gil_restore (void *p) +{ + PyGILState_STATE *state = p; + PyGILState_Release (*state); +} + +/* Return a new cleanup which will restore the Python GIL state. */ + +struct cleanup * +make_cleanup_py_restore_gil (PyGILState_STATE *state) +{ + return make_cleanup (py_gil_restore, state); +} + /* Converts a Python 8-bit string to a unicode string object. Assumes the 8-bit string is in the host charset. If an error occurs during conversion, returns NULL with a python exception set. |