public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Alexandra Hájková" <ahajkova@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/2] gdb: move gdbpy_gil into python-internal.h
Date: Thu,  7 Dec 2023 12:02:39 +0100	[thread overview]
Message-ID: <20231207110240.1853760-1-ahajkova@redhat.com> (raw)

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.
---
 gdb/python/python-internal.h | 24 ++++++++++++++++++++++++
 gdb/python/python.c          | 24 ------------------------
 2 files changed, 24 insertions(+), 24 deletions(-)

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 @@ class gdbpy_allow_threads
   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 8a36673a3e4..f9df57b9fd5 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
-- 
2.41.0


             reply	other threads:[~2023-12-07 11:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-07 11:02 Alexandra Hájková [this message]
2023-12-07 11:02 ` [PATCH 2/2] gdb/python: avoid use of _PyOS_ReadlineTState Alexandra Hájková
2023-12-08 18:04   ` Tom Tromey
2023-12-08 18:04 ` [PATCH 1/2] gdb: move gdbpy_gil into python-internal.h Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231207110240.1853760-1-ahajkova@redhat.com \
    --to=ahajkova@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).