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:
parent
3d6e9d2336
commit
a70b814420
144 changed files with 1033 additions and 1326 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue