9b90152
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
9b90152
From: =?UTF-8?q?Alexandra=20H=C3=A1jkov=C3=A1?= <ahajkova@redhat.com>
9b90152
Date: Mon, 8 Jan 2024 13:12:15 +0100
9b90152
Subject: gdb-rhbz2250652-gdbpy_gil.patch
9b90152
9b90152
gdb: move gdbpy_gil into python-internal.h
9b90152
9b90152
Move gdbpy_gil class into python-internal.h, the next
9b90152
commit wants to make use of this class from a file other
9b90152
than python.c.
9b90152
9b90152
Approved-By: Tom Tromey <tom@tromey.com>
9b90152
9b90152
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
9b90152
--- a/gdb/python/python-internal.h
9b90152
+++ b/gdb/python/python-internal.h
9b90152
@@ -754,6 +754,30 @@ class gdbpy_allow_threads
9b90152
   PyThreadState *m_save;
9b90152
 };
9b90152
 
9b90152
+/* A helper class to save and restore the GIL, but without touching
9b90152
+   the other globals that are handled by gdbpy_enter.  */
9b90152
+
9b90152
+class gdbpy_gil
9b90152
+{
9b90152
+public:
9b90152
+
9b90152
+  gdbpy_gil ()
9b90152
+    : m_state (PyGILState_Ensure ())
9b90152
+  {
9b90152
+  }
9b90152
+
9b90152
+  ~gdbpy_gil ()
9b90152
+  {
9b90152
+    PyGILState_Release (m_state);
9b90152
+  }
9b90152
+
9b90152
+  DISABLE_COPY_AND_ASSIGN (gdbpy_gil);
9b90152
+
9b90152
+private:
9b90152
+
9b90152
+  PyGILState_STATE m_state;
9b90152
+};
9b90152
+
9b90152
 /* Use this after a TRY_EXCEPT to throw the appropriate Python
9b90152
    exception.  */
9b90152
 #define GDB_PY_HANDLE_EXCEPTION(Exception)	\
9b90152
diff --git a/gdb/python/python.c b/gdb/python/python.c
9b90152
--- a/gdb/python/python.c
9b90152
+++ b/gdb/python/python.c
9b90152
@@ -257,30 +257,6 @@ gdbpy_enter::finalize ()
9b90152
   python_gdbarch = target_gdbarch ();
9b90152
 }
9b90152
 
9b90152
-/* A helper class to save and restore the GIL, but without touching
9b90152
-   the other globals that are handled by gdbpy_enter.  */
9b90152
-
9b90152
-class gdbpy_gil
9b90152
-{
9b90152
-public:
9b90152
-
9b90152
-  gdbpy_gil ()
9b90152
-    : m_state (PyGILState_Ensure ())
9b90152
-  {
9b90152
-  }
9b90152
-
9b90152
-  ~gdbpy_gil ()
9b90152
-  {
9b90152
-    PyGILState_Release (m_state);
9b90152
-  }
9b90152
-
9b90152
-  DISABLE_COPY_AND_ASSIGN (gdbpy_gil);
9b90152
-
9b90152
-private:
9b90152
-
9b90152
-  PyGILState_STATE m_state;
9b90152
-};
9b90152
-
9b90152
 /* Set the quit flag.  */
9b90152
 
9b90152
 static void