From patchwork Sat Mar 7 15:59:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 5518 Received: (qmail 125617 invoked by alias); 7 Mar 2015 15:59:58 -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 125608 invoked by uid 89); 7 Mar 2015 15:59:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.6 required=5.0 tests=AWL, BAYES_50, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sat, 07 Mar 2015 15:59:56 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t27Fxt4k016487 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Sat, 7 Mar 2015 10:59:55 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t27Fxrmf007213 for ; Sat, 7 Mar 2015 10:59:54 -0500 Message-ID: <54FB2079.80502@redhat.com> Date: Sat, 07 Mar 2015 15:59:53 +0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: Re: [PATCH 34/36] more making TRY/CATCH callers look more like real C++ try/catch blocks References: <1423524046-20605-1-git-send-email-palves@redhat.com> <1423524046-20605-35-git-send-email-palves@redhat.com> In-Reply-To: <1423524046-20605-35-git-send-email-palves@redhat.com> On 02/09/2015 11:20 PM, Pedro Alves wrote: > All these were caught by actually making TRY/CATCH use try/catch > behind the scenes, which then resulted in the build failing because > there was code between the try and catch blocks. > I've added a ChangeLog entry, and pushed this in, as below. ---- From 6c63c96a22d216fb5d51c5d93646066d29e08ea1 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Sat, 7 Mar 2015 14:50:05 +0000 Subject: [PATCH 4/6] more making TRY/CATCH callers look more like real C++ try/catch blocks All these were caught by actually making TRY/CATCH use try/catch behind the scenes, which then resulted in the build failing (on x86_64 Fedora 20) because there was code between the try and catch blocks. gdb/ChangeLog: 2015-03-07 Pedro Alves * breakpoint.c (save_breakpoints): Adjust to avoid code between TRY and CATCH. * gdbtypes.c (safe_parse_type): Remove empty line. (types_deeply_equal): * guile/scm-frame.c (gdbscm_frame_name): * linux-thread-db.c (find_new_threads_once): * python/py-breakpoint.c (bppy_get_commands): * record-btrace.c (record_btrace_insert_breakpoint) (record_btrace_remove_breakpoint, record_btrace_start_replaying) (record_btrace_start_replaying): Adjust to avoid code between TRY and CATCH. --- gdb/ChangeLog | 14 ++++++++++++++ gdb/breakpoint.c | 5 +++-- gdb/gdbtypes.c | 24 ++++++++++++++---------- gdb/guile/scm-frame.c | 9 +++------ gdb/linux-thread-db.c | 10 ++++++---- gdb/python/py-breakpoint.c | 3 ++- gdb/record-btrace.c | 20 ++++++++++---------- 7 files changed, 52 insertions(+), 33 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6df72f7..a18830f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,19 @@ 2015-03-07 Pedro Alves + * breakpoint.c (save_breakpoints): Adjust to avoid code between + TRY and CATCH. + * gdbtypes.c (safe_parse_type): Remove empty line. + (types_deeply_equal): + * guile/scm-frame.c (gdbscm_frame_name): + * linux-thread-db.c (find_new_threads_once): + * python/py-breakpoint.c (bppy_get_commands): + * record-btrace.c (record_btrace_insert_breakpoint) + (record_btrace_remove_breakpoint, record_btrace_start_replaying) + (record_btrace_start_replaying): Adjust to avoid code between TRY + and CATCH. + +2015-03-07 Pedro Alves + * common/common-exceptions.c (struct catcher) : No longer a pointer to volatile exception. Now an exception value. : Delete field. diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 0e59638..923523e 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -15926,6 +15926,7 @@ save_breakpoints (char *filename, int from_tty, if (tp->type != bp_dprintf && tp->commands) { + struct gdb_exception exception; fprintf_unfiltered (fp, " commands\n"); @@ -15934,14 +15935,14 @@ save_breakpoints (char *filename, int from_tty, { print_command_lines (current_uiout, tp->commands->commands, 2); } - ui_out_redirect (current_uiout, NULL); - CATCH (ex, RETURN_MASK_ALL) { + ui_out_redirect (current_uiout, NULL); throw_exception (ex); } END_CATCH + ui_out_redirect (current_uiout, NULL); fprintf_unfiltered (fp, " end\n"); } diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index af59d42..4cbbe95 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -2309,7 +2309,6 @@ safe_parse_type (struct gdbarch *gdbarch, char *p, int length) { type = parse_and_eval_type (p, length); } - CATCH (except, RETURN_MASK_ERROR) { type = builtin_type (gdbarch)->builtin_void; @@ -3237,6 +3236,7 @@ check_types_worklist (VEC (type_equality_entry_d) **worklist, int types_deeply_equal (struct type *type1, struct type *type2) { + struct gdb_exception except = exception_none; int result = 0; struct bcache *cache; VEC (type_equality_entry_d) *worklist = NULL; @@ -3254,23 +3254,27 @@ types_deeply_equal (struct type *type1, struct type *type2) entry.type2 = type2; VEC_safe_push (type_equality_entry_d, worklist, &entry); + /* check_types_worklist calls several nested helper functions, some + of which can raise a GDB exception, so we just check and rethrow + here. If there is a GDB exception, a comparison is not capable + (or trusted), so exit. */ TRY { result = check_types_worklist (&worklist, cache); } - /* check_types_worklist calls several nested helper functions, - some of which can raise a GDB Exception, so we just check - and rethrow here. If there is a GDB exception, a comparison - is not capable (or trusted), so exit. */ - bcache_xfree (cache); - VEC_free (type_equality_entry_d, worklist); - /* Rethrow if there was a problem. */ - CATCH (except, RETURN_MASK_ALL) + CATCH (ex, RETURN_MASK_ALL) { - throw_exception (except); + except = ex; } END_CATCH + bcache_xfree (cache); + VEC_free (type_equality_entry_d, worklist); + + /* Rethrow if there was a problem. */ + if (except.reason < 0) + throw_exception (except); + return result; } diff --git a/gdb/guile/scm-frame.c b/gdb/guile/scm-frame.c index 6189802..ea51d1b 100644 --- a/gdb/guile/scm-frame.c +++ b/gdb/guile/scm-frame.c @@ -426,7 +426,6 @@ gdbscm_frame_name (SCM self) enum language lang = language_minimal; struct frame_info *frame = NULL; SCM result; - struct gdb_exception except = exception_none; f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); @@ -436,15 +435,13 @@ gdbscm_frame_name (SCM self) if (frame != NULL) find_frame_funname (frame, &name, &lang, NULL); } - CATCH (ex, RETURN_MASK_ALL) + CATCH (except, RETURN_MASK_ALL) { - except = ex; + xfree (name); + GDBSCM_HANDLE_GDB_EXCEPTION (except); } END_CATCH - xfree (name); - GDBSCM_HANDLE_GDB_EXCEPTION (except); - if (frame == NULL) { gdbscm_invalid_object_error (FUNC_NAME, SCM_ARG1, self, diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index 0669750..88094a7 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -1702,16 +1702,18 @@ find_new_threads_once (struct thread_db_info *info, int iteration, TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS); } - - if (libthread_db_debug) + CATCH (except, RETURN_MASK_ERROR) { - CATCH (except, RETURN_MASK_ERROR) + if (libthread_db_debug) { exception_fprintf (gdb_stdlog, except, "Warning: find_new_threads_once: "); } - END_CATCH + } + END_CATCH + if (libthread_db_debug) + { fprintf_unfiltered (gdb_stdlog, _("Found %d new threads in iteration %d.\n"), data.new_threads, iteration); diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c index dcf1d5a..42a8596 100644 --- a/gdb/python/py-breakpoint.c +++ b/gdb/python/py-breakpoint.c @@ -503,15 +503,16 @@ bppy_get_commands (PyObject *self, void *closure) { print_command_lines (current_uiout, breakpoint_commands (bp), 0); } - ui_out_redirect (current_uiout, NULL); CATCH (except, RETURN_MASK_ALL) { + ui_out_redirect (current_uiout, NULL); do_cleanups (chain); gdbpy_convert_exception (except); return NULL; } END_CATCH + ui_out_redirect (current_uiout, NULL); cmdstr = ui_file_xstrdup (string_file, &length); make_cleanup (xfree, cmdstr); result = PyString_Decode (cmdstr, strlen (cmdstr), host_charset (), NULL); diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index 6bd9d01..5eb5cf4 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -1155,14 +1155,13 @@ record_btrace_insert_breakpoint (struct target_ops *ops, { ret = ops->beneath->to_insert_breakpoint (ops->beneath, gdbarch, bp_tgt); } - - replay_memory_access = old; - CATCH (except, RETURN_MASK_ALL) { + replay_memory_access = old; throw_exception (except); } END_CATCH + replay_memory_access = old; return ret; } @@ -1187,14 +1186,13 @@ record_btrace_remove_breakpoint (struct target_ops *ops, { ret = ops->beneath->to_remove_breakpoint (ops->beneath, gdbarch, bp_tgt); } - - replay_memory_access = old; - CATCH (except, RETURN_MASK_ALL) { + replay_memory_access = old; throw_exception (except); } END_CATCH + replay_memory_access = old; return ret; } @@ -1706,12 +1704,11 @@ record_btrace_start_replaying (struct thread_info *tp) if (upd_step_stack_frame_id) tp->control.step_stack_frame_id = frame_id; } - - /* Restore the previous execution state. */ - set_executing (tp->ptid, executing); - CATCH (except, RETURN_MASK_ALL) { + /* Restore the previous execution state. */ + set_executing (tp->ptid, executing); + xfree (btinfo->replay); btinfo->replay = NULL; @@ -1721,6 +1718,9 @@ record_btrace_start_replaying (struct thread_info *tp) } END_CATCH + /* Restore the previous execution state. */ + set_executing (tp->ptid, executing); + return replay; }