From 8e7b59a53f5851810d5feffbee9d339c4935f4eb Mon Sep 17 00:00:00 2001 From: Keith Seitz Date: Mon, 9 Jan 2012 20:27:49 +0000 Subject: [PATCH] * Makefile.in (SFILES): Remove wrapper.c. (HFILES_NO_SRCDIR): Remove wrapper.h. (COMMON_OBS): Remove wrapper.o. * cli/cli-interp.c: Don't inlude wrapper.h. * corelow.c: Likewise. (core_open): Replace gdb_target_find_new_threads with TRY_CATCH around target_find_new_threads. * eval.c (fetch_subexp_value): Likewise for value_fetch_lazy. * gdbtypes.c (safe_parse_type): Likewise for parse_and_eval_type. * varobj.c (varobj_create): Likewise for parse_exp_1 and evaluate_expression. (varobj_set_value): Likewise for evaluate_expression and value_assign. (install_new_variable): Likewise for value_fetch_lazy. (adjust_value_for_child_access): Likewise for value_ind. (c_describe_child): Likewise for value_subscript and value_ind. (c_value_of_root): Likewise for evaluate_expression. * wrapper.c: Remove. * wrapper.h: Remove. --- gdb/ChangeLog | 23 ++++++ gdb/Makefile.in | 5 +- gdb/cli/cli-interp.c | 1 - gdb/corelow.c | 11 ++- gdb/eval.c | 19 ++++- gdb/gdbtypes.c | 11 ++- gdb/varobj.c | 89 ++++++++++++++++----- gdb/wrapper.c | 185 ------------------------------------------- gdb/wrapper.h | 53 ------------- 9 files changed, 124 insertions(+), 273 deletions(-) delete mode 100644 gdb/wrapper.c delete mode 100644 gdb/wrapper.h diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b66a56c839f..99c63191858 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,26 @@ +2012-01-09 Keith Seitz + + * Makefile.in (SFILES): Remove wrapper.c. + (HFILES_NO_SRCDIR): Remove wrapper.h. + (COMMON_OBS): Remove wrapper.o. + * cli/cli-interp.c: Don't inlude wrapper.h. + * corelow.c: Likewise. + (core_open): Replace gdb_target_find_new_threads with + TRY_CATCH around target_find_new_threads. + * eval.c (fetch_subexp_value): Likewise for value_fetch_lazy. + * gdbtypes.c (safe_parse_type): Likewise for parse_and_eval_type. + * varobj.c (varobj_create): Likewise for parse_exp_1 and + evaluate_expression. + (varobj_set_value): Likewise for evaluate_expression and + value_assign. + (install_new_variable): Likewise for value_fetch_lazy. + (adjust_value_for_child_access): Likewise for value_ind. + (c_describe_child): Likewise for value_subscript and + value_ind. + (c_value_of_root): Likewise for evaluate_expression. + * wrapper.c: Remove. + * wrapper.h: Remove. + 2012-01-09 Doug Evans * dwarf2read.c (read_and_check_comp_unit_head): Renamed from diff --git a/gdb/Makefile.in b/gdb/Makefile.in index cd93768c190..a5196a761fa 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -735,7 +735,6 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c ada-tasks.c \ ui-out.c utils.c ui-file.h ui-file.c \ user-regs.c \ valarith.c valops.c valprint.c value.c varobj.c vec.c \ - wrapper.c \ xml-tdesc.c xml-support.c \ inferior.c gdb_usleep.c \ record.c gcore.c \ @@ -803,7 +802,7 @@ coff-pe-read.h parser-defs.h gdb_ptrace.h mips-linux-tdep.h \ m68k-tdep.h spu-tdep.h jv-lang.h environ.h solib-irix.h amd64-tdep.h \ doublest.h regset.h hppa-tdep.h ppc-linux-tdep.h rs6000-tdep.h \ common/gdb_locale.h common/gdb_dirent.h arch-utils.h trad-frame.h gnu-nat.h \ -language.h nbsd-tdep.h wrapper.h solib-svr4.h \ +language.h nbsd-tdep.h solib-svr4.h \ macroexp.h ui-file.h regcache.h gdb_string.h tracepoint.h i386-tdep.h \ inf-child.h p-lang.h event-top.h gdbtypes.h user-regs.h \ regformats/regdef.h config/alpha/nm-osf3.h config/i386/nm-i386gnu.h \ @@ -887,7 +886,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \ ada-lang.o c-lang.o d-lang.o f-lang.o objc-lang.o \ ada-tasks.o \ ui-out.o cli-out.o \ - varobj.o vec.o wrapper.o \ + varobj.o vec.o \ jv-lang.o jv-valprint.o jv-typeprint.o \ m2-lang.o opencl-lang.o p-lang.o p-typeprint.o p-valprint.o \ sentinel-frame.o \ diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c index 9c44b240709..70b6c2854a4 100644 --- a/gdb/cli/cli-interp.c +++ b/gdb/cli/cli-interp.c @@ -19,7 +19,6 @@ #include "defs.h" #include "interps.h" -#include "wrapper.h" #include "event-top.h" #include "ui-out.h" #include "cli-out.h" diff --git a/gdb/corelow.c b/gdb/corelow.c index bbfb8ee51fa..f98814a902b 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -46,8 +46,6 @@ #include "filenames.h" #include "progspace.h" #include "objfiles.h" -#include "wrapper.h" - #ifndef O_LARGEFILE #define O_LARGEFILE 0 @@ -290,6 +288,7 @@ core_open (char *filename, int from_tty) bfd *temp_bfd; int scratch_chan; int flags; + volatile struct gdb_exception except; target_preopen (from_tty); if (!filename) @@ -428,7 +427,13 @@ core_open (char *filename, 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. */ - gdb_target_find_new_threads (); + TRY_CATCH (except, RETURN_MASK_ERROR) + { + target_find_new_threads (); + } + + if (except.reason < 0) + exception_print (gdb_stderr, except); p = bfd_core_file_failing_command (core_bfd); if (p) diff --git a/gdb/eval.c b/gdb/eval.c index d48b450e92f..0244f7a039b 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -41,7 +41,6 @@ #include "gdb_obstack.h" #include "objfiles.h" #include "python/python.h" -#include "wrapper.h" #include "gdb_assert.h" @@ -234,9 +233,21 @@ fetch_subexp_value (struct expression *exp, int *pc, struct value **valp, /* Make sure it's not lazy, so that after the target stops again we have a non-lazy previous value to compare with. */ - if (result != NULL - && (!value_lazy (result) || gdb_value_fetch_lazy (result))) - *valp = result; + if (result != NULL) + { + if (!value_lazy (result)) + *valp = result; + else + { + volatile struct gdb_exception except; + + TRY_CATCH (except, RETURN_MASK_ERROR) + { + value_fetch_lazy (result); + *valp = result; + } + } + } if (val_chain) { diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index a7c72ff24ef..9a570ac54d9 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -33,11 +33,10 @@ #include "demangle.h" #include "complaints.h" #include "gdbcmd.h" -#include "wrapper.h" #include "cp-abi.h" #include "gdb_assert.h" #include "hashtab.h" - +#include "exceptions.h" /* Initialize BADNESS constants. */ @@ -1676,13 +1675,19 @@ safe_parse_type (struct gdbarch *gdbarch, char *p, int length) { struct ui_file *saved_gdb_stderr; struct type *type; + volatile struct gdb_exception except; /* 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)) + TRY_CATCH (except, RETURN_MASK_ERROR) + { + type = parse_and_eval_type (p, length); + } + + if (except.reason < 0) type = builtin_type (gdbarch)->builtin_void; /* Stop suppressing error messages. */ diff --git a/gdb/varobj.c b/gdb/varobj.c index 88eafce8123..b17d3fda712 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -21,7 +21,6 @@ #include "expression.h" #include "frame.h" #include "language.h" -#include "wrapper.h" #include "gdbcmd.h" #include "block.h" #include "valprint.h" @@ -573,6 +572,7 @@ varobj_create (char *objname, char *p; enum varobj_languages lang; struct value *value = NULL; + volatile struct gdb_exception except; /* Parse and evaluate the expression, filling in as much of the variable's data as possible. */ @@ -607,7 +607,12 @@ varobj_create (char *objname, innermost_block = NULL; /* Wrap the call to parse expression, so we can return a sensible error. */ - if (!gdb_parse_exp_1 (&p, block, 0, &var->root->exp)) + TRY_CATCH (except, RETURN_MASK_ERROR) + { + var->root->exp = parse_exp_1 (&p, block, 0); + } + + if (except.reason < 0) { do_cleanups (old_chain); return NULL; @@ -650,7 +655,12 @@ varobj_create (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(). */ - if (!gdb_evaluate_expression (var->root->exp, &value)) + TRY_CATCH (except, RETURN_MASK_ERROR) + { + value = evaluate_expression (var->root->exp); + } + + if (except.reason < 0) { /* Error getting the value. Try to at least get the right type. */ @@ -1358,12 +1368,18 @@ varobj_set_value (struct varobj *var, char *expression) struct value *value; int saved_input_radix = input_radix; char *s = expression; + volatile struct gdb_exception except; gdb_assert (varobj_editable_p (var)); input_radix = 10; /* ALWAYS reset to decimal temporarily. */ exp = parse_exp_1 (&s, 0, 0); - if (!gdb_evaluate_expression (exp, &value)) + TRY_CATCH (except, RETURN_MASK_ERROR) + { + value = evaluate_expression (exp); + } + + if (except.reason < 0) { /* We cannot proceed without a valid expression. */ xfree (exp); @@ -1385,13 +1401,16 @@ varobj_set_value (struct varobj *var, char *expression) array's content. */ value = coerce_array (value); - /* The new value may be lazy. gdb_value_assign, or - rather value_contents, will take care of this. - If fetching of the new value will fail, gdb_value_assign - with catch the exception. */ - if (!gdb_value_assign (var->value, value, &val)) + /* The new value may be lazy. value_assign, or + rather value_contents, will take care of this. */ + TRY_CATCH (except, RETURN_MASK_ERROR) + { + val = value_assign (var->value, value); + } + + if (except.reason < 0) return 0; - + /* 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 to '333' and then set again to '1', when -var-update will report this @@ -1594,12 +1613,22 @@ install_new_value (struct varobj *var, struct value *value, int initial) explicitly asked to compare the new value with the old one. */ intentionally_not_fetched = 1; } - else if (!gdb_value_fetch_lazy (value)) + else { - /* 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; + volatile struct gdb_exception except; + + TRY_CATCH (except, RETURN_MASK_ERROR) + { + value_fetch_lazy (value); + } + + if (except.reason < 0) + { + /* 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; + } } } @@ -2820,9 +2849,14 @@ adjust_value_for_child_access (struct value **value, { if (value && *value) { - int success = gdb_value_ind (*value, value); + volatile struct gdb_exception except; - if (!success) + TRY_CATCH (except, RETURN_MASK_ERROR) + { + *value = value_ind (*value); + } + + if (except.reason < 0) *value = NULL; } *type = target_type; @@ -2947,6 +2981,7 @@ c_describe_child (struct varobj *parent, int index, struct type *type = get_value_type (parent); char *parent_expression = NULL; int was_ptr; + volatile struct gdb_exception except; if (cname) *cname = NULL; @@ -2974,7 +3009,10 @@ c_describe_child (struct varobj *parent, int index, { int real_index = index + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)); - gdb_value_subscript (value, real_index, cvalue); + TRY_CATCH (except, RETURN_MASK_ERROR) + { + *cvalue = value_subscript (value, real_index); + } } if (ctype) @@ -3020,9 +3058,12 @@ c_describe_child (struct varobj *parent, int index, if (cvalue && value) { - int success = gdb_value_ind (value, cvalue); + TRY_CATCH (except, RETURN_MASK_ERROR) + { + *cvalue = value_ind (value); + } - if (!success) + if (except.reason < 0) *cvalue = NULL; } @@ -3126,9 +3167,15 @@ c_value_of_root (struct varobj **var_handle) if (within_scope) { + volatile struct gdb_exception except; + /* We need to catch errors here, because if evaluate expression fails we want to just return NULL. */ - gdb_evaluate_expression (var->root->exp, &new_val); + TRY_CATCH (except, RETURN_MASK_ERROR) + { + new_val = evaluate_expression (var->root->exp); + } + return new_val; } diff --git a/gdb/wrapper.c b/gdb/wrapper.c deleted file mode 100644 index 0a5e2376cba..00000000000 --- a/gdb/wrapper.c +++ /dev/null @@ -1,185 +0,0 @@ -/* Longjump free calls to GDB internal routines. - - Copyright (C) 1999-2000, 2005, 2007-2012 Free Software Foundation, - Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include "defs.h" -#include "value.h" -#include "exceptions.h" -#include "wrapper.h" -#include "ui-out.h" -#include "target.h" - -int -gdb_parse_exp_1 (char **stringptr, struct block *block, int comma, - struct expression **expression) -{ - volatile struct gdb_exception except; - - TRY_CATCH (except, RETURN_MASK_ERROR) - { - *expression = parse_exp_1 (stringptr, block, comma); - } - - if (except.reason < 0) - return 0; - return 1; -} - -int -gdb_evaluate_expression (struct expression *exp, struct value **value) -{ - volatile struct gdb_exception except; - - TRY_CATCH (except, RETURN_MASK_ERROR) - { - *value = evaluate_expression(exp); - } - - if (except.reason < 0) - return 0; - return 1; -} - -int -gdb_value_fetch_lazy (struct value *val) -{ - volatile struct gdb_exception except; - - TRY_CATCH (except, RETURN_MASK_ERROR) - { - value_fetch_lazy (val); - } - - if (except.reason < 0) - return 0; - return 1; -} - -int -gdb_value_equal (struct value *val1, struct value *val2, int *result) -{ - volatile struct gdb_exception except; - - TRY_CATCH (except, RETURN_MASK_ERROR) - { - *result = value_equal (val1, val2); - } - - if (except.reason < 0) - return 0; - return 1; -} - -int -gdb_value_assign (struct value *val1, struct value *val2, - struct value **result) -{ - volatile struct gdb_exception except; - - TRY_CATCH (except, RETURN_MASK_ERROR) - { - *result = value_assign (val1, val2); - } - - if (except.reason < 0) - return 0; - return 1; -} - -int -gdb_value_subscript (struct value *val, LONGEST index, - struct value **result) -{ - volatile struct gdb_exception except; - - TRY_CATCH (except, RETURN_MASK_ERROR) - { - *result = value_subscript (val, index); - } - - if (except.reason < 0) - return 0; - return 1; -} - -int -gdb_value_ind (struct value *val, struct value **result) -{ - volatile struct gdb_exception except; - - TRY_CATCH (except, RETURN_MASK_ERROR) - { - *result = value_ind (val); - } - - if (except.reason < 0) - return 0; - return 1; -} - -int -gdb_parse_and_eval_type (char *p, int length, struct type **type) -{ - volatile struct gdb_exception except; - - TRY_CATCH (except, RETURN_MASK_ERROR) - { - *type = parse_and_eval_type (p, length); - } - - if (except.reason < 0) - return 0; - return 1; -} - -enum gdb_rc -gdb_value_struct_elt (struct ui_out *uiout, struct value **result, - struct value **argp, struct value **args, char *name, - int *static_memfuncp, char *err) -{ - volatile struct gdb_exception except; - - TRY_CATCH (except, RETURN_MASK_ERROR) - { - *result = value_struct_elt (argp, args, name, static_memfuncp, err); - } - - if (except.reason < 0) - return GDB_RC_FAIL; - return GDB_RC_OK; -} - -/* Call target_find_new_threads without throwing exception. Exception is - printed if it got thrown. */ - -int -gdb_target_find_new_threads (void) -{ - volatile struct gdb_exception except; - - TRY_CATCH (except, RETURN_MASK_ERROR) - { - target_find_new_threads (); - } - - if (except.reason < 0) - { - exception_print (gdb_stderr, except); - return 0; - } - return 1; -} diff --git a/gdb/wrapper.h b/gdb/wrapper.h deleted file mode 100644 index 974b17bba7f..00000000000 --- a/gdb/wrapper.h +++ /dev/null @@ -1,53 +0,0 @@ -/* Longjump free calls to GDB internal routines. - - Copyright (C) 1999-2000, 2005, 2007-2012 Free Software Foundation, - Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifndef WRAPPER_H -#define WRAPPER_H 1 - -#include "gdb.h" - -struct value; -struct expression; -struct block; - -extern int gdb_parse_exp_1 (char **, struct block *, - int, struct expression **); - -extern int gdb_evaluate_expression (struct expression *, struct value **); - -extern int gdb_value_fetch_lazy (struct value *); - -extern int gdb_value_equal (struct value *, struct value *, int *); - -extern int gdb_value_assign (struct value *, struct value *, struct value **); - -extern int gdb_value_subscript (struct value *, LONGEST, struct value **); - -extern enum gdb_rc gdb_value_struct_elt (struct ui_out *uiout, - struct value **result_ptr, - struct value **argp, - struct value **args, char *name, - int *static_memfuncp, char *err); - -extern int gdb_value_ind (struct value *val, struct value ** rval); - -extern int gdb_parse_and_eval_type (char *, int, struct type **); - -extern int gdb_target_find_new_threads (void); - -#endif /* wrapper.h */ -- 2.30.2