From patchwork Thu Nov 10 22:19:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 17399 Received: (qmail 64650 invoked by alias); 10 Nov 2016 22:20:39 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 64364 invoked by uid 89); 10 Nov 2016 22:20:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=33829, 816, 81, 6, ptid X-HELO: gproxy7-pub.mail.unifiedlayer.com Received: from gproxy7-pub.mail.unifiedlayer.com (HELO gproxy7-pub.mail.unifiedlayer.com) (70.40.196.235) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with SMTP; Thu, 10 Nov 2016 22:20:02 +0000 Received: (qmail 28015 invoked by uid 0); 10 Nov 2016 22:20:00 -0000 Received: from unknown (HELO cmgw2) (10.0.90.83) by gproxy7.mail.unifiedlayer.com with SMTP; 10 Nov 2016 22:20:00 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by cmgw2 with id 6NKt1u01H2f2jeq01NKw67; Thu, 10 Nov 2016 15:19:58 -0700 X-Authority-Analysis: v=2.1 cv=PIacp5aC c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=L24OOQBejmoA:10 a=zstS-IiYAAAA:8 a=R2bjUq08KUyrS1G5RgMA:9 a=JsM9x4wzybhRlxuG:21 a=NbglpAEoDoDtFTJ0:21 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 174-16-143-211.hlrn.qwest.net ([174.16.143.211]:60120 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_1) (envelope-from ) id 1c4xhL-0002sd-9X; Thu, 10 Nov 2016 15:19:55 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 05/20] Use gdbpy_enter in py-inferior.c Date: Thu, 10 Nov 2016 15:19:32 -0700 Message-Id: <1478816387-27064-6-git-send-email-tom@tromey.com> In-Reply-To: <1478816387-27064-1-git-send-email-tom@tromey.com> References: <1478816387-27064-1-git-send-email-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1c4xhL-0002sd-9X X-Source-Sender: 174-16-143-211.hlrn.qwest.net (bapiya.Home) [174.16.143.211]:60120 X-Source-Auth: tom+tromey.com X-Email-Count: 6 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== Change py-inferior.c to use gdbpy_enter. 2016-11-10 Tom Tromey * 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 + * 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 + * 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.