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/guile/scm-frame.c | 95 +++++++++++++++++++++------------------------------ 1 file changed, 38 insertions(+), 57 deletions(-) (limited to 'gdb/guile/scm-frame.c') 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 ()); } -- cgit v1.1