From: Nicholas Duffek Date: Mon, 3 Apr 2000 03:39:09 +0000 (+0000) Subject: * gdbtypes.c (safe_parse_type): New wrapper function to ignore X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c91ecb25c3d04094aafd260522f8d85e2286ff87;p=binutils-gdb.git * gdbtypes.c (safe_parse_type): New wrapper function to ignore error() during parse_and_eval_type(). (check_stub_method): Call safe_parse_type instead of parse_and_eval_type(). * wrapper.c (gdb_parse_and_eval_type): New wrapper function. (wrap_parse_and_eval_type): New support function. * wrapper.h (gdb_parse_and_eval_type): Prototype. (wrap_parse_and_eval_type): Prototype. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index fe57e2a1640..77a867c1074 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,14 @@ +2000-04-02 Nick Duffek + + * gdbtypes.c (safe_parse_type): New wrapper function to ignore + error() during parse_and_eval_type(). + (check_stub_method): Call safe_parse_type instead of + parse_and_eval_type(). + * wrapper.c (gdb_parse_and_eval_type): New wrapper function. + (wrap_parse_and_eval_type): New support function. + * wrapper.h (gdb_parse_and_eval_type): Prototype. + (wrap_parse_and_eval_type): Prototype. + Sun Apr 2 10:32:54 2000 Andrew Cagney * MAINTAINERS: Eli Zaretskii is a doco maintainer. diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 08d194fcfc9..0d5bee84489 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -33,6 +33,7 @@ #include "demangle.h" #include "complaints.h" #include "gdbcmd.h" +#include "wrapper.h" /* These variables point to the objects representing the predefined C data types. */ @@ -1422,6 +1423,30 @@ cfront_mangle_name (type, i, j) #undef ADD_EXTRA /* End of new code added to support parsing of Cfront stabs strings */ +/* Parse a type expression in the string [P..P+LENGTH). If an error occurs, + silently return builtin_type_void. */ + +struct type * +safe_parse_type (char *p, int length) +{ + struct ui_file *saved_gdb_stderr; + struct type *type; + + /* Suppress error messages. */ + saved_gdb_stderr = gdb_stderr; + gdb_stderr = ui_file_new (); + + /* Call parse_and_eval_type() without fear of longjmp()s. */ + if (!gdb_parse_and_eval_type (p, length, &type)) + type = builtin_type_void; + + /* Stop suppressing error messages. */ + ui_file_delete (gdb_stderr); + gdb_stderr = saved_gdb_stderr; + + return type; +} + /* Ugly hack to convert method stubs into method types. He ain't kiddin'. This demangles the name of the method into a string @@ -1496,7 +1521,7 @@ check_stub_method (type, method_id, signature_id) if (strncmp (argtypetext, "...", p - argtypetext) != 0) { argtypes[argcount] = - parse_and_eval_type (argtypetext, p - argtypetext); + safe_parse_type (argtypetext, p - argtypetext); argcount += 1; } argtypetext = p + 1; diff --git a/gdb/wrapper.c b/gdb/wrapper.c index 83405e508a2..7ee26a7d460 100644 --- a/gdb/wrapper.c +++ b/gdb/wrapper.c @@ -61,6 +61,9 @@ int wrap_value_subscript PARAMS ((char *)); int gdb_value_ind PARAMS ((value_ptr val, value_ptr * rval)); int wrap_value_ind PARAMS ((char *opaque_arg)); +int gdb_parse_and_eval_type (char *, int, struct type **); +int wrap_parse_and_eval_type (char *); + int gdb_parse_exp_1 (stringptr, block, comma, expression) char **stringptr; @@ -252,3 +255,33 @@ wrap_value_ind (opaque_arg) return 1; } +int +gdb_parse_and_eval_type (char *p, int length, struct type **type) +{ + struct gdb_wrapper_arguments args; + args.args[0].pointer = p; + args.args[1].integer = length; + + if (!catch_errors ((catch_errors_ftype *) wrap_parse_and_eval_type, &args, + "", RETURN_MASK_ALL)) + { + /* An error occurred */ + return 0; + } + + *type = (struct type *) args.result.pointer; + return 1; +} + +int +wrap_parse_and_eval_type (char *a) +{ + struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a; + + char *p = (char *) args->args[0].pointer; + int length = args->args[1].integer; + + args->result.pointer = (char *) parse_and_eval_type (p, length); + + return 1; +} diff --git a/gdb/wrapper.h b/gdb/wrapper.h index 401cad8a0c5..0345b89623e 100644 --- a/gdb/wrapper.h +++ b/gdb/wrapper.h @@ -38,4 +38,7 @@ extern int wrap_value_equal PARAMS ((char *)); extern int gdb_value_ind PARAMS ((value_ptr val, value_ptr * rval)); extern int wrap_value_ind PARAMS ((char *opaque_arg)); +extern int gdb_parse_and_eval_type (char *, int, struct type **); +extern int wrap_parse_and_eval_type (char *); + #endif /* WRAPPER_H */