From: Alexandra Hájková Date: Wed, 6 Dec 2023 16:17:25 +0000 (+0100) Subject: gdb: move gdbpy_gil into python-internal.h X-Git-Tag: binutils-2_42~611 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7ae9ecfd80104a793ed1d836fd4dc0aa1a9c7832;p=thirdparty%2Fbinutils-gdb.git gdb: move gdbpy_gil into python-internal.h Move gdbpy_gil class into python-internal.h, the next commit wants to make use of this class from a file other than python.c. Approved-By: Tom Tromey --- diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index 86eb5436f2a..14e15574685 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -772,6 +772,30 @@ private: PyThreadState *m_save; }; +/* A helper class to save and restore the GIL, but without touching + the other globals that are handled by gdbpy_enter. */ + +class gdbpy_gil +{ +public: + + gdbpy_gil () + : m_state (PyGILState_Ensure ()) + { + } + + ~gdbpy_gil () + { + PyGILState_Release (m_state); + } + + DISABLE_COPY_AND_ASSIGN (gdbpy_gil); + +private: + + PyGILState_STATE m_state; +}; + /* Use this after a TRY_EXCEPT to throw the appropriate Python exception. */ #define GDB_PY_HANDLE_EXCEPTION(Exception) \ diff --git a/gdb/python/python.c b/gdb/python/python.c index 832f374b39f..2ca3c50afd4 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -264,30 +264,6 @@ gdbpy_enter::finalize () python_gdbarch = current_inferior ()->arch (); } -/* A helper class to save and restore the GIL, but without touching - the other globals that are handled by gdbpy_enter. */ - -class gdbpy_gil -{ -public: - - gdbpy_gil () - : m_state (PyGILState_Ensure ()) - { - } - - ~gdbpy_gil () - { - PyGILState_Release (m_state); - } - - DISABLE_COPY_AND_ASSIGN (gdbpy_gil); - -private: - - PyGILState_STATE m_state; -}; - /* Set the quit flag. */ static void