From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA 05/20] Use gdbpy_enter in py-inferior.c
Date: Thu, 10 Nov 2016 22:20:00 -0000 [thread overview]
Message-ID: <1478816387-27064-6-git-send-email-tom@tromey.com> (raw)
In-Reply-To: <1478816387-27064-1-git-send-email-tom@tromey.com>
Change py-inferior.c to use gdbpy_enter.
2016-11-10 Tom Tromey <tom@tromey.com>
* python/py-inferior.c (python_on_normal_stop, python_on_resume)
(python_on_inferior_call_pre, python_on_inferior_call_post)
(python_on_memory_change, python_on_register_change)
(python_inferior_exit, python_new_objfile, add_thread_object)
(delete_thread_object, py_free_inferior): Use gdbpy_enter.
---
gdb/ChangeLog | 8 ++++++
gdb/python/py-inferior.c | 74 ++++++++++--------------------------------------
2 files changed, 23 insertions(+), 59 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 2deede2..c1d016f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
2016-11-10 Tom Tromey <tom@tromey.com>
+ * python/py-inferior.c (python_on_normal_stop, python_on_resume)
+ (python_on_inferior_call_pre, python_on_inferior_call_post)
+ (python_on_memory_change, python_on_register_change)
+ (python_inferior_exit, python_new_objfile, add_thread_object)
+ (delete_thread_object, py_free_inferior): Use gdbpy_enter.
+
+2016-11-10 Tom Tromey <tom@tromey.com>
+
* python/py-finishbreakpoint.c (bpfinishpy_handle_stop)
(bpfinishpy_handle_exit): Use gdbpy_enter.
diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index b343c0f..8f80d04 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -81,7 +81,6 @@ extern PyTypeObject membuf_object_type
static void
python_on_normal_stop (struct bpstats *bs, int print_frame)
{
- struct cleanup *cleanup;
enum gdb_signal stop_signal;
if (!gdb_python_initialized)
@@ -92,28 +91,22 @@ python_on_normal_stop (struct bpstats *bs, int print_frame)
stop_signal = inferior_thread ()->suspend.stop_signal;
- cleanup = ensure_python_env (get_current_arch (), current_language);
+ gdbpy_enter enter_py (get_current_arch (), current_language);
if (emit_stop_event (bs, stop_signal) < 0)
gdbpy_print_stack ();
-
- do_cleanups (cleanup);
}
static void
python_on_resume (ptid_t ptid)
{
- struct cleanup *cleanup;
-
if (!gdb_python_initialized)
return;
- cleanup = ensure_python_env (target_gdbarch (), current_language);
+ gdbpy_enter enter_py (target_gdbarch (), current_language);
if (emit_continue_event (ptid) < 0)
gdbpy_print_stack ();
-
- do_cleanups (cleanup);
}
/* Callback, registered as an observer, that notifies Python listeners
@@ -122,14 +115,10 @@ python_on_resume (ptid_t ptid)
static void
python_on_inferior_call_pre (ptid_t thread, CORE_ADDR address)
{
- struct cleanup *cleanup;
-
- cleanup = ensure_python_env (target_gdbarch (), current_language);
+ gdbpy_enter enter_py (target_gdbarch (), current_language);
if (emit_inferior_call_event (INFERIOR_CALL_PRE, thread, address) < 0)
gdbpy_print_stack ();
-
- do_cleanups (cleanup);
}
/* Callback, registered as an observer, that notifies Python listeners
@@ -138,14 +127,10 @@ python_on_inferior_call_pre (ptid_t thread, CORE_ADDR address)
static void
python_on_inferior_call_post (ptid_t thread, CORE_ADDR address)
{
- struct cleanup *cleanup;
-
- cleanup = ensure_python_env (target_gdbarch (), current_language);
+ gdbpy_enter enter_py (target_gdbarch (), current_language);
if (emit_inferior_call_event (INFERIOR_CALL_POST, thread, address) < 0)
gdbpy_print_stack ();
-
- do_cleanups (cleanup);
}
/* Callback, registered as an observer, that notifies Python listeners
@@ -155,14 +140,10 @@ python_on_inferior_call_post (ptid_t thread, CORE_ADDR address)
static void
python_on_memory_change (struct inferior *inferior, CORE_ADDR addr, ssize_t len, const bfd_byte *data)
{
- struct cleanup *cleanup;
-
- cleanup = ensure_python_env (target_gdbarch (), current_language);
+ gdbpy_enter enter_py (target_gdbarch (), current_language);
if (emit_memory_changed_event (addr, len) < 0)
gdbpy_print_stack ();
-
- do_cleanups (cleanup);
}
/* Callback, registered as an observer, that notifies Python listeners
@@ -172,34 +153,27 @@ python_on_memory_change (struct inferior *inferior, CORE_ADDR addr, ssize_t len,
static void
python_on_register_change (struct frame_info *frame, int regnum)
{
- struct cleanup *cleanup;
-
- cleanup = ensure_python_env (target_gdbarch (), current_language);
+ gdbpy_enter enter_py (target_gdbarch (), current_language);
if (emit_register_changed_event (frame, regnum) < 0)
gdbpy_print_stack ();
-
- do_cleanups (cleanup);
}
static void
python_inferior_exit (struct inferior *inf)
{
- struct cleanup *cleanup;
const LONGEST *exit_code = NULL;
if (!gdb_python_initialized)
return;
- cleanup = ensure_python_env (target_gdbarch (), current_language);
+ gdbpy_enter enter_py (target_gdbarch (), current_language);
if (inf->has_exit_code)
exit_code = &inf->exit_code;
if (emit_exited_event (exit_code, inf) < 0)
gdbpy_print_stack ();
-
- do_cleanups (cleanup);
}
/* Callback used to notify Python listeners about new objfiles loaded in the
@@ -209,15 +183,13 @@ python_inferior_exit (struct inferior *inf)
static void
python_new_objfile (struct objfile *objfile)
{
- struct cleanup *cleanup;
-
if (!gdb_python_initialized)
return;
- cleanup = ensure_python_env (objfile != NULL
- ? get_objfile_arch (objfile)
- : target_gdbarch (),
- current_language);
+ gdbpy_enter enter_py (objfile != NULL
+ ? get_objfile_arch (objfile)
+ : target_gdbarch (),
+ current_language);
if (objfile == NULL)
{
@@ -229,8 +201,6 @@ python_new_objfile (struct objfile *objfile)
if (emit_new_objfile_event (objfile) < 0)
gdbpy_print_stack ();
}
-
- do_cleanups (cleanup);
}
/* Return a reference to the Python object of type Inferior
@@ -312,7 +282,6 @@ find_thread_object (ptid_t ptid)
static void
add_thread_object (struct thread_info *tp)
{
- struct cleanup *cleanup;
thread_object *thread_obj;
inferior_object *inf_obj;
struct threadlist_entry *entry;
@@ -320,13 +289,12 @@ add_thread_object (struct thread_info *tp)
if (!gdb_python_initialized)
return;
- cleanup = ensure_python_env (python_gdbarch, python_language);
+ gdbpy_enter enter_py (python_gdbarch, python_language);
thread_obj = create_thread_object (tp);
if (!thread_obj)
{
gdbpy_print_stack ();
- do_cleanups (cleanup);
return;
}
@@ -338,29 +306,23 @@ add_thread_object (struct thread_info *tp)
inf_obj->threads = entry;
inf_obj->nthreads++;
-
- do_cleanups (cleanup);
}
static void
delete_thread_object (struct thread_info *tp, int ignore)
{
- struct cleanup *cleanup;
inferior_object *inf_obj;
struct threadlist_entry **entry, *tmp;
if (!gdb_python_initialized)
return;
- cleanup = ensure_python_env (python_gdbarch, python_language);
+ gdbpy_enter enter_py (python_gdbarch, python_language);
inf_obj
= (inferior_object *) find_inferior_object (ptid_get_pid (tp->ptid));
if (!inf_obj)
- {
- do_cleanups (cleanup);
- return;
- }
+ return;
/* Find thread entry in its inferior's thread_list. */
for (entry = &inf_obj->threads; *entry != NULL; entry =
@@ -371,7 +333,6 @@ delete_thread_object (struct thread_info *tp, int ignore)
if (!*entry)
{
Py_DECREF (inf_obj);
- do_cleanups (cleanup);
return;
}
@@ -384,8 +345,6 @@ delete_thread_object (struct thread_info *tp, int ignore)
Py_DECREF (tmp->thread_obj);
Py_DECREF (inf_obj);
xfree (tmp);
-
- do_cleanups (cleanup);
}
static PyObject *
@@ -828,15 +787,13 @@ infpy_dealloc (PyObject *obj)
static void
py_free_inferior (struct inferior *inf, void *datum)
{
-
- struct cleanup *cleanup;
inferior_object *inf_obj = (inferior_object *) datum;
struct threadlist_entry *th_entry, *th_tmp;
if (!gdb_python_initialized)
return;
- cleanup = ensure_python_env (python_gdbarch, python_language);
+ gdbpy_enter enter_py (python_gdbarch, python_language);
inf_obj->inferior = NULL;
@@ -853,7 +810,6 @@ py_free_inferior (struct inferior *inf, void *datum)
inf_obj->nthreads = 0;
Py_DECREF ((PyObject *) inf_obj);
- do_cleanups (cleanup);
}
/* Implementation of gdb.selected_inferior() -> gdb.Inferior.
--
2.7.4
next prev parent reply other threads:[~2016-11-10 22:20 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-10 22:20 [RFA 00/20] more use of C++ in the Python layer Tom Tromey
2016-11-10 22:20 ` [RFA 10/20] Use gdbpy_enter in py-xmethods.c Tom Tromey
2016-11-10 22:20 ` [RFA 03/20] Use gdbpy_enter in py-cmd.c Tom Tromey
2016-11-10 22:20 ` [RFA 02/20] Use gdbpy_enter in py-breakpoint.c Tom Tromey
2016-11-10 22:20 ` [RFA 06/20] Use gdbpy_enter in py-objfile.c Tom Tromey
2016-11-10 22:20 ` [RFA 13/20] Use gdbpy_enter in py-prettyprint.c Tom Tromey
2016-11-10 22:20 ` [RFA 11/20] Use gdbpy_enter in py-unwind.c Tom Tromey
2016-11-10 22:20 ` [RFA 16/20] Use gdbpy_enter in gdbpy_get_matching_xmethod_workers Tom Tromey
2016-11-10 23:19 ` Pedro Alves
2016-11-11 3:19 ` Tom Tromey
2016-11-11 3:24 ` Pedro Alves
2016-11-12 17:09 ` Tom Tromey
2016-11-10 22:20 ` [RFA 09/20] Use gdbpy_enter in py-type.c Tom Tromey
2016-11-10 22:20 ` [RFA 17/20] Use gdbpy_reference in invoke_match_method Tom Tromey
2016-11-10 22:20 ` [RFA 14/20] Use gdbpy_enter in gdbpy_before_prompt_hook Tom Tromey
2016-11-10 23:19 ` Pedro Alves
2016-11-12 17:04 ` Tom Tromey
2016-11-10 22:20 ` Tom Tromey [this message]
2016-11-10 22:20 ` [RFA 04/20] Use gdbpy_enter in py-finishbreakpoint.c Tom Tromey
2016-11-10 22:20 ` [RFA 15/20] Use gdbpy_enter in python_interactive_command Tom Tromey
2016-11-10 22:20 ` [RFA 07/20] Use gdbpy_enter in py-progspace.c Tom Tromey
2016-11-10 22:20 ` [RFA 08/20] Use gdbpy_enter in python.c Tom Tromey
2016-11-10 22:20 ` [RFA 01/20] Introduce gdbpy_enter Tom Tromey
2016-11-10 23:19 ` Pedro Alves
2016-11-10 22:26 ` [RFA 20/20] Use gdbpy_enter_varobj in py-varobj.c Tom Tromey
2016-11-10 22:26 ` [RFA 18/20] Use gdbpy_enter in py-xmethod.c Tom Tromey
2016-11-10 22:26 ` [RFA 19/20] Introduce gdbpy_enter_varobj and use it Tom Tromey
2016-11-10 22:26 ` [RFA 12/20] Introduce htab_up and use gdbpy_enter in py-framefilter.c Tom Tromey
2016-11-10 23:52 ` [RFA 00/20] more use of C++ in the Python layer Pedro Alves
2016-11-11 3:19 ` Tom Tromey
2016-11-12 17:24 ` Tom Tromey
2016-11-15 14:57 ` Pedro Alves
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=1478816387-27064-6-git-send-email-tom@tromey.com \
--to=tom@tromey.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