mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-26 17:18:55 +00:00
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 <tom@tromey.com> * 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 <tom@tromey.com> * server.c: Use C++ exception handling. * linux-low.c: Use C++ exception handling. * gdbreplay.c: Use C++ exception handling.
This commit is contained in:
@@ -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<char> 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user