]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: move gdbpy_gil into python-internal.h
authorAlexandra Hájková <ahajkova@redhat.com>
Wed, 6 Dec 2023 16:17:25 +0000 (17:17 +0100)
committerAlexandra Hájková <ahajkova@redhat.com>
Wed, 13 Dec 2023 09:46:39 +0000 (10:46 +0100)
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 <tom@tromey.com>
gdb/python/python-internal.h
gdb/python/python.c

index 86eb5436f2aa31842d22320d00d32eacb40da696..14e1557468519fd6e08d224c11cc4d10b6632491 100644 (file)
@@ -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)     \
index 832f374b39fee67695e1dd0a65ac5423b6a11059..2ca3c50afd442506837dbfbe884c69a364d42412 100644 (file)
@@ -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