Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 926448 Details for
Bug 1116957
GDB Python GIL handling with gdb.execute("continue")
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Path to GDB for gdb.command to optionally release GIL
python_gil.patch (text/plain), 3.83 KB, created by
Phil Muldoon
on 2014-08-13 13:56:33 UTC
(
hide
)
Description:
Path to GDB for gdb.command to optionally release GIL
Filename:
MIME Type:
Creator:
Phil Muldoon
Created:
2014-08-13 13:56:33 UTC
Size:
3.83 KB
patch
obsolete
>diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi >index 4688783..afa458b 100644 >--- a/gdb/doc/python.texi >+++ b/gdb/doc/python.texi >@@ -230,6 +230,14 @@ returned as a string. The default is @code{False}, in which case the > return value is @code{None}. If @var{to_string} is @code{True}, the > @value{GDBN} virtual terminal will be temporarily set to unlimited width > and height, and its pagination will be disabled; @pxref{Screen Size}. >+ >+The @var{release_gil} flag specifies whether @value{GDBN} ought to >+release the Python GIL before executing the command. This is useful >+in multi-threaded Python programs where by default the Python >+interpreter will acquire the GIL and lock other threads from >+executing. After the command has completed executing in @value{GDBN} >+the Python GIL is reacquired. This flag must be a boolean value. If >+omitted, it defaults to @code{False}. > @end defun > > @findex gdb.breakpoints >diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h >index 6e7e600..8990a93 100644 >--- a/gdb/python/python-internal.h >+++ b/gdb/python/python-internal.h >@@ -141,6 +141,8 @@ typedef int Py_ssize_t; > #define PyGILState_Release(ARG) ((void)(ARG)) > #define PyEval_InitThreads() > #define PyThreadState_Swap(ARG) ((void)(ARG)) >+#define PyEval_SaveThread() ((void)(ARG)) >+#define PyEval_RestoreThread(ARG) ((void)(ARG)) > #define PyEval_ReleaseLock() > #endif > >diff --git a/gdb/python/python.c b/gdb/python/python.c >index 40c4ec9..4c55be6 100644 >--- a/gdb/python/python.c >+++ b/gdb/python/python.c >@@ -617,14 +617,18 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) > { > const char *arg; > PyObject *from_tty_obj = NULL, *to_string_obj = NULL; >- int from_tty, to_string; >+ PyObject *release_gil_obj = NULL; >+ int from_tty, to_string, release_gil; > volatile struct gdb_exception except; >- static char *keywords[] = {"command", "from_tty", "to_string", NULL }; >+ static char *keywords[] = {"command", "from_tty", "to_string", >+ "release_gil", NULL }; > char *result = NULL; >+ PyThreadState *state; > >- if (! PyArg_ParseTupleAndKeywords (args, kw, "s|O!O!", keywords, &arg, >+ if (! PyArg_ParseTupleAndKeywords (args, kw, "s|O!O!O!", keywords, &arg, > &PyBool_Type, &from_tty_obj, >- &PyBool_Type, &to_string_obj)) >+ &PyBool_Type, &to_string_obj, >+ &PyBool_Type, &release_gil_obj)) > return NULL; > > from_tty = 0; >@@ -645,12 +649,28 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) > to_string = cmp; > } > >+ release_gil = 0; >+ if (release_gil_obj) >+ { >+ int cmp = PyObject_IsTrue (release_gil_obj); >+ if (cmp < 0) >+ return NULL; >+ release_gil = cmp; >+ } >+ > TRY_CATCH (except, RETURN_MASK_ALL) > { > /* Copy the argument text in case the command modifies it. */ > char *copy = xstrdup (arg); > struct cleanup *cleanup = make_cleanup (xfree, copy); > >+ /* In the case of long running GDB commands, allow the user to >+ release the Python GIL acquired by Python. Restore the GIL >+ after the command has completed before handing back to >+ Python. */ >+ if (release_gil) >+ state = PyEval_SaveThread(); >+ > make_cleanup_restore_integer (&interpreter_async); > interpreter_async = 0; > >@@ -663,9 +683,21 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) > execute_command (copy, from_tty); > } > >+ /* Reacquire the GIL if it was released earlier. */ >+ if (release_gil) >+ PyEval_RestoreThread (state); >+ > do_cleanups (cleanup); > } >- GDB_PY_HANDLE_EXCEPTION (except); >+ if (except.reason < 0) >+ { >+ /* Reacquire the GIL if it was released earlier. */ >+ if (release_gil) >+ PyEval_RestoreThread (state); >+ >+ gdbpy_convert_exception (except); >+ return NULL; >+ } > > /* Do any commands attached to breakpoint we stopped at. */ > bpstat_do_actions ();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 1116957
: 926448