* [patch] Fix PR python/10806
@ 2009-10-21 11:47 Phil Muldoon
2009-10-21 21:02 ` Tom Tromey
0 siblings, 1 reply; 3+ messages in thread
From: Phil Muldoon @ 2009-10-21 11:47 UTC (permalink / raw)
To: Project Archer
[-- Attachment #1: Type: text/plain, Size: 700 bytes --]
This patch addresses PR python/10806. It is mechanical replacement of
the PyGILState_Ensure/Release with the more recently introduced
ensure_python_env.
OK?
Cheers,
Phil
2009-10-21 Phil Muldoon <pmuldoon@redhat.com>
PR python/10806
* python/python.c (run_python_script): Use ensure_python_env over
PyGILState_Ensure.
(gdbpy_run_events): Likewise.
(run_python_script): Likewise.
(source_python_script): Likewise.
* python/py-breakpoint.c (gdbpy_breakpoint_created): Likewise.
(gdbpy_breakpoint_deleted): Likewise.
* python/py-inferior.c (delete_inferior_object): Likewise.
(add_thread_objet): Likewise.
(delete_thread_object): Likewise.
[-- Attachment #2: pr10806.patch --]
[-- Type: text/plain, Size: 5459 bytes --]
diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index afa9526..783385e 100644
--- a/gdb/python/py-breakpoint.c
+++ b/gdb/python/py-breakpoint.c
@@ -26,7 +26,8 @@
#include "gdbcmd.h"
#include "gdbthread.h"
#include "observer.h"
-
+#include "arch-utils.h"
+#include "language.h"
/* From breakpoint.c. */
extern struct breakpoint *breakpoint_chain;
@@ -494,7 +495,7 @@ gdbpy_breakpoint_created (int num)
{
breakpoint_object *newbp;
struct breakpoint *bp;
- PyGILState_STATE state;
+ struct cleanup *cleanup;
if (num < 0)
return;
@@ -519,7 +520,7 @@ gdbpy_breakpoint_created (int num)
++bppy_live;
- state = PyGILState_Ensure ();
+ cleanup = ensure_python_env (get_current_arch (), current_language);
if (bppy_pending_object)
{
@@ -552,7 +553,7 @@ gdbpy_breakpoint_created (int num)
/* Just ignore errors here. */
PyErr_Clear ();
- PyGILState_Release (state);
+ do_cleanups (cleanup);
}
/* Callback that is used when a breakpoint is deleted. This will
@@ -560,9 +561,9 @@ gdbpy_breakpoint_created (int num)
static void
gdbpy_breakpoint_deleted (int num)
{
- PyGILState_STATE state;
+ struct cleanup *cleanup;
- state = PyGILState_Ensure ();
+ cleanup = ensure_python_env (get_current_arch (), current_language);
if (BPPY_VALID_P (num))
{
bppy_breakpoints[num]->bp = NULL;
@@ -570,7 +571,7 @@ gdbpy_breakpoint_deleted (int num)
bppy_breakpoints[num] = NULL;
--bppy_live;
}
- PyGILState_Release (state);
+ do_cleanups (cleanup);
}
\f
diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index 5e90cc2..6d970a1 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -136,7 +136,7 @@ add_inferior_object (int pid)
static void
delete_inferior_object (int pid)
{
- PyGILState_STATE state;
+ struct cleanup *cleanup;
struct inflist_entry **inf_entry, *inf_tmp;
struct threadlist_entry *th_entry, *th_tmp;
@@ -149,7 +149,7 @@ delete_inferior_object (int pid)
if (!*inf_entry)
return;
- state = PyGILState_Ensure ();
+ cleanup = ensure_python_env (get_current_arch (), current_language);
inf_tmp = *inf_entry;
inf_tmp->inf_obj->inferior = NULL;
@@ -172,7 +172,7 @@ delete_inferior_object (int pid)
ninferiors--;
- PyGILState_Release (state);
+ do_cleanups (cleanup);
}
/* Finds the Python Inferior object for the given pid. Returns a borrowed
@@ -215,19 +215,19 @@ find_thread_object (ptid_t ptid)
static void
add_thread_object (struct thread_info *tp)
{
- PyGILState_STATE state;
+ struct cleanup *cleanup;
thread_object *thread_obj;
inferior_object *inf_obj;
struct threadlist_entry *entry;
- state = PyGILState_Ensure ();
+ cleanup = ensure_python_env (get_current_arch (), current_language);
thread_obj = create_thread_object (tp);
if (!thread_obj)
{
warning (_("Can't create Python InferiorThread object."));
gdbpy_print_stack ();
- PyGILState_Release (state);
+ do_cleanups (cleanup);
return;
}
@@ -240,13 +240,13 @@ add_thread_object (struct thread_info *tp)
inf_obj->threads = entry;
inf_obj->nthreads++;
- PyGILState_Release (state);
+ do_cleanups (cleanup);
}
static void
delete_thread_object (struct thread_info *tp, int ignore)
{
- PyGILState_STATE state;
+ struct cleanup *cleanup;
inferior_object *inf_obj;
thread_object *thread_obj;
struct threadlist_entry **entry, *tmp;
@@ -263,7 +263,7 @@ delete_thread_object (struct thread_info *tp, int ignore)
if (!*entry)
return;
- state = PyGILState_Ensure ();
+ cleanup = ensure_python_env (get_current_arch (), current_language);
tmp = *entry;
tmp->thread_obj->thread = NULL;
@@ -275,7 +275,7 @@ delete_thread_object (struct thread_info *tp, int ignore)
xfree (tmp);
- PyGILState_Release (state);
+ do_cleanups (cleanup);
}
static PyObject *
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 5a2a9ae..707b700 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -474,11 +474,11 @@ static int gdbpy_event_fds[2];
static void
gdbpy_run_events (int err, gdb_client_data ignore)
{
- PyGILState_STATE state;
+ struct cleanup *cleanup;
char buffer[100];
int r;
- state = PyGILState_Ensure ();
+ cleanup = ensure_python_env (get_current_arch (), current_language);
/* Just read whatever is available on the fd. It is relatively
harmless if there are any bytes left over. */
@@ -500,7 +500,7 @@ gdbpy_run_events (int err, gdb_client_data ignore)
xfree (item);
}
- PyGILState_Release (state);
+ do_cleanups (cleanup);
}
/* Submit an event to the gdb thread. */
@@ -622,10 +622,9 @@ void
run_python_script (int argc, char **argv)
{
FILE *input;
- PyGILState_STATE state;
/* We never free this, since we plan to exit at the end. */
- state = PyGILState_Ensure ();
+ ensure_python_env (get_current_arch (), current_language);
running_python_script = 1;
PySys_SetArgv (argc - 1, argv + 1);
@@ -643,14 +642,13 @@ run_python_script (int argc, char **argv)
void
source_python_script (FILE *stream, char *file)
{
- PyGILState_STATE state;
-
- state = PyGILState_Ensure ();
+ struct cleanup *cleanup;
+ cleanup = ensure_python_env (get_current_arch (), current_language);
PyRun_SimpleFile (stream, file);
fclose (stream);
- PyGILState_Release (state);
+ do_cleanups (cleanup);
}
\f
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] Fix PR python/10806
2009-10-21 11:47 [patch] Fix PR python/10806 Phil Muldoon
@ 2009-10-21 21:02 ` Tom Tromey
2009-10-22 7:40 ` Phil Muldoon
0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2009-10-21 21:02 UTC (permalink / raw)
To: Phil Muldoon; +Cc: Project Archer
Phil> This patch addresses PR python/10806. It is mechanical replacement of
Phil> the PyGILState_Ensure/Release with the more recently introduced
Phil> ensure_python_env.
Phil> OK?
This is fine, thanks.
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] Fix PR python/10806
2009-10-21 21:02 ` Tom Tromey
@ 2009-10-22 7:40 ` Phil Muldoon
0 siblings, 0 replies; 3+ messages in thread
From: Phil Muldoon @ 2009-10-22 7:40 UTC (permalink / raw)
To: Tom Tromey; +Cc: Project Archer
On 10/21/2009 10:02 PM, Tom Tromey wrote:
> Phil> This patch addresses PR python/10806. It is mechanical replacement of
> Phil> the PyGILState_Ensure/Release with the more recently introduced
> Phil> ensure_python_env.
>
> Phil> OK?
>
> This is fine, thanks.
>
Committed, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-10-22 7:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-21 11:47 [patch] Fix PR python/10806 Phil Muldoon
2009-10-21 21:02 ` Tom Tromey
2009-10-22 7:40 ` Phil Muldoon
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).