From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1028) id 92B103858C5E; Mon, 27 Feb 2023 23:21:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 92B103858C5E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677540092; bh=7hFa8VsZT5bom+TQ5cYq997UmMoGs1sEZqFgVucWdb4=; h=From:To:Subject:Date:From; b=QouB2ggnCVAfPWZsanvkKkyksqRmG+OvnwdwV9B1KA+XzATwLhVDLb65NKIXofnQR yLErTCpzKd1ATVjbs0ThWYiD5vsoDCjGP3z49EfbTlkcVrDSn5YTspHFaWrNnPW38I 0XHmzf/XjHO/hH1pAnXSVeDC5vvo3k6Is2qox1Ds= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Kevin Buettner To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Catch gdb_exception_error instead of gdb_exception (in many places) X-Act-Checkin: binutils-gdb X-Git-Author: Kevin Buettner X-Git-Refname: refs/heads/master X-Git-Oldrev: 63509715af867d635ad0e8cfe5a662bfc67b4ddf X-Git-Newrev: b1ffd1124a8c5170a9e06b867a886b1138d28514 Message-Id: <20230227232132.92B103858C5E@sourceware.org> Date: Mon, 27 Feb 2023 23:21:32 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Db1ffd1124a8c= 5170a9e06b867a886b1138d28514 commit b1ffd1124a8c5170a9e06b867a886b1138d28514 Author: Kevin Buettner Date: Mon Feb 27 16:11:37 2023 -0700 Catch gdb_exception_error instead of gdb_exception (in many places) =20 As described in the previous commit for this series, I became concerned that there might be instances in which a QUIT (due to either a SIGINT or SIGTERM) might not cause execution to return to the top level. In some (though very few) instances, it is okay to not propagate the exception for a Ctrl-C / SIGINT, but I don't think that it is ever okay to swallow the exception caused by a SIGTERM. Allowing that to happen would definitely be a deviation from the current behavior in which GDB exits upon receipt of a SIGTERM. =20 I looked at all cases where an exception handler catches a gdb_exception. Handlers which did NOT need modification were those which satisifed one or more of the following conditions: =20 1) There is no call path to maybe_quit() in the try block. I used a static analysis tool to help make this determination. In instances where the tool didn't provide an answer of "yes, this call path can result in maybe_quit() being called", I reviewed it by hand. =20 2) The catch block contains a throw for conditions that it doesn't want to handle; these "not handled" conditions must include the quit exception and the new "forced quit" exceptio= n. =20 3) There was (also) a catch for gdb_exception_quit. =20 Any try/catch blocks not meeting the above conditions could potentially swallow a QUIT exception. =20 My first thought was to add catch blocks for gdb_exception_quit and then rethrow the exception. But Pedro pointed out that this can be handled without adding additional code by simply catching gdb_exception_error instead. That's what this patch series does. =20 There are some oddball cases which needed to be handled differently, plus the extension languages, but those are handled in later patches. =20 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D26761 Tested-by: Tom de Vries Approved-by: Pedro Alves Diff: --- gdb/ada-lang.c | 2 +- gdb/breakpoint.c | 8 ++++---- gdb/i386-linux-tdep.c | 2 +- gdb/inf-loop.c | 2 +- gdb/infcmd.c | 2 +- gdb/infrun.c | 2 +- gdb/jit.c | 2 +- gdb/mi/mi-cmd-break.c | 2 +- gdb/mi/mi-interp.c | 2 +- gdb/objc-lang.c | 2 +- gdb/parse.c | 2 +- gdb/printcmd.c | 2 +- gdb/record-btrace.c | 2 +- gdb/record-full.c | 2 +- gdb/solib.c | 2 +- gdb/sparc64-linux-tdep.c | 2 +- gdb/symfile-mem.c | 2 +- 17 files changed, 20 insertions(+), 20 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 39cca3b9e80..7b07c4f9473 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -12351,7 +12351,7 @@ should_stop_exception (const struct bp_location *bl) scoped_value_mark mark; stop =3D value_true (evaluate_expression (ada_loc->excep_cond_expr.g= et ())); } - catch (const gdb_exception &ex) + catch (const gdb_exception_error &ex) { exception_fprintf (gdb_stderr, ex, _("Error in testing exception condition:\n")); diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 0db3adaf916..ebf9d8f1349 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -2840,7 +2840,7 @@ insert_bp_location (struct bp_location *bl, if (val) bp_excpt =3D gdb_exception {RETURN_ERROR, GENERIC_ERROR}; } - catch (gdb_exception &e) + catch (gdb_exception_error &e) { rethrow_on_target_close_error (e); bp_excpt =3D std::move (e); @@ -5302,7 +5302,7 @@ bpstat_check_watchpoint (bpstat *bs) { e =3D watchpoint_check (bs); } - catch (const gdb_exception &ex) + catch (const gdb_exception_error &ex) { exception_fprintf (gdb_stderr, ex, "Error evaluating expression " @@ -5546,7 +5546,7 @@ bpstat_check_breakpoint_conditions (bpstat *bs, threa= d_info *thread) { condition_result =3D breakpoint_cond_eval (cond); } - catch (const gdb_exception &ex) + catch (const gdb_exception_error &ex) { exception_fprintf (gdb_stderr, ex, "Error in testing breakpoint condition:\n"); @@ -13518,7 +13518,7 @@ enable_breakpoint_disp (struct breakpoint *bpt, enu= m bpdisp disposition, bpt->enable_state =3D bp_enabled; update_watchpoint (w, true /* reparse */); } - catch (const gdb_exception &e) + catch (const gdb_exception_error &e) { bpt->enable_state =3D orig_enable_state; exception_fprintf (gdb_stderr, e, _("Cannot enable watchpoint %d: "), diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c index ad0377de5a6..a6adeca1b97 100644 --- a/gdb/i386-linux-tdep.c +++ b/gdb/i386-linux-tdep.c @@ -415,7 +415,7 @@ i386_linux_report_signal_info (struct gdbarch *gdbarch,= struct ui_out *uiout, access =3D parse_and_eval_long ("$_siginfo._sifields._sigfault.si_addr"); } - catch (const gdb_exception &exception) + catch (const gdb_exception_error &exception) { return; } diff --git a/gdb/inf-loop.c b/gdb/inf-loop.c index f49d1c3c872..b9f25008247 100644 --- a/gdb/inf-loop.c +++ b/gdb/inf-loop.c @@ -69,7 +69,7 @@ inferior_event_handler (enum inferior_event_type event_ty= pe) { bpstat_do_actions (); } - catch (const gdb_exception &e) + catch (const gdb_exception_error &e) { /* If the user was running a foreground execution command, then propagate the error so that the prompt diff --git a/gdb/infcmd.c b/gdb/infcmd.c index e3436470b7c..c369b795757 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -1585,7 +1585,7 @@ print_return_value (struct ui_out *uiout, struct retu= rn_value_info *rv) delete the breakpoint. */ print_return_value_1 (uiout, rv); } - catch (const gdb_exception &ex) + catch (const gdb_exception_error &ex) { exception_print (gdb_stdout, ex); } diff --git a/gdb/infrun.c b/gdb/infrun.c index 79e1a6abd2a..ab77300f1ff 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -8875,7 +8875,7 @@ normal_stop () { execute_cmd_pre_hook (stop_command); } - catch (const gdb_exception &ex) + catch (const gdb_exception_error &ex) { exception_fprintf (gdb_stderr, ex, "Error while running hook_stop:\n"); diff --git a/gdb/jit.c b/gdb/jit.c index 0b089bc6a82..7f4b9f0fd37 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -716,7 +716,7 @@ jit_reader_try_read_symtab (gdbarch *gdbarch, jit_code_= entry *code_entry, code_entry->symfile_size)) status =3D 0; } - catch (const gdb_exception &e) + catch (const gdb_exception_error &e) { status =3D 0; } diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c index 8b0483803b6..75957b75bad 100644 --- a/gdb/mi/mi-cmd-break.c +++ b/gdb/mi/mi-cmd-break.c @@ -58,7 +58,7 @@ breakpoint_notify (struct breakpoint *b) { print_breakpoint (b); } - catch (const gdb_exception &ex) + catch (const gdb_exception_error &ex) { exception_print (gdb_stderr, ex); } diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index 29d1aee8235..e1244f3df43 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -841,7 +841,7 @@ mi_print_breakpoint_for_event (struct mi_interp *mi, br= eakpoint *bp) =20 print_breakpoint (bp); } - catch (const gdb_exception &ex) + catch (const gdb_exception_error &ex) { exception_print (gdb_stderr, ex); } diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index f43d158a770..4a9dee44dd7 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -1286,7 +1286,7 @@ find_objc_msgcall_submethod (int (*f) (CORE_ADDR, COR= E_ADDR *), if (f (pc, new_pc) =3D=3D 0) return 1; } - catch (const gdb_exception &ex) + catch (const gdb_exception_error &ex) { exception_fprintf (gdb_stderr, ex, "Unable to determine target of " diff --git a/gdb/parse.c b/gdb/parse.c index f2917b30740..b2cc6c59fb5 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -514,7 +514,7 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR= pc, { lang->parser (&ps); } - catch (const gdb_exception &except) + catch (const gdb_exception_error &except) { /* If parsing for completion, allow this to succeed; but if no expression elements have been written, then there's nothing diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 0d3bc292d4e..341efc779fe 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -2126,7 +2126,7 @@ do_one_display (struct display *d) d->exp =3D parse_expression (d->exp_string.c_str (), &tracker); d->block =3D tracker.block (); } - catch (const gdb_exception &ex) + catch (const gdb_exception_error &ex) { /* Can't re-parse the expression. Disable this display item. */ d->enabled_p =3D false; diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index 0daba893813..61de8491bb9 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -2932,7 +2932,7 @@ cmd_record_btrace_start (const char *args, int from_t= ty) { execute_command ("target record-btrace", from_tty); } - catch (const gdb_exception &exception) + catch (const gdb_exception_error &exception) { record_btrace_conf.format =3D BTRACE_FORMAT_BTS; =20 diff --git a/gdb/record-full.c b/gdb/record-full.c index e3cfa3f45d5..15c5b7d682e 100644 --- a/gdb/record-full.c +++ b/gdb/record-full.c @@ -785,7 +785,7 @@ record_full_message_wrapper_safe (struct regcache *regc= ache, { record_full_message (regcache, signal); } - catch (const gdb_exception &ex) + catch (const gdb_exception_error &ex) { exception_print (gdb_stderr, ex); return false; diff --git a/gdb/solib.c b/gdb/solib.c index 60bdf46cb91..ec0fcfb5beb 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -785,7 +785,7 @@ update_solib_list (int from_tty) { ops->open_symbol_file_object (from_tty); } - catch (const gdb_exception &ex) + catch (const gdb_exception_error &ex) { exception_fprintf (gdb_stderr, ex, "Error reading attached " diff --git a/gdb/sparc64-linux-tdep.c b/gdb/sparc64-linux-tdep.c index beff812eeef..685df066f3a 100644 --- a/gdb/sparc64-linux-tdep.c +++ b/gdb/sparc64-linux-tdep.c @@ -139,7 +139,7 @@ sparc64_linux_report_signal_info (struct gdbarch *gdbar= ch, struct ui_out *uiout, if (si_code >=3D SEGV_ACCADI && si_code <=3D SEGV_ADIPERR) addr =3D parse_and_eval_long ("$_siginfo._sifields._sigfault.si_addr"); } - catch (const gdb_exception &exception) + catch (const gdb_exception_error &exception) { return; } diff --git a/gdb/symfile-mem.c b/gdb/symfile-mem.c index d36b9090e7e..7ac3ac709ec 100644 --- a/gdb/symfile-mem.c +++ b/gdb/symfile-mem.c @@ -197,7 +197,7 @@ add_vsyscall_page (inferior *inf) name.c_str (), 0 /* from_tty */); } - catch (const gdb_exception &ex) + catch (const gdb_exception_error &ex) { exception_print (gdb_stderr, ex); }