From a70b814420059e1f2de2130d532ddd7b2b2500fc Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 3 Apr 2019 16:02:42 -0600 Subject: Rewrite TRY/CATCH This rewrites gdb's TRY/CATCH to plain C++ try/catch. The patch was largely written by script, though one change (to a comment in common-exceptions.h) was reverted by hand. gdb/ChangeLog 2019-04-08 Tom Tromey * xml-support.c: Use C++ exception handling. * x86-linux-nat.c: Use C++ exception handling. * windows-nat.c: Use C++ exception handling. * varobj.c: Use C++ exception handling. * value.c: Use C++ exception handling. * valprint.c: Use C++ exception handling. * valops.c: Use C++ exception handling. * unittests/parse-connection-spec-selftests.c: Use C++ exception handling. * unittests/cli-utils-selftests.c: Use C++ exception handling. * typeprint.c: Use C++ exception handling. * tui/tui.c: Use C++ exception handling. * tracefile-tfile.c: Use C++ exception handling. * top.c: Use C++ exception handling. * thread.c: Use C++ exception handling. * target.c: Use C++ exception handling. * symmisc.c: Use C++ exception handling. * symfile-mem.c: Use C++ exception handling. * stack.c: Use C++ exception handling. * sparc64-linux-tdep.c: Use C++ exception handling. * solib.c: Use C++ exception handling. * solib-svr4.c: Use C++ exception handling. * solib-spu.c: Use C++ exception handling. * solib-frv.c: Use C++ exception handling. * solib-dsbt.c: Use C++ exception handling. * selftest-arch.c: Use C++ exception handling. * s390-tdep.c: Use C++ exception handling. * rust-lang.c: Use C++ exception handling. * rust-exp.y: Use C++ exception handling. * rs6000-tdep.c: Use C++ exception handling. * rs6000-aix-tdep.c: Use C++ exception handling. * riscv-tdep.c: Use C++ exception handling. * remote.c: Use C++ exception handling. * remote-fileio.c: Use C++ exception handling. * record-full.c: Use C++ exception handling. * record-btrace.c: Use C++ exception handling. * python/python.c: Use C++ exception handling. * python/py-value.c: Use C++ exception handling. * python/py-utils.c: Use C++ exception handling. * python/py-unwind.c: Use C++ exception handling. * python/py-type.c: Use C++ exception handling. * python/py-symbol.c: Use C++ exception handling. * python/py-record.c: Use C++ exception handling. * python/py-record-btrace.c: Use C++ exception handling. * python/py-progspace.c: Use C++ exception handling. * python/py-prettyprint.c: Use C++ exception handling. * python/py-param.c: Use C++ exception handling. * python/py-objfile.c: Use C++ exception handling. * python/py-linetable.c: Use C++ exception handling. * python/py-lazy-string.c: Use C++ exception handling. * python/py-infthread.c: Use C++ exception handling. * python/py-inferior.c: Use C++ exception handling. * python/py-gdb-readline.c: Use C++ exception handling. * python/py-framefilter.c: Use C++ exception handling. * python/py-frame.c: Use C++ exception handling. * python/py-finishbreakpoint.c: Use C++ exception handling. * python/py-cmd.c: Use C++ exception handling. * python/py-breakpoint.c: Use C++ exception handling. * python/py-arch.c: Use C++ exception handling. * printcmd.c: Use C++ exception handling. * ppc-linux-tdep.c: Use C++ exception handling. * parse.c: Use C++ exception handling. * p-valprint.c: Use C++ exception handling. * objc-lang.c: Use C++ exception handling. * mi/mi-main.c: Use C++ exception handling. * mi/mi-interp.c: Use C++ exception handling. * mi/mi-cmd-stack.c: Use C++ exception handling. * mi/mi-cmd-break.c: Use C++ exception handling. * main.c: Use C++ exception handling. * linux-thread-db.c: Use C++ exception handling. * linux-tdep.c: Use C++ exception handling. * linux-nat.c: Use C++ exception handling. * linux-fork.c: Use C++ exception handling. * linespec.c: Use C++ exception handling. * language.c: Use C++ exception handling. * jit.c: Use C++ exception handling. * infrun.c: Use C++ exception handling. * infcmd.c: Use C++ exception handling. * infcall.c: Use C++ exception handling. * inf-loop.c: Use C++ exception handling. * i386-tdep.c: Use C++ exception handling. * i386-linux-tdep.c: Use C++ exception handling. * guile/scm-value.c: Use C++ exception handling. * guile/scm-type.c: Use C++ exception handling. * guile/scm-symtab.c: Use C++ exception handling. * guile/scm-symbol.c: Use C++ exception handling. * guile/scm-pretty-print.c: Use C++ exception handling. * guile/scm-ports.c: Use C++ exception handling. * guile/scm-param.c: Use C++ exception handling. * guile/scm-math.c: Use C++ exception handling. * guile/scm-lazy-string.c: Use C++ exception handling. * guile/scm-frame.c: Use C++ exception handling. * guile/scm-disasm.c: Use C++ exception handling. * guile/scm-cmd.c: Use C++ exception handling. * guile/scm-breakpoint.c: Use C++ exception handling. * guile/scm-block.c: Use C++ exception handling. * guile/guile-internal.h: Use C++ exception handling. * gnu-v3-abi.c: Use C++ exception handling. * gdbtypes.c: Use C++ exception handling. * frame.c: Use C++ exception handling. * frame-unwind.c: Use C++ exception handling. * fbsd-tdep.c: Use C++ exception handling. * f-valprint.c: Use C++ exception handling. * exec.c: Use C++ exception handling. * event-top.c: Use C++ exception handling. * event-loop.c: Use C++ exception handling. * eval.c: Use C++ exception handling. * dwarf2read.c: Use C++ exception handling. * dwarf2loc.c: Use C++ exception handling. * dwarf2-frame.c: Use C++ exception handling. * dwarf2-frame-tailcall.c: Use C++ exception handling. * dwarf-index-write.c: Use C++ exception handling. * dwarf-index-cache.c: Use C++ exception handling. * dtrace-probe.c: Use C++ exception handling. * disasm-selftests.c: Use C++ exception handling. * darwin-nat.c: Use C++ exception handling. * cp-valprint.c: Use C++ exception handling. * cp-support.c: Use C++ exception handling. * cp-abi.c: Use C++ exception handling. * corelow.c: Use C++ exception handling. * completer.c: Use C++ exception handling. * compile/compile-object-run.c: Use C++ exception handling. * compile/compile-object-load.c: Use C++ exception handling. * compile/compile-cplus-symbols.c: Use C++ exception handling. * compile/compile-c-symbols.c: Use C++ exception handling. * common/selftest.c: Use C++ exception handling. * common/new-op.c: Use C++ exception handling. * cli/cli-script.c: Use C++ exception handling. * cli/cli-interp.c: Use C++ exception handling. * cli/cli-cmds.c: Use C++ exception handling. * c-varobj.c: Use C++ exception handling. * btrace.c: Use C++ exception handling. * breakpoint.c: Use C++ exception handling. * break-catch-throw.c: Use C++ exception handling. * arch-utils.c: Use C++ exception handling. * amd64-tdep.c: Use C++ exception handling. * ada-valprint.c: Use C++ exception handling. * ada-typeprint.c: Use C++ exception handling. * ada-lang.c: Use C++ exception handling. * aarch64-tdep.c: Use C++ exception handling. gdb/gdbserver/ChangeLog 2019-04-08 Tom Tromey * server.c: Use C++ exception handling. * linux-low.c: Use C++ exception handling. * gdbreplay.c: Use C++ exception handling. --- gdb/ChangeLog | 143 ++++++++++++++++++++++ gdb/aarch64-tdep.c | 10 +- gdb/ada-lang.c | 35 +++--- gdb/ada-typeprint.c | 5 +- gdb/ada-valprint.c | 5 +- gdb/amd64-tdep.c | 15 +-- gdb/arch-utils.c | 5 +- gdb/break-catch-throw.c | 15 +-- gdb/breakpoint.c | 70 +++++------ gdb/btrace.c | 35 +++--- gdb/c-varobj.c | 20 ++- gdb/cli/cli-cmds.c | 5 +- gdb/cli/cli-interp.c | 5 +- gdb/cli/cli-script.c | 10 +- gdb/common/new-op.c | 5 +- gdb/common/selftest.c | 5 +- gdb/compile/compile-c-symbols.c | 15 +-- gdb/compile/compile-cplus-symbols.c | 10 +- gdb/compile/compile-object-load.c | 5 +- gdb/compile/compile-object-run.c | 5 +- gdb/completer.c | 20 ++- gdb/corelow.c | 10 +- gdb/cp-abi.c | 10 +- gdb/cp-support.c | 15 +-- gdb/cp-valprint.c | 10 +- gdb/darwin-nat.c | 10 +- gdb/disasm-selftests.c | 5 +- gdb/dtrace-probe.c | 5 +- gdb/dwarf-index-cache.c | 10 +- gdb/dwarf-index-write.c | 5 +- gdb/dwarf2-frame-tailcall.c | 5 +- gdb/dwarf2-frame.c | 15 +-- gdb/dwarf2loc.c | 15 +-- gdb/dwarf2read.c | 5 +- gdb/eval.c | 25 ++-- gdb/event-loop.c | 5 +- gdb/event-top.c | 15 +-- gdb/exec.c | 10 +- gdb/f-valprint.c | 5 +- gdb/fbsd-tdep.c | 15 +-- gdb/frame-unwind.c | 5 +- gdb/frame.c | 30 ++--- gdb/gdbserver/ChangeLog | 6 + gdb/gdbserver/gdbreplay.c | 5 +- gdb/gdbserver/linux-low.c | 10 +- gdb/gdbserver/server.c | 30 ++--- gdb/gdbtypes.c | 5 +- gdb/gnu-v3-abi.c | 5 +- gdb/guile/guile-internal.h | 5 +- gdb/guile/scm-block.c | 5 +- gdb/guile/scm-breakpoint.c | 40 +++--- gdb/guile/scm-cmd.c | 5 +- gdb/guile/scm-disasm.c | 5 +- gdb/guile/scm-frame.c | 95 ++++++--------- gdb/guile/scm-lazy-string.c | 5 +- gdb/guile/scm-math.c | 5 +- gdb/guile/scm-param.c | 10 +- gdb/guile/scm-ports.c | 5 +- gdb/guile/scm-pretty-print.c | 5 +- gdb/guile/scm-symbol.c | 25 ++-- gdb/guile/scm-symtab.c | 5 +- gdb/guile/scm-type.c | 60 ++++----- gdb/guile/scm-value.c | 75 +++++------- gdb/i386-linux-tdep.c | 5 +- gdb/i386-tdep.c | 15 +-- gdb/inf-loop.c | 5 +- gdb/infcall.c | 5 +- gdb/infcmd.c | 10 +- gdb/infrun.c | 35 +++--- gdb/jit.c | 5 +- gdb/language.c | 5 +- gdb/linespec.c | 30 ++--- gdb/linux-fork.c | 5 +- gdb/linux-nat.c | 20 ++- gdb/linux-tdep.c | 5 +- gdb/linux-thread-db.c | 15 +-- gdb/main.c | 15 +-- gdb/mi/mi-cmd-break.c | 5 +- gdb/mi/mi-cmd-stack.c | 5 +- gdb/mi/mi-interp.c | 5 +- gdb/mi/mi-main.c | 10 +- gdb/objc-lang.c | 5 +- gdb/p-valprint.c | 5 +- gdb/parse.c | 10 +- gdb/ppc-linux-tdep.c | 5 +- gdb/printcmd.c | 20 ++- gdb/python/py-arch.c | 5 +- gdb/python/py-breakpoint.c | 40 +++--- gdb/python/py-cmd.c | 5 +- gdb/python/py-finishbreakpoint.c | 30 ++--- gdb/python/py-frame.c | 90 ++++++-------- gdb/python/py-framefilter.c | 10 +- gdb/python/py-gdb-readline.c | 5 +- gdb/python/py-inferior.c | 25 ++-- gdb/python/py-infthread.c | 5 +- gdb/python/py-lazy-string.c | 5 +- gdb/python/py-linetable.c | 5 +- gdb/python/py-objfile.c | 10 +- gdb/python/py-param.c | 5 +- gdb/python/py-prettyprint.c | 10 +- gdb/python/py-progspace.c | 10 +- gdb/python/py-record-btrace.c | 20 ++- gdb/python/py-record.c | 10 +- gdb/python/py-symbol.c | 25 ++-- gdb/python/py-type.c | 90 ++++++-------- gdb/python/py-unwind.c | 20 ++- gdb/python/py-utils.c | 5 +- gdb/python/py-value.c | 155 ++++++++++-------------- gdb/python/python.c | 35 +++--- gdb/record-btrace.c | 45 +++---- gdb/record-full.c | 20 ++- gdb/remote-fileio.c | 5 +- gdb/remote.c | 25 ++-- gdb/riscv-tdep.c | 10 +- gdb/rs6000-aix-tdep.c | 5 +- gdb/rs6000-tdep.c | 10 +- gdb/rust-exp.y | 5 +- gdb/rust-lang.c | 5 +- gdb/s390-tdep.c | 5 +- gdb/selftest-arch.c | 5 +- gdb/solib-dsbt.c | 5 +- gdb/solib-frv.c | 5 +- gdb/solib-spu.c | 5 +- gdb/solib-svr4.c | 30 ++--- gdb/solib.c | 20 ++- gdb/sparc64-linux-tdep.c | 5 +- gdb/stack.c | 55 ++++----- gdb/symfile-mem.c | 5 +- gdb/symmisc.c | 5 +- gdb/target.c | 5 +- gdb/thread.c | 5 +- gdb/top.c | 20 ++- gdb/tracefile-tfile.c | 5 +- gdb/tui/tui.c | 5 +- gdb/typeprint.c | 5 +- gdb/unittests/cli-utils-selftests.c | 10 +- gdb/unittests/parse-connection-spec-selftests.c | 5 +- gdb/valops.c | 10 +- gdb/valprint.c | 5 +- gdb/value.c | 10 +- gdb/varobj.c | 30 ++--- gdb/windows-nat.c | 5 +- gdb/x86-linux-nat.c | 5 +- gdb/xml-support.c | 10 +- 144 files changed, 1033 insertions(+), 1326 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index fb579b9..19ae18a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,148 @@ 2019-04-08 Tom Tromey + * xml-support.c: Use C++ exception handling. + * x86-linux-nat.c: Use C++ exception handling. + * windows-nat.c: Use C++ exception handling. + * varobj.c: Use C++ exception handling. + * value.c: Use C++ exception handling. + * valprint.c: Use C++ exception handling. + * valops.c: Use C++ exception handling. + * unittests/parse-connection-spec-selftests.c: Use C++ exception + handling. + * unittests/cli-utils-selftests.c: Use C++ exception handling. + * typeprint.c: Use C++ exception handling. + * tui/tui.c: Use C++ exception handling. + * tracefile-tfile.c: Use C++ exception handling. + * top.c: Use C++ exception handling. + * thread.c: Use C++ exception handling. + * target.c: Use C++ exception handling. + * symmisc.c: Use C++ exception handling. + * symfile-mem.c: Use C++ exception handling. + * stack.c: Use C++ exception handling. + * sparc64-linux-tdep.c: Use C++ exception handling. + * solib.c: Use C++ exception handling. + * solib-svr4.c: Use C++ exception handling. + * solib-spu.c: Use C++ exception handling. + * solib-frv.c: Use C++ exception handling. + * solib-dsbt.c: Use C++ exception handling. + * selftest-arch.c: Use C++ exception handling. + * s390-tdep.c: Use C++ exception handling. + * rust-lang.c: Use C++ exception handling. + * rust-exp.y: Use C++ exception handling. + * rs6000-tdep.c: Use C++ exception handling. + * rs6000-aix-tdep.c: Use C++ exception handling. + * riscv-tdep.c: Use C++ exception handling. + * remote.c: Use C++ exception handling. + * remote-fileio.c: Use C++ exception handling. + * record-full.c: Use C++ exception handling. + * record-btrace.c: Use C++ exception handling. + * python/python.c: Use C++ exception handling. + * python/py-value.c: Use C++ exception handling. + * python/py-utils.c: Use C++ exception handling. + * python/py-unwind.c: Use C++ exception handling. + * python/py-type.c: Use C++ exception handling. + * python/py-symbol.c: Use C++ exception handling. + * python/py-record.c: Use C++ exception handling. + * python/py-record-btrace.c: Use C++ exception handling. + * python/py-progspace.c: Use C++ exception handling. + * python/py-prettyprint.c: Use C++ exception handling. + * python/py-param.c: Use C++ exception handling. + * python/py-objfile.c: Use C++ exception handling. + * python/py-linetable.c: Use C++ exception handling. + * python/py-lazy-string.c: Use C++ exception handling. + * python/py-infthread.c: Use C++ exception handling. + * python/py-inferior.c: Use C++ exception handling. + * python/py-gdb-readline.c: Use C++ exception handling. + * python/py-framefilter.c: Use C++ exception handling. + * python/py-frame.c: Use C++ exception handling. + * python/py-finishbreakpoint.c: Use C++ exception handling. + * python/py-cmd.c: Use C++ exception handling. + * python/py-breakpoint.c: Use C++ exception handling. + * python/py-arch.c: Use C++ exception handling. + * printcmd.c: Use C++ exception handling. + * ppc-linux-tdep.c: Use C++ exception handling. + * parse.c: Use C++ exception handling. + * p-valprint.c: Use C++ exception handling. + * objc-lang.c: Use C++ exception handling. + * mi/mi-main.c: Use C++ exception handling. + * mi/mi-interp.c: Use C++ exception handling. + * mi/mi-cmd-stack.c: Use C++ exception handling. + * mi/mi-cmd-break.c: Use C++ exception handling. + * main.c: Use C++ exception handling. + * linux-thread-db.c: Use C++ exception handling. + * linux-tdep.c: Use C++ exception handling. + * linux-nat.c: Use C++ exception handling. + * linux-fork.c: Use C++ exception handling. + * linespec.c: Use C++ exception handling. + * language.c: Use C++ exception handling. + * jit.c: Use C++ exception handling. + * infrun.c: Use C++ exception handling. + * infcmd.c: Use C++ exception handling. + * infcall.c: Use C++ exception handling. + * inf-loop.c: Use C++ exception handling. + * i386-tdep.c: Use C++ exception handling. + * i386-linux-tdep.c: Use C++ exception handling. + * guile/scm-value.c: Use C++ exception handling. + * guile/scm-type.c: Use C++ exception handling. + * guile/scm-symtab.c: Use C++ exception handling. + * guile/scm-symbol.c: Use C++ exception handling. + * guile/scm-pretty-print.c: Use C++ exception handling. + * guile/scm-ports.c: Use C++ exception handling. + * guile/scm-param.c: Use C++ exception handling. + * guile/scm-math.c: Use C++ exception handling. + * guile/scm-lazy-string.c: Use C++ exception handling. + * guile/scm-frame.c: Use C++ exception handling. + * guile/scm-disasm.c: Use C++ exception handling. + * guile/scm-cmd.c: Use C++ exception handling. + * guile/scm-breakpoint.c: Use C++ exception handling. + * guile/scm-block.c: Use C++ exception handling. + * guile/guile-internal.h: Use C++ exception handling. + * gnu-v3-abi.c: Use C++ exception handling. + * gdbtypes.c: Use C++ exception handling. + * frame.c: Use C++ exception handling. + * frame-unwind.c: Use C++ exception handling. + * fbsd-tdep.c: Use C++ exception handling. + * f-valprint.c: Use C++ exception handling. + * exec.c: Use C++ exception handling. + * event-top.c: Use C++ exception handling. + * event-loop.c: Use C++ exception handling. + * eval.c: Use C++ exception handling. + * dwarf2read.c: Use C++ exception handling. + * dwarf2loc.c: Use C++ exception handling. + * dwarf2-frame.c: Use C++ exception handling. + * dwarf2-frame-tailcall.c: Use C++ exception handling. + * dwarf-index-write.c: Use C++ exception handling. + * dwarf-index-cache.c: Use C++ exception handling. + * dtrace-probe.c: Use C++ exception handling. + * disasm-selftests.c: Use C++ exception handling. + * darwin-nat.c: Use C++ exception handling. + * cp-valprint.c: Use C++ exception handling. + * cp-support.c: Use C++ exception handling. + * cp-abi.c: Use C++ exception handling. + * corelow.c: Use C++ exception handling. + * completer.c: Use C++ exception handling. + * compile/compile-object-run.c: Use C++ exception handling. + * compile/compile-object-load.c: Use C++ exception handling. + * compile/compile-cplus-symbols.c: Use C++ exception handling. + * compile/compile-c-symbols.c: Use C++ exception handling. + * common/selftest.c: Use C++ exception handling. + * common/new-op.c: Use C++ exception handling. + * cli/cli-script.c: Use C++ exception handling. + * cli/cli-interp.c: Use C++ exception handling. + * cli/cli-cmds.c: Use C++ exception handling. + * c-varobj.c: Use C++ exception handling. + * btrace.c: Use C++ exception handling. + * breakpoint.c: Use C++ exception handling. + * break-catch-throw.c: Use C++ exception handling. + * arch-utils.c: Use C++ exception handling. + * amd64-tdep.c: Use C++ exception handling. + * ada-valprint.c: Use C++ exception handling. + * ada-typeprint.c: Use C++ exception handling. + * ada-lang.c: Use C++ exception handling. + * aarch64-tdep.c: Use C++ exception handling. + +2019-04-08 Tom Tromey + * xml-support.c (gdb_xml_parser::parse): Update. * x86-linux-nat.c (x86_linux_nat_target::enable_btrace): Update. * value.c (show_convenience): Update. diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 68b6549..bd04a67 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -874,16 +874,15 @@ aarch64_make_prologue_cache (struct frame_info *this_frame, void **this_cache) cache->saved_regs = trad_frame_alloc_saved_regs (this_frame); *this_cache = cache; - TRY + try { aarch64_make_prologue_cache_1 (this_frame, cache); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (ex.error != NOT_AVAILABLE_ERROR) throw_exception (ex); } - END_CATCH return cache; } @@ -1006,19 +1005,18 @@ aarch64_make_stub_cache (struct frame_info *this_frame, void **this_cache) cache->saved_regs = trad_frame_alloc_saved_regs (this_frame); *this_cache = cache; - TRY + try { cache->prev_sp = get_frame_register_unsigned (this_frame, AARCH64_SP_REGNUM); cache->prev_pc = get_frame_pc (this_frame); cache->available_p = 1; } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (ex.error != NOT_AVAILABLE_ERROR) throw_exception (ex); } - END_CATCH return cache; } diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 19cc22d..4b51ef1 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -6723,16 +6723,15 @@ ada_tag_value_at_base_address (struct value *obj) see ada_tag_name for more details. We do not print the error message for the same reason. */ - TRY + try { offset_to_top = value_as_long (value_ind (value_ptradd (val, -2))); } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { return obj; } - END_CATCH /* If offset is null, nothing to do. */ @@ -6869,17 +6868,16 @@ ada_tag_name (struct value *tag) We also do not print the error message either (which often is very low-level (Eg: "Cannot read memory at 0x[...]"), but instead let the caller print a more meaningful message if necessary. */ - TRY + try { struct value *tsd = ada_get_tsd_from_tag (tag); if (tsd != NULL) name = ada_tag_name_from_tsd (tsd); } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { } - END_CATCH return name; } @@ -9054,11 +9052,11 @@ ada_to_fixed_type_1 (struct type *type, const gdb_byte *valaddr, LONGEST size; xsnprintf (xvz_name, strlen (name) + 7, "%s___XVZ", name); - TRY + try { xvz_found = get_int_var_value (xvz_name, size); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { /* We found the variable, but somehow failed to read its value. Rethrow the same error, but with a little @@ -9069,7 +9067,6 @@ ada_to_fixed_type_1 (struct type *type, const gdb_byte *valaddr, _("unable to read value of %s (%s)"), xvz_name, except.what ()); } - END_CATCH if (xvz_found && TYPE_LENGTH (fixed_record_type) != size) { @@ -12346,15 +12343,14 @@ ada_exception_message (void) { gdb::unique_xmalloc_ptr e_msg; - TRY + try { e_msg = ada_exception_message_1 (); } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { e_msg.reset (nullptr); } - END_CATCH return e_msg; } @@ -12370,17 +12366,16 @@ ada_exception_name_addr (enum ada_exception_catchpoint_kind ex, { CORE_ADDR result = 0; - TRY + try { result = ada_exception_name_addr_1 (ex, b); } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { warning (_("failed to get exception name: %s"), e.what ()); return 0; } - END_CATCH return result; } @@ -12461,19 +12456,18 @@ create_excep_cond_exprs (struct ada_catchpoint *c, const char *s; s = cond_string.c_str (); - TRY + try { exp = parse_exp_1 (&s, bl->address, block_for_pc (bl->address), 0); } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { warning (_("failed to reevaluate internal exception condition " "for catchpoint %d: %s"), c->number, e.what ()); } - END_CATCH } ada_loc->excep_cond_expr = std::move (exp); @@ -12531,7 +12525,7 @@ should_stop_exception (const struct bp_location *bl) } stop = 1; - TRY + try { struct value *mark; @@ -12539,12 +12533,11 @@ should_stop_exception (const struct bp_location *bl) stop = value_true (evaluate_expression (ada_loc->excep_cond_expr.get ())); value_free_to_mark (mark); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { exception_fprintf (gdb_stderr, ex, _("Error in testing exception condition:\n")); } - END_CATCH return stop; } diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c index efcd14b..8b71524 100644 --- a/gdb/ada-typeprint.c +++ b/gdb/ada-typeprint.c @@ -163,12 +163,12 @@ print_range (struct type *type, struct ui_file *stream, LONGEST lo = 0, hi = 0; /* init for gcc -Wall */ int got_error = 0; - TRY + try { lo = ada_discrete_type_low_bound (type); hi = ada_discrete_type_high_bound (type); } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { /* This can happen when the range is dynamic. Sometimes, resolving dynamic property values requires us to have @@ -178,7 +178,6 @@ print_range (struct type *type, struct ui_file *stream, fprintf_filtered (stream, "<>"); got_error = 1; } - END_CATCH if (!got_error) { diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index ac963a6..5349e93 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -1203,18 +1203,17 @@ ada_val_print (struct type *type, struct value *val, const struct value_print_options *options) { - TRY + try { ada_val_print_1 (type, embedded_offset, address, stream, recurse, val, options, current_language); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { fprintf_filtered (stream, _(""), except.what ()); } - END_CATCH } void diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index d589295..dca3c4f 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -2581,16 +2581,15 @@ amd64_frame_cache (struct frame_info *this_frame, void **this_cache) cache = amd64_alloc_frame_cache (); *this_cache = cache; - TRY + try { amd64_frame_cache_1 (this_frame, cache); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (ex.error != NOT_AVAILABLE_ERROR) throw_exception (ex); } - END_CATCH return cache; } @@ -2699,7 +2698,7 @@ amd64_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache) cache = amd64_alloc_frame_cache (); - TRY + try { get_frame_register (this_frame, AMD64_RSP_REGNUM, buf); cache->base = extract_unsigned_integer (buf, 8, byte_order) - 8; @@ -2713,12 +2712,11 @@ amd64_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache) cache->base_p = 1; } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (ex.error != NOT_AVAILABLE_ERROR) throw_exception (ex); } - END_CATCH *this_cache = cache; return cache; @@ -2876,7 +2874,7 @@ amd64_epilogue_frame_cache (struct frame_info *this_frame, void **this_cache) cache = amd64_alloc_frame_cache (); *this_cache = cache; - TRY + try { /* Cache base will be %esp plus cache->sp_offset (-8). */ get_frame_register (this_frame, AMD64_RSP_REGNUM, buf); @@ -2894,12 +2892,11 @@ amd64_epilogue_frame_cache (struct frame_info *this_frame, void **this_cache) cache->base_p = 1; } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (ex.error != NOT_AVAILABLE_ERROR) throw_exception (ex); } - END_CATCH return cache; } diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index 52a08da..7623aac 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -969,13 +969,12 @@ gdbarch_skip_prologue_noexcept (gdbarch *gdbarch, CORE_ADDR pc) noexcept { CORE_ADDR new_pc = pc; - TRY + try { new_pc = gdbarch_skip_prologue (gdbarch, pc); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) {} - END_CATCH return new_pc; } diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c index c8d66e0..f9f4684 100644 --- a/gdb/break-catch-throw.c +++ b/gdb/break-catch-throw.c @@ -154,7 +154,7 @@ check_status_exception_catchpoint (struct bpstats *bs) if (self->pattern == NULL) return; - TRY + try { struct value *typeinfo_arg; std::string canon; @@ -166,11 +166,10 @@ check_status_exception_catchpoint (struct bpstats *bs) if (!canon.empty ()) std::swap (type_name, canon); } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { exception_print (gdb_stderr, e); } - END_CATCH if (!type_name.empty ()) { @@ -189,17 +188,17 @@ re_set_exception_catchpoint (struct breakpoint *self) struct program_space *filter_pspace = current_program_space; /* We first try to use the probe interface. */ - TRY + try { event_location_up location = new_probe_location (exception_functions[kind].probe); sals = parse_probes (location.get (), filter_pspace, NULL); } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { /* Using the probe interface failed. Let's fallback to the normal catchpoint mode. */ - TRY + try { struct explicit_location explicit_loc; @@ -210,16 +209,14 @@ re_set_exception_catchpoint (struct breakpoint *self) sals = self->ops->decode_location (self, location.get (), filter_pspace); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { /* NOT_FOUND_ERROR just means the breakpoint will be pending, so let it through. */ if (ex.error != NOT_FOUND_ERROR) throw_exception (ex); } - END_CATCH } - END_CATCH update_breakpoint_locations (self, filter_pspace, sals, {}); } diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 6e835a5..8dfbb11 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -2097,18 +2097,17 @@ parse_cond_to_aexpr (CORE_ADDR scope, struct expression *cond) /* We don't want to stop processing, so catch any errors that may show up. */ - TRY + try { aexpr = gen_eval_for_expr (scope, cond); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { /* If we got here, it means the condition could not be parsed to a valid bytecode expression and thus can't be evaluated on the target's side. It's no use iterating through the conditions. */ } - END_CATCH /* We have a valid agent expression. */ return aexpr; @@ -2272,19 +2271,18 @@ parse_cmd_to_aexpr (CORE_ADDR scope, char *cmd) /* We don't want to stop processing, so catch any errors that may show up. */ - TRY + try { aexpr = gen_printf (scope, gdbarch, 0, 0, format_start, format_end - format_start, argvec.size (), argvec.data ()); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { /* If we got here, it means the command could not be parsed to a valid bytecode expression and thus can't be evaluated on the target's side. It's no use iterating through the other commands. */ } - END_CATCH /* We have a valid agent expression, return it. */ return aexpr; @@ -2539,7 +2537,7 @@ insert_bp_location (struct bp_location *bl, || !(section_is_overlay (bl->section))) { /* No overlay handling: just set the breakpoint. */ - TRY + try { int val; @@ -2547,11 +2545,10 @@ insert_bp_location (struct bp_location *bl, if (val) bp_excpt = gdb_exception {RETURN_ERROR, GENERIC_ERROR}; } - CATCH (e, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &e) { bp_excpt = e; } - END_CATCH } else { @@ -2574,7 +2571,7 @@ insert_bp_location (struct bp_location *bl, bl->overlay_target_info.reqstd_address = addr; /* No overlay handling: just set the breakpoint. */ - TRY + try { int val; @@ -2587,11 +2584,10 @@ insert_bp_location (struct bp_location *bl, bp_excpt = gdb_exception {RETURN_ERROR, GENERIC_ERROR}; } - CATCH (e, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &e) { bp_excpt = e; } - END_CATCH if (bp_excpt.reason != 0) fprintf_unfiltered (tmp_error_stream, @@ -2604,7 +2600,7 @@ insert_bp_location (struct bp_location *bl, if (section_is_mapped (bl->section)) { /* Yes. This overlay section is mapped into memory. */ - TRY + try { int val; @@ -2612,11 +2608,10 @@ insert_bp_location (struct bp_location *bl, if (val) bp_excpt = gdb_exception {RETURN_ERROR, GENERIC_ERROR}; } - CATCH (e, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &e) { bp_excpt = e; } - END_CATCH } else { @@ -5017,11 +5012,11 @@ bpstat_check_watchpoint (bpstat bs) { wp_check_result e; - TRY + try { e = watchpoint_check (bs); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { exception_fprintf (gdb_stderr, ex, "Error evaluating expression " @@ -5036,7 +5031,6 @@ bpstat_check_watchpoint (bpstat bs) watchpoint_del_at_next_stop (b); e = WP_DELETED; } - END_CATCH switch (e) { @@ -5255,16 +5249,15 @@ bpstat_check_breakpoint_conditions (bpstat bs, thread_info *thread) } if (within_current_scope) { - TRY + try { condition_result = breakpoint_cond_eval (cond); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { exception_fprintf (gdb_stderr, ex, "Error in testing breakpoint condition:\n"); } - END_CATCH } else { @@ -9246,11 +9239,11 @@ create_breakpoint (struct gdbarch *gdbarch, if (extra_string != NULL && *extra_string == '\0') extra_string = NULL; - TRY + try { ops->create_sals_from_location (location, &canonical, type_wanted); } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { /* If caller is interested in rc value from parse, set value. */ @@ -9280,7 +9273,6 @@ create_breakpoint (struct gdbarch *gdbarch, else throw_exception (e); } - END_CATCH if (!pending && canonical.lsals.empty ()) return 0; @@ -12060,14 +12052,13 @@ static void update_global_location_list_nothrow (enum ugll_insert_mode insert_mode) { - TRY + try { update_global_location_list (insert_mode); } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { } - END_CATCH } /* Clear BKP from a BPS. */ @@ -13529,20 +13520,19 @@ update_breakpoint_locations (struct breakpoint *b, const char *s; s = b->cond_string; - TRY + try { new_loc->cond = parse_exp_1 (&s, sal.pc, block_for_pc (sal.pc), 0); } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { warning (_("failed to reevaluate condition " "for breakpoint %d: %s"), b->number, e.what ()); new_loc->enabled = 0; } - END_CATCH } if (!sals_end.empty ()) @@ -13609,11 +13599,11 @@ location_to_sals (struct breakpoint *b, struct event_location *location, std::vector sals; - TRY + try { sals = b->ops->decode_location (b, location, search_pspace); } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { int not_found_and_ok = 0; @@ -13648,7 +13638,6 @@ location_to_sals (struct breakpoint *b, struct event_location *location, throw_exception (e); } } - END_CATCH if (exception.reason == 0 || exception.error != NOT_FOUND_ERROR) { @@ -13820,17 +13809,16 @@ breakpoint_re_set (void) ALL_BREAKPOINTS_SAFE (b, b_tmp) { - TRY + try { breakpoint_re_set_one (b); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { exception_fprintf (gdb_stderr, ex, "Error in re-setting breakpoint %d: ", b->number); } - END_CATCH } jit_breakpoint_re_set (); @@ -14297,7 +14285,7 @@ enable_breakpoint_disp (struct breakpoint *bpt, enum bpdisp disposition, /* Initialize it just to avoid a GCC false warning. */ enum enable_state orig_enable_state = bp_disabled; - TRY + try { struct watchpoint *w = (struct watchpoint *) bpt; @@ -14305,14 +14293,13 @@ enable_breakpoint_disp (struct breakpoint *bpt, enum bpdisp disposition, bpt->enable_state = bp_enabled; update_watchpoint (w, 1 /* reparse */); } - CATCH (e, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &e) { bpt->enable_state = orig_enable_state; exception_fprintf (gdb_stderr, e, _("Cannot enable watchpoint %d: "), bpt->number); return; } - END_CATCH } bpt->enable_state = bp_enabled; @@ -15040,16 +15027,15 @@ save_breakpoints (const char *filename, int from_tty, fp.puts (" commands\n"); current_uiout->redirect (&fp); - TRY + try { print_command_lines (current_uiout, tp->commands.get (), 2); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { current_uiout->redirect (NULL); throw_exception (ex); } - END_CATCH current_uiout->redirect (NULL); fp.puts (" end\n"); diff --git a/gdb/btrace.c b/gdb/btrace.c index 12af468..3bfd1c8 100644 --- a/gdb/btrace.c +++ b/gdb/btrace.c @@ -678,7 +678,7 @@ ftrace_classify_insn (struct gdbarch *gdbarch, CORE_ADDR pc) enum btrace_insn_class iclass; iclass = BTRACE_INSN_OTHER; - TRY + try { if (gdbarch_insn_is_call (gdbarch, pc)) iclass = BTRACE_INSN_CALL; @@ -687,10 +687,9 @@ ftrace_classify_insn (struct gdbarch *gdbarch, CORE_ADDR pc) else if (gdbarch_insn_is_jump (gdbarch, pc)) iclass = BTRACE_INSN_JUMP; } - CATCH (error, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &error) { } - END_CATCH return iclass; } @@ -1103,14 +1102,13 @@ btrace_compute_ftrace_bts (struct thread_info *tp, level = std::min (level, bfun->level); size = 0; - TRY + try { size = gdb_insn_length (gdbarch, pc); } - CATCH (error, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &error) { } - END_CATCH insn.pc = pc; insn.size = size; @@ -1370,17 +1368,16 @@ btrace_pt_readmem_callback (gdb_byte *buffer, size_t size, int result, errcode; result = (int) size; - TRY + try { errcode = target_read_code ((CORE_ADDR) pc, buffer, size); if (errcode != 0) result = -pte_nomap; } - CATCH (error, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &error) { result = -pte_nomap; } - END_CATCH return result; } @@ -1464,7 +1461,7 @@ btrace_compute_ftrace_pt (struct thread_info *tp, if (decoder == NULL) error (_("Failed to allocate the Intel Processor Trace decoder.")); - TRY + try { struct pt_image *image; @@ -1479,7 +1476,7 @@ btrace_compute_ftrace_pt (struct thread_info *tp, ftrace_add_pt (btinfo, decoder, &level, gaps); } - CATCH (error, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &error) { /* Indicate a gap in the trace if we quit trace processing. */ if (error.reason == RETURN_QUIT && !btinfo->functions.empty ()) @@ -1489,7 +1486,6 @@ btrace_compute_ftrace_pt (struct thread_info *tp, throw_exception (error); } - END_CATCH btrace_finalize_ftrace_pt (decoder, tp, level); } @@ -1556,17 +1552,16 @@ btrace_compute_ftrace (struct thread_info *tp, struct btrace_data *btrace, { std::vector gaps; - TRY + try { btrace_compute_ftrace_1 (tp, btrace, cpu, gaps); } - CATCH (error, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &error) { btrace_finalize_ftrace (tp, gaps); throw_exception (error); } - END_CATCH btrace_finalize_ftrace (tp, gaps); } @@ -1617,7 +1612,7 @@ btrace_enable (struct thread_info *tp, const struct btrace_config *conf) return; /* We need to undo the enable in case of errors. */ - TRY + try { /* Add an entry for the current PC so we start tracing from where we enabled it. @@ -1632,13 +1627,12 @@ btrace_enable (struct thread_info *tp, const struct btrace_config *conf) && can_access_registers_thread (tp)) btrace_add_pc (tp); } - CATCH (exception, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &exception) { btrace_disable (tp); throw_exception (exception); } - END_CATCH } /* See btrace.h. */ @@ -3062,18 +3056,17 @@ btrace_maint_update_pt_packets (struct btrace_thread_info *btinfo) if (decoder == NULL) error (_("Failed to allocate the Intel Processor Trace decoder.")); - TRY + try { btrace_maint_decode_pt (&btinfo->maint, decoder); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { pt_pkt_free_decoder (decoder); if (except.reason < 0) throw_exception (except); } - END_CATCH pt_pkt_free_decoder (decoder); } diff --git a/gdb/c-varobj.c b/gdb/c-varobj.c index 2d24774..36290dd 100644 --- a/gdb/c-varobj.c +++ b/gdb/c-varobj.c @@ -92,16 +92,15 @@ adjust_value_for_child_access (struct value **value, if (value && *value) { - TRY + try { *value = value_ind (*value); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { *value = NULL; } - END_CATCH } *type = target_type; if (was_ptr) @@ -253,18 +252,17 @@ value_struct_element_index (struct value *value, int type_index) gdb_assert (TYPE_CODE (type) == TYPE_CODE_STRUCT || TYPE_CODE (type) == TYPE_CODE_UNION); - TRY + try { if (field_is_static (&TYPE_FIELD (type, type_index))) result = value_static_field (type, type_index); else result = value_primitive_field (value, 0, type_index, type); } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { return NULL; } - END_CATCH return result; } @@ -316,14 +314,13 @@ c_describe_child (const struct varobj *parent, int index, { int real_index = index + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)); - TRY + try { *cvalue = value_subscript (value, real_index); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { } - END_CATCH } if (ctype) @@ -393,16 +390,15 @@ c_describe_child (const struct varobj *parent, int index, if (cvalue && value) { - TRY + try { *cvalue = value_ind (value); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { *cvalue = NULL; } - END_CATCH } /* Don't use get_target_type because it calls diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 5dc94a5..1dc82b3 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -250,7 +250,7 @@ complete_command (const char *arg, int from_tty) int quote_char = '\0'; const char *word; - TRY + try { word = completion_find_completion_word (tracker_handle_brkchars, arg, "e_char); @@ -267,11 +267,10 @@ complete_command (const char *arg, int from_tty) tracker = &tracker_handle_completions; } } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { return; } - END_CATCH std::string arg_prefix (arg, word - arg); diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c index 088f4f1..c8cc1b4 100644 --- a/gdb/cli/cli-interp.c +++ b/gdb/cli/cli-interp.c @@ -363,15 +363,14 @@ safe_execute_command (struct ui_out *command_uiout, const char *command, scoped_restore saved_uiout = make_scoped_restore (¤t_uiout, command_uiout); - TRY + try { execute_command (command, from_tty); } - CATCH (exception, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &exception) { e = exception; } - END_CATCH /* FIXME: cagney/2005-01-13: This shouldn't be needed. Instead the caller should print the exception. */ diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c index f558c06..4964553 100644 --- a/gdb/cli/cli-script.c +++ b/gdb/cli/cli-script.c @@ -1050,16 +1050,15 @@ process_next_line (const char *p, struct command_line **command, if (validator) { - TRY + try { validator ((*command)->line); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { free_command_lines (command); throw_exception (ex); } - END_CATCH } /* Nothing special. */ @@ -1540,11 +1539,11 @@ script_from_file (FILE *stream, const char *file) scoped_restore save_async = make_scoped_restore (¤t_ui->async, 0); - TRY + try { read_command_file (stream); } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { /* Re-throw the error, but with the file name information prepended. */ @@ -1553,7 +1552,6 @@ script_from_file (FILE *stream, const char *file) source_file_name.c_str (), source_line_number, e.what ()); } - END_CATCH } /* Print the definition of user command C to STREAM. Or, if C is a diff --git a/gdb/common/new-op.c b/gdb/common/new-op.c index cff6686..c358b80 100644 --- a/gdb/common/new-op.c +++ b/gdb/common/new-op.c @@ -60,15 +60,14 @@ operator new (std::size_t sz) QUIT gdb_exception. This is necessary because operator new can only ever throw std::bad_alloc, or something that extends it. */ - TRY + try { malloc_failure (sz); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { throw gdb_quit_bad_alloc (ex); } - END_CATCH } return p; } diff --git a/gdb/common/selftest.c b/gdb/common/selftest.c index 1e73708..3f3ff74 100644 --- a/gdb/common/selftest.c +++ b/gdb/common/selftest.c @@ -81,18 +81,17 @@ run_tests (const char *filter) && name.find (filter) == std::string::npos) continue; - TRY + try { debug_printf (_("Running selftest %s.\n"), name.c_str ()); ++ran; (*test) (); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { ++failed; debug_printf ("Self test failed: %s\n", ex.what ()); } - END_CATCH reset (); } diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c index 10d9ada..7e76db3 100644 --- a/gdb/compile/compile-c-symbols.c +++ b/gdb/compile/compile-c-symbols.c @@ -344,7 +344,7 @@ gcc_convert_symbol (void *datum, /* We can't allow exceptions to escape out of this callback. Safest is to simply emit a gcc error. */ - TRY + try { struct block_symbol sym; @@ -367,11 +367,10 @@ gcc_convert_symbol (void *datum, } } - CATCH (e, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &e) { context->plugin ().error (e.what ()); } - END_CATCH if (compile_debug && !found) fprintf_unfiltered (gdb_stdlog, @@ -393,7 +392,7 @@ gcc_symbol_address (void *datum, struct gcc_c_context *gcc_context, /* We can't allow exceptions to escape out of this callback. Safest is to simply emit a gcc error. */ - TRY + try { struct symbol *sym; @@ -430,11 +429,10 @@ gcc_symbol_address (void *datum, struct gcc_c_context *gcc_context, } } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { context->plugin ().error (e.what ()); } - END_CATCH if (compile_debug && !found) fprintf_unfiltered (gdb_stdlog, @@ -548,7 +546,7 @@ generate_c_for_for_one_variable (compile_instance *compiler, struct symbol *sym) { - TRY + try { if (is_dynamic_type (SYMBOL_TYPE (sym))) { @@ -600,11 +598,10 @@ generate_c_for_for_one_variable (compile_instance *compiler, } } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { compiler->insert_symbol_error (sym, e.what ()); } - END_CATCH } /* See compile-c.h. */ diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c index 4914c7c..1bb3a6f 100644 --- a/gdb/compile/compile-cplus-symbols.c +++ b/gdb/compile/compile-cplus-symbols.c @@ -343,7 +343,7 @@ gcc_cplus_convert_symbol (void *datum, bool found = false; compile_cplus_instance *instance = (compile_cplus_instance *) datum; - TRY + try { /* Symbol searching is a three part process unfortunately. */ @@ -388,13 +388,12 @@ gcc_cplus_convert_symbol (void *datum, } } } - CATCH (e, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &e) { /* We can't allow exceptions to escape out of this callback. Safest is to simply emit a gcc error. */ instance->plugin ().error (e.what ()); } - END_CATCH if (compile_debug && !found) fprintf_unfiltered (gdb_stdlog, @@ -431,7 +430,7 @@ gcc_cplus_symbol_address (void *datum, struct gcc_cp_context *gcc_context, /* We can't allow exceptions to escape out of this callback. Safest is to simply emit a gcc error. */ - TRY + try { struct symbol *sym = lookup_symbol (identifier, nullptr, VAR_DOMAIN, nullptr).symbol; @@ -467,11 +466,10 @@ gcc_cplus_symbol_address (void *datum, struct gcc_cp_context *gcc_context, } } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { instance->plugin ().error (e.what ()); } - END_CATCH if (compile_debug && !found) fprintf_unfiltered (gdb_stdlog, diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c index db8238d..29542e7 100644 --- a/gdb/compile/compile-object-load.c +++ b/gdb/compile/compile-object-load.c @@ -50,16 +50,15 @@ munmap_list::~munmap_list () { for (auto &item : items) { - TRY + try { gdbarch_infcall_munmap (target_gdbarch (), item.addr, item.size); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { /* There's not much the user can do, so just ignore this. */ } - END_CATCH } } diff --git a/gdb/compile/compile-object-run.c b/gdb/compile/compile-object-run.c index 82b8393..1c4dd20 100644 --- a/gdb/compile/compile-object-run.c +++ b/gdb/compile/compile-object-run.c @@ -137,7 +137,7 @@ compile_object_run (struct compile_module *module) xfree (module); module = NULL; - TRY + try { struct type *func_type = SYMBOL_TYPE (func_sym); htab_t copied_types; @@ -173,7 +173,7 @@ compile_object_run (struct compile_module *module) call_function_by_hand_dummy (func_val, NULL, args, do_module_cleanup, data); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { /* In the case of DTOR_FOUND or in the case of EXECUTED nothing needs to be done. */ @@ -185,7 +185,6 @@ compile_object_run (struct compile_module *module) do_module_cleanup (data, 0); throw_exception (ex); } - END_CATCH dtor_found = find_dummy_frame_dtor (do_module_cleanup, data); gdb_assert (!dtor_found && executed); diff --git a/gdb/completer.c b/gdb/completer.c index d7cf4fd..6d87174 100644 --- a/gdb/completer.c +++ b/gdb/completer.c @@ -1021,15 +1021,14 @@ complete_expression (completion_tracker &tracker, /* Perform a tentative parse of the expression, to see whether a field completion is required. */ - TRY + try { type = parse_expression_for_completion (text, &fieldname, &code); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { return; } - END_CATCH if (fieldname != nullptr && type) { @@ -1445,16 +1444,15 @@ complete_line_internal (completion_tracker &tracker, const char *line_buffer, int point, complete_line_internal_reason reason) { - TRY + try { complete_line_internal_1 (tracker, text, line_buffer, point, reason); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { if (except.error != MAX_COMPLETIONS_REACHED_ERROR) throw_exception (except); } - END_CATCH } /* See completer.h. */ @@ -1859,17 +1857,16 @@ gdb_completion_word_break_characters () /* New completion starting. */ current_completion.aborted = false; - TRY + try { return gdb_completion_word_break_characters_throw (); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { /* Set this to that gdb_rl_attempted_completion_function knows to abort early. */ current_completion.aborted = true; } - END_CATCH return NULL; } @@ -2207,14 +2204,13 @@ gdb_rl_attempted_completion_function (const char *text, int start, int end) if (current_completion.aborted) return NULL; - TRY + try { return gdb_rl_attempted_completion_function_throw (text, start, end); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { } - END_CATCH return NULL; } diff --git a/gdb/corelow.c b/gdb/corelow.c index 7fb4297..a0fab14 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -461,16 +461,15 @@ core_target_open (const char *arg, int from_tty) may be a thread_stratum target loaded on top of target core by now. The layer above should claim threads found in the BFD sections. */ - TRY + try { target_update_thread_list (); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { exception_print (gdb_stderr, except); } - END_CATCH p = bfd_core_file_failing_command (core_bfd); if (p) @@ -517,15 +516,14 @@ core_target_open (const char *arg, int from_tty) anything about threads. That is why the test is >= 2. */ if (thread_count () >= 2) { - TRY + try { thread_command (NULL, from_tty); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { exception_print (gdb_stderr, except); } - END_CATCH } } diff --git a/gdb/cp-abi.c b/gdb/cp-abi.c index b858b19..f82da4b 100644 --- a/gdb/cp-abi.c +++ b/gdb/cp-abi.c @@ -73,13 +73,13 @@ baseclass_offset (struct type *type, int index, const gdb_byte *valaddr, gdb_assert (current_cp_abi.baseclass_offset != NULL); - TRY + try { res = (*current_cp_abi.baseclass_offset) (type, index, valaddr, embedded_offset, address, val); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (ex.error != NOT_AVAILABLE_ERROR) throw_exception (ex); @@ -88,7 +88,6 @@ baseclass_offset (struct type *type, int index, const gdb_byte *valaddr, _("Cannot determine virtual baseclass offset " "of incomplete object")); } - END_CATCH return res; } @@ -112,15 +111,14 @@ value_rtti_type (struct value *v, int *full, if ((current_cp_abi.rtti_type) == NULL) return NULL; - TRY + try { ret = (*current_cp_abi.rtti_type) (v, full, top, using_enc); } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { return NULL; } - END_CATCH return ret; } diff --git a/gdb/cp-support.c b/gdb/cp-support.c index b79dd5c..07265ef 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -151,15 +151,14 @@ inspect_type (struct demangle_parse_info *info, sym = NULL; - TRY + try { sym = lookup_symbol (name, 0, VAR_DOMAIN, 0).symbol; } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { return 0; } - END_CATCH if (sym != NULL) { @@ -223,17 +222,16 @@ inspect_type (struct demangle_parse_info *info, } string_file buf; - TRY + try { type_print (type, "", &buf, -1); } /* If type_print threw an exception, there is little point in continuing, so just bow out gracefully. */ - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { return 0; } - END_CATCH len = buf.size (); name = (char *) obstack_copy0 (&info->obstack, buf.c_str (), len); @@ -424,15 +422,14 @@ replace_typedefs (struct demangle_parse_info *info, struct symbol *sym = NULL; sym = NULL; - TRY + try { sym = lookup_symbol (local_name.get (), 0, VAR_DOMAIN, 0).symbol; } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { } - END_CATCH if (sym != NULL) { diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index 308c25b..f45bacc 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -320,18 +320,17 @@ cp_print_value_fields (struct type *type, struct type *real_type, { struct value *v = NULL; - TRY + try { v = value_static_field (type, i); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { fprintf_filtered (stream, _(""), ex.what ()); } - END_CATCH cp_print_static_field (TYPE_FIELD_TYPE (type, i), v, stream, recurse + 1, @@ -509,18 +508,17 @@ cp_print_value (struct type *type, struct type *real_type, thisoffset = offset; thistype = real_type; - TRY + try { boffset = baseclass_offset (type, i, valaddr, offset, address, val); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (ex.error == NOT_AVAILABLE_ERROR) skip = -1; else skip = 1; } - END_CATCH if (skip == 0) { diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c index 79a6599..caa4fd1 100644 --- a/gdb/darwin-nat.c +++ b/gdb/darwin-nat.c @@ -1611,7 +1611,7 @@ darwin_attach_pid (struct inferior *inf) darwin_inferior *priv = new darwin_inferior; inf->priv.reset (priv); - TRY + try { kret = task_for_pid (gdb_task, inf->pid, &priv->task); if (kret != KERN_SUCCESS) @@ -1688,14 +1688,13 @@ darwin_attach_pid (struct inferior *inf) darwin_setup_exceptions (inf); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { exit_inferior (inf); inferior_ptid = null_ptid; throw_exception (ex); } - END_CATCH target_ops *darwin_ops = get_native_target (); if (!target_is_pushed (darwin_ops)) @@ -1949,11 +1948,11 @@ The error was: %s"), /* Maybe it was cached by some earlier gdb. */ if (stat (new_name.c_str (), &sb) != 0 || !S_ISREG (sb.st_mode)) { - TRY + try { copy_shell_to_cache (shell, new_name); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { warning (_("This version of macOS has System Integrity Protection.\n\ Because `startup-with-shell' is enabled, gdb tried to work around SIP by\n\ @@ -1965,7 +1964,6 @@ you \"run\". To prevent these attempts, you can use:\n\ ex.what ()); return false; } - END_CATCH printf_filtered (_("Note: this version of macOS has System Integrity Protection.\n\ Because `startup-with-shell' is enabled, gdb has worked around this by\n\ diff --git a/gdb/disasm-selftests.c b/gdb/disasm-selftests.c index 48b466b..aa4d499 100644 --- a/gdb/disasm-selftests.c +++ b/gdb/disasm-selftests.c @@ -192,16 +192,15 @@ memory_error_test (struct gdbarch *gdbarch) gdb_disassembler_test di (gdbarch); bool saw_memory_error = false; - TRY + try { di.print_insn (0); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (ex.error == MEMORY_ERROR) saw_memory_error = true; } - END_CATCH /* Expect MEMORY_ERROR. */ SELF_CHECK (saw_memory_error); diff --git a/gdb/dtrace-probe.c b/gdb/dtrace-probe.c index bd5cddc..92fda24 100644 --- a/gdb/dtrace-probe.c +++ b/gdb/dtrace-probe.c @@ -484,15 +484,14 @@ dtrace_process_dof_probe (struct objfile *objfile, int'. */ struct type *type = builtin_type (gdbarch)->builtin_long; - TRY + try { expr = parse_expression_with_language (type_str.c_str (), language_c); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { } - END_CATCH if (expr != NULL && expr.get ()->elts[0].opcode == OP_TYPE) type = expr.get ()->elts[1].type; diff --git a/gdb/dwarf-index-cache.c b/gdb/dwarf-index-cache.c index 6e087f9..e03bbfc 100644 --- a/gdb/dwarf-index-cache.c +++ b/gdb/dwarf-index-cache.c @@ -110,7 +110,7 @@ index_cache::store (struct dwarf2_per_objfile *dwarf2_per_objfile) std::string build_id_str = build_id_to_string (build_id); - TRY + try { /* Try to create the containing directory. */ if (!mkdir_recursive (m_dir.c_str ())) @@ -129,13 +129,12 @@ index_cache::store (struct dwarf2_per_objfile *dwarf2_per_objfile) write_psymtabs_to_index (dwarf2_per_objfile, m_dir.c_str (), build_id_str.c_str (), dw_index_kind::GDB_INDEX); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { if (debug_index_cache) printf_unfiltered ("index cache: couldn't store index cache for objfile " "%s: %s", objfile_name (obj), except.what ()); } - END_CATCH } #if HAVE_SYS_MMAN_H @@ -172,7 +171,7 @@ index_cache::lookup_gdb_index (const bfd_build_id *build_id, /* Compute where we would expect a gdb index file for this build id to be. */ std::string filename = make_index_filename (build_id, INDEX4_SUFFIX); - TRY + try { if (debug_index_cache) printf_unfiltered ("index cache: trying to read %s\n", @@ -189,13 +188,12 @@ index_cache::lookup_gdb_index (const bfd_build_id *build_id, ((const gdb_byte *) mmap_resource->mapping.get (), mmap_resource->mapping.size ()); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { if (debug_index_cache) printf_unfiltered ("index cache: couldn't read %s: %s\n", filename.c_str (), except.what ()); } - END_CATCH return {}; } diff --git a/gdb/dwarf-index-write.c b/gdb/dwarf-index-write.c index 01c1256..531256f 100644 --- a/gdb/dwarf-index-write.c +++ b/gdb/dwarf-index-write.c @@ -1675,19 +1675,18 @@ save_gdb_index_command (const char *arg, int from_tty) if (dwarf2_per_objfile != NULL) { - TRY + try { const char *basename = lbasename (objfile_name (objfile)); write_psymtabs_to_index (dwarf2_per_objfile, arg, basename, index_kind); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { exception_fprintf (gdb_stderr, except, _("Error while writing index for `%s': "), objfile_name (objfile)); } - END_CATCH } } diff --git a/gdb/dwarf2-frame-tailcall.c b/gdb/dwarf2-frame-tailcall.c index 4cf7f5f..178a65c 100644 --- a/gdb/dwarf2-frame-tailcall.c +++ b/gdb/dwarf2-frame-tailcall.c @@ -377,7 +377,7 @@ dwarf2_tailcall_sniffer_first (struct frame_info *this_frame, this_pc = get_frame_address_in_block (this_frame); /* Catch any unwinding errors. */ - TRY + try { int sp_regnum; @@ -399,13 +399,12 @@ dwarf2_tailcall_sniffer_first (struct frame_info *this_frame, } } } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { if (entry_values_debug) exception_print (gdb_stdout, except); return; } - END_CATCH /* Ambiguous unwind or unambiguous unwind verified as matching. */ if (chain == NULL || chain->length == 0) diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c index f1ba0c9..2274d67 100644 --- a/gdb/dwarf2-frame.c +++ b/gdb/dwarf2-frame.c @@ -1044,7 +1044,7 @@ dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache) execute_cfa_program (fde, instr, fde->end, gdbarch, get_frame_address_in_block (this_frame), &fs); - TRY + try { /* Calculate the CFA. */ switch (fs.regs.cfa_how) @@ -1068,7 +1068,7 @@ dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache) internal_error (__FILE__, __LINE__, _("Unknown CFA rule.")); } } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (ex.error == NOT_AVAILABLE_ERROR) { @@ -1078,7 +1078,6 @@ dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache) throw_exception (ex); } - END_CATCH /* Initialize the register state. */ { @@ -2245,7 +2244,7 @@ dwarf2_build_frame_info (struct objfile *objfile) if (txt) unit->tbase = txt->vma; - TRY + try { frame_ptr = unit->dwarf_frame_buffer; while (frame_ptr < unit->dwarf_frame_buffer + unit->dwarf_frame_size) @@ -2254,7 +2253,7 @@ dwarf2_build_frame_info (struct objfile *objfile) EH_CIE_OR_FDE_TYPE_ID); } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { warning (_("skipping .eh_frame info of %s: %s"), objfile_name (objfile), e.what ()); @@ -2267,7 +2266,6 @@ dwarf2_build_frame_info (struct objfile *objfile) } /* The cie_table is discarded by the next if. */ } - END_CATCH if (cie_table.num_entries != 0) { @@ -2287,7 +2285,7 @@ dwarf2_build_frame_info (struct objfile *objfile) { int num_old_fde_entries = fde_table.num_entries; - TRY + try { frame_ptr = unit->dwarf_frame_buffer; while (frame_ptr < unit->dwarf_frame_buffer + unit->dwarf_frame_size) @@ -2295,7 +2293,7 @@ dwarf2_build_frame_info (struct objfile *objfile) &cie_table, &fde_table, EH_CIE_OR_FDE_TYPE_ID); } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { warning (_("skipping .debug_frame info of %s: %s"), objfile_name (objfile), e.what ()); @@ -2318,7 +2316,6 @@ dwarf2_build_frame_info (struct objfile *objfile) fde_table.num_entries = num_old_fde_entries; /* The cie_table is discarded by the next if. */ } - END_CATCH } /* Discard the cie_table, it is no longer needed. */ diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c index 29d289b..d712c29 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -1195,11 +1195,11 @@ call_site_find_chain (struct gdbarch *gdbarch, CORE_ADDR caller_pc, { struct call_site_chain *retval = NULL; - TRY + try { retval = call_site_find_chain_1 (gdbarch, caller_pc, callee_pc); } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { if (e.error == NO_ENTRY_VALUE_ERROR) { @@ -1211,7 +1211,6 @@ call_site_find_chain (struct gdbarch *gdbarch, CORE_ADDR caller_pc, else throw_exception (e); } - END_CATCH return retval; } @@ -2164,11 +2163,11 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, ctx.ref_addr_size = dwarf2_per_cu_ref_addr_size (per_cu); ctx.offset = dwarf2_per_cu_text_offset (per_cu); - TRY + try { ctx.eval (data, size); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (ex.error == NOT_AVAILABLE_ERROR) { @@ -2188,7 +2187,6 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, else throw_exception (ex); } - END_CATCH if (ctx.pieces.size () > 0) { @@ -2382,11 +2380,11 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton, ctx.ref_addr_size = dwarf2_per_cu_ref_addr_size (dlbaton->per_cu); ctx.offset = dwarf2_per_cu_text_offset (dlbaton->per_cu); - TRY + try { ctx.eval (dlbaton->data, dlbaton->size); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (ex.error == NOT_AVAILABLE_ERROR) { @@ -2401,7 +2399,6 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton, else throw_exception (ex); } - END_CATCH switch (ctx.location) { diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 8881a1e..6453e4a 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -6332,7 +6332,7 @@ dwarf2_build_psymtabs (struct objfile *objfile) init_psymbol_list (objfile, 1024); - TRY + try { /* This isn't really ideal: all the data we allocate on the objfile's obstack is still uselessly kept around. However, @@ -6344,11 +6344,10 @@ dwarf2_build_psymtabs (struct objfile *objfile) /* (maybe) store an index in the cache. */ global_index_cache.store (dwarf2_per_objfile); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { exception_print (gdb_stderr, except); } - END_CATCH } /* Return the total length of the CU described by HEADER. */ diff --git a/gdb/eval.c b/gdb/eval.c index 3f768b4..fa65fb1 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -201,11 +201,11 @@ fetch_subexp_value (struct expression *exp, int *pc, struct value **valp, mark = value_mark (); result = NULL; - TRY + try { result = evaluate_subexp (NULL_TYPE, exp, pc, EVAL_NORMAL); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { /* Ignore memory errors if we want watchpoints pointing at inaccessible memory to still be created; otherwise, throw the @@ -221,7 +221,6 @@ fetch_subexp_value (struct expression *exp, int *pc, struct value **valp, break; } } - END_CATCH new_mark = value_mark (); if (mark == new_mark) @@ -238,15 +237,14 @@ fetch_subexp_value (struct expression *exp, int *pc, struct value **valp, else { - TRY + try { value_fetch_lazy (result); *valp = result; } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { } - END_CATCH } } @@ -716,19 +714,18 @@ evaluate_var_value (enum noside noside, const block *blk, symbol *var) struct value *ret = NULL; - TRY + try { ret = value_of_variable (var, blk); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { if (noside != EVAL_AVOID_SIDE_EFFECTS) throw_exception (except); ret = value_zero (SYMBOL_TYPE (var), not_lval); } - END_CATCH return ret; } @@ -957,19 +954,18 @@ evaluate_funcall (type *expect_type, expression *exp, int *pos, while (unop_user_defined_p (op, arg2)) { struct value *value = NULL; - TRY + try { value = value_x_unop (arg2, op, noside); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { if (except.error == NOT_FOUND_ERROR) break; else throw_exception (except); } - END_CATCH arg2 = value; } @@ -2047,19 +2043,18 @@ evaluate_subexp_standard (struct type *expect_type, while (unop_user_defined_p (op, arg1)) { struct value *value = NULL; - TRY + try { value = value_x_unop (arg1, op, noside); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { if (except.error == NOT_FOUND_ERROR) break; else throw_exception (except); } - END_CATCH arg1 = value; } diff --git a/gdb/event-loop.c b/gdb/event-loop.c index 28e8164..0219578 100644 --- a/gdb/event-loop.c +++ b/gdb/event-loop.c @@ -366,11 +366,11 @@ start_event_loop (void) { int result = 0; - TRY + try { result = gdb_do_one_event (); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { exception_print (gdb_stderr, ex); @@ -394,7 +394,6 @@ start_event_loop (void) /* Maybe better to set a flag to be checked somewhere as to whether display the prompt or not. */ } - END_CATCH if (result < 0) break; diff --git a/gdb/event-top.c b/gdb/event-top.c index fb5d51c..2d6dda3 100644 --- a/gdb/event-top.c +++ b/gdb/event-top.c @@ -208,15 +208,14 @@ gdb_rl_callback_handler (char *rl) noexcept struct gdb_exception gdb_rl_expt = exception_none; struct ui *ui = current_ui; - TRY + try { ui->input_handler (gdb::unique_xmalloc_ptr (rl)); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { gdb_rl_expt = ex; } - END_CATCH /* If we caught a GDB exception, longjmp out of the readline callback. There's no other way for the callback to signal to @@ -1082,27 +1081,25 @@ static void async_disconnect (gdb_client_data arg) { - TRY + try { quit_cover (); } - CATCH (exception, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &exception) { fputs_filtered ("Could not kill the program being debugged", gdb_stderr); exception_print (gdb_stderr, exception); } - END_CATCH - TRY + try { pop_all_targets (); } - CATCH (exception, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &exception) { } - END_CATCH signal (SIGHUP, SIG_DFL); /*FIXME: ??????????? */ raise (SIGHUP); diff --git a/gdb/exec.c b/gdb/exec.c index 3f30922..6a9f919 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -161,33 +161,31 @@ try_open_exec_file (const char *exec_file_host, struct inferior *inf, Even without a symbol file, the remote-based debugging session should continue normally instead of ending abruptly. Hence we catch thrown errors/exceptions in the following code. */ - TRY + try { /* We must do this step even if exec_file_host is NULL, so that exec_file_attach will clear state. */ exec_file_attach (exec_file_host, add_flags & SYMFILE_VERBOSE); } - CATCH (err, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &err) { if (err.message != NULL) warning ("%s", err.what ()); prev_err = err; } - END_CATCH if (exec_file_host != NULL) { - TRY + try { symbol_file_add_main (exec_file_host, add_flags); } - CATCH (err, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &err) { if (!exception_print_same (prev_err, err)) warning ("%s", err.what ()); } - END_CATCH } } diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index 8eb8062..8d9dd16 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -407,18 +407,17 @@ info_common_command_for_block (const struct block *block, const char *comname, printf_filtered ("%s = ", SYMBOL_PRINT_NAME (common->contents[index])); - TRY + try { val = value_of_variable (common->contents[index], block); value_print (val, gdb_stdout, &opts); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { printf_filtered ("", except.what ()); } - END_CATCH putchar_filtered ('\n'); } diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c index cd207d8..4c5daca 100644 --- a/gdb/fbsd-tdep.c +++ b/gdb/fbsd-tdep.c @@ -746,15 +746,14 @@ fbsd_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size) } /* Thread register information. */ - TRY + try { update_thread_list (); } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { exception_print (gdb_stderr, e); } - END_CATCH /* Like the kernel, prefer dumping the signalled thread first. "First thread" is what tools use to infer the signalled thread. @@ -1985,7 +1984,7 @@ fbsd_read_integer_by_name (struct gdbarch *gdbarch, const char *name) static void fbsd_fetch_rtld_offsets (struct gdbarch *gdbarch, struct fbsd_pspace_data *data) { - TRY + try { /* Fetch offsets from debug symbols in rtld. */ struct symbol *obj_entry_sym @@ -2000,13 +1999,12 @@ fbsd_fetch_rtld_offsets (struct gdbarch *gdbarch, struct fbsd_pspace_data *data) data->rtld_offsets_valid = true; return; } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { data->off_linkmap = -1; } - END_CATCH - TRY + try { /* Fetch offsets from global variables in libthr. Note that this does not work for single-threaded processes that are not @@ -2018,11 +2016,10 @@ fbsd_fetch_rtld_offsets (struct gdbarch *gdbarch, struct fbsd_pspace_data *data) data->rtld_offsets_valid = true; return; } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { data->off_linkmap = -1; } - END_CATCH } /* Helper function to read the TLS index of an object file associated diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c index e5ddeba..18e1579 100644 --- a/gdb/frame-unwind.c +++ b/gdb/frame-unwind.c @@ -101,11 +101,11 @@ frame_unwind_try_unwinder (struct frame_info *this_frame, void **this_cache, frame_prepare_for_sniffer (this_frame, unwinder); - TRY + try { res = unwinder->sniffer (unwinder, this_frame, this_cache); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { /* Catch all exceptions, caused by either interrupt or error. Reset *THIS_CACHE. */ @@ -122,7 +122,6 @@ frame_unwind_try_unwinder (struct frame_info *this_frame, void **this_cache, } throw_exception (ex); } - END_CATCH if (res) return 1; diff --git a/gdb/frame.c b/gdb/frame.c index b71cd6f..1fe465a 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -894,12 +894,12 @@ frame_unwind_pc (struct frame_info *this_frame) different ways that a PC could be unwound. */ prev_gdbarch = frame_unwind_arch (this_frame); - TRY + try { pc = gdbarch_unwind_pc (prev_gdbarch, this_frame); pc_p = 1; } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (ex.error == NOT_AVAILABLE_ERROR) { @@ -924,7 +924,6 @@ frame_unwind_pc (struct frame_info *this_frame) else throw_exception (ex); } - END_CATCH if (pc_p) { @@ -1894,7 +1893,7 @@ get_prev_frame_if_no_cycle (struct frame_info *this_frame) if (prev_frame->level == 0) return prev_frame; - TRY + try { compute_frame_id (prev_frame); if (!frame_stash_add (prev_frame)) @@ -1914,14 +1913,13 @@ get_prev_frame_if_no_cycle (struct frame_info *this_frame) prev_frame = NULL; } } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { prev_frame->next = NULL; this_frame->prev = NULL; throw_exception (ex); } - END_CATCH return prev_frame; } @@ -2092,11 +2090,11 @@ get_prev_frame_always (struct frame_info *this_frame) { struct frame_info *prev_frame = NULL; - TRY + try { prev_frame = get_prev_frame_always_1 (this_frame); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (ex.error == MEMORY_ERROR) { @@ -2120,7 +2118,6 @@ get_prev_frame_always (struct frame_info *this_frame) else throw_exception (ex); } - END_CATCH return prev_frame; } @@ -2379,18 +2376,17 @@ get_frame_pc_if_available (struct frame_info *frame, CORE_ADDR *pc) gdb_assert (frame->next != NULL); - TRY + try { *pc = frame_unwind_pc (frame->next); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (ex.error == NOT_AVAILABLE_ERROR) return 0; else throw_exception (ex); } - END_CATCH return 1; } @@ -2462,17 +2458,16 @@ get_frame_address_in_block_if_available (struct frame_info *this_frame, CORE_ADDR *pc) { - TRY + try { *pc = get_frame_address_in_block (this_frame); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (ex.error == NOT_AVAILABLE_ERROR) return 0; throw_exception (ex); } - END_CATCH return 1; } @@ -2747,17 +2742,16 @@ get_frame_language (struct frame_info *frame) a PC that is guaranteed to be inside the frame's code block. */ - TRY + try { pc = get_frame_address_in_block (frame); pc_p = 1; } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (ex.error != NOT_AVAILABLE_ERROR) throw_exception (ex); } - END_CATCH if (pc_p) { diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index f0923a6..00312e6 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,5 +1,11 @@ 2019-04-08 Tom Tromey + * server.c: Use C++ exception handling. + * linux-low.c: Use C++ exception handling. + * gdbreplay.c: Use C++ exception handling. + +2019-04-08 Tom Tromey + * server.c (handle_btrace_general_set, handle_qxfer_btrace) (handle_qxfer_btrace_conf, detach_or_kill_for_exit_cleanup) (captured_main, main): Update. diff --git a/gdb/gdbserver/gdbreplay.c b/gdb/gdbserver/gdbreplay.c index 1acd24b..bf566ab 100644 --- a/gdb/gdbserver/gdbreplay.c +++ b/gdb/gdbserver/gdbreplay.c @@ -528,11 +528,11 @@ captured_main (int argc, char *argv[]) int main (int argc, char *argv[]) { - TRY + try { captured_main (argc, argv); } - CATCH (exception, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &exception) { if (exception.reason == RETURN_ERROR) { @@ -542,7 +542,6 @@ main (int argc, char *argv[]) exit (1); } - END_CATCH gdb_assert_not_reached ("captured_main should never return"); } diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 65919c3..6ca79d5 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -1531,7 +1531,7 @@ linux_detach_one_lwp (struct lwp_info *lwp) /* Preparing to resume may try to write registers, and fail if the lwp is zombie. If that happens, ignore the error. We'll handle it below, when detach fails with ESRCH. */ - TRY + try { /* Flush any pending changes to the process's registers. */ regcache_invalidate_thread (thread); @@ -1540,12 +1540,11 @@ linux_detach_one_lwp (struct lwp_info *lwp) if (the_low_target.prepare_to_resume != NULL) the_low_target.prepare_to_resume (lwp); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (!check_ptrace_stopped_lwp_gone (lwp)) throw_exception (ex); } - END_CATCH lwpid = lwpid_of (thread); if (ptrace (PTRACE_DETACH, lwpid, (PTRACE_TYPE_ARG3) 0, @@ -4508,16 +4507,15 @@ static void linux_resume_one_lwp (struct lwp_info *lwp, int step, int signal, siginfo_t *info) { - TRY + try { linux_resume_one_lwp_throw (lwp, step, signal, info); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (!check_ptrace_stopped_lwp_gone (lwp)) throw_exception (ex); } - END_CATCH } /* This function is called once per thread via for_each_thread. diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index 0f4341c..99ce21e 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -459,7 +459,7 @@ handle_btrace_general_set (char *own_buf) return -1; } - TRY + try { if (strcmp (op, "bts") == 0) handle_btrace_enable_bts (thread); @@ -472,11 +472,10 @@ handle_btrace_general_set (char *own_buf) write_ok (own_buf); } - CATCH (exception, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &exception) { sprintf (own_buf, "E.%s", exception.what ()); } - END_CATCH return 1; } @@ -1876,18 +1875,17 @@ handle_qxfer_btrace (const char *annex, { buffer_free (&cache); - TRY + try { result = target_read_btrace (thread->btrace, &cache, type); if (result != 0) memcpy (cs.own_buf, cache.buffer, cache.used_size); } - CATCH (exception, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &exception) { sprintf (cs.own_buf, "E.%s", exception.what ()); result = -1; } - END_CATCH if (result != 0) return -3; @@ -1948,18 +1946,17 @@ handle_qxfer_btrace_conf (const char *annex, { buffer_free (&cache); - TRY + try { result = target_read_btrace_conf (thread->btrace, &cache); if (result != 0) memcpy (cs.own_buf, cache.buffer, cache.used_size); } - CATCH (exception, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &exception) { sprintf (cs.own_buf, "E.%s", exception.what ()); result = -1; } - END_CATCH if (result != 0) return -3; @@ -3552,18 +3549,17 @@ static int exit_code; static void detach_or_kill_for_exit_cleanup () { - TRY + try { detach_or_kill_for_exit (); } - CATCH (exception, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &exception) { fflush (stdout); fprintf (stderr, "Detach or kill failed: %s\n", exception.what ()); exit_code = 1; } - END_CATCH } /* Main function. This is called by the real "main" function, @@ -3866,7 +3862,7 @@ captured_main (int argc, char *argv[]) remote_open (port); - TRY + try { /* Wait for events. This will return when all event sources are removed from the event loop. */ @@ -3931,7 +3927,7 @@ captured_main (int argc, char *argv[]) } } } - CATCH (exception, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &exception) { fflush (stdout); fprintf (stderr, "gdbserver: %s\n", exception.what ()); @@ -3945,7 +3941,6 @@ captured_main (int argc, char *argv[]) if (run_once) throw_quit ("Quit"); } - END_CATCH } } @@ -3955,11 +3950,11 @@ int main (int argc, char *argv[]) { - TRY + try { captured_main (argc, argv); } - CATCH (exception, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &exception) { if (exception.reason == RETURN_ERROR) { @@ -3971,7 +3966,6 @@ main (int argc, char *argv[]) exit (exit_code); } - END_CATCH gdb_assert_not_reached ("captured_main should never return"); } diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index b1a5137..373b30a 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -2571,15 +2571,14 @@ safe_parse_type (struct gdbarch *gdbarch, char *p, int length) gdb_stderr = &null_stream; /* Call parse_and_eval_type() without fear of longjmp()s. */ - TRY + try { type = parse_and_eval_type (p, length); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { type = builtin_type (gdbarch)->builtin_void; } - END_CATCH /* Stop suppressing error messages. */ gdb_stderr = saved_gdb_stderr; diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index 786f416..01bb82b 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -906,16 +906,15 @@ print_one_vtable (struct gdbarch *gdbarch, struct value *value, if (gdbarch_vtable_function_descriptors (gdbarch)) vfn = value_addr (vfn); - TRY + try { addr = value_as_address (vfn); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { printf_filtered (_(""), ex.what ()); got_error = 1; } - END_CATCH if (!got_error) print_function_pointer_address (opts, gdbarch, addr, gdb_stdout); diff --git a/gdb/guile/guile-internal.h b/gdb/guile/guile-internal.h index d05f468..0a24325 100644 --- a/gdb/guile/guile-internal.h +++ b/gdb/guile/guile-internal.h @@ -677,15 +677,14 @@ gdbscm_wrap (Function &&func, Args &&... args) { SCM result = SCM_BOOL_F; - TRY + try { result = func (std::forward (args)...); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH if (gdbscm_is_exception (result)) gdbscm_throw (result); diff --git a/gdb/guile/scm-block.c b/gdb/guile/scm-block.c index df1dfe5..6f91f88 100644 --- a/gdb/guile/scm-block.c +++ b/gdb/guile/scm-block.c @@ -680,18 +680,17 @@ gdbscm_lookup_block (SCM pc_scm) gdbscm_parse_function_args (FUNC_NAME, SCM_ARG1, NULL, "U", pc_scm, &pc); - TRY + try { cust = find_pc_compunit_symtab (pc); if (cust != NULL && COMPUNIT_OBJFILE (cust) != NULL) block = block_for_pc (pc); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH if (cust == NULL || COMPUNIT_OBJFILE (cust) == NULL) { diff --git a/gdb/guile/scm-breakpoint.c b/gdb/guile/scm-breakpoint.c index d052748..356abca 100644 --- a/gdb/guile/scm-breakpoint.c +++ b/gdb/guile/scm-breakpoint.c @@ -429,7 +429,7 @@ gdbscm_register_breakpoint_x (SCM self) current_language, symbol_name_match_type::WILD); - TRY + try { int internal = bp_smob->spec.is_internal; @@ -465,11 +465,10 @@ gdbscm_register_breakpoint_x (SCM self) gdb_assert_not_reached ("invalid breakpoint type"); } } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { except = ex; } - END_CATCH /* Ensure this gets reset, even if there's an error. */ pending_breakpoint_scm = SCM_BOOL_F; @@ -490,15 +489,14 @@ gdbscm_delete_breakpoint_x (SCM self) breakpoint_smob *bp_smob = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - TRY + try { delete_breakpoint (bp_smob->bp); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH return SCM_UNSPECIFIED; } @@ -588,18 +586,17 @@ gdbscm_set_breakpoint_enabled_x (SCM self, SCM newvalue) SCM_ASSERT_TYPE (gdbscm_is_bool (newvalue), newvalue, SCM_ARG2, FUNC_NAME, _("boolean")); - TRY + try { if (gdbscm_is_true (newvalue)) enable_breakpoint (bp_smob->bp); else disable_breakpoint (bp_smob->bp); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH return SCM_UNSPECIFIED; } @@ -626,15 +623,14 @@ gdbscm_set_breakpoint_silent_x (SCM self, SCM newvalue) SCM_ASSERT_TYPE (gdbscm_is_bool (newvalue), newvalue, SCM_ARG2, FUNC_NAME, _("boolean")); - TRY + try { breakpoint_set_silent (bp_smob->bp, gdbscm_is_true (newvalue)); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH return SCM_UNSPECIFIED; } @@ -667,15 +663,14 @@ gdbscm_set_breakpoint_ignore_count_x (SCM self, SCM newvalue) if (value < 0) value = 0; - TRY + try { set_ignore_count (bp_smob->number, (int) value, 0); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH return SCM_UNSPECIFIED; } @@ -788,15 +783,14 @@ gdbscm_set_breakpoint_task_x (SCM self, SCM newvalue) { id = scm_to_long (newvalue); - TRY + try { valid_id = valid_task_id (id); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH if (! valid_id) { @@ -809,15 +803,14 @@ gdbscm_set_breakpoint_task_x (SCM self, SCM newvalue) else SCM_ASSERT_TYPE (0, newvalue, SCM_ARG2, FUNC_NAME, _("integer or #f")); - TRY + try { breakpoint_set_task (bp_smob->bp, id); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH return SCM_UNSPECIFIED; } @@ -975,16 +968,15 @@ gdbscm_breakpoint_commands (SCM self) string_file buf; current_uiout->redirect (&buf); - TRY + try { print_command_lines (current_uiout, breakpoint_commands (bp), 0); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { current_uiout->redirect (NULL); gdbscm_throw_gdb_exception (except); } - END_CATCH current_uiout->redirect (NULL); result = gdbscm_scm_from_c_string (buf.c_str ()); diff --git a/gdb/guile/scm-cmd.c b/gdb/guile/scm-cmd.c index 1266a79..a89650b 100644 --- a/gdb/guile/scm-cmd.c +++ b/gdb/guile/scm-cmd.c @@ -758,7 +758,7 @@ gdbscm_register_command_x (SCM self) c_smob->cmd_name = gdbscm_gc_xstrdup (cmd_name); xfree (cmd_name); - TRY + try { if (c_smob->is_prefix) { @@ -776,11 +776,10 @@ gdbscm_register_command_x (SCM self) c_smob->doc, cmd_list); } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH /* Note: At this point the command exists in gdb. So no more errors after this point. */ diff --git a/gdb/guile/scm-disasm.c b/gdb/guile/scm-disasm.c index e4a9c92..584de37 100644 --- a/gdb/guile/scm-disasm.c +++ b/gdb/guile/scm-disasm.c @@ -247,7 +247,7 @@ gdbscm_arch_disassemble (SCM self, SCM start_scm, SCM rest) int insn_len = 0; string_file buf; - TRY + try { if (using_port) { @@ -257,11 +257,10 @@ gdbscm_arch_disassemble (SCM self, SCM start_scm, SCM rest) else insn_len = gdb_print_insn (gdbarch, pc, &buf, NULL); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH result = scm_cons (dascm_make_insn (pc, buf.c_str (), insn_len), result); diff --git a/gdb/guile/scm-frame.c b/gdb/guile/scm-frame.c index 22c7892..9360bb9 100644 --- a/gdb/guile/scm-frame.c +++ b/gdb/guile/scm-frame.c @@ -229,7 +229,7 @@ frscm_scm_from_frame (struct frame_info *frame, struct inferior *inferior) if (*slot != NULL) return (*slot)->containing_scm; - TRY + try { /* Try to get the previous frame, to determine if this is the last frame in a corrupt stack. If so, we need to store the frame_id of the next @@ -248,11 +248,10 @@ frscm_scm_from_frame (struct frame_info *frame, struct inferior *inferior) } gdbarch = get_frame_arch (frame); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { return gdbscm_scm_from_gdb_exception (except); } - END_CATCH f_scm = frscm_make_frame_smob (); f_smob = (frame_smob *) SCM_SMOB_DATA (f_scm); @@ -397,15 +396,14 @@ gdbscm_frame_valid_p (SCM self) f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - TRY + try { frame = frscm_frame_smob_to_frame (f_smob); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH return scm_from_bool (frame != NULL); } @@ -425,17 +423,16 @@ gdbscm_frame_name (SCM self) f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - TRY + try { frame = frscm_frame_smob_to_frame (f_smob); if (frame != NULL) name = find_frame_funname (frame, &lang, NULL); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH if (frame == NULL) { @@ -463,17 +460,16 @@ gdbscm_frame_type (SCM self) f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - TRY + try { frame = frscm_frame_smob_to_frame (f_smob); if (frame != NULL) type = get_frame_type (frame); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH if (frame == NULL) { @@ -495,15 +491,14 @@ gdbscm_frame_arch (SCM self) f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - TRY + try { frame = frscm_frame_smob_to_frame (f_smob); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH if (frame == NULL) { @@ -526,15 +521,14 @@ gdbscm_frame_unwind_stop_reason (SCM self) f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - TRY + try { frame = frscm_frame_smob_to_frame (f_smob); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH if (frame == NULL) { @@ -559,17 +553,16 @@ gdbscm_frame_pc (SCM self) f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - TRY + try { frame = frscm_frame_smob_to_frame (f_smob); if (frame != NULL) pc = get_frame_pc (frame); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH if (frame == NULL) { @@ -592,17 +585,16 @@ gdbscm_frame_block (SCM self) f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - TRY + try { frame = frscm_frame_smob_to_frame (f_smob); if (frame != NULL) block = get_frame_block (frame, NULL); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH if (frame == NULL) { @@ -643,17 +635,16 @@ gdbscm_frame_function (SCM self) f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - TRY + try { frame = frscm_frame_smob_to_frame (f_smob); if (frame != NULL) sym = find_pc_function (get_frame_address_in_block (frame)); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH if (frame == NULL) { @@ -680,17 +671,16 @@ gdbscm_frame_older (SCM self) f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - TRY + try { frame = frscm_frame_smob_to_frame (f_smob); if (frame != NULL) prev = get_prev_frame (frame); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH if (frame == NULL) { @@ -717,17 +707,16 @@ gdbscm_frame_newer (SCM self) f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - TRY + try { frame = frscm_frame_smob_to_frame (f_smob); if (frame != NULL) next = get_next_frame (frame); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH if (frame == NULL) { @@ -753,17 +742,16 @@ gdbscm_frame_sal (SCM self) f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - TRY + try { frame = frscm_frame_smob_to_frame (f_smob); if (frame != NULL) sal = find_frame_sal (frame); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH if (frame == NULL) { @@ -791,7 +779,7 @@ gdbscm_frame_read_register (SCM self, SCM register_scm) struct gdb_exception except = exception_none; - TRY + try { int regnum; @@ -805,11 +793,10 @@ gdbscm_frame_read_register (SCM self, SCM register_scm) value = value_of_register (regnum, frame); } } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { except = ex; } - END_CATCH xfree (register_str); GDBSCM_HANDLE_GDB_EXCEPTION (except); @@ -851,15 +838,14 @@ gdbscm_frame_read_var (SCM self, SCM symbol_scm, SCM rest) f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - TRY + try { frame = frscm_frame_smob_to_frame (f_smob); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH if (frame == NULL) { @@ -897,7 +883,7 @@ gdbscm_frame_read_var (SCM self, SCM symbol_scm, SCM rest) /* N.B. Between here and the end of the scope, don't do anything to cause a Scheme exception. */ - TRY + try { struct block_symbol lookup_sym; @@ -908,11 +894,10 @@ gdbscm_frame_read_var (SCM self, SCM symbol_scm, SCM rest) var = lookup_sym.symbol; block = lookup_sym.block; } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { except = ex; } - END_CATCH } GDBSCM_HANDLE_GDB_EXCEPTION (except); @@ -928,15 +913,14 @@ gdbscm_frame_read_var (SCM self, SCM symbol_scm, SCM rest) _("gdb:symbol or string")); } - TRY + try { value = read_var_value (var, block, frame); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH return vlscm_scm_from_value (value); } @@ -952,17 +936,16 @@ gdbscm_frame_select (SCM self) f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - TRY + try { frame = frscm_frame_smob_to_frame (f_smob); if (frame != NULL) select_frame (frame); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH if (frame == NULL) { @@ -981,15 +964,14 @@ gdbscm_newest_frame (void) { struct frame_info *frame = NULL; - TRY + try { frame = get_current_frame (); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH return frscm_scm_from_frame_unsafe (frame, current_inferior ()); } @@ -1002,15 +984,14 @@ gdbscm_selected_frame (void) { struct frame_info *frame = NULL; - TRY + try { frame = get_selected_frame (_("No frame is currently selected")); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH return frscm_scm_from_frame_unsafe (frame, current_inferior ()); } diff --git a/gdb/guile/scm-lazy-string.c b/gdb/guile/scm-lazy-string.c index a874e68..5dd386a 100644 --- a/gdb/guile/scm-lazy-string.c +++ b/gdb/guile/scm-lazy-string.c @@ -309,7 +309,7 @@ lsscm_safe_lazy_string_to_value (SCM string, int arg_pos, return NULL; } - TRY + try { struct type *type = tyscm_scm_to_type (ls_smob->type); struct type *realtype = check_typedef (type); @@ -336,12 +336,11 @@ lsscm_safe_lazy_string_to_value (SCM string, int arg_pos, break; } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { *except_scmp = gdbscm_scm_from_gdb_exception (except); return NULL; } - END_CATCH return value; } diff --git a/gdb/guile/scm-math.c b/gdb/guile/scm-math.c index d351ed0..3be9fb6 100644 --- a/gdb/guile/scm-math.c +++ b/gdb/guile/scm-math.c @@ -723,7 +723,7 @@ vlscm_convert_typed_value_from_scheme (const char *func_name, *except_scmp = SCM_BOOL_F; - TRY + try { if (vlscm_is_value (obj)) { @@ -824,11 +824,10 @@ vlscm_convert_typed_value_from_scheme (const char *func_name, value = NULL; } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { except_scm = gdbscm_scm_from_gdb_exception (except); } - END_CATCH if (gdbscm_is_true (except_scm)) { diff --git a/gdb/guile/scm-param.c b/gdb/guile/scm-param.c index 69bc97e..ee29712 100644 --- a/gdb/guile/scm-param.c +++ b/gdb/guile/scm-param.c @@ -1006,7 +1006,7 @@ gdbscm_register_parameter_x (SCM self) _("parameter exists, \"show\" command is already defined")); } - TRY + try { add_setshow_generic (p_smob->type, p_smob->cmd_class, p_smob->cmd_name, p_smob, @@ -1018,11 +1018,10 @@ gdbscm_register_parameter_x (SCM self) set_list, show_list, &p_smob->set_command, &p_smob->show_command); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH /* Note: At this point the parameter exists in gdb. So no more errors after this point. */ @@ -1064,15 +1063,14 @@ gdbscm_parameter_value (SCM self) if (name == NULL) gdbscm_throw (except_scm); newarg = concat ("show ", name.get (), (char *) NULL); - TRY + try { found = lookup_cmd_composition (newarg, &alias, &prefix, &cmd); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { except = ex; } - END_CATCH xfree (newarg); GDBSCM_HANDLE_GDB_EXCEPTION (except); diff --git a/gdb/guile/scm-ports.c b/gdb/guile/scm-ports.c index 2950b1e..20557f8 100644 --- a/gdb/guile/scm-ports.c +++ b/gdb/guile/scm-ports.c @@ -272,18 +272,17 @@ ioscm_write (SCM port, const void *data, size_t size) if (scm_is_eq (port, input_port_scm)) return; - TRY + try { if (scm_is_eq (port, error_port_scm)) fputsn_filtered ((const char *) data, size, gdb_stderr); else fputsn_filtered ((const char *) data, size, gdb_stdout); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH } /* Flush gdb's stdout or stderr. */ diff --git a/gdb/guile/scm-pretty-print.c b/gdb/guile/scm-pretty-print.c index e509694..6706f82 100644 --- a/gdb/guile/scm-pretty-print.c +++ b/gdb/guile/scm-pretty-print.c @@ -524,7 +524,7 @@ ppscm_pretty_print_one_value (SCM printer, struct value **out_value, SCM result = SCM_BOOL_F; *out_value = NULL; - TRY + try { pretty_printer_worker_smob *w_smob = (pretty_printer_worker_smob *) SCM_SMOB_DATA (printer); @@ -558,10 +558,9 @@ ppscm_pretty_print_one_value (SCM printer, struct value **out_value, (_("invalid result from pretty-printer to-string"), result); } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { } - END_CATCH return result; } diff --git a/gdb/guile/scm-symbol.c b/gdb/guile/scm-symbol.c index de3a158..65eb101 100644 --- a/gdb/guile/scm-symbol.c +++ b/gdb/guile/scm-symbol.c @@ -486,15 +486,14 @@ gdbscm_symbol_needs_frame_p (SCM self) struct symbol *symbol = s_smob->symbol; int result = 0; - TRY + try { result = symbol_read_needs_frame (symbol); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH return scm_from_bool (result); } @@ -539,7 +538,7 @@ gdbscm_symbol_value (SCM self, SCM rest) _("cannot get the value of a typedef")); } - TRY + try { if (f_smob != NULL) { @@ -557,11 +556,10 @@ gdbscm_symbol_value (SCM self, SCM rest) can happen with nested functions). */ value = read_var_value (symbol, NULL, frame_info); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH return vlscm_scm_from_value (value); } @@ -604,30 +602,28 @@ gdbscm_lookup_symbol (SCM name_scm, SCM rest) { struct frame_info *selected_frame; - TRY + try { selected_frame = get_selected_frame (_("no frame selected")); block = get_frame_block (selected_frame, NULL); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { xfree (name); GDBSCM_HANDLE_GDB_EXCEPTION (ex); } - END_CATCH } struct gdb_exception except = exception_none; - TRY + try { symbol = lookup_symbol (name, block, (domain_enum) domain, &is_a_field_of_this).symbol; } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { except = ex; } - END_CATCH xfree (name); GDBSCM_HANDLE_GDB_EXCEPTION (except); @@ -656,15 +652,14 @@ gdbscm_lookup_global_symbol (SCM name_scm, SCM rest) name_scm, &name, rest, &domain_arg_pos, &domain); - TRY + try { symbol = lookup_global_symbol (name, NULL, (domain_enum) domain).symbol; } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { except = ex; } - END_CATCH xfree (name); GDBSCM_HANDLE_GDB_EXCEPTION (except); diff --git a/gdb/guile/scm-symtab.c b/gdb/guile/scm-symtab.c index 5ba7755..8879c32 100644 --- a/gdb/guile/scm-symtab.c +++ b/gdb/guile/scm-symtab.c @@ -591,17 +591,16 @@ gdbscm_find_pc_line (SCM pc_scm) gdbscm_parse_function_args (FUNC_NAME, SCM_ARG1, NULL, "U", pc_scm, &pc_ull); - TRY + try { CORE_ADDR pc = (CORE_ADDR) pc_ull; sal = find_pc_line (pc, 0); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH return stscm_scm_from_sal (sal); } diff --git a/gdb/guile/scm-type.c b/gdb/guile/scm-type.c index 2d2e3dd..ee0bfa7 100644 --- a/gdb/guile/scm-type.c +++ b/gdb/guile/scm-type.c @@ -105,19 +105,18 @@ tyscm_type_smob_type (type_smob *t_smob) static std::string tyscm_type_name (struct type *type) { - TRY + try { string_file stb; LA_PRINT_TYPE (type, "", &stb, -1, 0, &type_print_raw_options); return std::move (stb.string ()); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { SCM excp = gdbscm_scm_from_gdb_exception (except); gdbscm_throw (excp); } - END_CATCH gdb_assert_not_reached ("no way to get here"); } @@ -235,15 +234,14 @@ tyscm_equal_p_type_smob (SCM type1_scm, SCM type2_scm) type1 = type1_smob->type; type2 = type2_smob->type; - TRY + try { result = types_deeply_equal (type1, type2); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH return scm_from_bool (result); } @@ -629,14 +627,13 @@ gdbscm_type_sizeof (SCM self) = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); struct type *type = t_smob->type; - TRY + try { check_typedef (type); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { } - END_CATCH /* Ignore exceptions. */ @@ -653,15 +650,14 @@ gdbscm_type_strip_typedefs (SCM self) = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); struct type *type = t_smob->type; - TRY + try { type = check_typedef (type); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH return tyscm_scm_from_type (type); } @@ -675,15 +671,14 @@ tyscm_get_composite (struct type *type) for (;;) { - TRY + try { type = check_typedef (type); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH if (TYPE_CODE (type) != TYPE_CODE_PTR && TYPE_CODE (type) != TYPE_CODE_REF) @@ -730,17 +725,16 @@ tyscm_array_1 (SCM self, SCM n1_scm, SCM n2_scm, int is_vector, _("Array length must not be negative")); } - TRY + try { array = lookup_array_range_type (type, n1, n2); if (is_vector) make_vector_type (array); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH return tyscm_scm_from_type (array); } @@ -787,15 +781,14 @@ gdbscm_type_pointer (SCM self) = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); struct type *type = t_smob->type; - TRY + try { type = lookup_pointer_type (type); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH return tyscm_scm_from_type (type); } @@ -849,15 +842,14 @@ gdbscm_type_reference (SCM self) = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); struct type *type = t_smob->type; - TRY + try { type = lookup_lvalue_reference_type (type); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH return tyscm_scm_from_type (type); } @@ -887,15 +879,14 @@ gdbscm_type_const (SCM self) = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); struct type *type = t_smob->type; - TRY + try { type = make_cv_type (1, 0, type, NULL); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH return tyscm_scm_from_type (type); } @@ -910,15 +901,14 @@ gdbscm_type_volatile (SCM self) = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); struct type *type = t_smob->type; - TRY + try { type = make_cv_type (0, 1, type, NULL); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH return tyscm_scm_from_type (type); } @@ -933,15 +923,14 @@ gdbscm_type_unqualified (SCM self) = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); struct type *type = t_smob->type; - TRY + try { type = make_cv_type (0, 0, type, NULL); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH return tyscm_scm_from_type (type); } @@ -1230,7 +1219,7 @@ tyscm_lookup_typename (const char *type_name, const struct block *block) { struct type *type = NULL; - TRY + try { if (startswith (type_name, "struct ")) type = lookup_struct (type_name + 7, NULL); @@ -1242,11 +1231,10 @@ tyscm_lookup_typename (const char *type_name, const struct block *block) type = lookup_typename (current_language, get_current_arch (), type_name, block, 0); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { return NULL; } - END_CATCH return type; } diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c index 658924b..7f119a2 100644 --- a/gdb/guile/scm-value.c +++ b/gdb/guile/scm-value.c @@ -156,18 +156,17 @@ vlscm_print_value_smob (SCM self, SCM port, scm_print_state *pstate) instead of writingp. */ opts.raw = !!pstate->writingp; - TRY + try { string_file stb; common_val_print (v_smob->value, &stb, 0, &opts, current_language); scm_puts (stb.c_str (), port); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH if (pstate->writingp) scm_puts (">", port); @@ -187,15 +186,14 @@ vlscm_equal_p_value_smob (SCM v1, SCM v2) const value_smob *v2_smob = (value_smob *) SCM_SMOB_DATA (v2); int result = 0; - TRY + try { result = value_equal (v1_smob->value, v2_smob->value); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH return scm_from_bool (result); } @@ -392,14 +390,13 @@ gdbscm_value_address (SCM self) SCM address = SCM_BOOL_F; - TRY + try { address = vlscm_scm_from_value (value_addr (value)); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { } - END_CATCH if (gdbscm_is_exception (address)) return address; @@ -496,7 +493,7 @@ gdbscm_value_dynamic_type (SCM self) if (! SCM_UNBNDP (v_smob->dynamic_type)) return v_smob->dynamic_type; - TRY + try { scoped_value_mark free_values; @@ -532,11 +529,10 @@ gdbscm_value_dynamic_type (SCM self) type = NULL; } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH if (type == NULL) v_smob->dynamic_type = gdbscm_value_type (self); @@ -684,15 +680,14 @@ gdbscm_value_call (SCM self, SCM args) long args_count; struct value **vargs = NULL; - TRY + try { ftype = check_typedef (value_type (function)); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH SCM_ASSERT_TYPE (TYPE_CODE (ftype) == TYPE_CODE_FUNC, self, SCM_ARG1, FUNC_NAME, @@ -751,17 +746,16 @@ gdbscm_value_to_bytevector (SCM self) type = value_type (value); - TRY + try { type = check_typedef (type); length = TYPE_LENGTH (type); contents = value_contents (value); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH bv = scm_c_make_bytevector (length); memcpy (SCM_BYTEVECTOR_CONTENTS (bv), contents, length); @@ -795,31 +789,29 @@ gdbscm_value_to_bool (SCM self) type = value_type (value); - TRY + try { type = check_typedef (type); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH SCM_ASSERT_TYPE (is_intlike (type, 1), self, SCM_ARG1, FUNC_NAME, _("integer-like gdb value")); - TRY + try { if (TYPE_CODE (type) == TYPE_CODE_PTR) l = value_as_address (value); else l = value_as_long (value); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH return scm_from_bool (l != 0); } @@ -838,31 +830,29 @@ gdbscm_value_to_integer (SCM self) type = value_type (value); - TRY + try { type = check_typedef (type); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH SCM_ASSERT_TYPE (is_intlike (type, 1), self, SCM_ARG1, FUNC_NAME, _("integer-like gdb value")); - TRY + try { if (TYPE_CODE (type) == TYPE_CODE_PTR) l = value_as_address (value); else l = value_as_long (value); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH if (TYPE_UNSIGNED (type)) return gdbscm_scm_from_ulongest (l); @@ -885,20 +875,19 @@ gdbscm_value_to_real (SCM self) type = value_type (value); - TRY + try { type = check_typedef (type); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH SCM_ASSERT_TYPE (is_intlike (type, 0) || TYPE_CODE (type) == TYPE_CODE_FLT, self, SCM_ARG1, FUNC_NAME, _("number")); - TRY + try { if (is_floating_value (value)) { @@ -916,11 +905,10 @@ gdbscm_value_to_real (SCM self) check = value_from_longest (type, (LONGEST) d); } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH /* TODO: Is there a better way to check if the value fits? */ if (!value_equal (value, check)) @@ -1004,18 +992,17 @@ gdbscm_value_to_string (SCM self, SCM rest) /* We don't assume anything about the result of scm_port_conversion_strategy. From this point on, if errors is not 'errors, use 'substitute. */ - TRY + try { gdb::unique_xmalloc_ptr buffer; LA_GET_STRING (value, &buffer, &length, &char_type, &la_encoding); buffer_contents = buffer.release (); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { xfree (encoding); GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH /* If errors is "error", scm_from_stringn may throw a Scheme exception. Make sure we don't leak. This is done via scm_dynwind_begin, et.al. */ @@ -1077,7 +1064,7 @@ gdbscm_value_to_lazy_string (SCM self, SCM rest) _("invalid length")); } - TRY + try { scoped_value_mark free_values; @@ -1132,11 +1119,10 @@ gdbscm_value_to_lazy_string (SCM self, SCM rest) result = lsscm_make_lazy_string (addr, length, encoding, type); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { except = ex; } - END_CATCH xfree (encoding); GDBSCM_HANDLE_GDB_EXCEPTION (except); @@ -1191,15 +1177,14 @@ gdbscm_value_print (SCM self) string_file stb; - TRY + try { common_val_print (value, &stb, 0, &opts, current_language); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDBSCM_HANDLE_GDB_EXCEPTION (except); } - END_CATCH /* Use SCM_FAILED_CONVERSION_QUESTION_MARK to ensure this doesn't throw an error if the encoding fails. diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c index fa6b86f..01bfb2c 100644 --- a/gdb/i386-linux-tdep.c +++ b/gdb/i386-linux-tdep.c @@ -402,7 +402,7 @@ i386_linux_handle_segmentation_fault (struct gdbarch *gdbarch, if (!i386_mpx_enabled ()) return; - TRY + try { /* Sigcode evaluates if the actual segfault is a boundary violation. */ sig_code = parse_and_eval_long ("$_siginfo.si_code\n"); @@ -414,11 +414,10 @@ i386_linux_handle_segmentation_fault (struct gdbarch *gdbarch, access = parse_and_eval_long ("$_siginfo._sifields._sigfault.si_addr"); } - CATCH (exception, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &exception) { return; } - END_CATCH /* If this is not a boundary violation just return. */ if (sig_code != SIG_CODE_BONDARY_FAULT) diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 4e63832..27f2edf 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -2082,16 +2082,15 @@ i386_frame_cache (struct frame_info *this_frame, void **this_cache) cache = i386_alloc_frame_cache (); *this_cache = cache; - TRY + try { i386_frame_cache_1 (this_frame, cache); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (ex.error != NOT_AVAILABLE_ERROR) throw_exception (ex); } - END_CATCH return cache; } @@ -2252,7 +2251,7 @@ i386_epilogue_frame_cache (struct frame_info *this_frame, void **this_cache) cache = i386_alloc_frame_cache (); *this_cache = cache; - TRY + try { cache->pc = get_frame_func (this_frame); @@ -2266,12 +2265,11 @@ i386_epilogue_frame_cache (struct frame_info *this_frame, void **this_cache) cache->base_p = 1; } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (ex.error != NOT_AVAILABLE_ERROR) throw_exception (ex); } - END_CATCH return cache; } @@ -2438,7 +2436,7 @@ i386_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache) cache = i386_alloc_frame_cache (); - TRY + try { get_frame_register (this_frame, I386_ESP_REGNUM, buf); cache->base = extract_unsigned_integer (buf, 4, byte_order) - 4; @@ -2462,12 +2460,11 @@ i386_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache) cache->base_p = 1; } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (ex.error != NOT_AVAILABLE_ERROR) throw_exception (ex); } - END_CATCH *this_cache = cache; return cache; diff --git a/gdb/inf-loop.c b/gdb/inf-loop.c index d0e19d5..0aca863 100644 --- a/gdb/inf-loop.c +++ b/gdb/inf-loop.c @@ -67,11 +67,11 @@ inferior_event_handler (enum inferior_event_type event_type, /* Don't propagate breakpoint commands errors. Either we're stopping or some command resumes the inferior. The user will be informed. */ - TRY + try { bpstat_do_actions (); } - CATCH (e, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &e) { /* If the user was running a foreground execution command, then propagate the error so that the prompt @@ -83,7 +83,6 @@ inferior_event_handler (enum inferior_event_type event_type, else exception_print (gdb_stderr, e); } - END_CATCH } break; diff --git a/gdb/infcall.c b/gdb/infcall.c index 50fae6d..0e5b6aa 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -597,7 +597,7 @@ run_inferior_call (struct call_thread_fsm *sm, /* We want to print return value, please... */ call_thread->control.proceed_to_finish = 1; - TRY + try { proceed (real_pc, GDB_SIGNAL_0); @@ -605,11 +605,10 @@ run_inferior_call (struct call_thread_fsm *sm, target supports asynchronous execution. */ wait_sync_command_done (); } - CATCH (e, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &e) { caught_error = e; } - END_CATCH /* If GDB has the prompt blocked before, then ensure that it remains so. normal_stop calls async_enable_stdin, so reset the prompt diff --git a/gdb/infcmd.c b/gdb/infcmd.c index c5977c4..2b24fae 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -447,16 +447,15 @@ post_create_inferior (struct target_ops *target, int from_tty) thread_info *thr = inferior_thread (); thr->suspend.stop_pc = 0; - TRY + try { thr->suspend.stop_pc = regcache_read_pc (get_current_regcache ()); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (ex.error != NOT_AVAILABLE_ERROR) throw_exception (ex); } - END_CATCH if (exec_bfd) { @@ -1646,18 +1645,17 @@ print_return_value (struct ui_out *uiout, struct return_value_info *rv) || TYPE_CODE (check_typedef (rv->type)) == TYPE_CODE_VOID) return; - TRY + try { /* print_return_value_1 can throw an exception in some circumstances. We need to catch this so that we still delete the breakpoint. */ print_return_value_1 (uiout, rv); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { exception_print (gdb_stdout, ex); } - END_CATCH } /* Data for the FSM that manages the finish command. */ diff --git a/gdb/infrun.c b/gdb/infrun.c index e441281..9bda7fc 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -1776,11 +1776,11 @@ displaced_step_prepare (thread_info *thread) { int prepared = -1; - TRY + try { prepared = displaced_step_prepare_throw (thread); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { struct displaced_step_inferior_state *displaced_state; @@ -1808,7 +1808,6 @@ displaced_step_prepare (thread_info *thread) = get_displaced_stepping_state (thread->inf); displaced_state->failed_before = 1; } - END_CATCH return prepared; } @@ -2612,11 +2611,11 @@ resume_1 (enum gdb_signal sig) static void resume (gdb_signal sig) { - TRY + try { resume_1 (sig); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { /* If resuming is being aborted for any reason, delete any single-step breakpoint resume_1 may have created, to avoid @@ -2627,7 +2626,6 @@ resume (gdb_signal sig) delete_single_step_breakpoints (inferior_thread ()); throw_exception (ex); } - END_CATCH } @@ -7270,7 +7268,7 @@ insert_exception_resume_breakpoint (struct thread_info *tp, struct frame_info *frame, struct symbol *sym) { - TRY + try { struct block_symbol vsym; struct value *value; @@ -7301,11 +7299,10 @@ insert_exception_resume_breakpoint (struct thread_info *tp, inferior_thread ()->control.exception_resume_breakpoint = bp; } } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { /* We want to ignore errors here. */ } - END_CATCH } /* A helper for check_exception_resume that sets an @@ -7364,7 +7361,7 @@ check_exception_resume (struct execution_control_state *ecs, if (!func) return; - TRY + try { const struct block *b; struct block_iterator iter; @@ -7401,10 +7398,9 @@ check_exception_resume (struct execution_control_state *ecs, } } } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { } - END_CATCH } static void @@ -7531,18 +7527,17 @@ keep_going_pass_signal (struct execution_control_state *ecs) stop_all_threads (); /* Stop stepping if inserting breakpoints fails. */ - TRY + try { insert_breakpoints (); } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { exception_print (gdb_stderr, e); stop_waiting (ecs); clear_step_over_info (); return; } - END_CATCH ecs->event_thread->control.trap_expected = (remove_bp || remove_wps); @@ -8064,16 +8059,15 @@ normal_stop (void) { stop_context saved_context; - TRY + try { execute_cmd_pre_hook (stop_command); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { exception_fprintf (gdb_stderr, ex, "Error while running hook_stop:\n"); } - END_CATCH /* If the stop hook resumes the target, then there's no point in trying to notify about the previous stop; its context is @@ -8770,11 +8764,11 @@ restore_infcall_control_state (struct infcall_control_state *inf_status) /* The point of the try/catch is that if the stack is clobbered, walking the stack might encounter a garbage pointer and error() trying to dereference it. */ - TRY + try { restore_selected_frame (inf_status->selected_frame_id); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { exception_fprintf (gdb_stderr, ex, "Unable to restore previously selected frame:\n"); @@ -8782,7 +8776,6 @@ restore_infcall_control_state (struct infcall_control_state *inf_status) innermost frame. */ select_frame (get_current_frame ()); } - END_CATCH } delete inf_status; diff --git a/gdb/jit.c b/gdb/jit.c index 1f87bf2..1b78a93 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -849,17 +849,16 @@ jit_reader_try_read_symtab (struct jit_code_entry *code_entry, gdb_mem = (gdb_byte *) xmalloc (code_entry->symfile_size); status = 1; - TRY + try { if (target_read_memory (code_entry->symfile_addr, gdb_mem, code_entry->symfile_size)) status = 0; } - CATCH (e, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &e) { status = 0; } - END_CATCH if (status) { diff --git a/gdb/language.c b/gdb/language.c index ea294e6..0dc4cb3 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -172,18 +172,17 @@ set_language_command (const char *ignore, /* Enter auto mode. Set to the current frame's language, if known, or fallback to the initial language. */ language_mode = language_mode_auto; - TRY + try { struct frame_info *frame; frame = get_selected_frame (NULL); flang = get_frame_language (frame); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { flang = language_unknown; } - END_CATCH if (flang != language_unknown) set_language (flang); diff --git a/gdb/linespec.c b/gdb/linespec.c index 2f39d09..04eb938 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -2383,16 +2383,15 @@ convert_explicit_location_to_linespec (struct linespec_state *self, if (source_filename != NULL) { - TRY + try { *result->file_symtabs = symtabs_from_filename (source_filename, self->search_pspace); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { source_file_not_found_error (source_filename); } - END_CATCH result->explicit_loc.source_filename = xstrdup (source_filename); } else @@ -2608,17 +2607,16 @@ parse_linespec (linespec_parser *parser, const char *arg, gdb::unique_xmalloc_ptr user_filename = copy_token_string (token); /* Check if the input is a filename. */ - TRY + try { *PARSER_RESULT (parser)->file_symtabs = symtabs_from_filename (user_filename.get (), PARSER_STATE (parser)->search_pspace); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { file_exception = ex; } - END_CATCH if (file_exception.reason >= 0) { @@ -2923,7 +2921,7 @@ linespec_complete_label (completion_tracker &tracker, line_offset unknown_offset = { 0, LINE_OFFSET_UNKNOWN }; - TRY + try { convert_explicit_location_to_linespec (PARSER_STATE (&parser), PARSER_RESULT (&parser), @@ -2932,11 +2930,10 @@ linespec_complete_label (completion_tracker &tracker, func_name_match_type, NULL, unknown_offset); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { return; } - END_CATCH complete_label (tracker, &parser, label_name); } @@ -2959,14 +2956,13 @@ linespec_complete (completion_tracker &tracker, const char *text, /* Parse as much as possible. parser.completion_word will hold furthest completion point we managed to parse to. */ - TRY + try { parse_linespec (&parser, text, match_type); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { } - END_CATCH if (parser.completion_quote_char != '\0' && parser.completion_quote_end != NULL @@ -3148,17 +3144,16 @@ event_location_to_sals (linespec_parser *parser, case LINESPEC_LOCATION: { PARSER_STATE (parser)->is_linespec = 1; - TRY + try { const linespec_location *ls = get_linespec_location (location); result = parse_linespec (parser, ls->spec_string, ls->match_type); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { throw_exception (except); } - END_CATCH } break; @@ -3959,7 +3954,7 @@ find_linespec_symbols (struct linespec_state *state, if (!classes.empty ()) { /* Now locate a list of suitable methods named METHOD. */ - TRY + try { find_method (state, file_symtabs, klass.c_str (), method.c_str (), @@ -3968,12 +3963,11 @@ find_linespec_symbols (struct linespec_state *state, /* If successful, we're done. If NOT_FOUND_ERROR was not thrown, rethrow the exception that we did get. */ - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { if (except.error != NOT_FOUND_ERROR) throw_exception (except); } - END_CATCH } } } diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c index fe401b2..229f660 100644 --- a/gdb/linux-fork.c +++ b/gdb/linux-fork.c @@ -427,19 +427,18 @@ public: if (m_oldfp != nullptr) { /* Switch back to inferior_ptid. */ - TRY + try { remove_breakpoints (); fork_load_infrun_state (m_oldfp); insert_breakpoints (); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { warning (_("Couldn't restore checkpoint state in %s: %s"), target_pid_to_str (m_oldfp->ptid).c_str (), ex.what ()); } - END_CATCH } } diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 13b76f8..c2eb55f 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -1188,11 +1188,11 @@ linux_nat_target::attach (const char *args, int from_tty) /* Make sure we report all signals during attach. */ pass_signals ({}); - TRY + try { inf_ptrace_target::attach (args, from_tty); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { pid_t pid = parse_pid_to_attach (args); std::string reason = linux_ptrace_attach_fail_reason (pid); @@ -1203,7 +1203,6 @@ linux_nat_target::attach (const char *args, int from_tty) else throw_error (ex.error, "%s", ex.what ()); } - END_CATCH /* The ptrace base target adds the main thread with (pid,0,0) format. Decorate it with lwp info. */ @@ -1402,16 +1401,15 @@ detach_one_lwp (struct lwp_info *lp, int *signo_p) /* Preparing to resume may try to write registers, and fail if the lwp is zombie. If that happens, ignore the error. We'll handle it below, when detach fails with ESRCH. */ - TRY + try { linux_target->low_prepare_to_resume (lp); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (!check_ptrace_stopped_lwp_gone (lp)) throw_exception (ex); } - END_CATCH if (ptrace (PTRACE_DETACH, lwpid, 0, signo) < 0) { @@ -1585,16 +1583,15 @@ check_ptrace_stopped_lwp_gone (struct lwp_info *lp) static void linux_resume_one_lwp (struct lwp_info *lp, int step, enum gdb_signal signo) { - TRY + try { linux_resume_one_lwp_throw (lp, step, signo); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (!check_ptrace_stopped_lwp_gone (lp)) throw_exception (ex); } - END_CATCH } /* Resume LP. */ @@ -3526,7 +3523,7 @@ resume_stopped_resumed_lwps (struct lwp_info *lp, const ptid_t wait_ptid) struct regcache *regcache = get_thread_regcache (lp->ptid); struct gdbarch *gdbarch = regcache->arch (); - TRY + try { CORE_ADDR pc = regcache_read_pc (regcache); int leave_stopped = 0; @@ -3552,12 +3549,11 @@ resume_stopped_resumed_lwps (struct lwp_info *lp, const ptid_t wait_ptid) linux_resume_one_lwp_throw (lp, lp->step, GDB_SIGNAL_0); } } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (!check_ptrace_stopped_lwp_gone (lp)) throw_exception (ex); } - END_CATCH } return 0; diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index f6c4f7b..ccc5d17 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -1926,15 +1926,14 @@ linux_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size) } /* Thread register information. */ - TRY + try { update_thread_list (); } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { exception_print (gdb_stderr, e); } - END_CATCH /* Like the kernel, prefer dumping the signalled thread first. "First thread" is what tools use to infer the signalled thread. diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index a735807..e1b2ae6 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -497,12 +497,12 @@ static int thread_db_find_new_threads_silently (thread_info *stopped) { - TRY + try { thread_db_find_new_threads_2 (stopped, true); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { if (libthread_db_debug) exception_fprintf (gdb_stdlog, except, @@ -532,7 +532,6 @@ thread_db_find_new_threads_silently (thread_info *stopped) return 1; } } - END_CATCH return 0; } @@ -757,7 +756,7 @@ check_thread_db (struct thread_db_info *info, bool log_progress) fail. */ linux_stop_and_wait_all_lwps (); - TRY + try { td_err_e err = td_ta_thr_iter_p (info->thread_agent, check_thread_db_callback, @@ -773,7 +772,7 @@ check_thread_db (struct thread_db_info *info, bool log_progress) if (!tdb_testinfo->threads_seen) error (_("no threads seen")); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { if (warning_pre_print) fputs_unfiltered (warning_pre_print, gdb_stderr); @@ -783,7 +782,6 @@ check_thread_db (struct thread_db_info *info, bool log_progress) test_passed = false; } - END_CATCH if (test_passed && log_progress) debug_printf (_("libthread_db integrity checks passed.\n")); @@ -1509,7 +1507,7 @@ find_new_threads_once (struct thread_db_info *info, int iteration, /* See comment in thread_db_update_thread_list. */ gdb_assert (info->td_ta_thr_iter_p != NULL); - TRY + try { /* Iterate over all user-space threads to discover new threads. */ err = info->td_ta_thr_iter_p (info->thread_agent, @@ -1520,7 +1518,7 @@ find_new_threads_once (struct thread_db_info *info, int iteration, TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { if (libthread_db_debug) { @@ -1528,7 +1526,6 @@ find_new_threads_once (struct thread_db_info *info, int iteration, "Warning: find_new_threads_once: "); } } - END_CATCH if (libthread_db_debug) { diff --git a/gdb/main.c b/gdb/main.c index 97ffc3f..8abd9de 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -365,7 +365,7 @@ static int catch_command_errors (catch_command_errors_const_ftype command, const char *arg, int from_tty) { - TRY + try { int was_sync = current_ui->prompt_state == PROMPT_BLOCKED; @@ -373,11 +373,10 @@ catch_command_errors (catch_command_errors_const_ftype command, maybe_wait_sync_command_done (was_sync); } - CATCH (e, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &e) { return handle_command_errors (e); } - END_CATCH return 1; } @@ -1169,15 +1168,14 @@ captured_main (void *data) change - SET_TOP_LEVEL() - has been eliminated. */ while (1) { - TRY + try { captured_command_loop (); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { exception_print (gdb_stderr, ex); } - END_CATCH } /* No exit -- exit is through quit_command. */ } @@ -1185,15 +1183,14 @@ captured_main (void *data) int gdb_main (struct captured_main_args *args) { - TRY + try { captured_main (args); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { exception_print (gdb_stderr, ex); } - END_CATCH /* The only way to end up here is by an error (normal exit is handled by quit_force()), hence always return an error status. */ diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c index 4f25977..bf35891 100644 --- a/gdb/mi/mi-cmd-break.c +++ b/gdb/mi/mi-cmd-break.c @@ -54,15 +54,14 @@ breakpoint_notify (struct breakpoint *b) { if (mi_can_breakpoint_notify) { - TRY + try { print_breakpoint (b); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { exception_print (gdb_stderr, ex); } - END_CATCH } } diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index 0cec856..c689d49 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -531,7 +531,7 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what, stb.printf (_(""), arg->error); else { - TRY + try { struct value_print_options opts; @@ -540,12 +540,11 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what, common_val_print (arg->val, &stb, 0, &opts, language_def (SYMBOL_LANGUAGE (arg->sym))); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { stb.printf (_(""), except.what ()); } - END_CATCH } uiout->field_stream ("value", stb); } diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index 9c20016..26dfc4a 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -823,18 +823,17 @@ mi_print_breakpoint_for_event (struct mi_interp *mi, breakpoint *bp) ui_out_redirect. */ mi_uiout->redirect (mi->event_channel); - TRY + try { scoped_restore restore_uiout = make_scoped_restore (¤t_uiout, mi_uiout); print_breakpoint (bp); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { exception_print (gdb_stderr, ex); } - END_CATCH mi_uiout->redirect (NULL); } diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 2fbcd65..33cd1f8 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -1938,16 +1938,15 @@ mi_execute_command (const char *cmd, int from_tty) target_log_command (cmd); - TRY + try { command = mi_parse (cmd, &token); } - CATCH (exception, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &exception) { mi_print_exception (token, exception); xfree (token); } - END_CATCH if (command != NULL) { @@ -1966,11 +1965,11 @@ mi_execute_command (const char *cmd, int from_tty) timestamp (command->cmd_start); } - TRY + try { captured_mi_execute_command (current_uiout, command.get ()); } - CATCH (result, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &result) { /* Like in start_event_loop, enable input and force display of the prompt. Otherwise, any command that calls @@ -1984,7 +1983,6 @@ mi_execute_command (const char *cmd, int from_tty) mi_print_exception (command->token, result); mi_out_rewind (current_uiout); } - END_CATCH bpstat_do_actions (); diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index 83d2c05..20e2790 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -1297,18 +1297,17 @@ find_objc_msgcall_submethod (int (*f) (CORE_ADDR, CORE_ADDR *), CORE_ADDR pc, CORE_ADDR *new_pc) { - TRY + try { if (f (pc, new_pc) == 0) return 1; } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { exception_fprintf (gdb_stderr, ex, "Unable to determine target of " "Objective-C method call (ignoring):\n"); } - END_CATCH return 0; } diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index b11292a..5b0b9dc 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -751,18 +751,17 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr, thisoffset = offset; - TRY + try { boffset = baseclass_offset (type, i, valaddr, offset, address, val); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (ex.error == NOT_AVAILABLE_ERROR) skip = -1; else skip = 1; } - END_CATCH if (skip == 0) { diff --git a/gdb/parse.c b/gdb/parse.c index 359f6f8..5ae1cb9 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -1137,11 +1137,11 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc, scoped_restore_current_language lang_saver; set_language (lang->la_language); - TRY + try { lang->la_parser (&ps); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { /* If parsing for completion, allow this to succeed; but if no expression elements have been written, then there's nothing @@ -1149,7 +1149,6 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc, if (! ps.parse_completion || ps.expout_ptr == 0) throw_exception (except); } - END_CATCH /* We have to operate on an "expression *", due to la_post_parser, which explains this funny-looking double release. */ @@ -1224,16 +1223,15 @@ parse_expression_for_completion (const char *string, int subexp; expr_completion_state cstate; - TRY + try { exp = parse_exp_in_context (&string, 0, 0, 0, 0, &subexp, nullptr, &cstate); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { /* Nothing, EXP remains NULL. */ } - END_CATCH if (exp == NULL) return NULL; diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c index 1943560..e2ead9d 100644 --- a/gdb/ppc-linux-tdep.c +++ b/gdb/ppc-linux-tdep.c @@ -1827,7 +1827,7 @@ ppc_linux_spe_context (int wordsize, enum bfd_endian byte_order, { struct target_ops *target = current_top_target (); - TRY + try { /* We do not call target_translate_tls_address here, because svr4_fetch_objfile_link_map may invalidate the frame chain, @@ -1842,11 +1842,10 @@ ppc_linux_spe_context (int wordsize, enum bfd_endian byte_order, spe_context_cache_ptid = inferior_ptid; } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { return 0; } - END_CATCH } /* Read variable value. */ diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 5a55a1c..8b6f1ca 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1881,13 +1881,13 @@ do_one_display (struct display *d) if (d->exp == NULL) { - TRY + try { innermost_block_tracker tracker; d->exp = parse_expression (d->exp_string, &tracker); d->block = tracker.block (); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { /* Can't re-parse the expression. Disable this display item. */ d->enabled_p = 0; @@ -1895,7 +1895,6 @@ do_one_display (struct display *d) d->exp_string, ex.what ()); return; } - END_CATCH } if (d->block) @@ -1942,7 +1941,7 @@ do_one_display (struct display *d) annotate_display_value (); - TRY + try { struct value *val; CORE_ADDR addr; @@ -1953,12 +1952,11 @@ do_one_display (struct display *d) addr = gdbarch_addr_bits_remove (d->exp->gdbarch, addr); do_examine (d->format, d->exp->gdbarch, addr); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { fprintf_filtered (gdb_stdout, _("\n"), ex.what ()); } - END_CATCH } else { @@ -1981,18 +1979,17 @@ do_one_display (struct display *d) get_formatted_print_options (&opts, d->format.format); opts.raw = d->format.raw; - TRY + try { struct value *val; val = evaluate_expression (d->exp.get ()); print_formatted (val, d->format.size, &opts, gdb_stdout); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { fprintf_filtered (gdb_stdout, _(""), ex.what ()); } - END_CATCH printf_filtered ("\n"); } @@ -2174,7 +2171,7 @@ print_variable_and_value (const char *name, struct symbol *var, fputs_styled (name, variable_name_style.style (), stream); fputs_filtered (" = ", stream); - TRY + try { struct value *val; struct value_print_options opts; @@ -2192,12 +2189,11 @@ print_variable_and_value (const char *name, struct symbol *var, function. */ frame = NULL; } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { fprintf_filtered (stream, "", name, except.what ()); } - END_CATCH fprintf_filtered (stream, "\n"); } diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c index 23cb2c5..c7c6fae 100644 --- a/gdb/python/py-arch.c +++ b/gdb/python/py-arch.c @@ -199,16 +199,15 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw) string_file stb; - TRY + try { insn_len = gdb_print_insn (gdbarch, pc, &stb, NULL); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { gdbpy_convert_exception (except); return NULL; } - END_CATCH if (PyDict_SetItemString (insn_dict.get (), "addr", gdb_py_long_from_ulongest (pc)) diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c index ba3b4f0..16c717c 100644 --- a/gdb/python/py-breakpoint.c +++ b/gdb/python/py-breakpoint.c @@ -138,18 +138,17 @@ bppy_set_enabled (PyObject *self, PyObject *newvalue, void *closure) if (cmp < 0) return -1; - TRY + try { if (cmp == 1) enable_breakpoint (self_bp->bp); else disable_breakpoint (self_bp->bp); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_SET_HANDLE_EXCEPTION (except); } - END_CATCH return 0; } @@ -247,15 +246,14 @@ bppy_set_task (PyObject *self, PyObject *newvalue, void *closure) if (! gdb_py_int_as_long (newvalue, &id)) return -1; - TRY + try { valid_id = valid_task_id (id); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_SET_HANDLE_EXCEPTION (except); } - END_CATCH if (! valid_id) { @@ -290,15 +288,14 @@ bppy_delete_breakpoint (PyObject *self, PyObject *args) BPPY_REQUIRE_VALID (self_bp); - TRY + try { delete_breakpoint (self_bp->bp); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH Py_RETURN_NONE; } @@ -332,15 +329,14 @@ bppy_set_ignore_count (PyObject *self, PyObject *newvalue, void *closure) if (value < 0) value = 0; - TRY + try { set_ignore_count (self_bp->number, (int) value, 0); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_SET_HANDLE_EXCEPTION (except); } - END_CATCH return 0; } @@ -469,15 +465,14 @@ bppy_set_condition (PyObject *self, PyObject *newvalue, void *closure) exp = exp_holder.get (); } - TRY + try { set_breakpoint_condition (self_bp->bp, exp, 0); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { except = ex; } - END_CATCH GDB_PY_SET_HANDLE_EXCEPTION (except); @@ -499,17 +494,16 @@ bppy_get_commands (PyObject *self, void *closure) string_file stb; current_uiout->redirect (&stb); - TRY + try { print_command_lines (current_uiout, breakpoint_commands (bp), 0); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { current_uiout->redirect (NULL); gdbpy_convert_exception (except); return NULL; } - END_CATCH current_uiout->redirect (NULL); return host_string_to_python_string (stb.c_str ()).release (); @@ -530,7 +524,7 @@ bppy_set_commands (PyObject *self, PyObject *newvalue, void *closure) if (commands == nullptr) return -1; - TRY + try { bool first = true; char *save_ptr = nullptr; @@ -546,11 +540,10 @@ bppy_set_commands (PyObject *self, PyObject *newvalue, void *closure) counted_command_line lines = read_command_lines_1 (reader, 1, nullptr); breakpoint_set_commands (self_bp->bp, std::move (lines)); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { except = ex; } - END_CATCH GDB_PY_SET_HANDLE_EXCEPTION (except); @@ -801,7 +794,7 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) bppy_pending_object->number = -1; bppy_pending_object->bp = NULL; - TRY + try { switch (type) { @@ -871,13 +864,12 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) error(_("Do not understand breakpoint type to set.")); } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { bppy_pending_object = NULL; gdbpy_convert_exception (except); return -1; } - END_CATCH BPPY_SET_REQUIRE_VALID ((gdbpy_breakpoint_object *) self); return 0; diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c index 1677c3d..2432127 100644 --- a/gdb/python/py-cmd.c +++ b/gdb/python/py-cmd.c @@ -541,7 +541,7 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw) gdbpy_ref<> self_ref = gdbpy_ref<>::new_reference (self); - TRY + try { struct cmd_list_element *cmd; @@ -572,7 +572,7 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw) set_cmd_completer_handle_brkchars (cmd, cmdpy_completer_handle_brkchars); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { xfree (cmd_name); xfree (docstring); @@ -580,7 +580,6 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw) gdbpy_convert_exception (except); return -1; } - END_CATCH return 0; } diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c index f3affbd..6faffd2e 100644 --- a/gdb/python/py-finishbreakpoint.c +++ b/gdb/python/py-finishbreakpoint.c @@ -101,7 +101,7 @@ bpfinishpy_pre_stop_hook (struct gdbpy_breakpoint_object *bp_obj) if (!self_finishbp->return_type) return; - TRY + try { struct value *function = value_object_to_value (self_finishbp->function_value); @@ -121,12 +121,11 @@ bpfinishpy_pre_stop_hook (struct gdbpy_breakpoint_object *bp_obj) self_finishbp->return_value = Py_None; } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { gdbpy_convert_exception (except); gdbpy_print_stack (); } - END_CATCH } /* Triggered when gdbpy_should_stop has triggered the `stop' callback @@ -136,18 +135,17 @@ void bpfinishpy_post_stop_hook (struct gdbpy_breakpoint_object *bp_obj) { - TRY + try { /* Can't delete it here, but it will be removed at the next stop. */ disable_breakpoint (bp_obj->bp); gdb_assert (bp_obj->bp->disposition == disp_del); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { gdbpy_convert_exception (except); gdbpy_print_stack (); } - END_CATCH } /* Python function to create a new breakpoint. */ @@ -172,7 +170,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) &frame_obj, &internal)) return -1; - TRY + try { /* Default frame to newest frame if necessary. */ if (frame_obj == NULL) @@ -210,12 +208,11 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) } } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { gdbpy_convert_exception (except); return -1; } - END_CATCH if (PyErr_Occurred ()) return -1; @@ -244,7 +241,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) self_bpfinish->return_type = NULL; self_bpfinish->function_value = NULL; - TRY + try { if (get_frame_pc_if_available (frame, &pc)) { @@ -270,12 +267,11 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) } } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { /* Just swallow. Either the return type or the function value remain NULL. */ } - END_CATCH if (self_bpfinish->return_type == NULL || self_bpfinish->function_value == NULL) { @@ -291,7 +287,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) bppy_pending_object->number = -1; bppy_pending_object->bp = NULL; - TRY + try { /* Set a breakpoint on the return address. */ event_location_up location @@ -306,11 +302,10 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) &bkpt_breakpoint_ops, 0, 1, internal_bp, 0); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_SET_HANDLE_EXCEPTION (except); } - END_CATCH self_bpfinish->py_bp.bp->frame_id = frame_id; self_bpfinish->py_bp.is_finish_bp = 1; @@ -362,19 +357,18 @@ bpfinishpy_detect_out_scope_cb (struct breakpoint *b, void *args) /* Check scope if not currently stopped at the FinishBreakpoint. */ if (b != bp_stopped) { - TRY + try { if (b->pspace == current_inferior ()->pspace && (!target_has_registers || frame_find_by_id (b->frame_id) == NULL)) bpfinishpy_out_of_scope (finish_bp); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { gdbpy_convert_exception (except); gdbpy_print_stack (); } - END_CATCH } } diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c index 0eef654..9066f60 100644 --- a/gdb/python/py-frame.c +++ b/gdb/python/py-frame.c @@ -95,15 +95,14 @@ frapy_is_valid (PyObject *self, PyObject *args) { struct frame_info *frame = NULL; - TRY + try { frame = frame_object_to_frame_info (self); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (frame == NULL) Py_RETURN_FALSE; @@ -122,17 +121,16 @@ frapy_name (PyObject *self, PyObject *args) enum language lang; PyObject *result; - TRY + try { FRAPY_REQUIRE_VALID (self, frame); name = find_frame_funname (frame, &lang, NULL); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (name) { @@ -157,17 +155,16 @@ frapy_type (PyObject *self, PyObject *args) struct frame_info *frame; enum frame_type type = NORMAL_FRAME;/* Initialize to appease gcc warning. */ - TRY + try { FRAPY_REQUIRE_VALID (self, frame); type = get_frame_type (frame); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return PyInt_FromLong (type); } @@ -181,15 +178,14 @@ frapy_arch (PyObject *self, PyObject *args) struct frame_info *frame = NULL; /* Initialize to appease gcc warning. */ frame_object *obj = (frame_object *) self; - TRY + try { FRAPY_REQUIRE_VALID (self, frame); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return gdbarch_to_arch_object (obj->gdbarch); } @@ -203,15 +199,14 @@ frapy_unwind_stop_reason (PyObject *self, PyObject *args) struct frame_info *frame = NULL; /* Initialize to appease gcc warning. */ enum unwind_stop_reason stop_reason; - TRY + try { FRAPY_REQUIRE_VALID (self, frame); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH stop_reason = get_frame_unwind_stop_reason (frame); @@ -227,17 +222,16 @@ frapy_pc (PyObject *self, PyObject *args) CORE_ADDR pc = 0; /* Initialize to appease gcc warning. */ struct frame_info *frame; - TRY + try { FRAPY_REQUIRE_VALID (self, frame); pc = get_frame_pc (frame); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return gdb_py_long_from_ulongest (pc); } @@ -254,7 +248,7 @@ frapy_read_register (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", ®num_str)) return NULL; - TRY + try { struct frame_info *frame; int regnum; @@ -270,11 +264,10 @@ frapy_read_register (PyObject *self, PyObject *args) if (val == NULL) PyErr_SetString (PyExc_ValueError, _("Unknown register.")); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return val == NULL ? NULL : value_to_value_object (val); } @@ -288,16 +281,15 @@ frapy_block (PyObject *self, PyObject *args) struct frame_info *frame; const struct block *block = NULL, *fn_block; - TRY + try { FRAPY_REQUIRE_VALID (self, frame); block = get_frame_block (frame, NULL); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH for (fn_block = block; fn_block != NULL && BLOCK_FUNCTION (fn_block) == NULL; @@ -330,7 +322,7 @@ frapy_function (PyObject *self, PyObject *args) struct symbol *sym = NULL; struct frame_info *frame; - TRY + try { enum language funlang; @@ -339,11 +331,10 @@ frapy_function (PyObject *self, PyObject *args) gdb::unique_xmalloc_ptr funname = find_frame_funname (frame, &funlang, &sym); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (sym) return symbol_to_symbol_object (sym); @@ -362,7 +353,7 @@ frame_info_to_frame_object (struct frame_info *frame) if (frame_obj == NULL) return NULL; - TRY + try { /* Try to get the previous frame, to determine if this is the last frame @@ -382,12 +373,11 @@ frame_info_to_frame_object (struct frame_info *frame) } frame_obj->gdbarch = get_frame_arch (frame); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { gdbpy_convert_exception (except); return NULL; } - END_CATCH return (PyObject *) frame_obj.release (); } @@ -402,17 +392,16 @@ frapy_older (PyObject *self, PyObject *args) struct frame_info *frame, *prev = NULL; PyObject *prev_obj = NULL; /* Initialize to appease gcc warning. */ - TRY + try { FRAPY_REQUIRE_VALID (self, frame); prev = get_prev_frame (frame); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (prev) prev_obj = frame_info_to_frame_object (prev); @@ -435,17 +424,16 @@ frapy_newer (PyObject *self, PyObject *args) struct frame_info *frame, *next = NULL; PyObject *next_obj = NULL; /* Initialize to appease gcc warning. */ - TRY + try { FRAPY_REQUIRE_VALID (self, frame); next = get_next_frame (frame); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (next) next_obj = frame_info_to_frame_object (next); @@ -467,18 +455,17 @@ frapy_find_sal (PyObject *self, PyObject *args) struct frame_info *frame; PyObject *sal_obj = NULL; /* Initialize to appease gcc warning. */ - TRY + try { FRAPY_REQUIRE_VALID (self, frame); symtab_and_line sal = find_frame_sal (frame); sal_obj = symtab_and_line_to_sal_object (sal); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return sal_obj; } @@ -523,7 +510,7 @@ frapy_read_var (PyObject *self, PyObject *args) } } - TRY + try { struct block_symbol lookup_sym; FRAPY_REQUIRE_VALID (self, frame); @@ -534,12 +521,11 @@ frapy_read_var (PyObject *self, PyObject *args) var = lookup_sym.symbol; block = lookup_sym.block; } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { gdbpy_convert_exception (except); return NULL; } - END_CATCH if (!var) { @@ -556,17 +542,16 @@ frapy_read_var (PyObject *self, PyObject *args) return NULL; } - TRY + try { FRAPY_REQUIRE_VALID (self, frame); val = read_var_value (var, block, frame); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return value_to_value_object (val); } @@ -578,17 +563,16 @@ frapy_select (PyObject *self, PyObject *args) { struct frame_info *fi; - TRY + try { FRAPY_REQUIRE_VALID (self, fi); select_frame (fi); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH Py_RETURN_NONE; } @@ -601,15 +585,14 @@ gdbpy_newest_frame (PyObject *self, PyObject *args) { struct frame_info *frame = NULL; - TRY + try { frame = get_current_frame (); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return frame_info_to_frame_object (frame); } @@ -622,15 +605,14 @@ gdbpy_selected_frame (PyObject *self, PyObject *args) { struct frame_info *frame = NULL; - TRY + try { frame = get_selected_frame ("No frame is currently selected."); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return frame_info_to_frame_object (frame); } diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c index 7b241bb..deb4a8f 100644 --- a/gdb/python/py-framefilter.c +++ b/gdb/python/py-framefilter.c @@ -1081,16 +1081,15 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang, if (!gdb_python_initialized) return EXT_LANG_BT_NO_FILTERS; - TRY + try { gdbarch = get_frame_arch (frame); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { /* Let gdb try to print the stack trace. */ return EXT_LANG_BT_NO_FILTERS; } - END_CATCH gdbpy_enter enter_py (gdbarch, current_language); @@ -1166,17 +1165,16 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang, } } - TRY + try { success = py_print_frame (item.get (), flags, args_type, out, 0, levels_printed.get ()); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { gdbpy_convert_exception (except); success = EXT_LANG_BT_ERROR; } - END_CATCH /* Do not exit on error printing a single frame. Print the error and continue with other frames. */ diff --git a/gdb/python/py-gdb-readline.c b/gdb/python/py-gdb-readline.c index 1e6cd73..51ec6d8 100644 --- a/gdb/python/py-gdb-readline.c +++ b/gdb/python/py-gdb-readline.c @@ -39,12 +39,12 @@ gdbpy_readline_wrapper (FILE *sys_stdin, FILE *sys_stdout, int n; char *p = NULL, *q; - TRY + try { p = command_line_input (prompt, "python"); } /* Handle errors by raising Python exceptions. */ - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { /* Detect user interrupt (Ctrl-C). */ if (except.reason == RETURN_QUIT) @@ -59,7 +59,6 @@ gdbpy_readline_wrapper (FILE *sys_stdin, FILE *sys_stdout, PyEval_SaveThread (); return NULL; } - END_CATCH /* Detect EOF (Ctrl-D). */ if (p == NULL) diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c index 72fbf6d..fee6b30 100644 --- a/gdb/python/py-inferior.c +++ b/gdb/python/py-inferior.c @@ -389,15 +389,14 @@ infpy_threads (PyObject *self, PyObject *args) INFPY_REQUIRE_VALID (inf_obj); - TRY + try { update_thread_list (); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH tuple = PyTuple_New (inf_obj->nthreads); if (!tuple) @@ -508,17 +507,16 @@ infpy_read_memory (PyObject *self, PyObject *args, PyObject *kw) || get_addr_from_python (length_obj, &length) < 0) return NULL; - TRY + try { buffer.reset ((gdb_byte *) xmalloc (length)); read_memory (addr, buffer.get (), length); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH gdbpy_ref membuf_obj (PyObject_New (membuf_object, &membuf_object_type)); @@ -572,15 +570,14 @@ infpy_write_memory (PyObject *self, PyObject *args, PyObject *kw) else if (get_addr_from_python (length_obj, &length) < 0) return nullptr; - TRY + try { write_memory_with_notification (addr, buffer, length); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { except = ex; } - END_CATCH GDB_PY_HANDLE_EXCEPTION (except); @@ -725,17 +722,16 @@ infpy_search_memory (PyObject *self, PyObject *args, PyObject *kw) return nullptr; } - TRY + try { found = target_search_memory (start_addr, length, buffer, pattern_size, &found_addr); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { except = ex; } - END_CATCH GDB_PY_HANDLE_EXCEPTION (except); @@ -782,7 +778,7 @@ infpy_thread_from_thread_handle (PyObject *self, PyObject *args, PyObject *kw) return NULL; } - TRY + try { struct thread_info *thread_info; struct value *val = value_object_to_value (handle_obj); @@ -791,11 +787,10 @@ infpy_thread_from_thread_handle (PyObject *self, PyObject *args, PyObject *kw) if (thread_info != NULL) return thread_to_thread_object (thread_info).release (); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH Py_RETURN_NONE; } diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c index bf90d08..3c6d147 100644 --- a/gdb/python/py-infthread.c +++ b/gdb/python/py-infthread.c @@ -181,15 +181,14 @@ thpy_switch (PyObject *self, PyObject *args) THPY_REQUIRE_VALID (thread_obj); - TRY + try { switch_to_thread (thread_obj->thread); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH Py_RETURN_NONE; } diff --git a/gdb/python/py-lazy-string.c b/gdb/python/py-lazy-string.c index 443aeb7..61722d9 100644 --- a/gdb/python/py-lazy-string.c +++ b/gdb/python/py-lazy-string.c @@ -113,7 +113,7 @@ stpy_convert_to_value (PyObject *self, PyObject *args) return NULL; } - TRY + try { struct type *type = type_object_to_type (self_string->type); struct type *realtype; @@ -142,11 +142,10 @@ stpy_convert_to_value (PyObject *self, PyObject *args) break; } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return value_to_value_object (val); } diff --git a/gdb/python/py-linetable.c b/gdb/python/py-linetable.c index b9d74b8..813b2d9 100644 --- a/gdb/python/py-linetable.c +++ b/gdb/python/py-linetable.c @@ -164,15 +164,14 @@ ltpy_get_pcs_for_line (PyObject *self, PyObject *args) if (! PyArg_ParseTuple (args, GDB_PY_LL_ARG, &py_line)) return NULL; - TRY + try { pcs = find_pcs_for_symtab_line (symtab, py_line, &best_entry); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return build_line_table_tuple_from_pcs (py_line, pcs); } diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c index 67f63b3..75ccc18 100644 --- a/gdb/python/py-objfile.c +++ b/gdb/python/py-objfile.c @@ -130,15 +130,14 @@ objfpy_get_build_id (PyObject *self, void *closure) OBJFPY_REQUIRE_VALID (obj); - TRY + try { build_id = build_id_bfd_get (objfile->obfd); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (build_id != NULL) { @@ -421,17 +420,16 @@ objfpy_add_separate_debug_file (PyObject *self, PyObject *args, PyObject *kw) if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s", keywords, &file_name)) return NULL; - TRY + try { gdb_bfd_ref_ptr abfd (symfile_bfd_open (file_name)); symbol_file_add_separate (abfd.get (), file_name, 0, obj->objfile); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH Py_RETURN_NONE; } diff --git a/gdb/python/py-param.c b/gdb/python/py-param.c index 3b79a5c..c211d47 100644 --- a/gdb/python/py-param.c +++ b/gdb/python/py-param.c @@ -726,21 +726,20 @@ parmpy_init (PyObject *self, PyObject *args, PyObject *kwds) Py_INCREF (self); - TRY + try { add_setshow_generic (parmclass, (enum command_class) cmdtype, cmd_name, obj, set_doc.get (), show_doc.get (), doc.get (), set_list, show_list); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { xfree (cmd_name); Py_DECREF (self); gdbpy_convert_exception (except); return -1; } - END_CATCH return 0; } diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c index e64d1f8..a02965d 100644 --- a/gdb/python/py-prettyprint.c +++ b/gdb/python/py-prettyprint.c @@ -190,7 +190,7 @@ pretty_print_one_value (PyObject *printer, struct value **out_value) gdbpy_ref<> result; *out_value = NULL; - TRY + try { if (!PyObject_HasAttr (printer, gdbpy_to_string_cst)) result = gdbpy_ref<>::new_reference (Py_None); @@ -212,10 +212,9 @@ pretty_print_one_value (PyObject *printer, struct value **out_value) } } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { } - END_CATCH return result; } @@ -637,15 +636,14 @@ apply_varobj_pretty_printer (PyObject *printer_obj, gdbpy_ref<> gdbpy_get_varobj_pretty_printer (struct value *value) { - TRY + try { value = value_copy (value); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH gdbpy_ref<> val_obj (value_to_value_object (value)); if (val_obj == NULL) diff --git a/gdb/python/py-progspace.c b/gdb/python/py-progspace.c index b82a91b..eb6acb2 100644 --- a/gdb/python/py-progspace.c +++ b/gdb/python/py-progspace.c @@ -381,7 +381,7 @@ pspy_block_for_pc (PyObject *o, PyObject *args) if (!PyArg_ParseTuple (args, GDB_PY_LLU_ARG, &pc)) return NULL; - TRY + try { scoped_restore_current_program_space saver; @@ -391,11 +391,10 @@ pspy_block_for_pc (PyObject *o, PyObject *args) if (cust != NULL && COMPUNIT_OBJFILE (cust) != NULL) block = block_for_pc (pc); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (cust == NULL || COMPUNIT_OBJFILE (cust) == NULL) { @@ -425,7 +424,7 @@ pspy_find_pc_line (PyObject *o, PyObject *args) if (!PyArg_ParseTuple (args, GDB_PY_LLU_ARG, &pc_llu)) return NULL; - TRY + try { struct symtab_and_line sal; CORE_ADDR pc; @@ -437,11 +436,10 @@ pspy_find_pc_line (PyObject *o, PyObject *args) sal = find_pc_line (pc, 0); result = symtab_and_line_to_sal_object (sal); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return result; } diff --git a/gdb/python/py-record-btrace.c b/gdb/python/py-record-btrace.c index 229a3b8..64b25fa 100644 --- a/gdb/python/py-record-btrace.c +++ b/gdb/python/py-record-btrace.c @@ -208,15 +208,14 @@ recpy_bt_insn_sal (PyObject *self, void *closure) if (insn == NULL) return NULL; - TRY + try { result = symtab_and_line_to_sal_object (find_pc_line (insn->pc, 0)); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return result; } @@ -279,16 +278,15 @@ recpy_bt_insn_data (PyObject *self, void *closure) if (insn == NULL) return NULL; - TRY + try { buffer.resize (insn->size); read_memory (insn->pc, buffer.data (), insn->size); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH object = PyBytes_FromStringAndSize ((const char *) buffer.data (), insn->size); @@ -316,16 +314,15 @@ recpy_bt_insn_decoded (PyObject *self, void *closure) if (insn == NULL) return NULL; - TRY + try { gdb_print_insn (target_gdbarch (), insn->pc, &strfile, NULL); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { gdbpy_convert_exception (except); return NULL; } - END_CATCH return PyBytes_FromString (strfile.string ().c_str ()); @@ -787,7 +784,7 @@ recpy_bt_goto (PyObject *self, PyObject *args) return PyErr_Format (PyExc_TypeError, _("Argument must be instruction.")); obj = (const recpy_element_object *) parse_obj; - TRY + try { struct btrace_insn_iterator iter; @@ -798,11 +795,10 @@ recpy_bt_goto (PyObject *self, PyObject *args) else target_goto_record (obj->number); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH Py_RETURN_NONE; } diff --git a/gdb/python/py-record.c b/gdb/python/py-record.c index e818560..66fa8bf 100644 --- a/gdb/python/py-record.c +++ b/gdb/python/py-record.c @@ -602,16 +602,15 @@ gdbpy_start_recording (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "|ss", &method, &format)) return NULL; - TRY + try { record_start (method, format, 0); ret = gdbpy_current_recording (self, args); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { gdbpy_convert_exception (except); } - END_CATCH return ret; } @@ -638,15 +637,14 @@ gdbpy_current_recording (PyObject *self, PyObject *args) PyObject * gdbpy_stop_recording (PyObject *self, PyObject *args) { - TRY + try { record_stop (0); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH Py_RETURN_NONE; } diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c index afff995..63d8ab1 100644 --- a/gdb/python/py-symbol.c +++ b/gdb/python/py-symbol.c @@ -196,15 +196,14 @@ sympy_needs_frame (PyObject *self, void *closure) SYMPY_REQUIRE_VALID (self, symbol); - TRY + try { result = symbol_read_needs_frame (symbol); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (result) Py_RETURN_TRUE; @@ -266,7 +265,7 @@ sympy_value (PyObject *self, PyObject *args) return NULL; } - TRY + try { if (frame_obj != NULL) { @@ -284,11 +283,10 @@ sympy_value (PyObject *self, PyObject *args) can happen with nested functions). */ value = read_var_value (symbol, NULL, frame_info); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return value_to_value_object (value); } @@ -388,28 +386,26 @@ gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw) { struct frame_info *selected_frame; - TRY + try { selected_frame = get_selected_frame (_("No frame selected.")); block = get_frame_block (selected_frame, NULL); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH } - TRY + try { symbol = lookup_symbol (name, block, (domain_enum) domain, &is_a_field_of_this).symbol; } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH gdbpy_ref<> ret_tuple (PyTuple_New (2)); if (ret_tuple == NULL) @@ -451,15 +447,14 @@ gdbpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw) &domain)) return NULL; - TRY + try { symbol = lookup_global_symbol (name, NULL, (domain_enum) domain).symbol; } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (symbol) { diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index c908ec6..d918fc0 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -312,15 +312,14 @@ typy_fields_items (PyObject *self, enum gdbpy_iter_kind kind) struct type *type = ((type_object *) py_type)->type; struct type *checked_type = type; - TRY + try { checked_type = check_typedef (checked_type); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH gdbpy_ref<> type_holder; if (checked_type != type) @@ -420,15 +419,14 @@ typy_strip_typedefs (PyObject *self, PyObject *args) { struct type *type = ((type_object *) self)->type; - TRY + try { type = check_typedef (type); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return type_to_type_object (type); } @@ -442,15 +440,14 @@ typy_get_composite (struct type *type) for (;;) { - TRY + try { type = check_typedef (type); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (TYPE_CODE (type) != TYPE_CODE_PTR && !TYPE_IS_REFERENCE (type)) break; @@ -510,17 +507,16 @@ typy_array_1 (PyObject *self, PyObject *args, int is_vector) return NULL; } - TRY + try { array = lookup_array_range_type (type, n1, n2); if (is_vector) make_vector_type (array); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return type_to_type_object (array); } @@ -547,15 +543,14 @@ typy_pointer (PyObject *self, PyObject *args) { struct type *type = ((type_object *) self)->type; - TRY + try { type = lookup_pointer_type (type); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return type_to_type_object (type); } @@ -616,15 +611,14 @@ typy_reference (PyObject *self, PyObject *args) { struct type *type = ((type_object *) self)->type; - TRY + try { type = lookup_lvalue_reference_type (type); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return type_to_type_object (type); } @@ -651,15 +645,14 @@ typy_const (PyObject *self, PyObject *args) { struct type *type = ((type_object *) self)->type; - TRY + try { type = make_cv_type (1, 0, type, NULL); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return type_to_type_object (type); } @@ -670,15 +663,14 @@ typy_volatile (PyObject *self, PyObject *args) { struct type *type = ((type_object *) self)->type; - TRY + try { type = make_cv_type (0, 1, type, NULL); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return type_to_type_object (type); } @@ -689,15 +681,14 @@ typy_unqualified (PyObject *self, PyObject *args) { struct type *type = ((type_object *) self)->type; - TRY + try { type = make_cv_type (0, 0, type, NULL); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return type_to_type_object (type); } @@ -708,14 +699,13 @@ typy_get_sizeof (PyObject *self, void *closure) { struct type *type = ((type_object *) self)->type; - TRY + try { check_typedef (type); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { } - END_CATCH /* Ignore exceptions. */ @@ -729,15 +719,14 @@ typy_get_alignof (PyObject *self, void *closure) struct type *type = ((type_object *) self)->type; ULONGEST align = 0; - TRY + try { align = type_align (type); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { align = 0; } - END_CATCH /* Ignore exceptions. */ @@ -749,7 +738,7 @@ typy_lookup_typename (const char *type_name, const struct block *block) { struct type *type = NULL; - TRY + try { if (startswith (type_name, "struct ")) type = lookup_struct (type_name + 7, NULL); @@ -761,11 +750,10 @@ typy_lookup_typename (const char *type_name, const struct block *block) type = lookup_typename (python_language, python_gdbarch, type_name, block, 0); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return type; } @@ -791,7 +779,7 @@ typy_lookup_type (struct demangle_component *demangled, if (! type) return NULL; - TRY + try { /* If the demangled_type matches with one of the types below, run the corresponding function and save the type @@ -816,11 +804,10 @@ typy_lookup_type (struct demangle_component *demangled, break; } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH } /* If we have a type from the switch statement above, just return @@ -854,16 +841,15 @@ typy_legacy_template_argument (struct type *type, const struct block *block, return NULL; } - TRY + try { /* Note -- this is not thread-safe. */ info = cp_demangled_name_to_comp (TYPE_NAME (type), &err); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (! info) { @@ -934,17 +920,16 @@ typy_template_argument (PyObject *self, PyObject *args) } } - TRY + try { type = check_typedef (type); if (TYPE_IS_REFERENCE (type)) type = check_typedef (TYPE_TARGET_TYPE (type)); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH /* We might not have DW_TAG_template_*, so try to parse the type's name. This is inefficient if we do not have a template type -- @@ -969,15 +954,14 @@ typy_template_argument (PyObject *self, PyObject *args) return NULL; } - TRY + try { val = value_of_variable (sym, block); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return value_to_value_object (val); } @@ -987,16 +971,15 @@ typy_str (PyObject *self) { string_file thetype; - TRY + try { LA_PRINT_TYPE (type_object_to_type (self), "", &thetype, -1, 0, &type_print_raw_options); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return PyUnicode_Decode (thetype.c_str (), thetype.size (), host_charset (), NULL); @@ -1023,17 +1006,16 @@ typy_richcompare (PyObject *self, PyObject *other, int op) result = true; else { - TRY + try { result = types_deeply_equal (type1, type2); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { /* If there is a GDB exception, a comparison is not capable (or trusted), so exit. */ GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH } if (op == (result ? Py_EQ : Py_NE)) diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c index f07a8d8..e506ec0 100644 --- a/gdb/python/py-unwind.c +++ b/gdb/python/py-unwind.c @@ -141,7 +141,7 @@ pyuw_value_obj_to_pointer (PyObject *pyo_value, CORE_ADDR *addr) int rc = 0; struct value *value; - TRY + try { if ((value = value_object_to_value (pyo_value)) != NULL) { @@ -150,11 +150,10 @@ pyuw_value_obj_to_pointer (PyObject *pyo_value, CORE_ADDR *addr) rc = 1; } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { gdbpy_convert_exception (except); } - END_CATCH return rc; } @@ -211,16 +210,15 @@ unwind_infopy_str (PyObject *self) stb.printf ("%s(%d, ", sep, reg.number); if (value != NULL) { - TRY + try { value_print (value, &stb, &opts); stb.puts (")"); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH } else stb.puts (")"); @@ -346,16 +344,15 @@ pending_framepy_str (PyObject *self) if (frame == NULL) return PyString_FromString ("Stale PendingFrame instance"); - TRY + try { sp_str = core_addr_to_string_nz (get_frame_sp (frame)); pc_str = core_addr_to_string_nz (get_frame_pc (frame)); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return PyString_FromFormat ("SP=%s,PC=%s", sp_str, pc_str); } @@ -385,7 +382,7 @@ pending_framepy_read_register (PyObject *self, PyObject *args) return NULL; } - TRY + try { /* Fetch the value associated with a register, whether it's a real register or a so called "user" register, like "pc", @@ -398,11 +395,10 @@ pending_framepy_read_register (PyObject *self, PyObject *args) "Cannot read register %d from frame.", regnum); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return val == NULL ? NULL : value_to_value_object (val); } diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c index 87715ee..76b5ac0 100644 --- a/gdb/python/py-utils.c +++ b/gdb/python/py-utils.c @@ -254,15 +254,14 @@ get_addr_from_python (PyObject *obj, CORE_ADDR *addr) if (gdbpy_is_value_object (obj)) { - TRY + try { *addr = value_as_address (value_object_to_value (obj)); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_SET_HANDLE_EXCEPTION (except); } - END_CATCH } else { diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index 1dcb60d..a761b1e 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -216,7 +216,7 @@ valpy_dereference (PyObject *self, PyObject *args) { PyObject *result = NULL; - TRY + try { struct value *res_val; scoped_value_mark free_values; @@ -224,11 +224,10 @@ valpy_dereference (PyObject *self, PyObject *args) res_val = value_ind (((value_object *) self)->value); result = value_to_value_object (res_val); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return result; } @@ -246,7 +245,7 @@ valpy_referenced_value (PyObject *self, PyObject *args) { PyObject *result = NULL; - TRY + try { struct value *self_val, *res_val; scoped_value_mark free_values; @@ -268,11 +267,10 @@ valpy_referenced_value (PyObject *self, PyObject *args) result = value_to_value_object (res_val); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return result; } @@ -284,7 +282,7 @@ valpy_reference_value (PyObject *self, PyObject *args, enum type_code refcode) { PyObject *result = NULL; - TRY + try { struct value *self_val; scoped_value_mark free_values; @@ -292,11 +290,10 @@ valpy_reference_value (PyObject *self, PyObject *args, enum type_code refcode) self_val = ((value_object *) self)->value; result = value_to_value_object (value_ref (self_val, refcode)); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return result; } @@ -320,7 +317,7 @@ valpy_const_value (PyObject *self, PyObject *args) { PyObject *result = NULL; - TRY + try { struct value *self_val, *res_val; scoped_value_mark free_values; @@ -329,11 +326,10 @@ valpy_const_value (PyObject *self, PyObject *args) res_val = make_cv_value (1, 0, self_val); result = value_to_value_object (res_val); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return result; } @@ -346,7 +342,7 @@ valpy_get_address (PyObject *self, void *closure) if (!val_obj->address) { - TRY + try { struct value *res_val; scoped_value_mark free_values; @@ -354,12 +350,11 @@ valpy_get_address (PyObject *self, void *closure) res_val = value_addr (val_obj->value); val_obj->address = value_to_value_object (res_val); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { val_obj->address = Py_None; Py_INCREF (Py_None); } - END_CATCH } Py_XINCREF (val_obj->address); @@ -397,7 +392,7 @@ valpy_get_dynamic_type (PyObject *self, void *closure) return obj->dynamic_type; } - TRY + try { struct value *val = obj->value; scoped_value_mark free_values; @@ -433,11 +428,10 @@ valpy_get_dynamic_type (PyObject *self, void *closure) type = NULL; } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (type == NULL) obj->dynamic_type = valpy_get_type (self, NULL); @@ -485,7 +479,7 @@ valpy_lazy_string (PyObject *self, PyObject *args, PyObject *kw) return NULL; } - TRY + try { scoped_value_mark free_values; struct type *type, *realtype; @@ -540,11 +534,10 @@ valpy_lazy_string (PyObject *self, PyObject *args, PyObject *kw) str_obj = gdbpy_create_lazy_string_object (addr, length, user_encoding, type); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return str_obj; } @@ -572,15 +565,14 @@ valpy_string (PyObject *self, PyObject *args, PyObject *kw) &user_encoding, &errors, &length)) return NULL; - TRY + try { LA_GET_STRING (value, &buffer, &length, &char_type, &la_encoding); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH encoding = (user_encoding && *user_encoding) ? user_encoding : la_encoding; return PyUnicode_Decode ((const char *) buffer.get (), @@ -733,16 +725,15 @@ valpy_format_string (PyObject *self, PyObject *args, PyObject *kw) string_file stb; - TRY + try { common_val_print (((value_object *) self)->value, &stb, 0, &opts, python_language); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return PyUnicode_Decode (stb.c_str (), stb.size (), host_charset (), NULL); } @@ -766,7 +757,7 @@ valpy_do_cast (PyObject *self, PyObject *args, enum exp_opcode op) return NULL; } - TRY + try { struct value *val = ((value_object *) self)->value; struct value *res_val; @@ -784,11 +775,10 @@ valpy_do_cast (PyObject *self, PyObject *args, enum exp_opcode op) result = value_to_value_object (res_val); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return result; } @@ -849,7 +839,7 @@ value_has_field (struct value *v, PyObject *field) return -1; } - TRY + try { val_type = value_type (v); val_type = check_typedef (val_type); @@ -863,11 +853,10 @@ value_has_field (struct value *v, PyObject *field) else has_field = 0; } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_SET_HANDLE_EXCEPTION (except); } - END_CATCH return has_field; } @@ -988,7 +977,7 @@ valpy_getitem (PyObject *self, PyObject *key) } } - TRY + try { struct value *tmp = self_value->value; struct value *res_val = NULL; @@ -1042,11 +1031,10 @@ valpy_getitem (PyObject *self, PyObject *key) if (res_val) result = value_to_value_object (res_val); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { except = ex; } - END_CATCH GDB_PY_HANDLE_EXCEPTION (except); @@ -1072,15 +1060,14 @@ valpy_call (PyObject *self, PyObject *args, PyObject *keywords) struct type *ftype = NULL; PyObject *result = NULL; - TRY + try { ftype = check_typedef (value_type (function)); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (TYPE_CODE (ftype) != TYPE_CODE_FUNC) { @@ -1115,7 +1102,7 @@ valpy_call (PyObject *self, PyObject *args, PyObject *keywords) } } - TRY + try { scoped_value_mark free_values; @@ -1124,11 +1111,10 @@ valpy_call (PyObject *self, PyObject *args, PyObject *keywords) gdb::make_array_view (vargs, args_count)); result = value_to_value_object (return_value); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return result; } @@ -1145,16 +1131,15 @@ valpy_str (PyObject *self) string_file stb; - TRY + try { common_val_print (((value_object *) self)->value, &stb, 0, &opts, python_language); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return PyUnicode_Decode (stb.c_str (), stb.size (), host_charset (), NULL); } @@ -1166,15 +1151,14 @@ valpy_get_is_optimized_out (PyObject *self, void *closure) struct value *value = ((value_object *) self)->value; int opt = 0; - TRY + try { opt = value_optimized_out (value); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (opt) Py_RETURN_TRUE; @@ -1189,15 +1173,14 @@ valpy_get_is_lazy (PyObject *self, void *closure) struct value *value = ((value_object *) self)->value; int opt = 0; - TRY + try { opt = value_lazy (value); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (opt) Py_RETURN_TRUE; @@ -1211,16 +1194,15 @@ valpy_fetch_lazy (PyObject *self, PyObject *args) { struct value *value = ((value_object *) self)->value; - TRY + try { if (value_lazy (value)) value_fetch_lazy (value); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH Py_RETURN_NONE; } @@ -1384,15 +1366,14 @@ valpy_binop (enum valpy_opcode opcode, PyObject *self, PyObject *other) { PyObject *result = NULL; - TRY + try { result = valpy_binop_throw (opcode, self, other); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return result; } @@ -1448,7 +1429,7 @@ valpy_negative (PyObject *self) { PyObject *result = NULL; - TRY + try { /* Perhaps overkill, but consistency has some virtue. */ scoped_value_mark free_values; @@ -1457,11 +1438,10 @@ valpy_negative (PyObject *self) val = value_neg (((value_object *) self)->value); result = value_to_value_object (val); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return result; } @@ -1478,18 +1458,17 @@ valpy_absolute (PyObject *self) struct value *value = ((value_object *) self)->value; int isabs = 1; - TRY + try { scoped_value_mark free_values; if (value_less (value, value_zero (value_type (value), not_lval))) isabs = 0; } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (isabs) return valpy_positive (self); @@ -1506,7 +1485,7 @@ valpy_nonzero (PyObject *self) struct type *type; int nonzero = 0; /* Appease GCC warning. */ - TRY + try { type = check_typedef (value_type (self_value->value)); @@ -1519,11 +1498,10 @@ valpy_nonzero (PyObject *self) /* All other values are True. */ nonzero = 1; } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { except = ex; } - END_CATCH /* This is not documented in the Python documentation, but if this function fails, return -1 as slot_nb_nonzero does (the default @@ -1539,15 +1517,14 @@ valpy_invert (PyObject *self) { struct value *val = NULL; - TRY + try { val = value_complement (((value_object *) self)->value); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return value_to_value_object (val); } @@ -1667,15 +1644,14 @@ valpy_richcompare (PyObject *self, PyObject *other, int op) return NULL; } - TRY + try { result = valpy_richcompare_throw (self, other, op); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH /* In this case, the Python exception has already been set. */ if (result < 0) @@ -1696,7 +1672,7 @@ valpy_int (PyObject *self) struct type *type = value_type (value); LONGEST l = 0; - TRY + try { if (is_floating_value (value)) { @@ -1710,11 +1686,10 @@ valpy_int (PyObject *self) l = value_as_long (value); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (TYPE_UNSIGNED (type)) return gdb_py_object_from_ulongest (l).release (); @@ -1731,7 +1706,7 @@ valpy_long (PyObject *self) struct type *type = value_type (value); LONGEST l = 0; - TRY + try { if (is_floating_value (value)) { @@ -1747,11 +1722,10 @@ valpy_long (PyObject *self) l = value_as_long (value); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (TYPE_UNSIGNED (type)) return gdb_py_long_from_ulongest (l); @@ -1767,7 +1741,7 @@ valpy_float (PyObject *self) struct type *type = value_type (value); double d = 0; - TRY + try { type = check_typedef (type); @@ -1783,11 +1757,10 @@ valpy_float (PyObject *self) else error (_("Cannot convert value to float.")); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return PyFloat_FromDouble (d); } @@ -1837,7 +1810,7 @@ convert_value_from_python (PyObject *obj) gdb_assert (obj != NULL); - TRY + try { if (PyBool_Check (obj)) { @@ -1927,12 +1900,11 @@ convert_value_from_python (PyObject *obj) PyString_AsString (PyObject_Str (obj))); #endif } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { gdbpy_convert_exception (except); return NULL; } - END_CATCH return value; } @@ -1947,15 +1919,14 @@ gdbpy_history (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "i", &i)) return NULL; - TRY + try { res_val = access_value_history (i); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return value_to_value_object (res_val); } @@ -1970,7 +1941,7 @@ gdbpy_convenience_variable (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &varname)) return NULL; - TRY + try { struct internalvar *var = lookup_only_internalvar (varname); @@ -1981,11 +1952,10 @@ gdbpy_convenience_variable (PyObject *self, PyObject *args) res_val = NULL; } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (res_val == NULL) Py_RETURN_NONE; @@ -2012,7 +1982,7 @@ gdbpy_set_convenience_variable (PyObject *self, PyObject *args) return NULL; } - TRY + try { if (value == NULL) { @@ -2028,11 +1998,10 @@ gdbpy_set_convenience_variable (PyObject *self, PyObject *args) set_internalvar (var, value); } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH Py_RETURN_NONE; } diff --git a/gdb/python/python.c b/gdb/python/python.c index 0d9415c..503639e 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -497,15 +497,14 @@ gdbpy_parameter (PyObject *self, PyObject *args) std::string newarg = std::string ("show ") + arg; - TRY + try { found = lookup_cmd_composition (newarg.c_str (), &alias, &prefix, &cmd); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { GDB_PY_HANDLE_EXCEPTION (ex); } - END_CATCH if (!found) return PyErr_Format (PyExc_RuntimeError, @@ -574,7 +573,7 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) scoped_restore preventer = prevent_dont_repeat (); - TRY + try { gdbpy_allow_threads allow_threads; @@ -615,11 +614,10 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) /* Do any commands attached to breakpoint we stopped at. */ bpstat_do_actions (); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH if (to_string) return PyString_FromString (to_string_res.c_str ()); @@ -830,7 +828,7 @@ gdbpy_decode_line (PyObject *self, PyObject *args) std::vector decoded_sals; symtab_and_line def_sal; gdb::array_view sals; - TRY + try { if (location != NULL) { @@ -844,13 +842,12 @@ gdbpy_decode_line (PyObject *self, PyObject *args) sals = def_sal; } } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { /* We know this will always throw. */ gdbpy_convert_exception (ex); return NULL; } - END_CATCH if (!sals.empty ()) { @@ -898,16 +895,15 @@ gdbpy_parse_and_eval (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "s", &expr_str)) return NULL; - TRY + try { gdbpy_allow_threads allow_threads; result = parse_and_eval (expr_str); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH return value_to_value_object (result); } @@ -1136,7 +1132,7 @@ gdbpy_write (PyObject *self, PyObject *args, PyObject *kw) &stream_type)) return NULL; - TRY + try { switch (stream_type) { @@ -1154,11 +1150,10 @@ gdbpy_write (PyObject *self, PyObject *args, PyObject *kw) fprintf_filtered (gdb_stdout, "%s", arg); } } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { GDB_PY_HANDLE_EXCEPTION (except); } - END_CATCH Py_RETURN_NONE; } @@ -1224,14 +1219,13 @@ gdbpy_print_stack (void) /* PyErr_Print doesn't necessarily end output with a newline. This works because Python's stdout/stderr is fed through printf_filtered. */ - TRY + try { begin_line (); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { } - END_CATCH } /* Print "message", just error print message. */ else @@ -1245,7 +1239,7 @@ gdbpy_print_stack (void) if (msg != NULL) type = fetched_error.type_to_string (); - TRY + try { if (msg == NULL || type == NULL) { @@ -1260,10 +1254,9 @@ gdbpy_print_stack (void) fprintf_filtered (gdb_stderr, "Python Exception %s %s: \n", type.get (), msg.get ()); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { } - END_CATCH } } diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index 2a2140b..add8969 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -282,15 +282,14 @@ require_btrace (void) static void record_btrace_enable_warn (struct thread_info *tp) { - TRY + try { btrace_enable (tp, &record_btrace_conf); } - CATCH (error, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &error) { warning ("%s", error.what ()); } - END_CATCH } /* Enable automatic tracing of new threads. */ @@ -1479,16 +1478,15 @@ record_btrace_target::insert_breakpoint (struct gdbarch *gdbarch, replay_memory_access = replay_memory_access_read_write; ret = 0; - TRY + try { ret = this->beneath ()->insert_breakpoint (gdbarch, bp_tgt); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { replay_memory_access = old; throw_exception (except); } - END_CATCH replay_memory_access = old; return ret; @@ -1510,16 +1508,15 @@ record_btrace_target::remove_breakpoint (struct gdbarch *gdbarch, replay_memory_access = replay_memory_access_read_write; ret = 0; - TRY + try { ret = this->beneath ()->remove_breakpoint (gdbarch, bp_tgt, reason); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { replay_memory_access = old; throw_exception (except); } - END_CATCH replay_memory_access = old; return ret; @@ -1988,18 +1985,17 @@ get_thread_current_frame_id (struct thread_info *tp) set_executing (inferior_ptid, false); id = null_frame_id; - TRY + try { id = get_frame_id (get_current_frame ()); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { /* Restore the previous execution state. */ set_executing (inferior_ptid, executing); throw_exception (except); } - END_CATCH /* Restore the previous execution state. */ set_executing (inferior_ptid, executing); @@ -2027,7 +2023,7 @@ record_btrace_start_replaying (struct thread_info *tp) Since frames are computed differently when we're replaying, we need to recompute those stored frames and fix them up so we can still detect subroutines after we started replaying. */ - TRY + try { struct frame_id frame_id; int upd_step_frame_id, upd_step_stack_frame_id; @@ -2072,7 +2068,7 @@ record_btrace_start_replaying (struct thread_info *tp) if (upd_step_stack_frame_id) tp->control.step_stack_frame_id = frame_id; } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { xfree (btinfo->replay); btinfo->replay = NULL; @@ -2081,7 +2077,6 @@ record_btrace_start_replaying (struct thread_info *tp) throw_exception (except); } - END_CATCH return replay; } @@ -2894,16 +2889,15 @@ cmd_record_btrace_bts_start (const char *args, int from_tty) record_btrace_conf.format = BTRACE_FORMAT_BTS; - TRY + try { execute_command ("target record-btrace", from_tty); } - CATCH (exception, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &exception) { record_btrace_conf.format = BTRACE_FORMAT_NONE; throw_exception (exception); } - END_CATCH } /* Start recording in Intel Processor Trace format. */ @@ -2916,16 +2910,15 @@ cmd_record_btrace_pt_start (const char *args, int from_tty) record_btrace_conf.format = BTRACE_FORMAT_PT; - TRY + try { execute_command ("target record-btrace", from_tty); } - CATCH (exception, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &exception) { record_btrace_conf.format = BTRACE_FORMAT_NONE; throw_exception (exception); } - END_CATCH } /* Alias for "target record". */ @@ -2938,26 +2931,24 @@ cmd_record_btrace_start (const char *args, int from_tty) record_btrace_conf.format = BTRACE_FORMAT_PT; - TRY + try { execute_command ("target record-btrace", from_tty); } - CATCH (exception, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &exception) { record_btrace_conf.format = BTRACE_FORMAT_BTS; - TRY + try { execute_command ("target record-btrace", from_tty); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { record_btrace_conf.format = BTRACE_FORMAT_NONE; throw_exception (ex); } - END_CATCH } - END_CATCH } /* The "set record btrace" command. */ diff --git a/gdb/record-full.c b/gdb/record-full.c index ea0eddb..ce3f67f 100644 --- a/gdb/record-full.c +++ b/gdb/record-full.c @@ -708,7 +708,7 @@ record_full_message (struct regcache *regcache, enum gdb_signal signal) int ret; struct gdbarch *gdbarch = regcache->arch (); - TRY + try { record_full_arch_list_head = NULL; record_full_arch_list_tail = NULL; @@ -761,12 +761,11 @@ record_full_message (struct regcache *regcache, enum gdb_signal signal) if (ret < 0) error (_("Process record: failed to record execution log.")); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { record_full_list_release (record_full_arch_list_tail); throw_exception (ex); } - END_CATCH record_full_list->next = record_full_arch_list_head; record_full_arch_list_head->prev = record_full_list; @@ -782,16 +781,15 @@ static bool record_full_message_wrapper_safe (struct regcache *regcache, enum gdb_signal signal) { - TRY + try { record_full_message (regcache, signal); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { exception_print (gdb_stderr, ex); return false; } - END_CATCH return true; } @@ -1293,7 +1291,7 @@ record_full_wait_1 (struct target_ops *ops, int continue_flag = 1; int first_record_full_end = 1; - TRY + try { CORE_ADDR tmp_pc; @@ -1436,7 +1434,7 @@ record_full_wait_1 (struct target_ops *ops, else status->value.sig = GDB_SIGNAL_TRAP; } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { if (execution_direction == EXEC_REVERSE) { @@ -1448,7 +1446,6 @@ record_full_wait_1 (struct target_ops *ops, throw_exception (ex); } - END_CATCH } signal (SIGINT, handle_sigint); @@ -2374,7 +2371,7 @@ record_full_restore (void) record_full_arch_list_tail = NULL; record_full_insn_num = 0; - TRY + try { regcache = get_current_regcache (); @@ -2476,12 +2473,11 @@ record_full_restore (void) record_full_arch_list_add (rec); } } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { record_full_list_release (record_full_arch_list_tail); throw_exception (ex); } - END_CATCH /* Add record_full_arch_list_head to the end of record list. */ record_full_first.next = record_full_arch_list_head; diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c index 91caa2b..6887a6a 100644 --- a/gdb/remote-fileio.c +++ b/gdb/remote-fileio.c @@ -1185,18 +1185,17 @@ remote_fileio_request (remote_target *remote, char *buf, int ctrlc_pending_p) } else { - TRY + try { do_remote_fileio_request (remote, buf); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { if (ex.reason == RETURN_QUIT) remote_fileio_reply (remote, -1, FILEIO_EINTR); else remote_fileio_reply (remote, -1, FILEIO_EIO); } - END_CATCH } quit_handler = remote_fileio_o_quit_handler; diff --git a/gdb/remote.c b/gdb/remote.c index 2b21aea..0424ea4 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -1146,12 +1146,12 @@ remote_target::remote_get_noisy_reply () org_to = to; - TRY + try { gdbarch_relocate_instruction (target_gdbarch (), &to, from); relocated = 1; } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { if (ex.error == MEMORY_ERROR) { @@ -1170,7 +1170,6 @@ remote_target::remote_get_noisy_reply () } putpkt ("E01"); } - END_CATCH if (relocated) { @@ -5602,11 +5601,11 @@ remote_target::open_1 (const char *name, int from_tty, int extended_p) function. See cli-dump.c. */ { - TRY + try { remote->start_remote (from_tty, extended_p); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { /* Pop the partially set up target - unless something else did already before throwing the exception. */ @@ -5614,7 +5613,6 @@ remote_target::open_1 (const char *name, int from_tty, int extended_p) remote_unpush_target (); throw_exception (ex); } - END_CATCH } remote_btrace_reset (rs); @@ -9766,11 +9764,11 @@ remote_target::remote_kill_k () { /* Catch errors so the user can quit from gdb even when we aren't on speaking terms with the remote system. */ - TRY + try { putpkt ("k"); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (ex.error == TARGET_CLOSE_ERROR) { @@ -9788,7 +9786,6 @@ remote_target::remote_kill_k () user or higher layers decide what to do. */ throw_exception (ex); } - END_CATCH } void @@ -13135,11 +13132,11 @@ remote_target::get_trace_status (struct trace_status *ts) putpkt ("qTStatus"); - TRY + try { p = remote_get_noisy_reply (); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (ex.error != TARGET_CLOSE_ERROR) { @@ -13148,7 +13145,6 @@ remote_target::get_trace_status (struct trace_status *ts) } throw_exception (ex); } - END_CATCH result = packet_ok (p, &remote_protocol_packets[PACKET_qTStatus]); @@ -13790,16 +13786,15 @@ remote_target::enable_btrace (ptid_t ptid, const struct btrace_config *conf) /* If we fail to read the configuration, we lose some information, but the tracing itself is not impacted. */ - TRY + try { btrace_read_config (&tinfo->conf); } - CATCH (err, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &err) { if (err.message != NULL) warning ("%s", err.what ()); } - END_CATCH return tinfo; } diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index 1f88683..3cd9ba4 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -651,19 +651,18 @@ riscv_print_one_register_info (struct gdbarch *gdbarch, fputs_filtered (name, file); print_spaces_filtered (value_column_1 - strlen (name), file); - TRY + try { val = value_of_register (regnum, frame); regtype = value_type (val); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { /* Handle failure to read a register without interrupting the entire 'info registers' flow. */ fprintf_filtered (file, "%s\n", ex.what ()); return; } - END_CATCH print_raw_format = (value_entirely_available (val) && !value_optimized_out (val)); @@ -2802,17 +2801,16 @@ riscv_frame_this_id (struct frame_info *this_frame, { struct riscv_unwind_cache *cache; - TRY + try { cache = riscv_frame_cache (this_frame, prologue_cache); *this_id = cache->this_id; } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { /* Ignore errors, this leaves the frame id as the predefined outer frame id which terminates the backtrace at this point. */ } - END_CATCH } /* Implement the prev_register callback for RiscV frame unwinder. */ diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c index 2a5271c..0c0f026 100644 --- a/gdb/rs6000-aix-tdep.c +++ b/gdb/rs6000-aix-tdep.c @@ -670,18 +670,17 @@ rs6000_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR pc = 0; struct obj_section *pc_section; - TRY + try { pc = read_memory_unsigned_integer (addr, tdep->wordsize, byte_order); } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { /* An error occured during reading. Probably a memory error due to the section not being loaded yet. This address cannot be a function descriptor. */ return addr; } - END_CATCH pc_section = find_pc_section (pc); diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index e875ad9..2f08e0f 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -3451,7 +3451,7 @@ rs6000_frame_cache (struct frame_info *this_frame, void **this_cache) cache->pc = 0; cache->saved_regs = trad_frame_alloc_saved_regs (this_frame); - TRY + try { func = get_frame_func (this_frame); cache->pc = func; @@ -3468,13 +3468,12 @@ rs6000_frame_cache (struct frame_info *this_frame, void **this_cache) cache->base = get_frame_register_unsigned (this_frame, gdbarch_sp_regnum (gdbarch)); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (ex.error != NOT_AVAILABLE_ERROR) throw_exception (ex); return (struct rs6000_frame_cache *) (*this_cache); } - END_CATCH /* If the function appears to be frameless, check a couple of likely indicators that we have simply failed to find the frame setup. @@ -3683,7 +3682,7 @@ rs6000_epilogue_frame_cache (struct frame_info *this_frame, void **this_cache) (*this_cache) = cache; cache->saved_regs = trad_frame_alloc_saved_regs (this_frame); - TRY + try { /* At this point the stack looks as if we just entered the function, and the return address is stored in LR. */ @@ -3698,12 +3697,11 @@ rs6000_epilogue_frame_cache (struct frame_info *this_frame, void **this_cache) trad_frame_set_value (cache->saved_regs, gdbarch_pc_regnum (gdbarch), lr); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (ex.error != NOT_AVAILABLE_ERROR) throw_exception (ex); } - END_CATCH return cache; } diff --git a/gdb/rust-exp.y b/gdb/rust-exp.y index ba145b1..4aed05c 100644 --- a/gdb/rust-exp.y +++ b/gdb/rust-exp.y @@ -2615,17 +2615,16 @@ static void rust_lex_exception_test (rust_parser *parser, const char *input, const char *err) { - TRY + try { /* The "kind" doesn't matter. */ rust_lex_test_one (parser, input, DECIMAL_INTEGER); SELF_CHECK (0); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { SELF_CHECK (strcmp (except.what (), err) == 0); } - END_CATCH } /* Test that INPUT lexes as the identifier, string, or byte-string diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 0c6c13d..c14b45b 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1743,18 +1743,17 @@ tuple structs, and tuple-like enum variants")); field_name, TYPE_NAME (outer_type), rust_last_path_segment (TYPE_NAME (type))); - TRY + try { result = value_struct_elt (&lhs, NULL, field_name, NULL, "structure"); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { error (_("Could not find field %s of struct variant %s::%s"), field_name, TYPE_NAME (outer_type), rust_last_path_segment (TYPE_NAME (type))); } - END_CATCH } else result = value_struct_elt (&lhs, NULL, field_name, NULL, "structure"); diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index 90aba99..d44c108 100644 --- a/gdb/s390-tdep.c +++ b/gdb/s390-tdep.c @@ -2547,19 +2547,18 @@ s390_frame_unwind_cache (struct frame_info *this_frame, info->frame_base = -1; info->local_base = -1; - TRY + try { /* Try to use prologue analysis to fill the unwind cache. If this fails, fall back to reading the stack backchain. */ if (!s390_prologue_frame_unwind_cache (this_frame, info)) s390_backchain_frame_unwind_cache (this_frame, info); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (ex.error != NOT_AVAILABLE_ERROR) throw_exception (ex); } - END_CATCH return info; } diff --git a/gdb/selftest-arch.c b/gdb/selftest-arch.c index 7a64295..340056e 100644 --- a/gdb/selftest-arch.c +++ b/gdb/selftest-arch.c @@ -60,7 +60,7 @@ struct gdbarch_selftest : public selftest QUIT; - TRY + try { struct gdbarch_info info; @@ -72,13 +72,12 @@ struct gdbarch_selftest : public selftest function (gdbarch); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { pass = false; exception_fprintf (gdb_stderr, ex, _("Self test failed: arch %s: "), arches[i]); } - END_CATCH reset (); } diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c index 2031014..4cd8a69 100644 --- a/gdb/solib-dsbt.c +++ b/gdb/solib-dsbt.c @@ -830,14 +830,13 @@ enable_break (void) in the dynamic linker itself. */ gdb_bfd_ref_ptr tmp_bfd; - TRY + try { tmp_bfd = solib_bfd_open (buf); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { } - END_CATCH if (tmp_bfd == NULL) { diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c index 1b330b8..63edd41 100644 --- a/gdb/solib-frv.c +++ b/gdb/solib-frv.c @@ -561,14 +561,13 @@ enable_break2 (void) mechanism to find the dynamic linker's base address. */ gdb_bfd_ref_ptr tmp_bfd; - TRY + try { tmp_bfd = solib_bfd_open (buf); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { } - END_CATCH if (tmp_bfd == NULL) { diff --git a/gdb/solib-spu.c b/gdb/solib-spu.c index 0cce0c9..832da23 100644 --- a/gdb/solib-spu.c +++ b/gdb/solib-spu.c @@ -110,7 +110,7 @@ append_ocl_sos (struct so_list **link_ptr) { enum bfd_endian byte_order = bfd_big_endian (objfile->obfd)? BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE; - TRY + try { CORE_ADDR data = read_memory_unsigned_integer (*ocl_program_addr_base, @@ -133,7 +133,7 @@ append_ocl_sos (struct so_list **link_ptr) link_ptr = &newobj->next; } } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { /* Ignore memory errors. */ switch (ex.error) @@ -145,7 +145,6 @@ append_ocl_sos (struct so_list **link_ptr) break; } } - END_CATCH } } } diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 0b8cadb..53d5db8 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -869,16 +869,15 @@ solib_svr4_r_map (struct svr4_info *info) struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; CORE_ADDR addr = 0; - TRY + try { addr = read_memory_typed_address (info->debug_base + lmo->r_map_offset, ptr_type); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { exception_print (gdb_stderr, ex); } - END_CATCH return addr; } @@ -906,7 +905,7 @@ solib_svr4_r_ldsomap (struct svr4_info *info) enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ()); ULONGEST version = 0; - TRY + try { /* Check version, and return zero if `struct r_debug' doesn't have the r_ldsomap member. */ @@ -914,11 +913,10 @@ solib_svr4_r_ldsomap (struct svr4_info *info) = read_memory_unsigned_integer (info->debug_base + lmo->r_version_offset, lmo->r_version_size, byte_order); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { exception_print (gdb_stderr, ex); } - END_CATCH if (version < 2 || lmo->r_ldsomap_offset == -1) return 0; @@ -1732,16 +1730,15 @@ solib_event_probe_action (struct probe_and_action *pa) arg0: Lmid_t lmid (mandatory) arg1: struct r_debug *debug_base (mandatory) arg2: struct link_map *new (optional, for incremental updates) */ - TRY + try { probe_argc = pa->prob->get_argument_count (frame); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { exception_print (gdb_stderr, ex); probe_argc = 0; } - END_CATCH /* If get_argument_count throws an exception, probe_argc will be set to zero. However, if pa->prob does not have arguments, then @@ -1896,16 +1893,15 @@ svr4_handle_solib_event (void) scoped_restore inhibit_updates = inhibit_section_map_updates (current_program_space); - TRY + try { val = pa->prob->evaluate_argument (1, frame); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { exception_print (gdb_stderr, ex); val = NULL; } - END_CATCH if (val == NULL) return; @@ -1928,16 +1924,15 @@ svr4_handle_solib_event (void) if (action == UPDATE_OR_RELOAD) { - TRY + try { val = pa->prob->evaluate_argument (2, frame); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { exception_print (gdb_stderr, ex); return; } - END_CATCH if (val != NULL) lm = value_as_address (val); @@ -2279,14 +2274,13 @@ enable_break (struct svr4_info *info, int from_tty) mechanism to find the dynamic linker's base address. */ gdb_bfd_ref_ptr tmp_bfd; - TRY + try { tmp_bfd = solib_bfd_open (interp_name); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { } - END_CATCH if (tmp_bfd == NULL) goto bkpt_at_symbol; diff --git a/gdb/solib.c b/gdb/solib.c index 8cef5a0..75897ac 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -674,7 +674,7 @@ solib_read_symbols (struct so_list *so, symfile_add_flags flags) flags |= current_inferior ()->symfile_flags; - TRY + try { /* Have we already loaded this shared object? */ so->objfile = nullptr; @@ -700,13 +700,12 @@ solib_read_symbols (struct so_list *so, symfile_add_flags flags) so->symbols_loaded = 1; } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { exception_fprintf (gdb_stderr, e, _("Error while reading shared" " library symbols for %s:\n"), so->so_name); } - END_CATCH return 1; } @@ -748,17 +747,16 @@ update_solib_list (int from_tty) symbols now! */ if (inf->attach_flag && symfile_objfile == NULL) { - TRY + try { ops->open_symbol_file_object (from_tty); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { exception_fprintf (gdb_stderr, ex, "Error reading attached " "process's symbol file.\n"); } - END_CATCH } } @@ -868,7 +866,7 @@ update_solib_list (int from_tty) i->pspace = current_program_space; current_program_space->added_solibs.push_back (i); - TRY + try { /* Fill in the rest of the `struct so_list' node. */ if (!solib_map_sections (i)) @@ -879,13 +877,12 @@ update_solib_list (int from_tty) } } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { exception_fprintf (gdb_stderr, e, _("Error while mapping shared " "library sections:\n")); } - END_CATCH /* Notify any observer that the shared object has been loaded now that we've added it to GDB's tables. */ @@ -1333,19 +1330,18 @@ reload_shared_libraries_1 (int from_tty) { int got_error = 0; - TRY + try { solib_map_sections (so); } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { exception_fprintf (gdb_stderr, e, _("Error while mapping " "shared library sections:\n")); got_error = 1; } - END_CATCH if (!got_error && (auto_solib_add || was_loaded || libpthread_solib_p (so))) diff --git a/gdb/sparc64-linux-tdep.c b/gdb/sparc64-linux-tdep.c index 33170f2..6f2b10f 100644 --- a/gdb/sparc64-linux-tdep.c +++ b/gdb/sparc64-linux-tdep.c @@ -130,7 +130,7 @@ sparc64_linux_handle_segmentation_fault (struct gdbarch *gdbarch, CORE_ADDR addr = 0; long si_code = 0; - TRY + try { /* Evaluate si_code to see if the segfault is ADI related. */ si_code = parse_and_eval_long ("$_siginfo.si_code\n"); @@ -138,11 +138,10 @@ sparc64_linux_handle_segmentation_fault (struct gdbarch *gdbarch, if (si_code >= SEGV_ACCADI && si_code <= SEGV_ADIPERR) addr = parse_and_eval_long ("$_siginfo._sifields._sigfault.si_addr"); } - CATCH (exception, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &exception) { return; } - END_CATCH /* Print out ADI event based on sig_code value */ switch (si_code) diff --git a/gdb/stack.c b/gdb/stack.c index 7773ef9..87588e1 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -175,17 +175,16 @@ print_stack_frame (struct frame_info *frame, int print_level, if (current_uiout->is_mi_like_p ()) print_what = LOC_AND_ADDRESS; - TRY + try { print_frame_info (frame, print_level, print_what, 1 /* print_args */, set_current_sal); if (set_current_sal) set_current_sal_from_frame (frame); } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { } - END_CATCH } /* Print nameless arguments of frame FRAME on STREAM, where START is @@ -267,7 +266,7 @@ print_frame_arg (const struct frame_arg *arg) stb.printf (_(""), arg->error); else { - TRY + try { const struct language_defn *language; struct value_print_options opts; @@ -296,12 +295,11 @@ print_frame_arg (const struct frame_arg *arg) common_val_print (arg->val, &stb, 2, &opts, language); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { stb.printf (_(""), except.what ()); } - END_CATCH } } @@ -320,15 +318,14 @@ read_frame_local (struct symbol *sym, struct frame_info *frame, argp->val = NULL; argp->error = NULL; - TRY + try { argp->val = read_var_value (sym, NULL, frame); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { argp->error = xstrdup (except.what ()); } - END_CATCH } /* Read in inferior function parameter SYM at FRAME into ARGP. Caller is @@ -346,16 +343,15 @@ read_frame_arg (struct symbol *sym, struct frame_info *frame, if (print_entry_values != print_entry_values_only && print_entry_values != print_entry_values_preferred) { - TRY + try { val = read_var_value (sym, NULL, frame); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { val_error = (char *) alloca (except.message->size () + 1); strcpy (val_error, except.what ()); } - END_CATCH } if (SYMBOL_COMPUTED_OPS (sym) != NULL @@ -364,14 +360,14 @@ read_frame_arg (struct symbol *sym, struct frame_info *frame, && (print_entry_values != print_entry_values_if_needed || !val || value_optimized_out (val))) { - TRY + try { const struct symbol_computed_ops *ops; ops = SYMBOL_COMPUTED_OPS (sym); entryval = ops->read_variable_at_entry (sym, frame); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { if (except.error != NO_ENTRY_VALUE_ERROR) { @@ -379,7 +375,6 @@ read_frame_arg (struct symbol *sym, struct frame_info *frame, strcpy (entryval_error, except.what ()); } } - END_CATCH if (entryval != NULL && value_optimized_out (entryval)) entryval = NULL; @@ -407,7 +402,7 @@ read_frame_arg (struct symbol *sym, struct frame_info *frame, value. If it is a reference still try to verify if dereferenced DW_AT_call_data_value does not differ. */ - TRY + try { struct type *type_deref; @@ -428,7 +423,7 @@ read_frame_arg (struct symbol *sym, struct frame_info *frame, TYPE_LENGTH (type_deref))) val_equal = 1; } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { /* If the dereferenced content could not be fetched do not display anything. */ @@ -441,7 +436,6 @@ read_frame_arg (struct symbol *sym, struct frame_info *frame, strcpy (entryval_error, except.what ()); } } - END_CATCH /* Value was not a reference; and its content matches. */ if (val == val_deref) @@ -473,16 +467,15 @@ read_frame_arg (struct symbol *sym, struct frame_info *frame, { gdb_assert (val == NULL); - TRY + try { val = read_var_value (sym, NULL, frame); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { val_error = (char *) alloca (except.message->size () + 1); strcpy (val_error, except.what ()); } - END_CATCH } if (print_entry_values == print_entry_values_only || print_entry_values == print_entry_values_both @@ -759,19 +752,18 @@ do_gdb_disassembly (struct gdbarch *gdbarch, int how_many, CORE_ADDR low, CORE_ADDR high) { - TRY + try { gdb_disassembly (gdbarch, current_uiout, DISASSEMBLY_RAW_INSN, how_many, low, high); } - CATCH (exception, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &exception) { /* If an exception was thrown while doing the disassembly, print the error message, to give the user a clue of what happened. */ exception_print (gdb_stderr, exception); } - END_CATCH } /* Print information about frame FRAME. The output is format according @@ -1204,14 +1196,13 @@ print_frame (struct frame_info *frame, int print_level, { ui_out_emit_list list_emitter (uiout, "args"); - TRY + try { print_frame_args (func, frame, numargs, gdb_stdout); } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &e) { } - END_CATCH /* FIXME: ARGS must be a list. If one argument is a string it will have " that will not be properly escaped. */ @@ -1393,12 +1384,12 @@ info_frame_command_core (struct frame_info *fi, bool selected_frame_p) val_print_not_saved (gdb_stdout); else { - TRY + try { caller_pc = frame_unwind_caller_pc (fi); caller_pc_p = 1; } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { switch (ex.error) { @@ -1414,7 +1405,6 @@ info_frame_command_core (struct frame_info *fi, bool selected_frame_p) break; } } - END_CATCH } if (caller_pc_p) @@ -2694,7 +2684,7 @@ frame_apply_command_count (const char *which_command, QUIT; select_frame (fi); - TRY + try { std::string cmd_result; { @@ -2714,7 +2704,7 @@ frame_apply_command_count (const char *which_command, printf_filtered ("%s", cmd_result.c_str ()); } } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { fi = get_selected_frame (_("frame apply " "unable to get selected frame.")); @@ -2728,7 +2718,6 @@ frame_apply_command_count (const char *which_command, throw_exception (ex); } } - END_CATCH; } } diff --git a/gdb/symfile-mem.c b/gdb/symfile-mem.c index 1029c01..118f289 100644 --- a/gdb/symfile-mem.c +++ b/gdb/symfile-mem.c @@ -187,7 +187,7 @@ add_vsyscall_page (struct target_ops *target, int from_tty) char *name = xstrprintf ("system-supplied DSO at %s", paddress (target_gdbarch (), vsyscall_range.start)); - TRY + try { /* Pass zero for FROM_TTY, because the action of loading the vsyscall DSO was not triggered by the user, even if the @@ -198,11 +198,10 @@ add_vsyscall_page (struct target_ops *target, int from_tty) name, 0 /* from_tty */); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { exception_print (gdb_stderr, ex); } - END_CATCH } } diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 0220b42..8867ba7 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -349,16 +349,15 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile) block, not any blocks from included symtabs. */ ALL_DICT_SYMBOLS (BLOCK_MULTIDICT (b), miter, sym) { - TRY + try { print_symbol (gdbarch, sym, depth + 1, outfile); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { exception_fprintf (gdb_stderr, ex, "Error printing symbol:\n"); } - END_CATCH } } fprintf_filtered (outfile, "\n"); diff --git a/gdb/target.c b/gdb/target.c index 646f913..9b777ea 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -704,7 +704,7 @@ target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset) { ptid_t ptid = inferior_ptid; - TRY + try { CORE_ADDR lm_addr; @@ -720,7 +720,7 @@ target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset) } /* If an error occurred, print TLS related messages here. Otherwise, throw the error to some higher catcher. */ - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { int objfile_is_library = (objfile->flags & OBJF_SHARED); @@ -771,7 +771,6 @@ target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset) break; } } - END_CATCH } else error (_("Cannot find thread-local variables on this target")); diff --git a/gdb/thread.c b/gdb/thread.c index a86f269..cde7c34 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -1459,7 +1459,7 @@ thr_try_catch_cmd (thread_info *thr, const char *cmd, int from_tty, const qcs_flags &flags) { switch_to_thread (thr); - TRY + try { std::string cmd_result = execute_command_to_string (cmd, from_tty); if (!flags.silent || cmd_result.length () > 0) @@ -1471,7 +1471,7 @@ thr_try_catch_cmd (thread_info *thr, const char *cmd, int from_tty, printf_filtered ("%s", cmd_result.c_str ()); } } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { if (!flags.silent) { @@ -1485,7 +1485,6 @@ thr_try_catch_cmd (thread_info *thr, const char *cmd, int from_tty, throw_exception (ex); } } - END_CATCH; } /* Apply a GDB command to a list of threads. List syntax is a whitespace diff --git a/gdb/top.c b/gdb/top.c index 1fc259f..829b534 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -1621,31 +1621,29 @@ quit_force (int *exit_arg, int from_tty) /* We want to handle any quit errors and exit regardless. */ /* Get out of tfind mode, and kill or detach all inferiors. */ - TRY + try { disconnect_tracing (); iterate_over_inferiors (kill_or_detach, &qt); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { exception_print (gdb_stderr, ex); } - END_CATCH /* Give all pushed targets a chance to do minimal cleanup, and pop them all out. */ - TRY + try { pop_all_targets (); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { exception_print (gdb_stderr, ex); } - END_CATCH /* Save the history information if it is appropriate to do so. */ - TRY + try { if (write_history_p && history_filename) { @@ -1667,11 +1665,10 @@ quit_force (int *exit_arg, int from_tty) gdb_safe_append_history (); } } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { exception_print (gdb_stderr, ex); } - END_CATCH /* Destroy any values currently allocated now instead of leaving it to global destructors, because that may be too late. For @@ -1680,15 +1677,14 @@ quit_force (int *exit_arg, int from_tty) finalize_values (); /* Do any final cleanups before exiting. */ - TRY + try { do_final_cleanups (); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { exception_print (gdb_stderr, ex); } - END_CATCH exit (exit_code); } diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c index 020a6be..6581cb1 100644 --- a/gdb/tracefile-tfile.c +++ b/gdb/tracefile-tfile.c @@ -511,7 +511,7 @@ tfile_target_open (const char *arg, int from_tty) ts->disconnected_tracing = 0; ts->circular_buffer = 0; - TRY + try { /* Read through a section of newline-terminated lines that define things like tracepoints. */ @@ -547,13 +547,12 @@ tfile_target_open (const char *arg, int from_tty) if (trace_regblock_size == 0) error (_("No register block size recorded in trace file")); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { /* Remove the partially set up target. */ unpush_target (&tfile_ops); throw_exception (ex); } - END_CATCH inferior_appeared (current_inferior (), TFILE_PID); inferior_ptid = ptid_t (TFILE_PID); diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c index 4c99632..533b7bc 100644 --- a/gdb/tui/tui.c +++ b/gdb/tui/tui.c @@ -96,7 +96,7 @@ tui_rl_switch_mode (int notused1, int notused2) /* Don't let exceptions escape. We're in the middle of a readline callback that isn't prepared for that. */ - TRY + try { if (tui_active) { @@ -110,14 +110,13 @@ tui_rl_switch_mode (int notused1, int notused2) tui_enable (); } } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { exception_print (gdb_stderr, ex); if (!tui_active) rl_prep_terminal (0); } - END_CATCH /* Clear the readline in case switching occurred in middle of something. */ diff --git a/gdb/typeprint.c b/gdb/typeprint.c index 0a93a83..91ce29b 100644 --- a/gdb/typeprint.c +++ b/gdb/typeprint.c @@ -413,17 +413,16 @@ type_print (struct type *type, const char *varstring, struct ui_file *stream, std::string type_to_string (struct type *type) { - TRY + try { string_file stb; type_print (type, "", &stb, -1); return std::move (stb.string ()); } - CATCH (except, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &except) { } - END_CATCH return {}; } diff --git a/gdb/unittests/cli-utils-selftests.c b/gdb/unittests/cli-utils-selftests.c index e357b06..6b0efe5 100644 --- a/gdb/unittests/cli-utils-selftests.c +++ b/gdb/unittests/cli-utils-selftests.c @@ -78,19 +78,18 @@ test_number_or_range_parser () number_or_range_parser minus_one ("-1"); SELF_CHECK (!minus_one.finished ()); - TRY + try { minus_one.get_number (); SELF_CHECK (false); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { SELF_CHECK (ex.reason == RETURN_ERROR); SELF_CHECK (ex.error == GENERIC_ERROR); SELF_CHECK (strcmp (ex.what (), "negative value") == 0); SELF_CHECK (strcmp (minus_one.cur_tok (), "-1") == 0); } - END_CATCH; } /* Test that a - followed by not a number does not give an error. */ @@ -209,7 +208,7 @@ test_parse_flags_qcs () const char *t4 = "-c -s non flags args"; qcs_flags flags; - TRY + try { SELF_CHECK (parse_flags_qcs ("test_parse_flags_qcs.t4.cs", &t4, @@ -220,7 +219,7 @@ test_parse_flags_qcs () &flags); SELF_CHECK (false); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { SELF_CHECK (ex.reason == RETURN_ERROR); SELF_CHECK (ex.error == GENERIC_ERROR); @@ -229,7 +228,6 @@ test_parse_flags_qcs () "test_parse_flags_qcs.t4.cs: " "-c and -s are mutually exclusive") == 0); } - END_CATCH; } } diff --git a/gdb/unittests/parse-connection-spec-selftests.c b/gdb/unittests/parse-connection-spec-selftests.c index 969c51e..a33b3d8 100644 --- a/gdb/unittests/parse-connection-spec-selftests.c +++ b/gdb/unittests/parse-connection-spec-selftests.c @@ -212,18 +212,17 @@ test_conn (const parse_conn_test &c) memset (&hint, 0, sizeof (hint)); - TRY + try { ret = parse_connection_spec (c.connspec, &hint); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { /* If we caught an error, we should check if this connection spec was supposed to fail. */ SELF_CHECK (c.should_fail); return; } - END_CATCH SELF_CHECK (!c.should_fail); SELF_CHECK (ret.host_str == c.expected_result.host_str); diff --git a/gdb/valops.c b/gdb/valops.c index 3d1f39f..69da319 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -3621,11 +3621,11 @@ value_rtti_indirect_type (struct value *v, int *full, else if (TYPE_CODE (type) == TYPE_CODE_PTR) { - TRY + try { target = value_ind (v); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { if (except.error == MEMORY_ERROR) { @@ -3636,7 +3636,6 @@ value_rtti_indirect_type (struct value *v, int *full, } throw_exception (except); } - END_CATCH } else return NULL; @@ -3774,14 +3773,13 @@ value_of_this_silent (const struct language_defn *lang) { struct value *ret = NULL; - TRY + try { ret = value_of_this (lang); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { } - END_CATCH return ret; } diff --git a/gdb/valprint.c b/gdb/valprint.c index 1002090..7554730 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -1054,17 +1054,16 @@ val_print (struct type *type, LONGEST embedded_offset, return; } - TRY + try { language->la_val_print (type, embedded_offset, address, stream, recurse, val, &local_opts); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { fprintf_filtered (stream, _("")); } - END_CATCH } /* Check whether the value VAL is printable. Return 1 if it is; diff --git a/gdb/value.c b/gdb/value.c index 02307c1..99a27b5 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1405,15 +1405,14 @@ value_optimized_out (struct value *value) fetch it. */ if (value->optimized_out.empty () && value->lazy) { - TRY + try { value_fetch_lazy (value); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { /* Fall back to checking value->optimized_out. */ } - END_CATCH } return !value->optimized_out.empty (); @@ -2535,18 +2534,17 @@ show_convenience (const char *ignore, int from_tty) } printf_filtered (("$%s = "), var->name); - TRY + try { struct value *val; val = value_of_internalvar (gdbarch, var); value_print (val, gdb_stdout, &opts); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &ex) { fprintf_filtered (gdb_stdout, _(""), ex.what ()); } - END_CATCH printf_filtered (("\n")); } diff --git a/gdb/varobj.c b/gdb/varobj.c index abace99..54b0943 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -314,16 +314,15 @@ varobj_create (const char *objname, | INNERMOST_BLOCK_FOR_REGISTERS); /* Wrap the call to parse expression, so we can return a sensible error. */ - TRY + try { var->root->exp = parse_exp_1 (&p, pc, block, 0, &tracker); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { return NULL; } - END_CATCH /* Don't allow variables to be created for types. */ if (var->root->exp->elts[0].opcode == OP_TYPE @@ -364,11 +363,11 @@ varobj_create (const char *objname, /* We definitely need to catch errors here. If evaluate_expression succeeds we got the value we wanted. But if it fails, we still go on with a call to evaluate_type(). */ - TRY + try { value = evaluate_expression (var->root->exp.get ()); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { /* Error getting the value. Try to at least get the right type. */ @@ -376,7 +375,6 @@ varobj_create (const char *objname, var->type = value_type (type_only_value); } - END_CATCH if (value != NULL) { @@ -1034,17 +1032,16 @@ varobj_set_value (struct varobj *var, const char *expression) input_radix = 10; /* ALWAYS reset to decimal temporarily. */ expression_up exp = parse_exp_1 (&s, 0, 0, 0); - TRY + try { value = evaluate_expression (exp.get ()); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { /* We cannot proceed without a valid expression. */ return false; } - END_CATCH /* All types that are editable must also be changeable. */ gdb_assert (varobj_value_is_changeable_p (var)); @@ -1063,16 +1060,15 @@ varobj_set_value (struct varobj *var, const char *expression) /* The new value may be lazy. value_assign, or rather value_contents, will take care of this. */ - TRY + try { val = value_assign (var->value.get (), value); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { return false; } - END_CATCH /* If the value has changed, record it, so that next -var-update can report this change. If a variable had a value of '1', we've set it @@ -1311,19 +1307,18 @@ install_new_value (struct varobj *var, struct value *value, bool initial) else { - TRY + try { value_fetch_lazy (value); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { /* Set the value to NULL, so that for the next -var-update, we don't try to compare the new value with this value, that we couldn't even read. */ value = NULL; } - END_CATCH } } @@ -2139,14 +2134,13 @@ value_of_root_1 (struct varobj **var_handle) /* We need to catch errors here, because if evaluate expression fails we want to just return NULL. */ - TRY + try { new_val = evaluate_expression (var->root->exp.get ()); } - CATCH (except, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &except) { } - END_CATCH } return new_val; diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 47f6cbb..0df9e31 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -943,15 +943,14 @@ handle_unload_dll () static void catch_errors (void (*func) ()) { - TRY + try { func (); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { exception_print (gdb_stderr, ex); } - END_CATCH } /* Clear list of loaded DLLs. */ diff --git a/gdb/x86-linux-nat.c b/gdb/x86-linux-nat.c index f60ed8a..1aa491a 100644 --- a/gdb/x86-linux-nat.c +++ b/gdb/x86-linux-nat.c @@ -217,16 +217,15 @@ x86_linux_nat_target::enable_btrace (ptid_t ptid, const struct btrace_config *conf) { struct btrace_target_info *tinfo = nullptr; - TRY + try { tinfo = linux_enable_btrace (ptid, conf); } - CATCH (exception, RETURN_MASK_ERROR) + catch (const gdb_exception_RETURN_MASK_ERROR &exception) { error (_("Could not enable branch tracing for %s: %s"), target_pid_to_str (ptid).c_str (), exception.what ()); } - END_CATCH return tinfo; } diff --git a/gdb/xml-support.c b/gdb/xml-support.c index 587a3af..1a89213 100644 --- a/gdb/xml-support.c +++ b/gdb/xml-support.c @@ -383,15 +383,14 @@ gdb_xml_start_element_wrapper (void *data, const XML_Char *name, { struct gdb_xml_parser *parser = (struct gdb_xml_parser *) data; - TRY + try { parser->start_element (name, attrs); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { parser->set_error (ex); } - END_CATCH } /* Handle the end of an element. NAME is the current element. */ @@ -456,15 +455,14 @@ gdb_xml_end_element_wrapper (void *data, const XML_Char *name) { struct gdb_xml_parser *parser = (struct gdb_xml_parser *) data; - TRY + try { parser->end_element (name); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception_RETURN_MASK_ALL &ex) { parser->set_error (ex); } - END_CATCH } /* Free a parser and all its associated state. */ -- cgit v1.1