diff options
112 files changed, 2190 insertions, 1295 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 641a94c..6df72f7 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,20 @@ +2015-03-07 Pedro Alves <palves@redhat.com> + + * common/common-exceptions.c (struct catcher) <exception>: No + longer a pointer to volatile exception. Now an exception value. + <mask>: Delete field. + (exceptions_state_mc_init): Remove all parameters. Adjust. + (exceptions_state_mc): No longer pop the catcher here. + (exceptions_state_mc_catch): New function. + (throw_exception): Adjust. + * common/common-exceptions.h (exceptions_state_mc_init): Remove + all parameters. + (exceptions_state_mc_catch): Declare. + (TRY_CATCH): Rename to ... + (TRY): ... this. Remove EXCEPTION and MASK parameters. + (CATCH, END_CATCH): New. + All callers adjusted. + 2015-03-07 Tom Tromey <tromey@redhat.com> * top.c (quit_force): Inline and delete DO_TRY, DO_PRINT_EX. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 1e70d12..124e370 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -6479,7 +6479,6 @@ type_from_tag (struct value *tag) struct value * ada_tag_value_at_base_address (struct value *obj) { - volatile struct gdb_exception e; struct value *val; LONGEST offset_to_top = 0; struct type *ptr_type, *obj_type; @@ -6514,13 +6513,16 @@ 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_CATCH (e, RETURN_MASK_ERROR) + TRY { offset_to_top = value_as_long (value_ind (value_ptradd (val, -2))); } - if (e.reason < 0) - return obj; + CATCH (e, RETURN_MASK_ERROR) + { + return obj; + } + END_CATCH /* If offset is null, nothing to do. */ @@ -6632,7 +6634,6 @@ ada_tag_name_from_tsd (struct value *tsd) const char * ada_tag_name (struct value *tag) { - volatile struct gdb_exception e; char *name = NULL; if (!ada_is_tag_type (value_type (tag))) @@ -6647,13 +6648,17 @@ 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_CATCH (e, RETURN_MASK_ERROR) + 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) + { + } + END_CATCH return name; } @@ -11817,19 +11822,19 @@ static CORE_ADDR ada_exception_name_addr (enum ada_exception_catchpoint_kind ex, struct breakpoint *b) { - volatile struct gdb_exception e; CORE_ADDR result = 0; - TRY_CATCH (e, RETURN_MASK_ERROR) + TRY { result = ada_exception_name_addr_1 (ex, b); } - if (e.reason < 0) + CATCH (e, RETURN_MASK_ERROR) { warning (_("failed to get exception name: %s"), e.message); return 0; } + END_CATCH return result; } @@ -11929,16 +11934,15 @@ create_excep_cond_exprs (struct ada_catchpoint *c) if (!bl->shlib_disabled) { - volatile struct gdb_exception e; const char *s; s = cond_string; - TRY_CATCH (e, RETURN_MASK_ERROR) + TRY { exp = parse_exp_1 (&s, bl->address, block_for_pc (bl->address), 0); } - if (e.reason < 0) + CATCH (e, RETURN_MASK_ERROR) { warning (_("failed to reevaluate internal exception condition " "for catchpoint %d: %s"), @@ -11951,6 +11955,7 @@ create_excep_cond_exprs (struct ada_catchpoint *c) to NULL. */ exp = NULL; } + END_CATCH } ada_loc->excep_cond_expr = exp; @@ -12014,7 +12019,6 @@ should_stop_exception (const struct bp_location *bl) struct ada_catchpoint *c = (struct ada_catchpoint *) bl->owner; const struct ada_catchpoint_location *ada_loc = (const struct ada_catchpoint_location *) bl; - volatile struct gdb_exception ex; int stop; /* With no specific exception, should always stop. */ @@ -12029,7 +12033,7 @@ should_stop_exception (const struct bp_location *bl) } stop = 1; - TRY_CATCH (ex, RETURN_MASK_ALL) + TRY { struct value *mark; @@ -12037,9 +12041,13 @@ should_stop_exception (const struct bp_location *bl) stop = value_true (evaluate_expression (ada_loc->excep_cond_expr)); value_free_to_mark (mark); } - if (ex.reason < 0) - exception_fprintf (gdb_stderr, ex, - _("Error in testing exception condition:\n")); + CATCH (ex, RETURN_MASK_ALL) + { + exception_fprintf (gdb_stderr, ex, + _("Error in testing exception condition:\n")); + } + END_CATCH + return stop; } diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c index 6dba71b..fd85138 100644 --- a/gdb/ada-typeprint.c +++ b/gdb/ada-typeprint.c @@ -159,19 +159,19 @@ print_range (struct type *type, struct ui_file *stream, case TYPE_CODE_ENUM: { struct type *target_type; - volatile struct gdb_exception e; LONGEST lo = 0, hi = 0; /* init for gcc -Wall */ + int got_error = 0; target_type = TYPE_TARGET_TYPE (type); if (target_type == NULL) target_type = type; - TRY_CATCH (e, RETURN_MASK_ERROR) + TRY { lo = ada_discrete_type_low_bound (type); hi = ada_discrete_type_high_bound (type); } - if (e.reason < 0) + CATCH (e, RETURN_MASK_ERROR) { /* This can happen when the range is dynamic. Sometimes, resolving dynamic property values requires us to have @@ -179,8 +179,11 @@ print_range (struct type *type, struct ui_file *stream, when the user is using the "ptype" command on a type. Print the range as an unbounded range. */ fprintf_filtered (stream, "<>"); + got_error = 1; } - else + END_CATCH + + if (!got_error) { ada_print_scalar (target_type, lo, stream); fprintf_filtered (stream, " .. "); diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index d5cd04f..34539de 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -1159,15 +1159,18 @@ ada_val_print (struct type *type, const gdb_byte *valaddr, const struct value *val, const struct value_print_options *options) { - volatile struct gdb_exception except; /* XXX: this catches QUIT/ctrl-c as well. Isn't that busted? */ - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { ada_val_print_1 (type, valaddr, embedded_offset, address, stream, recurse, val, options, current_language); } + CATCH (except, RETURN_MASK_ALL) + { + } + END_CATCH } void diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index ca82858..3e5d1bd 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -2466,7 +2466,6 @@ amd64_frame_cache_1 (struct frame_info *this_frame, static struct amd64_frame_cache * amd64_frame_cache (struct frame_info *this_frame, void **this_cache) { - volatile struct gdb_exception ex; struct amd64_frame_cache *cache; if (*this_cache) @@ -2475,15 +2474,16 @@ amd64_frame_cache (struct frame_info *this_frame, void **this_cache) cache = amd64_alloc_frame_cache (); *this_cache = cache; - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { amd64_frame_cache_1 (this_frame, cache); } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ERROR) { if (ex.error != NOT_AVAILABLE_ERROR) throw_exception (ex); } + END_CATCH return cache; } @@ -2582,7 +2582,6 @@ amd64_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache) struct gdbarch *gdbarch = get_frame_arch (this_frame); struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - volatile struct gdb_exception ex; struct amd64_frame_cache *cache; CORE_ADDR addr; gdb_byte buf[8]; @@ -2593,7 +2592,7 @@ amd64_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache) cache = amd64_alloc_frame_cache (); - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { get_frame_register (this_frame, AMD64_RSP_REGNUM, buf); cache->base = extract_unsigned_integer (buf, 8, byte_order) - 8; @@ -2607,11 +2606,12 @@ amd64_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache) cache->base_p = 1; } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ERROR) { if (ex.error != NOT_AVAILABLE_ERROR) throw_exception (ex); } + END_CATCH *this_cache = cache; return cache; @@ -2758,7 +2758,6 @@ amd64_epilogue_frame_cache (struct frame_info *this_frame, void **this_cache) { struct gdbarch *gdbarch = get_frame_arch (this_frame); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - volatile struct gdb_exception ex; struct amd64_frame_cache *cache; gdb_byte buf[8]; @@ -2768,7 +2767,7 @@ amd64_epilogue_frame_cache (struct frame_info *this_frame, void **this_cache) cache = amd64_alloc_frame_cache (); *this_cache = cache; - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { /* Cache base will be %esp plus cache->sp_offset (-8). */ get_frame_register (this_frame, AMD64_RSP_REGNUM, buf); @@ -2786,11 +2785,12 @@ amd64_epilogue_frame_cache (struct frame_info *this_frame, void **this_cache) cache->base_p = 1; } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ERROR) { if (ex.error != NOT_AVAILABLE_ERROR) throw_exception (ex); } + END_CATCH return cache; } diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c index 726825a..f5616c8 100644 --- a/gdb/break-catch-throw.c +++ b/gdb/break-catch-throw.c @@ -163,7 +163,6 @@ check_status_exception_catchpoint (struct bpstats *bs) struct exception_catchpoint *self = (struct exception_catchpoint *) bs->breakpoint_at; char *type_name = NULL; - volatile struct gdb_exception e; bkpt_breakpoint_ops.check_status (bs); if (bs->stop == 0) @@ -172,7 +171,7 @@ check_status_exception_catchpoint (struct bpstats *bs) if (self->pattern == NULL) return; - TRY_CATCH (e, RETURN_MASK_ERROR) + TRY { struct value *typeinfo_arg; char *canon; @@ -187,8 +186,11 @@ check_status_exception_catchpoint (struct bpstats *bs) type_name = canon; } } - if (e.reason < 0) - exception_print (gdb_stderr, e); + CATCH (e, RETURN_MASK_ERROR) + { + exception_print (gdb_stderr, e); + } + END_CATCH if (type_name != NULL) { @@ -206,38 +208,38 @@ re_set_exception_catchpoint (struct breakpoint *self) { struct symtabs_and_lines sals = {0}; struct symtabs_and_lines sals_end = {0}; - volatile struct gdb_exception e; struct cleanup *cleanup; enum exception_event_kind kind = classify_exception_breakpoint (self); /* We first try to use the probe interface. */ - TRY_CATCH (e, RETURN_MASK_ERROR) + TRY { char *spec = ASTRDUP (exception_functions[kind].probe); sals = parse_probes (&spec, NULL); } - if (e.reason < 0) + CATCH (e, RETURN_MASK_ERROR) { - volatile struct gdb_exception ex; /* Using the probe interface failed. Let's fallback to the normal catchpoint mode. */ - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { char *spec = ASTRDUP (exception_functions[kind].function); self->ops->decode_linespec (self, &spec, &sals); } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ERROR) { /* NOT_FOUND_ERROR just means the breakpoint will be pending, so let it through. */ if (ex.error != NOT_FOUND_ERROR) throw_exception (ex); } + END_CATCH } + END_CATCH cleanup = make_cleanup (xfree, sals.sals); update_breakpoint_locations (self, sals, sals_end); diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index d85f271..0e59638 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -2221,25 +2221,25 @@ static struct agent_expr * parse_cond_to_aexpr (CORE_ADDR scope, struct expression *cond) { struct agent_expr *aexpr = NULL; - volatile struct gdb_exception ex; if (!cond) return NULL; /* We don't want to stop processing, so catch any errors that may show up. */ - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { aexpr = gen_eval_for_expr (scope, cond); } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ERROR) { /* If we got here, it means the condition could not be parsed to a valid bytecode expression and thus can't be evaluated on the target's side. It's no use iterating through the conditions. */ return NULL; } + END_CATCH /* We have a valid agent expression. */ return aexpr; @@ -2361,7 +2361,6 @@ parse_cmd_to_aexpr (CORE_ADDR scope, char *cmd) struct cleanup *old_cleanups = 0; struct expression *expr, **argvec; struct agent_expr *aexpr = NULL; - volatile struct gdb_exception ex; const char *cmdrest; const char *format_start, *format_end; struct format_piece *fpieces; @@ -2420,22 +2419,22 @@ parse_cmd_to_aexpr (CORE_ADDR scope, char *cmd) /* We don't want to stop processing, so catch any errors that may show up. */ - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { aexpr = gen_printf (scope, gdbarch, 0, 0, format_start, format_end - format_start, fpieces, nargs, argvec); } - - do_cleanups (old_cleanups); - - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ERROR) { /* If we got here, it means the command could not be parsed to a valid bytecode expression and thus can't be evaluated on the target's side. It's no use iterating through the other commands. */ - return NULL; + aexpr = NULL; } + END_CATCH + + do_cleanups (old_cleanups); /* We have a valid agent expression, return it. */ return aexpr; @@ -2572,7 +2571,6 @@ insert_bp_location (struct bp_location *bl, { enum errors bp_err = GDB_NO_ERROR; const char *bp_err_message = NULL; - volatile struct gdb_exception e; if (!should_be_inserted (bl) || (bl->inserted && !bl->needs_update)) return 0; @@ -2675,7 +2673,7 @@ insert_bp_location (struct bp_location *bl, || !(section_is_overlay (bl->section))) { /* No overlay handling: just set the breakpoint. */ - TRY_CATCH (e, RETURN_MASK_ALL) + TRY { int val; @@ -2683,11 +2681,12 @@ insert_bp_location (struct bp_location *bl, if (val) bp_err = GENERIC_ERROR; } - if (e.reason < 0) + CATCH (e, RETURN_MASK_ALL) { bp_err = e.error; bp_err_message = e.message; } + END_CATCH } else { @@ -2710,7 +2709,7 @@ insert_bp_location (struct bp_location *bl, bl->overlay_target_info.reqstd_address = addr; /* No overlay handling: just set the breakpoint. */ - TRY_CATCH (e, RETURN_MASK_ALL) + TRY { int val; @@ -2719,11 +2718,12 @@ insert_bp_location (struct bp_location *bl, if (val) bp_err = GENERIC_ERROR; } - if (e.reason < 0) + CATCH (e, RETURN_MASK_ALL) { bp_err = e.error; bp_err_message = e.message; } + END_CATCH if (bp_err != GDB_NO_ERROR) fprintf_unfiltered (tmp_error_stream, @@ -2736,7 +2736,7 @@ insert_bp_location (struct bp_location *bl, if (section_is_mapped (bl->section)) { /* Yes. This overlay section is mapped into memory. */ - TRY_CATCH (e, RETURN_MASK_ALL) + TRY { int val; @@ -2744,11 +2744,12 @@ insert_bp_location (struct bp_location *bl, if (val) bp_err = GENERIC_ERROR; } - if (e.reason < 0) + CATCH (e, RETURN_MASK_ALL) { bp_err = e.error; bp_err_message = e.message; } + END_CATCH } else { @@ -10004,7 +10005,6 @@ create_breakpoint (struct gdbarch *gdbarch, int from_tty, int enabled, int internal, unsigned flags) { - volatile struct gdb_exception e; char *copy_arg = NULL; char *addr_start = arg; struct linespec_result canonical; @@ -10018,24 +10018,17 @@ create_breakpoint (struct gdbarch *gdbarch, init_linespec_result (&canonical); - TRY_CATCH (e, RETURN_MASK_ALL) + TRY { ops->create_sals_from_address (&arg, &canonical, type_wanted, addr_start, ©_arg); } - - /* If caller is interested in rc value from parse, set value. */ - switch (e.reason) + CATCH (e, RETURN_MASK_ERROR) { - case GDB_NO_ERROR: - if (VEC_empty (linespec_sals, canonical.sals)) - return 0; - break; - case RETURN_ERROR: - switch (e.error) + /* If caller is interested in rc value from parse, set + value. */ + if (e.error == NOT_FOUND_ERROR) { - case NOT_FOUND_ERROR: - /* If pending breakpoint support is turned off, throw error. */ @@ -10066,14 +10059,14 @@ create_breakpoint (struct gdbarch *gdbarch, pending = 1; VEC_safe_push (linespec_sals, canonical.sals, &lsal); } - break; - default: - throw_exception (e); } - break; - default: - throw_exception (e); + else + throw_exception (e); } + END_CATCH + + if (VEC_empty (linespec_sals, canonical.sals)) + return 0; /* Create a chain of things that always need to be cleaned up. */ old_chain = make_cleanup_destroy_linespec_result (&canonical); @@ -11343,7 +11336,6 @@ static void watch_command_1 (const char *arg, int accessflag, int from_tty, int just_location, int internal) { - volatile struct gdb_exception e; struct breakpoint *b, *scope_breakpoint = NULL; struct expression *exp; const struct block *exp_valid_block = NULL, *cond_exp_valid_block = NULL; @@ -11655,17 +11647,18 @@ watch_command_1 (const char *arg, int accessflag, int from_tty, if (!just_location) value_free_to_mark (mark); - TRY_CATCH (e, RETURN_MASK_ALL) + TRY { /* Finally update the new watchpoint. This creates the locations that should be inserted. */ update_watchpoint (w, 1); } - if (e.reason < 0) + CATCH (e, RETURN_MASK_ALL) { delete_breakpoint (b); throw_exception (e); } + END_CATCH install_breakpoint (internal, b, 1); do_cleanups (back_to); @@ -13011,10 +13004,15 @@ breakpoint_retire_moribund (void) static void update_global_location_list_nothrow (enum ugll_insert_mode insert_mode) { - volatile struct gdb_exception e; - TRY_CATCH (e, RETURN_MASK_ERROR) - update_global_location_list (insert_mode); + TRY + { + update_global_location_list (insert_mode); + } + CATCH (e, RETURN_MASK_ERROR) + { + } + END_CATCH } /* Clear BKP from a BPS. */ @@ -14485,22 +14483,22 @@ update_breakpoint_locations (struct breakpoint *b, if (b->cond_string != NULL) { const char *s; - volatile struct gdb_exception e; s = b->cond_string; - TRY_CATCH (e, RETURN_MASK_ERROR) + TRY { new_loc->cond = parse_exp_1 (&s, sals.sals[i].pc, block_for_pc (sals.sals[i].pc), 0); } - if (e.reason < 0) + CATCH (e, RETURN_MASK_ERROR) { warning (_("failed to reevaluate condition " "for breakpoint %d: %s"), b->number, e.message); new_loc->enabled = 0; } + END_CATCH } if (sals_end.nelts) @@ -14564,18 +14562,21 @@ addr_string_to_sals (struct breakpoint *b, char *addr_string, int *found) { char *s; struct symtabs_and_lines sals = {0}; - volatile struct gdb_exception e; + struct gdb_exception exception = exception_none; gdb_assert (b->ops != NULL); s = addr_string; - TRY_CATCH (e, RETURN_MASK_ERROR) + TRY { b->ops->decode_linespec (b, &s, &sals); } - if (e.reason < 0) + CATCH (e, RETURN_MASK_ERROR) { int not_found_and_ok = 0; + + exception = e; + /* For pending breakpoints, it's expected that parsing will fail until the right shared library is loaded. User has already told to create pending breakpoints and don't need @@ -14602,8 +14603,9 @@ addr_string_to_sals (struct breakpoint *b, char *addr_string, int *found) throw_exception (e); } } + END_CATCH - if (e.reason == 0 || e.error != NOT_FOUND_ERROR) + if (exception.reason == 0 || exception.error != NOT_FOUND_ERROR) { int i; @@ -15094,9 +15096,8 @@ enable_breakpoint_disp (struct breakpoint *bpt, enum bpdisp disposition, { /* Initialize it just to avoid a GCC false warning. */ enum enable_state orig_enable_state = 0; - volatile struct gdb_exception e; - TRY_CATCH (e, RETURN_MASK_ALL) + TRY { struct watchpoint *w = (struct watchpoint *) bpt; @@ -15104,13 +15105,14 @@ enable_breakpoint_disp (struct breakpoint *bpt, enum bpdisp disposition, bpt->enable_state = bp_enabled; update_watchpoint (w, 1 /* reparse */); } - if (e.reason < 0) + CATCH (e, RETURN_MASK_ALL) { bpt->enable_state = orig_enable_state; exception_fprintf (gdb_stderr, e, _("Cannot enable watchpoint %d: "), bpt->number); return; } + END_CATCH } bpt->enable_state = bp_enabled; @@ -15924,19 +15926,21 @@ save_breakpoints (char *filename, int from_tty, if (tp->type != bp_dprintf && tp->commands) { - volatile struct gdb_exception ex; fprintf_unfiltered (fp, " commands\n"); ui_out_redirect (current_uiout, fp); - TRY_CATCH (ex, RETURN_MASK_ALL) + TRY { print_command_lines (current_uiout, tp->commands->commands, 2); } ui_out_redirect (current_uiout, NULL); - if (ex.reason < 0) - throw_exception (ex); + CATCH (ex, RETURN_MASK_ALL) + { + throw_exception (ex); + } + END_CATCH fprintf_unfiltered (fp, " end\n"); } diff --git a/gdb/btrace.c b/gdb/btrace.c index 5436ee9..68057c5 100644 --- a/gdb/btrace.c +++ b/gdb/btrace.c @@ -549,11 +549,10 @@ ftrace_update_insns (struct btrace_function *bfun, static enum btrace_insn_class ftrace_classify_insn (struct gdbarch *gdbarch, CORE_ADDR pc) { - volatile struct gdb_exception error; enum btrace_insn_class iclass; iclass = BTRACE_INSN_OTHER; - TRY_CATCH (error, RETURN_MASK_ERROR) + TRY { if (gdbarch_insn_is_call (gdbarch, pc)) iclass = BTRACE_INSN_CALL; @@ -562,6 +561,10 @@ ftrace_classify_insn (struct gdbarch *gdbarch, CORE_ADDR pc) else if (gdbarch_insn_is_jump (gdbarch, pc)) iclass = BTRACE_INSN_JUMP; } + CATCH (error, RETURN_MASK_ERROR) + { + } + END_CATCH return iclass; } @@ -598,7 +601,6 @@ btrace_compute_ftrace_bts (struct thread_info *tp, for (;;) { - volatile struct gdb_exception error; struct btrace_insn insn; int size; @@ -628,8 +630,14 @@ btrace_compute_ftrace_bts (struct thread_info *tp, level = min (level, end->level); size = 0; - TRY_CATCH (error, RETURN_MASK_ERROR) - size = gdb_insn_length (gdbarch, pc); + TRY + { + size = gdb_insn_length (gdbarch, pc); + } + CATCH (error, RETURN_MASK_ERROR) + { + } + END_CATCH insn.pc = pc; insn.size = size; diff --git a/gdb/c-varobj.c b/gdb/c-varobj.c index 363a356..59d8b0f 100644 --- a/gdb/c-varobj.c +++ b/gdb/c-varobj.c @@ -91,15 +91,17 @@ adjust_value_for_child_access (struct value **value, { if (value && *value) { - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { *value = value_ind (*value); } - if (except.reason < 0) - *value = NULL; + CATCH (except, RETURN_MASK_ERROR) + { + *value = NULL; + } + END_CATCH } *type = target_type; if (was_ptr) @@ -245,7 +247,6 @@ static struct value * value_struct_element_index (struct value *value, int type_index) { struct value *result = NULL; - volatile struct gdb_exception e; struct type *type = value_type (value); type = check_typedef (type); @@ -253,21 +254,20 @@ value_struct_element_index (struct value *value, int type_index) gdb_assert (TYPE_CODE (type) == TYPE_CODE_STRUCT || TYPE_CODE (type) == TYPE_CODE_UNION); - TRY_CATCH (e, RETURN_MASK_ERROR) + TRY { if (field_is_static (&TYPE_FIELD (type, type_index))) result = value_static_field (type, type_index); else result = value_primitive_field (value, 0, type_index, type); } - if (e.reason < 0) + CATCH (e, RETURN_MASK_ERROR) { return NULL; } - else - { - return result; - } + END_CATCH + + return result; } /* Obtain the information about child INDEX of the variable @@ -290,7 +290,6 @@ c_describe_child (const struct varobj *parent, int index, struct type *type = varobj_get_value_type (parent); char *parent_expression = NULL; int was_ptr; - volatile struct gdb_exception except; if (cname) *cname = NULL; @@ -319,10 +318,14 @@ c_describe_child (const struct varobj *parent, int index, { int real_index = index + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)); - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { *cvalue = value_subscript (value, real_index); } + CATCH (except, RETURN_MASK_ERROR) + { + } + END_CATCH } if (ctype) @@ -391,13 +394,16 @@ c_describe_child (const struct varobj *parent, int index, if (cvalue && value) { - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { *cvalue = value_ind (value); } - if (except.reason < 0) - *cvalue = NULL; + CATCH (except, RETURN_MASK_ERROR) + { + *cvalue = NULL; + } + END_CATCH } /* Don't use get_target_type because it calls diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c index 1069018..ce43a4a 100644 --- a/gdb/cli/cli-interp.c +++ b/gdb/cli/cli-interp.c @@ -179,7 +179,6 @@ cli_interpreter_exec (void *data, const char *command_str) static struct gdb_exception safe_execute_command (struct ui_out *command_uiout, char *command, int from_tty) { - volatile struct gdb_exception exception; struct gdb_exception e = exception_none; struct ui_out *saved_uiout; @@ -187,14 +186,15 @@ safe_execute_command (struct ui_out *command_uiout, char *command, int from_tty) saved_uiout = current_uiout; current_uiout = command_uiout; - TRY_CATCH (exception, RETURN_MASK_ALL) + TRY { execute_command (command, from_tty); } - if (exception.reason < 0) + CATCH (exception, RETURN_MASK_ALL) { e = exception; } + END_CATCH /* Restore the global builder. */ current_uiout = saved_uiout; diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c index 2ec8bcd..7a4ed78 100644 --- a/gdb/cli/cli-script.c +++ b/gdb/cli/cli-script.c @@ -1111,17 +1111,17 @@ process_next_line (char *p, struct command_line **command, int parse_commands, if (validator) { - volatile struct gdb_exception ex; - TRY_CATCH (ex, RETURN_MASK_ALL) + TRY { validator ((*command)->line, closure); } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ALL) { xfree (*command); throw_exception (ex); } + END_CATCH } /* Nothing special. */ @@ -1700,13 +1700,12 @@ script_from_file (FILE *stream, const char *file) interpreter_async = 0; { - volatile struct gdb_exception e; - TRY_CATCH (e, RETURN_MASK_ERROR) + TRY { read_command_file (stream); } - if (e.reason < 0) + CATCH (e, RETURN_MASK_ERROR) { /* Re-throw the error, but with the file name information prepended. */ @@ -1714,6 +1713,7 @@ script_from_file (FILE *stream, const char *file) _("%s:%d: Error in sourced command file:\n%s"), source_file_name, source_line_number, e.message); } + END_CATCH } do_cleanups (old_cleanups); diff --git a/gdb/common/common-exceptions.c b/gdb/common/common-exceptions.c index b65f259..2ad0ce1 100644 --- a/gdb/common/common-exceptions.c +++ b/gdb/common/common-exceptions.c @@ -46,9 +46,7 @@ struct catcher /* Jump buffer pointing back at the exception handler. */ SIGJMP_BUF buf; /* Status buffer belonging to the exception handler. */ - volatile struct gdb_exception *exception; - /* Saved/current state. */ - int mask; + struct gdb_exception exception; struct cleanup *saved_cleanup_chain; /* Back link. */ struct catcher *prev; @@ -74,16 +72,12 @@ catcher_list_size (void) } SIGJMP_BUF * -exceptions_state_mc_init (volatile struct gdb_exception *exception, - return_mask mask) +exceptions_state_mc_init (void) { struct catcher *new_catcher = XCNEW (struct catcher); - /* Start with no exception, save it's address. */ - *exception = exception_none; - new_catcher->exception = exception; - - new_catcher->mask = mask; + /* Start with no exception. */ + new_catcher->exception = exception_none; /* Prevent error/quit during FUNC from calling cleanups established prior to here. */ @@ -134,8 +128,7 @@ exceptions_state_mc (enum catcher_action action) switch (action) { case CATCH_ITER: - /* No error/quit has occured. Just clean up. */ - catcher_pop (); + /* No error/quit has occured. */ return 0; case CATCH_ITER_1: current_catcher->state = CATCHER_RUNNING_1; @@ -152,7 +145,6 @@ exceptions_state_mc (enum catcher_action action) { case CATCH_ITER: /* The did a "break" from the inner while loop. */ - catcher_pop (); return 0; case CATCH_ITER_1: current_catcher->state = CATCHER_RUNNING; @@ -169,21 +161,10 @@ exceptions_state_mc (enum catcher_action action) { case CATCH_ITER: { - struct gdb_exception exception = *current_catcher->exception; - - if (current_catcher->mask & RETURN_MASK (exception.reason)) - { - /* Exit normally if this catcher can handle this - exception. The caller analyses the func return - values. */ - catcher_pop (); - return 0; - } - /* The caller didn't request that the event be caught, - relay the event to the next containing - catch_errors(). */ - catcher_pop (); - throw_exception (exception); + /* Exit normally if this catcher can handle this + exception. The caller analyses the func return + values. */ + return 0; } default: internal_error (__FILE__, __LINE__, _("bad state")); @@ -194,6 +175,31 @@ exceptions_state_mc (enum catcher_action action) } int +exceptions_state_mc_catch (struct gdb_exception *exception, + int mask) +{ + *exception = current_catcher->exception; + catcher_pop (); + + if (exception->reason < 0) + { + if (mask & RETURN_MASK (exception->reason)) + { + /* Exit normally and let the called handle the + exception. */ + return 1; + } + + /* The caller didn't request that the event be caught, relay the + event to the next exception_catch/CATCH. */ + throw_exception (*exception); + } + + /* No exception was thrown. */ + return 0; +} + +int exceptions_state_mc_action_iter (void) { return exceptions_state_mc (CATCH_ITER); @@ -218,7 +224,7 @@ throw_exception (struct gdb_exception exception) to that call via setjmp's return value. Note that REASON can't be zero, by definition in defs.h. */ exceptions_state_mc (CATCH_THROWING); - *current_catcher->exception = exception; + current_catcher->exception = exception; SIGLONGJMP (current_catcher->buf, exception.reason); } diff --git a/gdb/common/common-exceptions.h b/gdb/common/common-exceptions.h index a32e6f9..d2c0bee 100644 --- a/gdb/common/common-exceptions.h +++ b/gdb/common/common-exceptions.h @@ -118,14 +118,13 @@ struct gdb_exception /* Functions to drive the exceptions state machine. Though declared here by necessity, these functions should be considered internal to - the exceptions subsystem and not used other than via the TRY_CATCH - macro defined below. */ + the exceptions subsystem and not used other than via the TRY/CATCH + macros defined below. */ -extern SIGJMP_BUF *exceptions_state_mc_init (volatile struct - gdb_exception *exception, - return_mask mask); +extern SIGJMP_BUF *exceptions_state_mc_init (void); extern int exceptions_state_mc_action_iter (void); extern int exceptions_state_mc_action_iter_1 (void); +extern int exceptions_state_mc_catch (struct gdb_exception *, int); /* Macro to wrap up standard try/catch behavior. @@ -138,26 +137,37 @@ extern int exceptions_state_mc_action_iter_1 (void); *INDENT-OFF* - volatile struct gdb_exception e; - TRY_CATCH (e, RETURN_MASK_ERROR) + TRY { } - switch (e.reason) + CATCH (e, RETURN_MASK_ERROR) { - case RETURN_ERROR: ... + switch (e.reason) + { + case RETURN_ERROR: ... + } } + END_CATCH */ -#define TRY_CATCH(EXCEPTION,MASK) \ +#define TRY \ { \ SIGJMP_BUF *buf = \ - exceptions_state_mc_init (&(EXCEPTION), (MASK)); \ + exceptions_state_mc_init (); \ SIGSETJMP (*buf); \ } \ while (exceptions_state_mc_action_iter ()) \ while (exceptions_state_mc_action_iter_1 ()) +#define CATCH(EXCEPTION, MASK) \ + { \ + struct gdb_exception EXCEPTION; \ + if (exceptions_state_mc_catch (&(EXCEPTION), MASK)) + +#define END_CATCH \ + } + /* *INDENT-ON* */ /* Hook to allow client-specific actions to be performed prior to diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c index 1921704..15efeff 100644 --- a/gdb/compile/compile-c-symbols.c +++ b/gdb/compile/compile-c-symbols.c @@ -424,7 +424,6 @@ gcc_convert_symbol (void *datum, { struct compile_c_instance *context = datum; domain_enum domain; - volatile struct gdb_exception e; int found = 0; switch (request) @@ -444,7 +443,7 @@ gcc_convert_symbol (void *datum, /* We can't allow exceptions to escape out of this callback. Safest is to simply emit a gcc error. */ - TRY_CATCH (e, RETURN_MASK_ALL) + TRY { struct symbol *sym; @@ -467,8 +466,11 @@ gcc_convert_symbol (void *datum, } } - if (e.reason < 0) - C_CTX (context)->c_ops->error (C_CTX (context), e.message); + CATCH (e, RETURN_MASK_ALL) + { + C_CTX (context)->c_ops->error (C_CTX (context), e.message); + } + END_CATCH if (compile_debug && !found) fprintf_unfiltered (gdb_stdout, @@ -484,13 +486,12 @@ gcc_symbol_address (void *datum, struct gcc_c_context *gcc_context, const char *identifier) { struct compile_c_instance *context = datum; - volatile struct gdb_exception e; gcc_address result = 0; int found = 0; /* We can't allow exceptions to escape out of this callback. Safest is to simply emit a gcc error. */ - TRY_CATCH (e, RETURN_MASK_ERROR) + TRY { struct symbol *sym; @@ -527,8 +528,11 @@ gcc_symbol_address (void *datum, struct gcc_c_context *gcc_context, } } - if (e.reason < 0) - C_CTX (context)->c_ops->error (C_CTX (context), e.message); + CATCH (e, RETURN_MASK_ERROR) + { + C_CTX (context)->c_ops->error (C_CTX (context), e.message); + } + END_CATCH if (compile_debug && !found) fprintf_unfiltered (gdb_stdout, @@ -643,9 +647,8 @@ generate_c_for_for_one_variable (struct compile_c_instance *compiler, CORE_ADDR pc, struct symbol *sym) { - volatile struct gdb_exception e; - TRY_CATCH (e, RETURN_MASK_ERROR) + TRY { if (is_dynamic_type (SYMBOL_TYPE (sym))) { @@ -699,7 +702,7 @@ generate_c_for_for_one_variable (struct compile_c_instance *compiler, } } - if (e.reason < 0) + CATCH (e, RETURN_MASK_ERROR) { if (compiler->symbol_err_map == NULL) compiler->symbol_err_map = htab_create_alloc (10, @@ -710,6 +713,7 @@ generate_c_for_for_one_variable (struct compile_c_instance *compiler, xfree); insert_symbol_error (compiler->symbol_err_map, sym, e.message); } + END_CATCH } /* See compile-internal.h. */ diff --git a/gdb/compile/compile-object-run.c b/gdb/compile/compile-object-run.c index c40de0e..6738aad 100644 --- a/gdb/compile/compile-object-run.c +++ b/gdb/compile/compile-object-run.c @@ -87,7 +87,6 @@ compile_object_run (struct compile_module *module) struct frame_id dummy_id; struct cleanup *cleanups; struct do_module_cleanup *data; - volatile struct gdb_exception ex; const char *objfile_name_s = objfile_name (module->objfile); int dtor_found, executed = 0; CORE_ADDR func_addr = module->func_addr; @@ -101,7 +100,7 @@ compile_object_run (struct compile_module *module) xfree (module->source_file); xfree (module); - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { func_val = value_from_pointer (builtin_type (target_gdbarch ())->builtin_func_ptr, @@ -121,7 +120,7 @@ compile_object_run (struct compile_module *module) do_module_cleanup, data); } } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ERROR) { /* In the case of DTOR_FOUND or in the case of EXECUTED nothing needs to be done. */ @@ -133,6 +132,7 @@ compile_object_run (struct compile_module *module) do_module_cleanup (data); throw_exception (ex); } + END_CATCH dtor_found = find_dummy_frame_dtor (do_module_cleanup, data); gdb_assert (!dtor_found && executed); diff --git a/gdb/completer.c b/gdb/completer.c index 58418f6..c8c0e4c 100644 --- a/gdb/completer.c +++ b/gdb/completer.c @@ -395,18 +395,21 @@ expression_completer (struct cmd_list_element *ignore, struct type *type = NULL; char *fieldname; const char *p; - volatile struct gdb_exception except; enum type_code code = TYPE_CODE_UNDEF; /* Perform a tentative parse of the expression, to see whether a field completion is required. */ fieldname = NULL; - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { type = parse_expression_for_completion (text, &fieldname, &code); } - if (except.reason < 0) - return NULL; + CATCH (except, RETURN_MASK_ERROR) + { + return NULL; + } + END_CATCH + if (fieldname && type) { for (;;) diff --git a/gdb/corelow.c b/gdb/corelow.c index 65e1326..9218003 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -278,7 +278,6 @@ core_open (const char *arg, int from_tty) bfd *temp_bfd; int scratch_chan; int flags; - volatile struct gdb_exception except; char *filename; target_preopen (from_tty); @@ -411,13 +410,16 @@ core_open (const char *arg, 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. */ - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { target_update_thread_list (); } - if (except.reason < 0) - exception_print (gdb_stderr, except); + CATCH (except, RETURN_MASK_ERROR) + { + exception_print (gdb_stderr, except); + } + END_CATCH p = bfd_core_file_failing_command (core_bfd); if (p) @@ -462,12 +464,15 @@ core_open (const char *arg, int from_tty) anything about threads. That is why the test is >= 2. */ if (thread_count () >= 2) { - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { thread_command (NULL, from_tty); } - if (except.reason < 0) - exception_print (gdb_stderr, except); + CATCH (except, RETURN_MASK_ERROR) + { + exception_print (gdb_stderr, except); + } + END_CATCH } } diff --git a/gdb/cp-abi.c b/gdb/cp-abi.c index 70a0528..b8af8f0 100644 --- a/gdb/cp-abi.c +++ b/gdb/cp-abi.c @@ -69,18 +69,17 @@ baseclass_offset (struct type *type, int index, const gdb_byte *valaddr, int embedded_offset, CORE_ADDR address, const struct value *val) { - volatile struct gdb_exception ex; int res = 0; gdb_assert (current_cp_abi.baseclass_offset != NULL); - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { res = (*current_cp_abi.baseclass_offset) (type, index, valaddr, embedded_offset, address, val); } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ERROR) { if (ex.error != NOT_AVAILABLE_ERROR) throw_exception (ex); @@ -89,6 +88,7 @@ baseclass_offset (struct type *type, int index, const gdb_byte *valaddr, _("Cannot determine virtual baseclass offset " "of incomplete object")); } + END_CATCH return res; } @@ -109,16 +109,19 @@ value_rtti_type (struct value *v, int *full, int *top, int *using_enc) { struct type *ret = NULL; - volatile struct gdb_exception e; if ((current_cp_abi.rtti_type) == NULL) return NULL; - TRY_CATCH (e, RETURN_MASK_ERROR) + TRY { ret = (*current_cp_abi.rtti_type) (v, full, top, using_enc); } - if (e.reason < 0) - return NULL; + CATCH (e, RETURN_MASK_ERROR) + { + return NULL; + } + END_CATCH + return ret; } diff --git a/gdb/cp-support.c b/gdb/cp-support.c index 260601f..4bbee94 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -157,7 +157,6 @@ inspect_type (struct demangle_parse_info *info, int i; char *name; struct symbol *sym; - volatile struct gdb_exception except; /* Copy the symbol's name from RET_COMP and look it up in the symbol table. */ @@ -173,12 +172,18 @@ inspect_type (struct demangle_parse_info *info, } sym = NULL; - TRY_CATCH (except, RETURN_MASK_ALL) - { - sym = lookup_symbol (name, 0, VAR_DOMAIN, 0); - } - if (except.reason >= 0 && sym != NULL) + TRY + { + sym = lookup_symbol (name, 0, VAR_DOMAIN, 0); + } + CATCH (except, RETURN_MASK_ALL) + { + return 0; + } + END_CATCH + + if (sym != NULL) { struct type *otype = SYMBOL_TYPE (sym); @@ -241,18 +246,19 @@ inspect_type (struct demangle_parse_info *info, } buf = mem_fileopen (); - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { type_print (type, "", buf, -1); } /* If type_print threw an exception, there is little point in continuing, so just bow out gracefully. */ - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { ui_file_delete (buf); return 0; } + END_CATCH name = ui_file_obsavestring (buf, &info->obstack, &len); ui_file_delete (buf); @@ -446,17 +452,21 @@ replace_typedefs (struct demangle_parse_info *info, if (local_name != NULL) { - struct symbol *sym; - volatile struct gdb_exception except; + struct symbol *sym = NULL; sym = NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { sym = lookup_symbol (local_name, 0, VAR_DOMAIN, 0); } + CATCH (except, RETURN_MASK_ALL) + { + } + END_CATCH + xfree (local_name); - if (except.reason >= 0 && sym != NULL) + if (sym != NULL) { struct type *otype = SYMBOL_TYPE (sym); const char *new_name = (*finder) (otype, data); diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index deb0ed8..feb3a66 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -313,18 +313,21 @@ cp_print_value_fields (struct type *type, struct type *real_type, } else if (field_is_static (&TYPE_FIELD (type, i))) { - volatile struct gdb_exception ex; struct value *v = NULL; - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { v = value_static_field (type, i); } - if (ex.reason < 0) - fprintf_filtered (stream, - _("<error reading variable: %s>"), - ex.message); + CATCH (ex, RETURN_MASK_ERROR) + { + fprintf_filtered (stream, + _("<error reading variable: %s>"), + ex.message); + } + END_CATCH + cp_print_static_field (TYPE_FIELD_TYPE (type, i), v, stream, recurse + 1, options); @@ -486,7 +489,6 @@ cp_print_value (struct type *type, struct type *real_type, const char *basename = TYPE_NAME (baseclass); const gdb_byte *base_valaddr = NULL; const struct value *base_val = NULL; - volatile struct gdb_exception ex; if (BASETYPE_VIA_VIRTUAL (type, i)) { @@ -506,17 +508,18 @@ cp_print_value (struct type *type, struct type *real_type, thisoffset = offset; thistype = real_type; - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { boffset = baseclass_offset (type, i, valaddr, offset, address, val); } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ERROR) { if (ex.error == NOT_AVAILABLE_ERROR) skip = -1; else skip = 1; } + END_CATCH if (skip == 0) { diff --git a/gdb/dwarf2-frame-tailcall.c b/gdb/dwarf2-frame-tailcall.c index c99fde0..b412a5b 100644 --- a/gdb/dwarf2-frame-tailcall.c +++ b/gdb/dwarf2-frame-tailcall.c @@ -368,7 +368,6 @@ dwarf2_tailcall_sniffer_first (struct frame_info *this_frame, struct gdbarch *prev_gdbarch; struct call_site_chain *chain = NULL; struct tailcall_cache *cache; - volatile struct gdb_exception except; gdb_assert (*tailcall_cachep == NULL); @@ -377,7 +376,7 @@ dwarf2_tailcall_sniffer_first (struct frame_info *this_frame, this_pc = get_frame_address_in_block (this_frame); /* Catch any unwinding errors. */ - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { int sp_regnum; @@ -397,12 +396,13 @@ dwarf2_tailcall_sniffer_first (struct frame_info *this_frame, prev_sp = frame_unwind_register_unsigned (this_frame, sp_regnum); prev_sp_p = 1; } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { if (entry_values_debug) exception_print (gdb_stdout, except); return; } + END_CATCH /* Ambiguous unwind or unambiguous unwind verified as matching. */ if (chain == NULL || chain->length == 0) diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c index b648aa3..8fb2ac7 100644 --- a/gdb/dwarf2-frame.c +++ b/gdb/dwarf2-frame.c @@ -1025,7 +1025,6 @@ dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache) struct dwarf2_frame_cache *cache; struct dwarf2_frame_state *fs; struct dwarf2_fde *fde; - volatile struct gdb_exception ex; CORE_ADDR entry_pc; const gdb_byte *instr; @@ -1102,7 +1101,7 @@ dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache) execute_cfa_program (fde, instr, fde->end, gdbarch, get_frame_address_in_block (this_frame), fs); - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { /* Calculate the CFA. */ switch (fs->regs.cfa_how) @@ -1126,7 +1125,7 @@ dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache) internal_error (__FILE__, __LINE__, _("Unknown CFA rule.")); } } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ERROR) { if (ex.error == NOT_AVAILABLE_ERROR) { @@ -1138,6 +1137,7 @@ dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache) throw_exception (ex); } + END_CATCH /* Initialize the register state. */ { @@ -2269,7 +2269,6 @@ dwarf2_build_frame_info (struct objfile *objfile) struct dwarf2_cie_table cie_table; struct dwarf2_fde_table fde_table; struct dwarf2_fde_table *fde_table2; - volatile struct gdb_exception e; cie_table.num_entries = 0; cie_table.entries = NULL; @@ -2311,7 +2310,7 @@ dwarf2_build_frame_info (struct objfile *objfile) if (txt) unit->tbase = txt->vma; - TRY_CATCH (e, RETURN_MASK_ERROR) + TRY { frame_ptr = unit->dwarf_frame_buffer; while (frame_ptr < unit->dwarf_frame_buffer + unit->dwarf_frame_size) @@ -2320,7 +2319,7 @@ dwarf2_build_frame_info (struct objfile *objfile) EH_CIE_OR_FDE_TYPE_ID); } - if (e.reason < 0) + CATCH (e, RETURN_MASK_ERROR) { warning (_("skipping .eh_frame info of %s: %s"), objfile_name (objfile), e.message); @@ -2333,6 +2332,7 @@ dwarf2_build_frame_info (struct objfile *objfile) } /* The cie_table is discarded by the next if. */ } + END_CATCH if (cie_table.num_entries != 0) { @@ -2352,7 +2352,7 @@ dwarf2_build_frame_info (struct objfile *objfile) { int num_old_fde_entries = fde_table.num_entries; - TRY_CATCH (e, RETURN_MASK_ERROR) + TRY { frame_ptr = unit->dwarf_frame_buffer; while (frame_ptr < unit->dwarf_frame_buffer + unit->dwarf_frame_size) @@ -2360,7 +2360,7 @@ dwarf2_build_frame_info (struct objfile *objfile) &cie_table, &fde_table, EH_CIE_OR_FDE_TYPE_ID); } - if (e.reason < 0) + CATCH (e, RETURN_MASK_ERROR) { warning (_("skipping .debug_frame info of %s: %s"), objfile_name (objfile), e.message); @@ -2383,6 +2383,7 @@ dwarf2_build_frame_info (struct objfile *objfile) fde_table.num_entries = num_old_fde_entries; /* The cie_table is discarded by the next if. */ } + END_CATCH } /* Discard the cie_table, it is no longer needed. */ diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c index aa569ee..e674933 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -983,14 +983,13 @@ struct call_site_chain * call_site_find_chain (struct gdbarch *gdbarch, CORE_ADDR caller_pc, CORE_ADDR callee_pc) { - volatile struct gdb_exception e; struct call_site_chain *retval = NULL; - TRY_CATCH (e, RETURN_MASK_ERROR) + TRY { retval = call_site_find_chain_1 (gdbarch, caller_pc, callee_pc); } - if (e.reason < 0) + CATCH (e, RETURN_MASK_ERROR) { if (e.error == NO_ENTRY_VALUE_ERROR) { @@ -1002,6 +1001,8 @@ call_site_find_chain (struct gdbarch *gdbarch, CORE_ADDR caller_pc, else throw_exception (e); } + END_CATCH + return retval; } @@ -2183,7 +2184,6 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, struct dwarf_expr_context *ctx; struct cleanup *old_chain, *value_chain; struct objfile *objfile = dwarf2_per_cu_objfile (per_cu); - volatile struct gdb_exception ex; if (byte_offset < 0) invalid_synthetic_pointer (); @@ -2206,11 +2206,11 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, ctx->baton = &baton; ctx->funcs = &dwarf_expr_ctx_funcs; - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { dwarf_expr_eval (ctx, data, size); } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ERROR) { if (ex.error == NOT_AVAILABLE_ERROR) { @@ -2229,6 +2229,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, else throw_exception (ex); } + END_CATCH if (ctx->num_pieces > 0) { diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index a283cba..c185d51 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -4221,14 +4221,13 @@ dwarf2_initialize_objfile (struct objfile *objfile) void dwarf2_build_psymtabs (struct objfile *objfile) { - volatile struct gdb_exception except; if (objfile->global_psymbols.size == 0 && objfile->static_psymbols.size == 0) { init_psymbol_list (objfile, 1024); } - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { /* This isn't really ideal: all the data we allocate on the objfile's obstack is still uselessly kept around. However, @@ -4238,8 +4237,11 @@ dwarf2_build_psymtabs (struct objfile *objfile) dwarf2_build_psymtabs_hard (objfile); discard_cleanups (cleanups); } - if (except.reason < 0) - exception_print (gdb_stderr, except); + CATCH (except, RETURN_MASK_ERROR) + { + exception_print (gdb_stderr, except); + } + END_CATCH } /* Return the total length of the CU described by HEADER. */ @@ -23171,16 +23173,18 @@ save_gdb_index_command (char *arg, int from_tty) dwarf2_per_objfile = objfile_data (objfile, dwarf2_objfile_data_key); if (dwarf2_per_objfile) { - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { write_psymtabs_to_index (objfile, arg); } - if (except.reason < 0) - exception_fprintf (gdb_stderr, except, - _("Error while writing index for `%s': "), - objfile_name (objfile)); + CATCH (except, RETURN_MASK_ERROR) + { + exception_fprintf (gdb_stderr, except, + _("Error while writing index for `%s': "), + objfile_name (objfile)); + } + END_CATCH } } } @@ -212,7 +212,6 @@ fetch_subexp_value (struct expression *exp, int *pc, struct value **valp, int preserve_errors) { struct value *mark, *new_mark, *result; - volatile struct gdb_exception ex; *valp = NULL; if (resultp) @@ -224,11 +223,11 @@ fetch_subexp_value (struct expression *exp, int *pc, struct value **valp, mark = value_mark (); result = NULL; - TRY_CATCH (ex, RETURN_MASK_ALL) + TRY { result = evaluate_subexp (NULL_TYPE, exp, pc, EVAL_NORMAL); } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ALL) { /* Ignore memory errors if we want watchpoints pointing at inaccessible memory to still be created; otherwise, throw the @@ -243,6 +242,7 @@ fetch_subexp_value (struct expression *exp, int *pc, struct value **valp, break; } } + END_CATCH new_mark = value_mark (); if (mark == new_mark) @@ -258,13 +258,16 @@ fetch_subexp_value (struct expression *exp, int *pc, struct value **valp, *valp = result; else { - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { value_fetch_lazy (result); *valp = result; } + CATCH (except, RETURN_MASK_ERROR) + { + } + END_CATCH } } @@ -762,16 +765,15 @@ evaluate_subexp_standard (struct type *expect_type, or reference to a base class and print object is on. */ { - volatile struct gdb_exception except; struct value *ret = NULL; - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { ret = value_of_variable (exp->elts[pc + 2].symbol, exp->elts[pc + 1].block); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { if (noside == EVAL_AVOID_SIDE_EFFECTS) ret = value_zero (SYMBOL_TYPE (exp->elts[pc + 2].symbol), @@ -779,6 +781,7 @@ evaluate_subexp_standard (struct type *expect_type, else throw_exception (except); } + END_CATCH return ret; } @@ -1446,20 +1449,21 @@ evaluate_subexp_standard (struct type *expect_type, operator and continue evaluation. */ while (unop_user_defined_p (op, arg2)) { - volatile struct gdb_exception except; struct value *value = NULL; - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { value = value_x_unop (arg2, op, noside); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { if (except.error == NOT_FOUND_ERROR) break; else throw_exception (except); } + END_CATCH + arg2 = value; } } @@ -1863,20 +1867,21 @@ evaluate_subexp_standard (struct type *expect_type, arg1 with the value returned by evaluating operator->(). */ while (unop_user_defined_p (op, arg1)) { - volatile struct gdb_exception except; struct value *value = NULL; - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { value = value_x_unop (arg1, op, noside); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { if (except.error == NOT_FOUND_ERROR) break; else throw_exception (except); } + END_CATCH + arg1 = value; } diff --git a/gdb/event-loop.c b/gdb/event-loop.c index a2b41a7..79e41fd 100644 --- a/gdb/event-loop.c +++ b/gdb/event-loop.c @@ -326,14 +326,13 @@ start_event_loop (void) processes it. */ while (1) { - volatile struct gdb_exception ex; int result = 0; - TRY_CATCH (ex, RETURN_MASK_ALL) + TRY { result = gdb_do_one_event (); } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ALL) { exception_print (gdb_stderr, ex); @@ -356,6 +355,8 @@ start_event_loop (void) /* Maybe better to set a flag to be checked somewhere as to whether display the prompt or not. */ } + END_CATCH + if (result < 0) break; } diff --git a/gdb/event-top.c b/gdb/event-top.c index bbda5dc..e9cc2d7 100644 --- a/gdb/event-top.c +++ b/gdb/event-top.c @@ -935,24 +935,28 @@ handle_sighup (int sig) static void async_disconnect (gdb_client_data arg) { - volatile struct gdb_exception exception; - TRY_CATCH (exception, RETURN_MASK_ALL) + TRY { quit_cover (); } - if (exception.reason < 0) + CATCH (exception, RETURN_MASK_ALL) { fputs_filtered ("Could not kill the program being debugged", gdb_stderr); exception_print (gdb_stderr, exception); } + END_CATCH - TRY_CATCH (exception, RETURN_MASK_ALL) + TRY { pop_all_targets (); } + CATCH (exception, RETURN_MASK_ALL) + { + } + END_CATCH signal (SIGHUP, SIG_DFL); /*FIXME: ??????????? */ raise (SIGHUP); diff --git a/gdb/exceptions.c b/gdb/exceptions.c index 64a653a..623e8e0 100644 --- a/gdb/exceptions.c +++ b/gdb/exceptions.c @@ -174,7 +174,6 @@ catch_exceptions_with_msg (struct ui_out *func_uiout, char **gdberrmsg, return_mask mask) { - volatile struct gdb_exception ex; struct gdb_exception exception = exception_none; volatile int val = 0; struct ui_out *saved_uiout; @@ -183,14 +182,15 @@ catch_exceptions_with_msg (struct ui_out *func_uiout, saved_uiout = current_uiout; current_uiout = func_uiout; - TRY_CATCH (ex, RETURN_MASK_ALL) + TRY { val = (*func) (current_uiout, func_args); } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ALL) { exception = ex; } + END_CATCH /* Restore the global builder. */ current_uiout = saved_uiout; @@ -228,17 +228,22 @@ int catch_errors (catch_errors_ftype *func, void *func_args, char *errstring, return_mask mask) { + struct gdb_exception exception = exception_none; volatile int val = 0; - volatile struct gdb_exception exception; struct ui_out *saved_uiout; /* Save the global ``struct ui_out'' builder. */ saved_uiout = current_uiout; - TRY_CATCH (exception, RETURN_MASK_ALL) + TRY { val = func (func_args); } + CATCH (ex, RETURN_MASK_ALL) + { + exception = ex; + } + END_CATCH /* Restore the global builder. */ current_uiout = saved_uiout; diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index c2aca71..e841edf 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -443,19 +443,22 @@ info_common_command_for_block (const struct block *block, const char *comname, for (index = 0; index < common->n_entries; index++) { struct value *val = NULL; - volatile struct gdb_exception except; printf_filtered ("%s = ", SYMBOL_PRINT_NAME (common->contents[index])); - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { val = value_of_variable (common->contents[index], block); value_print (val, gdb_stdout, &opts); } - if (except.reason < 0) - printf_filtered ("<error reading variable: %s>", except.message); + CATCH (except, RETURN_MASK_ERROR) + { + printf_filtered ("<error reading variable: %s>", except.message); + } + END_CATCH + putchar_filtered ('\n'); } } diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c index fcfedfd..bba1ae7 100644 --- a/gdb/frame-unwind.c +++ b/gdb/frame-unwind.c @@ -96,16 +96,15 @@ frame_unwind_try_unwinder (struct frame_info *this_frame, void **this_cache, const struct frame_unwind *unwinder) { struct cleanup *old_cleanup; - volatile struct gdb_exception ex; int res = 0; old_cleanup = frame_prepare_for_sniffer (this_frame, unwinder); - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { res = unwinder->sniffer (unwinder, this_frame, this_cache); } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ERROR) { if (ex.error == NOT_AVAILABLE_ERROR) { @@ -118,6 +117,7 @@ frame_unwind_try_unwinder (struct frame_info *this_frame, void **this_cache, } throw_exception (ex); } + END_CATCH if (res) { diff --git a/gdb/frame.c b/gdb/frame.c index 7088f32..b3cbf23 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -784,9 +784,9 @@ frame_unwind_pc (struct frame_info *this_frame) { if (gdbarch_unwind_pc_p (frame_unwind_arch (this_frame))) { - volatile struct gdb_exception ex; struct gdbarch *prev_gdbarch; CORE_ADDR pc = 0; + int pc_p = 0; /* The right way. The `pure' way. The one true way. This method depends solely on the register-unwind code to @@ -806,11 +806,12 @@ frame_unwind_pc (struct frame_info *this_frame) different ways that a PC could be unwound. */ prev_gdbarch = frame_unwind_arch (this_frame); - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { pc = gdbarch_unwind_pc (prev_gdbarch, this_frame); + pc_p = 1; } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ERROR) { if (ex.error == NOT_AVAILABLE_ERROR) { @@ -835,7 +836,9 @@ frame_unwind_pc (struct frame_info *this_frame) else throw_exception (ex); } - else + END_CATCH + + if (pc_p) { this_frame->prev_pc.value = pc; this_frame->prev_pc.status = CC_VALUE; @@ -1963,14 +1966,13 @@ get_prev_frame_always_1 (struct frame_info *this_frame) struct frame_info * get_prev_frame_always (struct frame_info *this_frame) { - volatile struct gdb_exception ex; struct frame_info *prev_frame = NULL; - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { prev_frame = get_prev_frame_always_1 (this_frame); } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ERROR) { if (ex.error == MEMORY_ERROR) { @@ -1994,6 +1996,7 @@ get_prev_frame_always (struct frame_info *this_frame) else throw_exception (ex); } + END_CATCH return prev_frame; } @@ -2222,21 +2225,21 @@ get_frame_pc (struct frame_info *frame) int get_frame_pc_if_available (struct frame_info *frame, CORE_ADDR *pc) { - volatile struct gdb_exception ex; gdb_assert (frame->next != NULL); - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { *pc = frame_unwind_pc (frame->next); } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ERROR) { if (ex.error == NOT_AVAILABLE_ERROR) return 0; else throw_exception (ex); } + END_CATCH return 1; } @@ -2307,18 +2310,18 @@ int get_frame_address_in_block_if_available (struct frame_info *this_frame, CORE_ADDR *pc) { - volatile struct gdb_exception ex; - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { *pc = get_frame_address_in_block (this_frame); } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ERROR) { if (ex.error == NOT_AVAILABLE_ERROR) return 0; throw_exception (ex); } + END_CATCH return 1; } diff --git a/gdb/gcore.c b/gdb/gcore.c index 3e05c61..44b9d0c 100644 --- a/gdb/gcore.c +++ b/gdb/gcore.c @@ -114,12 +114,19 @@ write_gcore_file_1 (bfd *obfd) void write_gcore_file (bfd *obfd) { - volatile struct gdb_exception except; + struct gdb_exception except = exception_none; target_prepare_to_generate_core (); - TRY_CATCH (except, RETURN_MASK_ALL) - write_gcore_file_1 (obfd); + TRY + { + write_gcore_file_1 (obfd); + } + CATCH (e, RETURN_MASK_ALL) + { + except = e; + } + END_CATCH target_done_generating_core (); diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index e735c8e..70cc374 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,8 @@ +2015-03-07 Pedro Alves <palves@redhat.com> + + Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH + instead. + 2015-03-06 Yao Qi <yao.qi@linaro.org> * linux-aarch64-low.c (aarch64_insert_point): Use diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index 4189877..08dbb60 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -3144,19 +3144,19 @@ static int exit_code; static void detach_or_kill_for_exit_cleanup (void *ignore) { - volatile struct gdb_exception exception; - TRY_CATCH (exception, RETURN_MASK_ALL) + TRY { detach_or_kill_for_exit (); } - if (exception.reason < 0) + CATCH (exception, RETURN_MASK_ALL) { fflush (stdout); fprintf (stderr, "Detach or kill failed: %s\n", exception.message); exit_code = 1; } + END_CATCH } /* Main function. This is called by the real "main" function, @@ -3385,7 +3385,6 @@ captured_main (int argc, char *argv[]) while (1) { - volatile struct gdb_exception exception; noack_mode = 0; multi_process = 0; @@ -3397,7 +3396,7 @@ captured_main (int argc, char *argv[]) remote_open (port); - TRY_CATCH (exception, RETURN_MASK_ERROR) + TRY { /* Wait for events. This will return when all event sources are removed from the event loop. */ @@ -3450,8 +3449,7 @@ captured_main (int argc, char *argv[]) } } } - - if (exception.reason == RETURN_ERROR) + CATCH (exception, RETURN_MASK_ERROR) { if (response_needed) { @@ -3459,6 +3457,7 @@ captured_main (int argc, char *argv[]) putpkt (own_buf); } } + END_CATCH } } @@ -3467,25 +3466,26 @@ captured_main (int argc, char *argv[]) int main (int argc, char *argv[]) { - volatile struct gdb_exception exception; - TRY_CATCH (exception, RETURN_MASK_ALL) + TRY { captured_main (argc, argv); } - - /* captured_main should never return. */ - gdb_assert (exception.reason < 0); - - if (exception.reason == RETURN_ERROR) + CATCH (exception, RETURN_MASK_ALL) { - fflush (stdout); - fprintf (stderr, "%s\n", exception.message); - fprintf (stderr, "Exiting\n"); - exit_code = 1; + if (exception.reason == RETURN_ERROR) + { + fflush (stdout); + fprintf (stderr, "%s\n", exception.message); + fprintf (stderr, "Exiting\n"); + exit_code = 1; + } + + exit (exit_code); } + END_CATCH - exit (exit_code); + gdb_assert_not_reached ("captured_main should never return"); } /* Skip PACKET until the next semi-colon (or end of string). */ diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index d087a12..af59d42 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -2299,20 +2299,22 @@ safe_parse_type (struct gdbarch *gdbarch, char *p, int length) { struct ui_file *saved_gdb_stderr; struct type *type = NULL; /* Initialize to keep gcc happy. */ - 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. */ - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { type = parse_and_eval_type (p, length); } - if (except.reason < 0) - type = builtin_type (gdbarch)->builtin_void; + CATCH (except, RETURN_MASK_ERROR) + { + type = builtin_type (gdbarch)->builtin_void; + } + END_CATCH /* Stop suppressing error messages. */ ui_file_delete (gdb_stderr); @@ -3235,7 +3237,6 @@ check_types_worklist (VEC (type_equality_entry_d) **worklist, int types_deeply_equal (struct type *type1, struct type *type2) { - volatile struct gdb_exception except; int result = 0; struct bcache *cache; VEC (type_equality_entry_d) *worklist = NULL; @@ -3253,7 +3254,7 @@ types_deeply_equal (struct type *type1, struct type *type2) entry.type2 = type2; VEC_safe_push (type_equality_entry_d, worklist, &entry); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { result = check_types_worklist (&worklist, cache); } @@ -3264,8 +3265,11 @@ types_deeply_equal (struct type *type1, struct type *type2) bcache_xfree (cache); VEC_free (type_equality_entry_d, worklist); /* Rethrow if there was a problem. */ - if (except.reason < 0) - throw_exception (except); + CATCH (except, RETURN_MASK_ALL) + { + throw_exception (except); + } + END_CATCH return result; } diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index d1ed8fc..5c04011 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -904,8 +904,8 @@ print_one_vtable (struct gdbarch *gdbarch, struct value *value, { /* Initialize it just to avoid a GCC false warning. */ CORE_ADDR addr = 0; + int got_error = 0; struct value *vfn; - volatile struct gdb_exception ex; printf_filtered ("[%d]: ", i); @@ -916,13 +916,18 @@ print_one_vtable (struct gdbarch *gdbarch, struct value *value, if (gdbarch_vtable_function_descriptors (gdbarch)) vfn = value_addr (vfn); - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { addr = value_as_address (vfn); } - if (ex.reason < 0) - printf_filtered (_("<error: %s>"), ex.message); - else + CATCH (ex, RETURN_MASK_ERROR) + { + printf_filtered (_("<error: %s>"), ex.message); + got_error = 1; + } + END_CATCH + + if (!got_error) print_function_pointer_address (opts, gdbarch, addr, gdb_stdout); printf_filtered ("\n"); } diff --git a/gdb/guile/guile.c b/gdb/guile/guile.c index 1895118..16d15b7 100644 --- a/gdb/guile/guile.c +++ b/gdb/guile/guile.c @@ -310,11 +310,11 @@ gdbscm_execute_gdb_command (SCM command_scm, SCM rest) { int from_tty_arg_pos = -1, to_string_arg_pos = -1; int from_tty = 0, to_string = 0; - volatile struct gdb_exception except; const SCM keywords[] = { from_tty_keyword, to_string_keyword, SCM_BOOL_F }; char *command; char *result = NULL; struct cleanup *cleanups; + struct gdb_exception except = exception_none; gdbscm_parse_function_args (FUNC_NAME, SCM_ARG1, keywords, "s#tt", command_scm, &command, rest, @@ -325,7 +325,7 @@ gdbscm_execute_gdb_command (SCM command_scm, SCM rest) executed. */ cleanups = make_cleanup (xfree, command); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct cleanup *inner_cleanups; @@ -346,6 +346,12 @@ gdbscm_execute_gdb_command (SCM command_scm, SCM rest) do_cleanups (inner_cleanups); } + CATCH (ex, RETURN_MASK_ALL) + { + except = ex; + } + END_CATCH + do_cleanups (cleanups); GDBSCM_HANDLE_GDB_EXCEPTION (except); diff --git a/gdb/guile/scm-block.c b/gdb/guile/scm-block.c index 36c14da..50dc6c7 100644 --- a/gdb/guile/scm-block.c +++ b/gdb/guile/scm-block.c @@ -678,18 +678,21 @@ gdbscm_lookup_block (SCM pc_scm) CORE_ADDR pc; const struct block *block = NULL; struct compunit_symtab *cust = NULL; - volatile struct gdb_exception except; gdbscm_parse_function_args (FUNC_NAME, SCM_ARG1, NULL, "U", pc_scm, &pc); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { cust = find_pc_compunit_symtab (pc); if (cust != NULL && COMPUNIT_OBJFILE (cust) != NULL) block = block_for_pc (pc); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH if (cust == NULL || COMPUNIT_OBJFILE (cust) == NULL) { diff --git a/gdb/guile/scm-breakpoint.c b/gdb/guile/scm-breakpoint.c index c1f9f91..ad853ed 100644 --- a/gdb/guile/scm-breakpoint.c +++ b/gdb/guile/scm-breakpoint.c @@ -407,7 +407,7 @@ gdbscm_register_breakpoint_x (SCM self) { breakpoint_smob *bp_smob = bpscm_get_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - volatile struct gdb_exception except; + struct gdb_exception except = exception_none; /* We only support registering breakpoints created with make-breakpoint. */ if (!bp_smob->is_scheme_bkpt) @@ -418,7 +418,7 @@ gdbscm_register_breakpoint_x (SCM self) pending_breakpoint_scm = self; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { char *location = bp_smob->spec.location; int internal = bp_smob->spec.is_internal; @@ -455,6 +455,12 @@ gdbscm_register_breakpoint_x (SCM self) gdb_assert_not_reached ("invalid breakpoint type"); } } + CATCH (ex, RETURN_MASK_ALL) + { + except = ex; + } + END_CATCH + /* Ensure this gets reset, even if there's an error. */ pending_breakpoint_scm = SCM_BOOL_F; GDBSCM_HANDLE_GDB_EXCEPTION (except); @@ -473,13 +479,16 @@ gdbscm_delete_breakpoint_x (SCM self) { breakpoint_smob *bp_smob = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { delete_breakpoint (bp_smob->bp); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH return SCM_UNSPECIFIED; } @@ -565,19 +574,22 @@ gdbscm_set_breakpoint_enabled_x (SCM self, SCM newvalue) { breakpoint_smob *bp_smob = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - volatile struct gdb_exception except; SCM_ASSERT_TYPE (gdbscm_is_bool (newvalue), newvalue, SCM_ARG2, FUNC_NAME, _("boolean")); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (gdbscm_is_true (newvalue)) enable_breakpoint (bp_smob->bp); else disable_breakpoint (bp_smob->bp); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH return SCM_UNSPECIFIED; } @@ -600,16 +612,19 @@ gdbscm_set_breakpoint_silent_x (SCM self, SCM newvalue) { breakpoint_smob *bp_smob = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - volatile struct gdb_exception except; SCM_ASSERT_TYPE (gdbscm_is_bool (newvalue), newvalue, SCM_ARG2, FUNC_NAME, _("boolean")); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { breakpoint_set_silent (bp_smob->bp, gdbscm_is_true (newvalue)); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH return SCM_UNSPECIFIED; } @@ -634,7 +649,6 @@ gdbscm_set_breakpoint_ignore_count_x (SCM self, SCM newvalue) breakpoint_smob *bp_smob = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); long value; - volatile struct gdb_exception except; SCM_ASSERT_TYPE (scm_is_signed_integer (newvalue, LONG_MIN, LONG_MAX), newvalue, SCM_ARG2, FUNC_NAME, _("integer")); @@ -643,11 +657,15 @@ gdbscm_set_breakpoint_ignore_count_x (SCM self, SCM newvalue) if (value < 0) value = 0; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { set_ignore_count (bp_smob->number, (int) value, 0); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH return SCM_UNSPECIFIED; } @@ -755,17 +773,20 @@ gdbscm_set_breakpoint_task_x (SCM self, SCM newvalue) = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); long id; int valid_id = 0; - volatile struct gdb_exception except; if (scm_is_signed_integer (newvalue, LONG_MIN, LONG_MAX)) { id = scm_to_long (newvalue); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { valid_id = valid_task_id (id); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH if (! valid_id) { @@ -778,11 +799,15 @@ gdbscm_set_breakpoint_task_x (SCM self, SCM newvalue) else SCM_ASSERT_TYPE (0, newvalue, SCM_ARG2, FUNC_NAME, _("integer or #f")); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { breakpoint_set_task (bp_smob->bp, id); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH return SCM_UNSPECIFIED; } @@ -855,7 +880,7 @@ gdbscm_set_breakpoint_condition_x (SCM self, SCM newvalue) breakpoint_smob *bp_smob = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); char *exp; - volatile struct gdb_exception except; + struct gdb_exception except = exception_none; SCM_ASSERT_TYPE (scm_is_string (newvalue) || gdbscm_is_false (newvalue), newvalue, SCM_ARG2, FUNC_NAME, @@ -866,10 +891,16 @@ gdbscm_set_breakpoint_condition_x (SCM self, SCM newvalue) else exp = gdbscm_scm_to_c_string (newvalue); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { set_breakpoint_condition (bp_smob->bp, exp ? exp : "", 0); } + CATCH (ex, RETURN_MASK_ALL) + { + except = ex; + } + END_CATCH + xfree (exp); GDBSCM_HANDLE_GDB_EXCEPTION (except); @@ -936,7 +967,6 @@ gdbscm_breakpoint_commands (SCM self) = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); struct breakpoint *bp; long length; - volatile struct gdb_exception except; struct ui_file *string_file; struct cleanup *chain; SCM result; @@ -951,16 +981,17 @@ gdbscm_breakpoint_commands (SCM self) chain = make_cleanup_ui_file_delete (string_file); ui_out_redirect (current_uiout, string_file); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { print_command_lines (current_uiout, breakpoint_commands (bp), 0); } ui_out_redirect (current_uiout, NULL); - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { do_cleanups (chain); gdbscm_throw_gdb_exception (except); } + END_CATCH cmdstr = ui_file_xstrdup (string_file, &length); make_cleanup (xfree, cmdstr); diff --git a/gdb/guile/scm-cmd.c b/gdb/guile/scm-cmd.c index 7c6d010..c870fcc 100644 --- a/gdb/guile/scm-cmd.c +++ b/gdb/guile/scm-cmd.c @@ -762,7 +762,6 @@ gdbscm_register_command_x (SCM self) char *cmd_name, *pfx_name; struct cmd_list_element **cmd_list; struct cmd_list_element *cmd = NULL; - volatile struct gdb_exception except; if (cmdscm_is_valid (c_smob)) scm_misc_error (FUNC_NAME, _("command is already registered"), SCM_EOL); @@ -772,7 +771,7 @@ gdbscm_register_command_x (SCM self) c_smob->cmd_name = gdbscm_gc_xstrdup (cmd_name); xfree (cmd_name); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (c_smob->is_prefix) { @@ -790,7 +789,11 @@ gdbscm_register_command_x (SCM self) NULL, c_smob->doc, cmd_list); } } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH /* Note: At this point the command exists in gdb. So no more errors after this point. */ diff --git a/gdb/guile/scm-disasm.c b/gdb/guile/scm-disasm.c index 5ae7075..782d915 100644 --- a/gdb/guile/scm-disasm.c +++ b/gdb/guile/scm-disasm.c @@ -283,9 +283,8 @@ gdbscm_arch_disassemble (SCM self, SCM start_scm, SCM rest) char *as = NULL; struct ui_file *memfile = mem_fileopen (); struct cleanup *cleanups = make_cleanup_ui_file_delete (memfile); - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (using_port) { @@ -295,7 +294,11 @@ gdbscm_arch_disassemble (SCM self, SCM start_scm, SCM rest) else insn_len = gdb_print_insn (gdbarch, pc, memfile, NULL); } - GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups); + } + END_CATCH as = ui_file_xstrdup (memfile, NULL); diff --git a/gdb/guile/scm-frame.c b/gdb/guile/scm-frame.c index a30c093..6189802 100644 --- a/gdb/guile/scm-frame.c +++ b/gdb/guile/scm-frame.c @@ -220,7 +220,6 @@ frscm_scm_from_frame (struct frame_info *frame, struct inferior *inferior) SCM f_scm; htab_t htab; eqable_gdb_smob **slot; - volatile struct gdb_exception except; struct frame_id frame_id = null_frame_id; struct gdbarch *gdbarch = NULL; int frame_id_is_next = 0; @@ -234,7 +233,7 @@ frscm_scm_from_frame (struct frame_info *frame, struct inferior *inferior) if (*slot != NULL) return (*slot)->containing_scm; - TRY_CATCH (except, RETURN_MASK_ALL) + 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 @@ -253,8 +252,11 @@ frscm_scm_from_frame (struct frame_info *frame, struct inferior *inferior) } gdbarch = get_frame_arch (frame); } - if (except.reason < 0) - return gdbscm_scm_from_gdb_exception (except); + CATCH (except, RETURN_MASK_ALL) + { + return gdbscm_scm_from_gdb_exception (except); + } + END_CATCH f_scm = frscm_make_frame_smob (); f_smob = (frame_smob *) SCM_SMOB_DATA (f_scm); @@ -396,15 +398,18 @@ gdbscm_frame_valid_p (SCM self) { frame_smob *f_smob; struct frame_info *frame = NULL; - volatile struct gdb_exception except; f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { frame = frscm_frame_smob_to_frame (f_smob); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH return scm_from_bool (frame != NULL); } @@ -421,18 +426,23 @@ gdbscm_frame_name (SCM self) enum language lang = language_minimal; struct frame_info *frame = NULL; SCM result; - volatile struct gdb_exception except; + struct gdb_exception except = exception_none; f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { frame = frscm_frame_smob_to_frame (f_smob); if (frame != NULL) find_frame_funname (frame, &name, &lang, NULL); } - if (except.reason < 0) - xfree (name); + CATCH (ex, RETURN_MASK_ALL) + { + except = ex; + } + END_CATCH + + xfree (name); GDBSCM_HANDLE_GDB_EXCEPTION (except); if (frame == NULL) @@ -461,17 +471,20 @@ gdbscm_frame_type (SCM self) frame_smob *f_smob; enum frame_type type = NORMAL_FRAME; struct frame_info *frame = NULL; - volatile struct gdb_exception except; f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { frame = frscm_frame_smob_to_frame (f_smob); if (frame != NULL) type = get_frame_type (frame); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH if (frame == NULL) { @@ -490,15 +503,18 @@ gdbscm_frame_arch (SCM self) { frame_smob *f_smob; struct frame_info *frame = NULL; - volatile struct gdb_exception except; f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { frame = frscm_frame_smob_to_frame (f_smob); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH if (frame == NULL) { @@ -517,16 +533,19 @@ gdbscm_frame_unwind_stop_reason (SCM self) { frame_smob *f_smob; struct frame_info *frame = NULL; - volatile struct gdb_exception except; enum unwind_stop_reason stop_reason; f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { frame = frscm_frame_smob_to_frame (f_smob); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH if (frame == NULL) { @@ -548,17 +567,20 @@ gdbscm_frame_pc (SCM self) frame_smob *f_smob; CORE_ADDR pc = 0; struct frame_info *frame = NULL; - volatile struct gdb_exception except; f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { frame = frscm_frame_smob_to_frame (f_smob); if (frame != NULL) pc = get_frame_pc (frame); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH if (frame == NULL) { @@ -578,17 +600,20 @@ gdbscm_frame_block (SCM self) frame_smob *f_smob; const struct block *block = NULL, *fn_block; struct frame_info *frame = NULL; - volatile struct gdb_exception except; f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { frame = frscm_frame_smob_to_frame (f_smob); if (frame != NULL) block = get_frame_block (frame, NULL); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH if (frame == NULL) { @@ -626,17 +651,20 @@ gdbscm_frame_function (SCM self) frame_smob *f_smob; struct symbol *sym = NULL; struct frame_info *frame = NULL; - volatile struct gdb_exception except; f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { frame = frscm_frame_smob_to_frame (f_smob); if (frame != NULL) sym = find_pc_function (get_frame_address_in_block (frame)); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH if (frame == NULL) { @@ -660,17 +688,20 @@ gdbscm_frame_older (SCM self) frame_smob *f_smob; struct frame_info *prev = NULL; struct frame_info *frame = NULL; - volatile struct gdb_exception except; f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { frame = frscm_frame_smob_to_frame (f_smob); if (frame != NULL) prev = get_prev_frame (frame); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH if (frame == NULL) { @@ -694,17 +725,20 @@ gdbscm_frame_newer (SCM self) frame_smob *f_smob; struct frame_info *next = NULL; struct frame_info *frame = NULL; - volatile struct gdb_exception except; f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { frame = frscm_frame_smob_to_frame (f_smob); if (frame != NULL) next = get_next_frame (frame); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH if (frame == NULL) { @@ -727,17 +761,20 @@ gdbscm_frame_sal (SCM self) frame_smob *f_smob; struct symtab_and_line sal; struct frame_info *frame = NULL; - volatile struct gdb_exception except; f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { frame = frscm_frame_smob_to_frame (f_smob); if (frame != NULL) find_frame_sal (frame, &sal); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH if (frame == NULL) { @@ -767,15 +804,18 @@ gdbscm_frame_read_var (SCM self, SCM symbol_scm, SCM rest) struct frame_info *frame = NULL; struct symbol *var = NULL; struct value *value = NULL; - volatile struct gdb_exception except; f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { frame = frscm_frame_smob_to_frame (f_smob); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH if (frame == NULL) { @@ -797,7 +837,7 @@ gdbscm_frame_read_var (SCM self, SCM symbol_scm, SCM rest) char *var_name; const struct block *block = NULL; struct cleanup *cleanup; - volatile struct gdb_exception except; + struct gdb_exception except = exception_none; if (! SCM_UNBNDP (block_scm)) { @@ -815,14 +855,19 @@ gdbscm_frame_read_var (SCM self, SCM symbol_scm, SCM rest) /* N.B. Between here and the call to do_cleanups, don't do anything to cause a Scheme exception without performing the cleanup. */ - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (block == NULL) block = get_frame_block (frame, NULL); var = lookup_symbol (var_name, block, VAR_DOMAIN, NULL); } - if (except.reason < 0) - do_cleanups (cleanup); + CATCH (ex, RETURN_MASK_ALL) + { + except = ex; + } + END_CATCH + + do_cleanups (cleanup); GDBSCM_HANDLE_GDB_EXCEPTION (except); if (var == NULL) @@ -841,11 +886,15 @@ gdbscm_frame_read_var (SCM self, SCM symbol_scm, SCM rest) _("gdb:symbol or string")); } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { value = read_var_value (var, frame); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH return vlscm_scm_from_value (value); } @@ -858,17 +907,20 @@ gdbscm_frame_select (SCM self) { frame_smob *f_smob; struct frame_info *frame = NULL; - volatile struct gdb_exception except; f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { frame = frscm_frame_smob_to_frame (f_smob); if (frame != NULL) select_frame (frame); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH if (frame == NULL) { @@ -886,13 +938,16 @@ static SCM gdbscm_newest_frame (void) { struct frame_info *frame = NULL; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { frame = get_current_frame (); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH return frscm_scm_from_frame_unsafe (frame, current_inferior ()); } @@ -904,13 +959,16 @@ static SCM gdbscm_selected_frame (void) { struct frame_info *frame = NULL; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { frame = get_selected_frame (_("No frame is currently selected")); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH return frscm_scm_from_frame_unsafe (frame, current_inferior ()); } diff --git a/gdb/guile/scm-lazy-string.c b/gdb/guile/scm-lazy-string.c index d9ca97e9..c84ead7 100644 --- a/gdb/guile/scm-lazy-string.c +++ b/gdb/guile/scm-lazy-string.c @@ -234,7 +234,6 @@ gdbscm_lazy_string_to_value (SCM self) SCM ls_scm = lsscm_get_lazy_string_arg_unsafe (self, SCM_ARG1, FUNC_NAME); lazy_string_smob *ls_smob = (lazy_string_smob *) SCM_SMOB_DATA (ls_scm); struct value *value = NULL; - volatile struct gdb_exception except; if (ls_smob->address == 0) { @@ -242,11 +241,15 @@ gdbscm_lazy_string_to_value (SCM self) _("cannot create a value from NULL"))); } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { value = value_at_lazy (ls_smob->type, ls_smob->address); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH return vlscm_scm_from_value (value); } @@ -268,7 +271,6 @@ lsscm_safe_lazy_string_to_value (SCM string, int arg_pos, { lazy_string_smob *ls_smob; struct value *value = NULL; - volatile struct gdb_exception except; gdb_assert (lsscm_is_lazy_string (string)); @@ -283,15 +285,16 @@ lsscm_safe_lazy_string_to_value (SCM string, int arg_pos, return NULL; } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { value = value_at_lazy (ls_smob->type, ls_smob->address); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { *except_scmp = gdbscm_scm_from_gdb_exception (except); return NULL; } + END_CATCH return value; } diff --git a/gdb/guile/scm-math.c b/gdb/guile/scm-math.c index 7ff37ce..4b6bb5d 100644 --- a/gdb/guile/scm-math.c +++ b/gdb/guile/scm-math.c @@ -83,7 +83,6 @@ vlscm_unop (enum valscm_unary_opcode opcode, SCM x, const char *func_name) struct value *res_val = NULL; SCM except_scm; struct cleanup *cleanups; - volatile struct gdb_exception except; cleanups = make_cleanup_value_free_to_mark (value_mark ()); @@ -95,7 +94,7 @@ vlscm_unop (enum valscm_unary_opcode opcode, SCM x, const char *func_name) gdbscm_throw (except_scm); } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { switch (opcode) { @@ -128,7 +127,11 @@ vlscm_unop (enum valscm_unary_opcode opcode, SCM x, const char *func_name) gdb_assert_not_reached ("unsupported operation"); } } - GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups); + } + END_CATCH gdb_assert (res_val != NULL); result = vlscm_scm_from_value (res_val); @@ -156,7 +159,6 @@ vlscm_binop (enum valscm_binary_opcode opcode, SCM x, SCM y, struct value *res_val = NULL; SCM except_scm; struct cleanup *cleanups; - volatile struct gdb_exception except; cleanups = make_cleanup_value_free_to_mark (value_mark ()); @@ -175,7 +177,7 @@ vlscm_binop (enum valscm_binary_opcode opcode, SCM x, SCM y, gdbscm_throw (except_scm); } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { switch (opcode) { @@ -264,7 +266,11 @@ vlscm_binop (enum valscm_binary_opcode opcode, SCM x, SCM y, gdb_assert_not_reached ("unsupported operation"); } } - GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups); + } + END_CATCH gdb_assert (res_val != NULL); result = vlscm_scm_from_value (res_val); @@ -441,7 +447,7 @@ vlscm_rich_compare (int op, SCM x, SCM y, const char *func_name) int result = 0; SCM except_scm; struct cleanup *cleanups; - volatile struct gdb_exception except; + struct gdb_exception except = exception_none; cleanups = make_cleanup_value_free_to_mark (value_mark ()); @@ -460,7 +466,7 @@ vlscm_rich_compare (int op, SCM x, SCM y, const char *func_name) gdbscm_throw (except_scm); } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { switch (op) { @@ -487,6 +493,12 @@ vlscm_rich_compare (int op, SCM x, SCM y, const char *func_name) gdb_assert_not_reached ("invalid <gdb:value> comparison"); } } + CATCH (ex, RETURN_MASK_ALL) + { + except = ex; + } + END_CATCH + do_cleanups (cleanups); GDBSCM_HANDLE_GDB_EXCEPTION (except); @@ -742,7 +754,6 @@ vlscm_convert_typed_value_from_scheme (const char *func_name, { struct value *value = NULL; SCM except_scm = SCM_BOOL_F; - volatile struct gdb_exception except; if (type == NULL) { @@ -752,7 +763,7 @@ vlscm_convert_typed_value_from_scheme (const char *func_name, *except_scmp = SCM_BOOL_F; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (vlscm_is_value (obj)) { @@ -859,8 +870,11 @@ vlscm_convert_typed_value_from_scheme (const char *func_name, value = NULL; } } - if (except.reason < 0) - except_scm = gdbscm_scm_from_gdb_exception (except); + CATCH (except, RETURN_MASK_ALL) + { + except_scm = gdbscm_scm_from_gdb_exception (except); + } + END_CATCH if (gdbscm_is_true (except_scm)) { diff --git a/gdb/guile/scm-param.c b/gdb/guile/scm-param.c index 02b4f8a..508bcb9 100644 --- a/gdb/guile/scm-param.c +++ b/gdb/guile/scm-param.c @@ -990,7 +990,6 @@ gdbscm_register_parameter_x (SCM self) = pascm_get_param_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); char *cmd_name; struct cmd_list_element **set_list, **show_list; - volatile struct gdb_exception except; if (pascm_is_valid (p_smob)) scm_misc_error (FUNC_NAME, _("parameter is already registered"), SCM_EOL); @@ -1014,7 +1013,7 @@ gdbscm_register_parameter_x (SCM self) _("parameter exists, \"show\" command is already defined")); } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { add_setshow_generic (p_smob->type, p_smob->cmd_class, p_smob->cmd_name, p_smob, @@ -1026,7 +1025,11 @@ gdbscm_register_parameter_x (SCM self) set_list, show_list, &p_smob->set_command, &p_smob->show_command); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH /* Note: At this point the parameter exists in gdb. So no more errors after this point. */ @@ -1063,16 +1066,22 @@ gdbscm_parameter_value (SCM self) const char *arg; char *newarg; int found = -1; - volatile struct gdb_exception except; + struct gdb_exception except = exception_none; name = gdbscm_scm_to_host_string (self, NULL, &except_scm); if (name == NULL) gdbscm_throw (except_scm); newarg = concat ("show ", name, (char *) NULL); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { found = lookup_cmd_composition (newarg, &alias, &prefix, &cmd); } + CATCH (ex, RETURN_MASK_ALL) + { + except = ex; + } + END_CATCH + xfree (name); xfree (newarg); GDBSCM_HANDLE_GDB_EXCEPTION (except); diff --git a/gdb/guile/scm-ports.c b/gdb/guile/scm-ports.c index dcf7d2d..8967b92 100644 --- a/gdb/guile/scm-ports.c +++ b/gdb/guile/scm-ports.c @@ -263,20 +263,23 @@ fputsn_filtered (const char *s, size_t size, struct ui_file *stream) static void ioscm_write (SCM port, const void *data, size_t size) { - volatile struct gdb_exception except; /* If we're called on stdin, punt. */ if (scm_is_eq (port, input_port_scm)) return; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (scm_is_eq (port, error_port_scm)) fputsn_filtered (data, size, gdb_stderr); else fputsn_filtered (data, size, gdb_stdout); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH } /* Flush gdb's stdout or stderr. */ diff --git a/gdb/guile/scm-pretty-print.c b/gdb/guile/scm-pretty-print.c index 82cf96c..860cf8e 100644 --- a/gdb/guile/scm-pretty-print.c +++ b/gdb/guile/scm-pretty-print.c @@ -529,11 +529,10 @@ ppscm_pretty_print_one_value (SCM printer, struct value **out_value, struct gdbarch *gdbarch, const struct language_defn *language) { - volatile struct gdb_exception except; SCM result = SCM_BOOL_F; *out_value = NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { int rc; pretty_printer_worker_smob *w_smob @@ -568,6 +567,10 @@ ppscm_pretty_print_one_value (SCM printer, struct value **out_value, (_("invalid result from pretty-printer to-string"), result); } } + CATCH (except, RETURN_MASK_ALL) + { + } + END_CATCH return result; } diff --git a/gdb/guile/scm-symbol.c b/gdb/guile/scm-symbol.c index 1891237..99ef928 100644 --- a/gdb/guile/scm-symbol.c +++ b/gdb/guile/scm-symbol.c @@ -483,14 +483,17 @@ gdbscm_symbol_needs_frame_p (SCM self) symbol_smob *s_smob = syscm_get_valid_symbol_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); struct symbol *symbol = s_smob->symbol; - volatile struct gdb_exception except; int result = 0; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { result = symbol_read_needs_frame (symbol); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH return scm_from_bool (result); } @@ -523,7 +526,6 @@ gdbscm_symbol_value (SCM self, SCM rest) frame_smob *f_smob = NULL; struct frame_info *frame_info = NULL; struct value *value = NULL; - volatile struct gdb_exception except; gdbscm_parse_function_args (FUNC_NAME, SCM_ARG2, keywords, "#O", rest, &frame_pos, &frame_scm); @@ -536,7 +538,7 @@ gdbscm_symbol_value (SCM self, SCM rest) _("cannot get the value of a typedef")); } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (f_smob != NULL) { @@ -550,7 +552,11 @@ gdbscm_symbol_value (SCM self, SCM rest) value = read_var_value (symbol, frame_info); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH return vlscm_scm_from_value (value); } @@ -571,8 +577,8 @@ gdbscm_lookup_symbol (SCM name_scm, SCM rest) int block_arg_pos = -1, domain_arg_pos = -1; struct field_of_this_result is_a_field_of_this; struct symbol *symbol = NULL; - volatile struct gdb_exception except; struct cleanup *cleanups; + struct gdb_exception except = exception_none; gdbscm_parse_function_args (FUNC_NAME, SCM_ARG1, keywords, "s#Oi", name_scm, &name, rest, @@ -597,18 +603,28 @@ gdbscm_lookup_symbol (SCM name_scm, SCM rest) { struct frame_info *selected_frame; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { selected_frame = get_selected_frame (_("no frame selected")); block = get_frame_block (selected_frame, NULL); } - GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups); + } + END_CATCH } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { symbol = lookup_symbol (name, block, domain, &is_a_field_of_this); } + CATCH (ex, RETURN_MASK_ALL) + { + except = ex; + } + END_CATCH + do_cleanups (cleanups); GDBSCM_HANDLE_GDB_EXCEPTION (except); @@ -630,8 +646,8 @@ gdbscm_lookup_global_symbol (SCM name_scm, SCM rest) int domain_arg_pos = -1; int domain = VAR_DOMAIN; struct symbol *symbol = NULL; - volatile struct gdb_exception except; struct cleanup *cleanups; + struct gdb_exception except = exception_none; gdbscm_parse_function_args (FUNC_NAME, SCM_ARG1, keywords, "s#i", name_scm, &name, rest, @@ -639,10 +655,16 @@ gdbscm_lookup_global_symbol (SCM name_scm, SCM rest) cleanups = make_cleanup (xfree, name); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { symbol = lookup_global_symbol (name, NULL, domain); } + CATCH (ex, RETURN_MASK_ALL) + { + except = ex; + } + END_CATCH + do_cleanups (cleanups); GDBSCM_HANDLE_GDB_EXCEPTION (except); diff --git a/gdb/guile/scm-symtab.c b/gdb/guile/scm-symtab.c index 03f616d..009a2b4 100644 --- a/gdb/guile/scm-symtab.c +++ b/gdb/guile/scm-symtab.c @@ -590,19 +590,22 @@ gdbscm_find_pc_line (SCM pc_scm) { ULONGEST pc_ull; struct symtab_and_line sal; - volatile struct gdb_exception except; init_sal (&sal); /* -Wall */ gdbscm_parse_function_args (FUNC_NAME, SCM_ARG1, NULL, "U", pc_scm, &pc_ull); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { CORE_ADDR pc = (CORE_ADDR) pc_ull; sal = find_pc_line (pc, 0); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH return stscm_scm_from_sal (sal); } diff --git a/gdb/guile/scm-type.c b/gdb/guile/scm-type.c index d21a7ae..fa0c213 100644 --- a/gdb/guile/scm-type.c +++ b/gdb/guile/scm-type.c @@ -108,9 +108,8 @@ static char * tyscm_type_name (struct type *type, SCM *excp) { char *name = NULL; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct cleanup *old_chain; struct ui_file *stb; @@ -123,11 +122,12 @@ tyscm_type_name (struct type *type, SCM *excp) name = ui_file_xstrdup (stb, NULL); do_cleanups (old_chain); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { *excp = gdbscm_scm_from_gdb_exception (except); return NULL; } + END_CATCH return name; } @@ -239,7 +239,6 @@ tyscm_equal_p_type_smob (SCM type1_scm, SCM type2_scm) type_smob *type1_smob, *type2_smob; struct type *type1, *type2; int result = 0; - volatile struct gdb_exception except; SCM_ASSERT_TYPE (tyscm_is_type (type1_scm), type1_scm, SCM_ARG1, FUNC_NAME, type_smob_name); @@ -250,11 +249,15 @@ tyscm_equal_p_type_smob (SCM type1_scm, SCM type2_scm) type1 = type1_smob->type; type2 = type2_smob->type; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { result = types_deeply_equal (type1, type2); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH return scm_from_bool (result); } @@ -628,12 +631,16 @@ gdbscm_type_sizeof (SCM self) type_smob *t_smob = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); struct type *type = t_smob->type; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { check_typedef (type); } + CATCH (except, RETURN_MASK_ALL) + { + } + END_CATCH + /* Ignore exceptions. */ return scm_from_long (TYPE_LENGTH (type)); @@ -648,13 +655,16 @@ gdbscm_type_strip_typedefs (SCM self) type_smob *t_smob = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); struct type *type = t_smob->type; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { type = check_typedef (type); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH return tyscm_scm_from_type (type); } @@ -665,15 +675,18 @@ gdbscm_type_strip_typedefs (SCM self) static struct type * tyscm_get_composite (struct type *type) { - volatile struct gdb_exception except; for (;;) { - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { type = check_typedef (type); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH if (TYPE_CODE (type) != TYPE_CODE_PTR && TYPE_CODE (type) != TYPE_CODE_REF) @@ -702,7 +715,6 @@ tyscm_array_1 (SCM self, SCM n1_scm, SCM n2_scm, int is_vector, struct type *type = t_smob->type; long n1, n2 = 0; struct type *array = NULL; - volatile struct gdb_exception except; gdbscm_parse_function_args (func_name, SCM_ARG2, NULL, "l|l", n1_scm, &n1, n2_scm, &n2); @@ -721,13 +733,17 @@ tyscm_array_1 (SCM self, SCM n1_scm, SCM n2_scm, int is_vector, _("Array length must not be negative")); } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { array = lookup_array_range_type (type, n1, n2); if (is_vector) make_vector_type (array); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH return tyscm_scm_from_type (array); } @@ -773,13 +789,16 @@ gdbscm_type_pointer (SCM self) type_smob *t_smob = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); struct type *type = t_smob->type; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { type = lookup_pointer_type (type); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH return tyscm_scm_from_type (type); } @@ -832,13 +851,16 @@ gdbscm_type_reference (SCM self) type_smob *t_smob = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); struct type *type = t_smob->type; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { type = lookup_reference_type (type); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH return tyscm_scm_from_type (type); } @@ -867,13 +889,16 @@ gdbscm_type_const (SCM self) type_smob *t_smob = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); struct type *type = t_smob->type; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { type = make_cv_type (1, 0, type, NULL); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH return tyscm_scm_from_type (type); } @@ -887,13 +912,16 @@ gdbscm_type_volatile (SCM self) type_smob *t_smob = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); struct type *type = t_smob->type; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { type = make_cv_type (0, 1, type, NULL); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH return tyscm_scm_from_type (type); } @@ -907,13 +935,16 @@ gdbscm_type_unqualified (SCM self) type_smob *t_smob = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); struct type *type = t_smob->type; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { type = make_cv_type (0, 0, type, NULL); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH return tyscm_scm_from_type (type); } @@ -1212,9 +1243,8 @@ static struct type * tyscm_lookup_typename (const char *type_name, const struct block *block) { struct type *type = NULL; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (startswith (type_name, "struct ")) type = lookup_struct (type_name + 7, NULL); @@ -1226,8 +1256,11 @@ tyscm_lookup_typename (const char *type_name, const struct block *block) type = lookup_typename (current_language, get_current_arch (), type_name, block, 0); } - if (except.reason < 0) - return NULL; + CATCH (except, RETURN_MASK_ALL) + { + return NULL; + } + END_CATCH return type; } diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c index cacc55c..b10460d 100644 --- a/gdb/guile/scm-value.c +++ b/gdb/guile/scm-value.c @@ -143,7 +143,6 @@ vlscm_print_value_smob (SCM self, SCM port, scm_print_state *pstate) value_smob *v_smob = (value_smob *) SCM_SMOB_DATA (self); char *s = NULL; struct value_print_options opts; - volatile struct gdb_exception except; if (pstate->writingp) gdbscm_printf (port, "#<%s ", value_smob_name); @@ -157,7 +156,7 @@ vlscm_print_value_smob (SCM self, SCM port, scm_print_state *pstate) instead of writingp. */ opts.raw = !!pstate->writingp; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct ui_file *stb = mem_fileopen (); struct cleanup *old_chain = make_cleanup_ui_file_delete (stb); @@ -167,7 +166,11 @@ vlscm_print_value_smob (SCM self, SCM port, scm_print_state *pstate) do_cleanups (old_chain); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH if (s != NULL) { @@ -192,13 +195,16 @@ vlscm_equal_p_value_smob (SCM v1, SCM v2) const value_smob *v1_smob = (value_smob *) SCM_SMOB_DATA (v1); const value_smob *v2_smob = (value_smob *) SCM_SMOB_DATA (v2); int result = 0; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { result = value_equal (v1_smob->value, v2_smob->value); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH return scm_from_bool (result); } @@ -360,7 +366,6 @@ gdbscm_make_lazy_value (SCM type_scm, SCM address_scm) struct value *value = NULL; SCM result; struct cleanup *cleanups; - volatile struct gdb_exception except; t_smob = tyscm_get_type_smob_arg_unsafe (type_scm, SCM_ARG1, FUNC_NAME); type = tyscm_type_smob_type (t_smob); @@ -372,11 +377,15 @@ gdbscm_make_lazy_value (SCM type_scm, SCM address_scm) /* There's no (current) need to wrap this in a TRY_CATCH, but for consistency and future-proofing we do. */ - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { value = value_from_contents_and_address (type, NULL, address); } - GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups); + } + END_CATCH result = vlscm_scm_from_value (value); @@ -396,13 +405,16 @@ gdbscm_value_optimized_out_p (SCM self) = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); struct value *value = v_smob->value; int opt = 0; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { opt = value_optimized_out (value); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH return scm_from_bool (opt); } @@ -423,15 +435,18 @@ gdbscm_value_address (SCM self) struct cleanup *cleanup = make_cleanup_value_free_to_mark (value_mark ()); SCM address; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { res_val = value_addr (value); } - if (except.reason < 0) - address = SCM_BOOL_F; - else + CATCH (except, RETURN_MASK_ALL) + { + address = SCM_BOOL_F; + } + END_CATCH + + if (res_val != NULL) address = vlscm_scm_from_value (res_val); do_cleanups (cleanup); @@ -457,15 +472,18 @@ gdbscm_value_dereference (SCM self) SCM result; struct value *res_val = NULL; struct cleanup *cleanups; - volatile struct gdb_exception except; cleanups = make_cleanup_value_free_to_mark (value_mark ()); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { res_val = value_ind (value); } - GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups); + } + END_CATCH result = vlscm_scm_from_value (res_val); @@ -495,11 +513,10 @@ gdbscm_value_referenced_value (SCM self) SCM result; struct value *res_val = NULL; struct cleanup *cleanups; - volatile struct gdb_exception except; cleanups = make_cleanup_value_free_to_mark (value_mark ()); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { switch (TYPE_CODE (check_typedef (value_type (value)))) { @@ -514,7 +531,11 @@ gdbscm_value_referenced_value (SCM self) " neither a pointer nor a reference")); } } - GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups); + } + END_CATCH result = vlscm_scm_from_value (res_val); @@ -550,12 +571,11 @@ gdbscm_value_dynamic_type (SCM self) = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); struct value *value = v_smob->value; struct type *type = NULL; - volatile struct gdb_exception except; if (! SCM_UNBNDP (v_smob->type)) return v_smob->dynamic_type; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct cleanup *cleanup = make_cleanup_value_free_to_mark (value_mark ()); @@ -594,7 +614,11 @@ gdbscm_value_dynamic_type (SCM self) do_cleanups (cleanup); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH if (type == NULL) v_smob->dynamic_type = gdbscm_value_type (self); @@ -619,11 +643,10 @@ vlscm_do_cast (SCM self, SCM type_scm, enum exp_opcode op, SCM result; struct value *res_val = NULL; struct cleanup *cleanups; - volatile struct gdb_exception except; cleanups = make_cleanup_value_free_to_mark (value_mark ()); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (op == UNOP_DYNAMIC_CAST) res_val = value_dynamic_cast (type, value); @@ -635,7 +658,11 @@ vlscm_do_cast (SCM self, SCM type_scm, enum exp_opcode op, res_val = value_cast (type, value); } } - GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups); + } + END_CATCH gdb_assert (res_val != NULL); result = vlscm_scm_from_value (res_val); @@ -686,7 +713,6 @@ gdbscm_value_field (SCM self, SCM field_scm) struct value *res_val = NULL; SCM result; struct cleanup *cleanups; - volatile struct gdb_exception except; SCM_ASSERT_TYPE (scm_is_string (field_scm), field_scm, SCM_ARG2, FUNC_NAME, _("string")); @@ -696,13 +722,17 @@ gdbscm_value_field (SCM self, SCM field_scm) field = gdbscm_scm_to_c_string (field_scm); make_cleanup (xfree, field); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct value *tmp = value; res_val = value_struct_elt (&tmp, NULL, field, NULL, NULL); } - GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups); + } + END_CATCH gdb_assert (res_val != NULL); result = vlscm_scm_from_value (res_val); @@ -730,7 +760,6 @@ gdbscm_value_subscript (SCM self, SCM index_scm) struct gdbarch *gdbarch; SCM result, except_scm; struct cleanup *cleanups; - volatile struct gdb_exception except; /* The sequencing here, as everywhere else, is important. We can't have existing cleanups when a Scheme exception is thrown. */ @@ -749,7 +778,7 @@ gdbscm_value_subscript (SCM self, SCM index_scm) gdbscm_throw (except_scm); } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct value *tmp = value; @@ -765,7 +794,11 @@ gdbscm_value_subscript (SCM self, SCM index_scm) res_val = value_subscript (tmp, value_as_long (index)); } - GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups); + } + END_CATCH gdb_assert (res_val != NULL); result = vlscm_scm_from_value (res_val); @@ -792,13 +825,16 @@ gdbscm_value_call (SCM self, SCM args) long args_count; struct value **vargs = NULL; SCM result = SCM_BOOL_F; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { ftype = check_typedef (value_type (function)); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH SCM_ASSERT_TYPE (TYPE_CODE (ftype) == TYPE_CODE_FUNC, self, SCM_ARG1, FUNC_NAME, @@ -832,7 +868,7 @@ gdbscm_value_call (SCM self, SCM args) gdb_assert (gdbscm_is_true (scm_null_p (args))); } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct cleanup *cleanup = make_cleanup_value_free_to_mark (mark); struct value *return_value; @@ -841,7 +877,11 @@ gdbscm_value_call (SCM self, SCM args) result = vlscm_scm_from_value (return_value); do_cleanups (cleanup); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH if (gdbscm_is_exception (result)) gdbscm_throw (result); @@ -861,17 +901,20 @@ gdbscm_value_to_bytevector (SCM self) size_t length = 0; const gdb_byte *contents = NULL; SCM bv; - volatile struct gdb_exception except; type = value_type (value); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { CHECK_TYPEDEF (type); length = TYPE_LENGTH (type); contents = value_contents (value); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH bv = scm_c_make_bytevector (length); memcpy (SCM_BYTEVECTOR_CONTENTS (bv), contents, length); @@ -902,27 +945,34 @@ gdbscm_value_to_bool (SCM self) struct value *value = v_smob->value; struct type *type; LONGEST l = 0; - volatile struct gdb_exception except; type = value_type (value); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { CHECK_TYPEDEF (type); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH SCM_ASSERT_TYPE (is_intlike (type, 1), self, SCM_ARG1, FUNC_NAME, _("integer-like gdb value")); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (TYPE_CODE (type) == TYPE_CODE_PTR) l = value_as_address (value); else l = value_as_long (value); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH return scm_from_bool (l != 0); } @@ -938,27 +988,34 @@ gdbscm_value_to_integer (SCM self) struct value *value = v_smob->value; struct type *type; LONGEST l = 0; - volatile struct gdb_exception except; type = value_type (value); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { CHECK_TYPEDEF (type); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH SCM_ASSERT_TYPE (is_intlike (type, 1), self, SCM_ARG1, FUNC_NAME, _("integer-like gdb value")); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (TYPE_CODE (type) == TYPE_CODE_PTR) l = value_as_address (value); else l = value_as_long (value); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH if (TYPE_UNSIGNED (type)) return gdbscm_scm_from_ulongest (l); @@ -977,24 +1034,31 @@ gdbscm_value_to_real (SCM self) struct value *value = v_smob->value; struct type *type; DOUBLEST d = 0; - volatile struct gdb_exception except; type = value_type (value); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { CHECK_TYPEDEF (type); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH SCM_ASSERT_TYPE (is_intlike (type, 0) || TYPE_CODE (type) == TYPE_CODE_FLT, self, SCM_ARG1, FUNC_NAME, _("number")); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { d = value_as_double (value); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH /* TODO: Is there a better way to check if the value fits? */ if (d != (double) d) @@ -1045,7 +1109,6 @@ gdbscm_value_to_string (SCM self, SCM rest) struct type *char_type = NULL; SCM result; struct cleanup *cleanups; - volatile struct gdb_exception except; /* The sequencing here, as everywhere else, is important. We can't have existing cleanups when a Scheme exception is thrown. */ @@ -1081,11 +1144,15 @@ gdbscm_value_to_string (SCM self, SCM rest) /* We don't assume anything about the result of scm_port_conversion_strategy. From this point on, if errors is not 'errors, use 'substitute. */ - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { LA_GET_STRING (value, &buffer, &length, &char_type, &la_encoding); } - GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups); + } + END_CATCH /* If errors is "error" scm_from_stringn may throw a Scheme exception. Make sure we don't leak. This is done via scm_dynwind_begin, et.al. */ @@ -1131,7 +1198,7 @@ gdbscm_value_to_lazy_string (SCM self, SCM rest) int length = -1; SCM result = SCM_BOOL_F; /* -Wall */ struct cleanup *cleanups; - volatile struct gdb_exception except; + struct gdb_exception except = exception_none; /* The sequencing here, as everywhere else, is important. We can't have existing cleanups when a Scheme exception is thrown. */ @@ -1142,7 +1209,7 @@ gdbscm_value_to_lazy_string (SCM self, SCM rest) cleanups = make_cleanup (xfree, encoding); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct cleanup *inner_cleanup = make_cleanup_value_free_to_mark (value_mark ()); @@ -1155,6 +1222,12 @@ gdbscm_value_to_lazy_string (SCM self, SCM rest) do_cleanups (inner_cleanup); } + CATCH (ex, RETURN_MASK_ALL) + { + except = ex; + } + END_CATCH + do_cleanups (cleanups); GDBSCM_HANDLE_GDB_EXCEPTION (except); @@ -1184,14 +1257,17 @@ gdbscm_value_fetch_lazy_x (SCM self) value_smob *v_smob = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); struct value *value = v_smob->value; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (value_lazy (value)) value_fetch_lazy (value); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH return SCM_UNSPECIFIED; } @@ -1207,12 +1283,11 @@ gdbscm_value_print (SCM self) struct value_print_options opts; char *s = NULL; SCM result; - volatile struct gdb_exception except; get_user_print_options (&opts); opts.deref_ref = 0; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct ui_file *stb = mem_fileopen (); struct cleanup *old_chain = make_cleanup_ui_file_delete (stb); @@ -1222,7 +1297,11 @@ gdbscm_value_print (SCM self) do_cleanups (old_chain); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH /* Use SCM_FAILED_CONVERSION_QUESTION_MARK to ensure this doesn't throw an error if the encoding fails. @@ -1246,7 +1325,6 @@ gdbscm_parse_and_eval (SCM expr_scm) struct value *res_val = NULL; SCM result; struct cleanup *cleanups; - volatile struct gdb_exception except; /* The sequencing here, as everywhere else, is important. We can't have existing cleanups when a Scheme exception is thrown. */ @@ -1257,11 +1335,15 @@ gdbscm_parse_and_eval (SCM expr_scm) cleanups = make_cleanup_value_free_to_mark (value_mark ()); make_cleanup (xfree, expr_str); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { res_val = parse_and_eval (expr_str); } - GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups); + } + END_CATCH gdb_assert (res_val != NULL); result = vlscm_scm_from_value (res_val); @@ -1282,15 +1364,18 @@ gdbscm_history_ref (SCM index) { int i; struct value *res_val = NULL; /* Initialize to appease gcc warning. */ - volatile struct gdb_exception except; gdbscm_parse_function_args (FUNC_NAME, SCM_ARG1, NULL, "i", index, &i); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { res_val = access_value_history (i); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH return vlscm_scm_from_value (res_val); } @@ -1304,16 +1389,19 @@ gdbscm_history_append_x (SCM value) int res_index = -1; struct value *v; value_smob *v_smob; - volatile struct gdb_exception except; v_smob = vlscm_get_value_smob_arg_unsafe (value, SCM_ARG1, FUNC_NAME); v = v_smob->value; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { res_index = record_latest_value (v); } - GDBSCM_HANDLE_GDB_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDBSCM_HANDLE_GDB_EXCEPTION (except); + } + END_CATCH return scm_from_int (res_index); } diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index d15d05a..4d97915 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -2049,7 +2049,6 @@ i386_frame_cache_1 (struct frame_info *this_frame, static struct i386_frame_cache * i386_frame_cache (struct frame_info *this_frame, void **this_cache) { - volatile struct gdb_exception ex; struct i386_frame_cache *cache; if (*this_cache) @@ -2058,15 +2057,16 @@ i386_frame_cache (struct frame_info *this_frame, void **this_cache) cache = i386_alloc_frame_cache (); *this_cache = cache; - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { i386_frame_cache_1 (this_frame, cache); } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ERROR) { if (ex.error != NOT_AVAILABLE_ERROR) throw_exception (ex); } + END_CATCH return cache; } @@ -2216,7 +2216,6 @@ i386_epilogue_frame_sniffer (const struct frame_unwind *self, static struct i386_frame_cache * i386_epilogue_frame_cache (struct frame_info *this_frame, void **this_cache) { - volatile struct gdb_exception ex; struct i386_frame_cache *cache; CORE_ADDR sp; @@ -2226,7 +2225,7 @@ i386_epilogue_frame_cache (struct frame_info *this_frame, void **this_cache) cache = i386_alloc_frame_cache (); *this_cache = cache; - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { cache->pc = get_frame_func (this_frame); @@ -2240,11 +2239,12 @@ i386_epilogue_frame_cache (struct frame_info *this_frame, void **this_cache) cache->base_p = 1; } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ERROR) { if (ex.error != NOT_AVAILABLE_ERROR) throw_exception (ex); } + END_CATCH return cache; } @@ -2402,7 +2402,6 @@ i386_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache) struct gdbarch *gdbarch = get_frame_arch (this_frame); struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - volatile struct gdb_exception ex; struct i386_frame_cache *cache; CORE_ADDR addr; gdb_byte buf[4]; @@ -2412,7 +2411,7 @@ i386_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache) cache = i386_alloc_frame_cache (); - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { get_frame_register (this_frame, I386_ESP_REGNUM, buf); cache->base = extract_unsigned_integer (buf, 4, byte_order) - 4; @@ -2436,11 +2435,12 @@ i386_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache) cache->base_p = 1; } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ERROR) { if (ex.error != NOT_AVAILABLE_ERROR) throw_exception (ex); } + END_CATCH *this_cache = cache; return cache; diff --git a/gdb/inf-loop.c b/gdb/inf-loop.c index adeb659..429cd73 100644 --- a/gdb/inf-loop.c +++ b/gdb/inf-loop.c @@ -50,13 +50,12 @@ inferior_event_handler (enum inferior_event_type event_type, error status. If an error occurs while getting an event from the target, just cancel the current command. */ { - volatile struct gdb_exception ex; - TRY_CATCH (ex, RETURN_MASK_ALL) + TRY { fetch_inferior_event (client_data); } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ALL) { bpstat_clear_actions (); do_all_intermediate_continuations (1); @@ -64,6 +63,7 @@ inferior_event_handler (enum inferior_event_type event_type, throw_exception (ex); } + END_CATCH } break; @@ -111,18 +111,21 @@ inferior_event_handler (enum inferior_event_type event_type, are only run when the command list is all done. */ if (interpreter_async) { - volatile struct gdb_exception e; check_frame_language_change (); /* Don't propagate breakpoint commands errors. Either we're stopping or some command resumes the inferior. The user will be informed. */ - TRY_CATCH (e, RETURN_MASK_ALL) + TRY { bpstat_do_actions (); } - exception_print (gdb_stderr, e); + CATCH (e, RETURN_MASK_ALL) + { + exception_print (gdb_stderr, e); + } + END_CATCH } break; diff --git a/gdb/infcall.c b/gdb/infcall.c index 350572b..705e377 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -383,7 +383,7 @@ get_function_name (CORE_ADDR funaddr, char *buf, int buf_size) static struct gdb_exception run_inferior_call (struct thread_info *call_thread, CORE_ADDR real_pc) { - volatile struct gdb_exception e; + struct gdb_exception caught_error = exception_none; int saved_in_infcall = call_thread->control.in_infcall; ptid_t call_thread_ptid = call_thread->ptid; int saved_sync_execution = sync_execution; @@ -401,7 +401,7 @@ run_inferior_call (struct thread_info *call_thread, CORE_ADDR real_pc) /* We want stop_registers, please... */ call_thread->control.proceed_to_finish = 1; - TRY_CATCH (e, RETURN_MASK_ALL) + TRY { int was_sync = sync_execution; @@ -423,6 +423,11 @@ run_inferior_call (struct thread_info *call_thread, CORE_ADDR real_pc) async_disable_stdin (); } } + CATCH (e, RETURN_MASK_ALL) + { + caught_error = e; + } + END_CATCH /* At this point the current thread may have changed. Refresh CALL_THREAD as it could be invalid if its thread has exited. */ @@ -435,7 +440,7 @@ run_inferior_call (struct thread_info *call_thread, CORE_ADDR real_pc) If all error()s out of proceed ended up calling normal_stop (and perhaps they should; it already does in the special case of error out of resume()), then we wouldn't need this. */ - if (e.reason < 0) + if (caught_error.reason < 0) { if (call_thread != NULL) breakpoint_auto_delete (call_thread->control.stop_bpstat); @@ -446,7 +451,7 @@ run_inferior_call (struct thread_info *call_thread, CORE_ADDR real_pc) sync_execution = saved_sync_execution; - return e; + return caught_error; } /* A cleanup function that calls delete_std_terminate_breakpoint. */ diff --git a/gdb/infcmd.c b/gdb/infcmd.c index e92b777..0211b5d 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -411,7 +411,6 @@ strip_bg_char (const char *args, int *bg_char_p) void post_create_inferior (struct target_ops *target, int from_tty) { - volatile struct gdb_exception ex; /* Be sure we own the terminal in case write operations are performed. */ target_terminal_ours (); @@ -426,15 +425,16 @@ post_create_inferior (struct target_ops *target, int from_tty) if the PC is unavailable (e.g., we're opening a core file with missing registers info), ignore it. */ stop_pc = 0; - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { stop_pc = regcache_read_pc (get_current_regcache ()); } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ERROR) { if (ex.error != NOT_AVAILABLE_ERROR) throw_exception (ex); } + END_CATCH if (exec_bfd) { @@ -1669,19 +1669,21 @@ finish_command_continuation (void *arg, int err) if (TYPE_CODE (value_type) != TYPE_CODE_VOID) { - volatile struct gdb_exception ex; struct value *func; func = read_var_value (a->function, get_current_frame ()); - TRY_CATCH (ex, RETURN_MASK_ALL) + TRY { /* print_return_value can throw an exception in some circumstances. We need to catch this so that we still delete the breakpoint. */ print_return_value (func, value_type); } - if (ex.reason < 0) - exception_print (gdb_stdout, ex); + CATCH (ex, RETURN_MASK_ALL) + { + exception_print (gdb_stdout, ex); + } + END_CATCH } } diff --git a/gdb/infrun.c b/gdb/infrun.c index b8c5d8e..0f8f531 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -6030,10 +6030,7 @@ insert_exception_resume_breakpoint (struct thread_info *tp, struct frame_info *frame, struct symbol *sym) { - volatile struct gdb_exception e; - - /* We want to ignore errors here. */ - TRY_CATCH (e, RETURN_MASK_ERROR) + TRY { struct symbol *vsym; struct value *value; @@ -6062,6 +6059,11 @@ insert_exception_resume_breakpoint (struct thread_info *tp, inferior_thread ()->control.exception_resume_breakpoint = bp; } } + CATCH (e, RETURN_MASK_ERROR) + { + /* We want to ignore errors here. */ + } + END_CATCH } /* A helper for check_exception_resume that sets an @@ -6102,7 +6104,6 @@ static void check_exception_resume (struct execution_control_state *ecs, struct frame_info *frame) { - volatile struct gdb_exception e; struct bound_probe probe; struct symbol *func; @@ -6121,7 +6122,7 @@ check_exception_resume (struct execution_control_state *ecs, if (!func) return; - TRY_CATCH (e, RETURN_MASK_ERROR) + TRY { const struct block *b; struct block_iterator iter; @@ -6158,6 +6159,10 @@ check_exception_resume (struct execution_control_state *ecs, } } } + CATCH (e, RETURN_MASK_ERROR) + { + } + END_CATCH } static void @@ -6200,7 +6205,6 @@ keep_going (struct execution_control_state *ecs) } else { - volatile struct gdb_exception e; struct regcache *regcache = get_current_regcache (); int remove_bp; int remove_wps; @@ -6240,16 +6244,17 @@ keep_going (struct execution_control_state *ecs) clear_step_over_info (); /* Stop stepping if inserting breakpoints fails. */ - TRY_CATCH (e, RETURN_MASK_ERROR) + TRY { insert_breakpoints (); } - if (e.reason < 0) + CATCH (e, RETURN_MASK_ERROR) { exception_print (gdb_stderr, e); stop_waiting (ecs); return; } + END_CATCH ecs->event_thread->control.trap_expected = (remove_bp || remove_wps); @@ -816,7 +816,6 @@ jit_reader_try_read_symtab (struct jit_code_entry *code_entry, int status; jit_dbg_reader_data priv_data; struct gdb_reader_funcs *funcs; - volatile struct gdb_exception e; struct gdb_symbol_callbacks callbacks = { jit_object_open_impl, @@ -839,12 +838,17 @@ jit_reader_try_read_symtab (struct jit_code_entry *code_entry, gdb_mem = xmalloc (code_entry->symfile_size); status = 1; - TRY_CATCH (e, RETURN_MASK_ALL) - if (target_read_memory (code_entry->symfile_addr, gdb_mem, - code_entry->symfile_size)) + TRY + { + if (target_read_memory (code_entry->symfile_addr, gdb_mem, + code_entry->symfile_size)) + status = 0; + } + CATCH (e, RETURN_MASK_ALL) + { status = 0; - if (e.reason < 0) - status = 0; + } + END_CATCH if (status) { diff --git a/gdb/linespec.c b/gdb/linespec.c index 265742d..9ec4a5e 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -2260,22 +2260,22 @@ parse_linespec (linespec_parser *parser, const char **argptr) if (token.type == LSTOKEN_COLON) { char *user_filename; - volatile struct gdb_exception ex; /* Get the current token again and extract the filename. */ token = linespec_lexer_lex_one (parser); user_filename = copy_token_string (token); /* Check if the input is a filename. */ - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { PARSER_RESULT (parser)->file_symtabs = symtabs_from_filename (user_filename); } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ERROR) { file_exception = ex; } + END_CATCH if (file_exception.reason >= 0) { @@ -3106,7 +3106,6 @@ find_linespec_symbols (struct linespec_state *state, struct cleanup *cleanup; char *canon; const char *lookup_name; - volatile struct gdb_exception except; cleanup = demangle_for_lookup (name, state->language->la_language, &lookup_name); @@ -3194,7 +3193,7 @@ find_linespec_symbols (struct linespec_state *state, if (!VEC_empty (symbolp, classes)) { /* Now locate a list of suitable methods named METHOD. */ - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { find_method (state, file_symtabs, klass, method, classes, symbols, minsyms); @@ -3202,11 +3201,12 @@ find_linespec_symbols (struct linespec_state *state, /* If successful, we're done. If NOT_FOUND_ERROR was not thrown, rethrow the exception that we did get. */ - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { if (except.error != NOT_FOUND_ERROR) throw_exception (except); } + END_CATCH } } diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 627280e..22ce842 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -1202,16 +1202,15 @@ linux_nat_attach (struct target_ops *ops, const char *args, int from_tty) struct lwp_info *lp; int status; ptid_t ptid; - volatile struct gdb_exception ex; /* Make sure we report all signals during attach. */ linux_nat_pass_signals (ops, 0, NULL); - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { linux_ops->to_attach (ops, args, from_tty); } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ERROR) { pid_t pid = parse_pid_to_attach (args); struct buffer buffer; @@ -1232,6 +1231,7 @@ linux_nat_attach (struct target_ops *ops, const char *args, int from_tty) else throw_error (ex.error, "%s", message); } + END_CATCH /* The ptrace base target adds the main thread with (pid,0,0) format. Decorate it with lwp info. */ diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index d9884f3..ea0d4cd 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -1545,7 +1545,6 @@ linux_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size) char *note_data = NULL; gdb_byte *auxv; int auxv_len; - volatile struct gdb_exception e; if (! gdbarch_iterate_over_regset_sections_p (gdbarch)) return NULL; @@ -1572,12 +1571,16 @@ linux_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size) } /* Thread register information. */ - TRY_CATCH (e, RETURN_MASK_ERROR) + TRY { update_thread_list (); } - if (e.reason < 0) - exception_print (gdb_stderr, e); + CATCH (e, RETURN_MASK_ERROR) + { + exception_print (gdb_stderr, e); + } + END_CATCH + thread_args.gdbarch = gdbarch; thread_args.pid = ptid_get_pid (inferior_ptid); thread_args.obfd = obfd; diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index f7f0d38..0669750 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -611,14 +611,13 @@ enable_thread_event_reporting (void) static int thread_db_find_new_threads_silently (ptid_t ptid) { - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { thread_db_find_new_threads_2 (ptid, 1); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { if (libthread_db_debug) exception_fprintf (gdb_stdlog, except, @@ -648,6 +647,8 @@ thread_db_find_new_threads_silently (ptid_t ptid) return 1; } } + END_CATCH + return 0; } @@ -1681,7 +1682,6 @@ static int find_new_threads_once (struct thread_db_info *info, int iteration, td_err_e *errp) { - volatile struct gdb_exception except; struct callback_data data; td_err_e err = TD_ERR; @@ -1691,7 +1691,7 @@ find_new_threads_once (struct thread_db_info *info, int iteration, /* See comment in thread_db_update_thread_list. */ gdb_assert (!target_has_execution || thread_db_use_events ()); - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { /* Iterate over all user-space threads to discover new threads. */ err = info->td_ta_thr_iter_p (info->thread_agent, @@ -1705,9 +1705,12 @@ find_new_threads_once (struct thread_db_info *info, int iteration, if (libthread_db_debug) { - if (except.reason < 0) - exception_fprintf (gdb_stdlog, except, - "Warning: find_new_threads_once: "); + CATCH (except, RETURN_MASK_ERROR) + { + exception_fprintf (gdb_stdlog, except, + "Warning: find_new_threads_once: "); + } + END_CATCH fprintf_unfiltered (gdb_stdlog, _("Found %d new threads in iteration %d.\n"), @@ -364,9 +364,7 @@ static int catch_command_errors (catch_command_errors_ftype *command, char *arg, int from_tty) { - volatile struct gdb_exception e; - - TRY_CATCH (e, RETURN_MASK_ALL) + TRY { int was_sync = sync_execution; @@ -374,7 +372,13 @@ catch_command_errors (catch_command_errors_ftype *command, maybe_wait_sync_command_done (was_sync); } - return handle_command_errors (e); + CATCH (e, RETURN_MASK_ALL) + { + return handle_command_errors (e); + } + END_CATCH + + return 1; } /* Type of the command callback passed to catch_command_errors_const. */ @@ -387,9 +391,7 @@ static int catch_command_errors_const (catch_command_errors_const_ftype *command, const char *arg, int from_tty) { - volatile struct gdb_exception e; - - TRY_CATCH (e, RETURN_MASK_ALL) + TRY { int was_sync = sync_execution; @@ -397,7 +399,13 @@ catch_command_errors_const (catch_command_errors_const_ftype *command, maybe_wait_sync_command_done (was_sync); } - return handle_command_errors (e); + CATCH (e, RETURN_MASK_ALL) + { + return handle_command_errors (e); + } + END_CATCH + + return 1; } /* Type of this option. */ diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index 18a357e..1b863eb 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -537,15 +537,13 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what, if (arg->val || arg->error) { - volatile struct gdb_exception except; + const char *error_message = NULL; if (arg->error) - except.message = arg->error; + error_message = arg->error; else { - /* TRY_CATCH has two statements, wrap it in a block. */ - - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { struct value_print_options opts; @@ -554,10 +552,15 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what, common_val_print (arg->val, stb, 0, &opts, language_def (SYMBOL_LANGUAGE (arg->sym))); } + CATCH (except, RETURN_MASK_ERROR) + { + error_message = except.message; + } + END_CATCH } - if (except.message) + if (error_message != NULL) fprintf_filtered (stb, _("<error reading variable: %s>"), - except.message); + error_message); ui_out_field_stream (uiout, "value", stb); } diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index f10b0bb..99ce385 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -808,7 +808,6 @@ mi_breakpoint_created (struct breakpoint *b) { struct mi_interp *mi = top_level_interpreter_data (); struct ui_out *mi_uiout = interp_ui_out (top_level_interpreter ()); - volatile struct gdb_exception e; if (mi_suppress_notification.breakpoint) return; @@ -827,8 +826,15 @@ mi_breakpoint_created (struct breakpoint *b) breakpoint_created notifications. So, we use ui_out_redirect. */ ui_out_redirect (mi_uiout, mi->event_channel); - TRY_CATCH (e, RETURN_MASK_ERROR) - gdb_breakpoint_query (mi_uiout, b->number, NULL); + TRY + { + gdb_breakpoint_query (mi_uiout, b->number, NULL); + } + CATCH (e, RETURN_MASK_ERROR) + { + } + END_CATCH + ui_out_redirect (mi_uiout, NULL); gdb_flush (mi->event_channel); @@ -862,7 +868,6 @@ mi_breakpoint_modified (struct breakpoint *b) { struct mi_interp *mi = top_level_interpreter_data (); struct ui_out *mi_uiout = interp_ui_out (top_level_interpreter ()); - volatile struct gdb_exception e; if (mi_suppress_notification.breakpoint) return; @@ -881,8 +886,15 @@ mi_breakpoint_modified (struct breakpoint *b) breakpoint_created notifications. So, we use ui_out_redirect. */ ui_out_redirect (mi_uiout, mi->event_channel); - TRY_CATCH (e, RETURN_MASK_ERROR) - gdb_breakpoint_query (mi_uiout, b->number, NULL); + TRY + { + gdb_breakpoint_query (mi_uiout, b->number, NULL); + } + CATCH (e, RETURN_MASK_ERROR) + { + } + END_CATCH + ui_out_redirect (mi_uiout, NULL); gdb_flush (mi->event_channel); diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 7412f7d..acbdb55 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -2080,7 +2080,6 @@ mi_execute_command (const char *cmd, int from_tty) { char *token; struct mi_parse *command = NULL; - volatile struct gdb_exception exception; /* This is to handle EOF (^D). We just quit gdb. */ /* FIXME: we should call some API function here. */ @@ -2089,18 +2088,19 @@ mi_execute_command (const char *cmd, int from_tty) target_log_command (cmd); - TRY_CATCH (exception, RETURN_MASK_ALL) + TRY { command = mi_parse (cmd, &token); } - if (exception.reason < 0) + CATCH (exception, RETURN_MASK_ALL) { mi_print_exception (token, exception); xfree (token); } - else + END_CATCH + + if (command != NULL) { - volatile struct gdb_exception result; ptid_t previous_ptid = inferior_ptid; command->token = token; @@ -2112,17 +2112,18 @@ mi_execute_command (const char *cmd, int from_tty) timestamp (command->cmd_start); } - TRY_CATCH (result, RETURN_MASK_ALL) + TRY { captured_mi_execute_command (current_uiout, command); } - if (result.reason < 0) + CATCH (result, RETURN_MASK_ALL) { /* The command execution failed and error() was called somewhere. */ mi_print_exception (command->token, result); mi_out_rewind (current_uiout); } + END_CATCH bpstat_do_actions (); diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index 043f98b..a66ff44 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -725,7 +725,6 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr, const char *basename = type_name_no_tag (baseclass); const gdb_byte *base_valaddr = NULL; int thisoffset; - volatile struct gdb_exception ex; int skip = 0; if (BASETYPE_VIA_VIRTUAL (type, i)) @@ -745,17 +744,18 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr, thisoffset = offset; - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { boffset = baseclass_offset (type, i, valaddr, offset, address, val); } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ERROR) { if (ex.error == NOT_AVAILABLE_ERROR) skip = -1; else skip = 1; } + END_CATCH if (skip == 0) { diff --git a/gdb/parse.c b/gdb/parse.c index 09fb0b3..ec23dbb 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -1133,7 +1133,6 @@ parse_exp_in_context_1 (const char **stringptr, CORE_ADDR pc, const struct block *block, int comma, int void_context_p, int *out_subexp) { - volatile struct gdb_exception except; struct cleanup *old_chain, *inner_chain; const struct language_defn *lang = NULL; struct parser_state ps; @@ -1215,12 +1214,12 @@ parse_exp_in_context_1 (const char **stringptr, CORE_ADDR pc, inner_chain = make_cleanup_restore_current_language (); set_language (lang->la_language); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (lang->la_parser (&ps)) lang->la_error (NULL); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { if (! parse_completion) { @@ -1228,6 +1227,7 @@ parse_exp_in_context_1 (const char **stringptr, CORE_ADDR pc, throw_exception (except); } } + END_CATCH reallocate_expout (&ps); @@ -1283,17 +1283,17 @@ parse_expression_for_completion (const char *string, char **name, struct expression *exp = NULL; struct value *val; int subexp; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { parse_completion = 1; exp = parse_exp_in_context (&string, 0, 0, 0, 0, &subexp); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { /* Nothing, EXP remains NULL. */ } + END_CATCH parse_completion = 0; if (exp == NULL) diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c index 6c6eacf..3afbff2 100644 --- a/gdb/ppc-linux-tdep.c +++ b/gdb/ppc-linux-tdep.c @@ -1231,9 +1231,8 @@ ppc_linux_spe_context (int wordsize, enum bfd_endian byte_order, if (!ptid_equal (spe_context_cache_ptid, inferior_ptid)) { struct target_ops *target = ¤t_target; - volatile struct gdb_exception ex; - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { /* We do not call target_translate_tls_address here, because svr4_fetch_objfile_link_map may invalidate the frame chain, @@ -1248,8 +1247,11 @@ ppc_linux_spe_context (int wordsize, enum bfd_endian byte_order, spe_context_cache_ptid = inferior_ptid; } - if (ex.reason < 0) - return 0; + CATCH (ex, RETURN_MASK_ERROR) + { + return 0; + } + END_CATCH } /* Read variable value. */ diff --git a/gdb/printcmd.c b/gdb/printcmd.c index cdbed30..05c68a0 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1692,15 +1692,14 @@ do_one_display (struct display *d) if (d->exp == NULL) { - volatile struct gdb_exception ex; - TRY_CATCH (ex, RETURN_MASK_ALL) + TRY { innermost_block = NULL; d->exp = parse_expression (d->exp_string); d->block = innermost_block; } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ALL) { /* Can't re-parse the expression. Disable this display item. */ d->enabled_p = 0; @@ -1708,6 +1707,7 @@ do_one_display (struct display *d) d->exp_string, ex.message); return; } + END_CATCH } if (d->block) @@ -1731,7 +1731,6 @@ do_one_display (struct display *d) printf_filtered (": "); if (d->format.size) { - volatile struct gdb_exception ex; annotate_display_format (); @@ -1755,7 +1754,7 @@ do_one_display (struct display *d) annotate_display_value (); - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { struct value *val; CORE_ADDR addr; @@ -1766,13 +1765,15 @@ do_one_display (struct display *d) addr = gdbarch_addr_bits_remove (d->exp->gdbarch, addr); do_examine (d->format, d->exp->gdbarch, addr); } - if (ex.reason < 0) - fprintf_filtered (gdb_stdout, _("<error: %s>\n"), ex.message); + CATCH (ex, RETURN_MASK_ERROR) + { + fprintf_filtered (gdb_stdout, _("<error: %s>\n"), ex.message); + } + END_CATCH } else { struct value_print_options opts; - volatile struct gdb_exception ex; annotate_display_format (); @@ -1791,15 +1792,19 @@ do_one_display (struct display *d) get_formatted_print_options (&opts, d->format.format); opts.raw = d->format.raw; - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { struct value *val; val = evaluate_expression (d->exp); print_formatted (val, d->format.size, &opts, gdb_stdout); } - if (ex.reason < 0) - fprintf_filtered (gdb_stdout, _("<error: %s>"), ex.message); + CATCH (ex, RETURN_MASK_ERROR) + { + fprintf_filtered (gdb_stdout, _("<error: %s>"), ex.message); + } + END_CATCH + printf_filtered ("\n"); } @@ -1975,13 +1980,12 @@ print_variable_and_value (const char *name, struct symbol *var, struct frame_info *frame, struct ui_file *stream, int indent) { - volatile struct gdb_exception except; if (!name) name = SYMBOL_PRINT_NAME (var); fprintf_filtered (stream, "%s%s = ", n_spaces (2 * indent), name); - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { struct value *val; struct value_print_options opts; @@ -1995,9 +1999,13 @@ print_variable_and_value (const char *name, struct symbol *var, function. */ frame = NULL; } - if (except.reason < 0) - fprintf_filtered(stream, "<error reading variable %s (%s)>", name, - except.message); + CATCH (except, RETURN_MASK_ERROR) + { + fprintf_filtered(stream, "<error reading variable %s (%s)>", name, + except.message); + } + END_CATCH + fprintf_filtered (stream, "\n"); } diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c index 49c654b..4fece39 100644 --- a/gdb/python/py-arch.c +++ b/gdb/python/py-arch.c @@ -199,7 +199,6 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw) char *as = NULL; struct ui_file *memfile = mem_fileopen (); PyObject *insn_dict = PyDict_New (); - volatile struct gdb_exception except; if (insn_dict == NULL) { @@ -217,11 +216,11 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw) return NULL; /* PyList_Append Sets the exception. */ } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { insn_len = gdb_print_insn (gdbarch, pc, memfile, NULL); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { Py_DECREF (result_list); ui_file_delete (memfile); @@ -229,6 +228,7 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw) gdbpy_convert_exception (except); return NULL; } + END_CATCH as = ui_file_xstrdup (memfile, NULL); if (PyDict_SetItemString (insn_dict, "addr", diff --git a/gdb/python/py-block.c b/gdb/python/py-block.c index fb6a6b6..6c0f5cb 100644 --- a/gdb/python/py-block.c +++ b/gdb/python/py-block.c @@ -373,19 +373,22 @@ gdbpy_block_for_pc (PyObject *self, PyObject *args) gdb_py_ulongest pc; const struct block *block = NULL; struct compunit_symtab *cust = NULL; - volatile struct gdb_exception except; if (!PyArg_ParseTuple (args, GDB_PY_LLU_ARG, &pc)) return NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { cust = find_pc_compunit_symtab (pc); if (cust != NULL && COMPUNIT_OBJFILE (cust) != NULL) block = block_for_pc (pc); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (cust == NULL || COMPUNIT_OBJFILE (cust) == NULL) { diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c index 7807e4e..dcf1d5a 100644 --- a/gdb/python/py-breakpoint.c +++ b/gdb/python/py-breakpoint.c @@ -114,7 +114,6 @@ bppy_set_enabled (PyObject *self, PyObject *newvalue, void *closure) { gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self; int cmp; - volatile struct gdb_exception except; BPPY_SET_REQUIRE_VALID (self_bp); @@ -136,14 +135,18 @@ bppy_set_enabled (PyObject *self, PyObject *newvalue, void *closure) if (cmp < 0) return -1; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (cmp == 1) enable_breakpoint (self_bp->bp); else disable_breakpoint (self_bp->bp); } - GDB_PY_SET_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_SET_HANDLE_EXCEPTION (except); + } + END_CATCH return 0; } @@ -227,7 +230,6 @@ bppy_set_task (PyObject *self, PyObject *newvalue, void *closure) gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self; long id; int valid_id = 0; - volatile struct gdb_exception except; BPPY_SET_REQUIRE_VALID (self_bp); @@ -242,11 +244,15 @@ bppy_set_task (PyObject *self, PyObject *newvalue, void *closure) if (! gdb_py_int_as_long (newvalue, &id)) return -1; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { valid_id = valid_task_id (id); } - GDB_PY_SET_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_SET_HANDLE_EXCEPTION (except); + } + END_CATCH if (! valid_id) { @@ -278,15 +284,18 @@ static PyObject * bppy_delete_breakpoint (PyObject *self, PyObject *args) { gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self; - volatile struct gdb_exception except; BPPY_REQUIRE_VALID (self_bp); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { delete_breakpoint (self_bp->bp); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH Py_RETURN_NONE; } @@ -298,7 +307,6 @@ bppy_set_ignore_count (PyObject *self, PyObject *newvalue, void *closure) { gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self; long value; - volatile struct gdb_exception except; BPPY_SET_REQUIRE_VALID (self_bp); @@ -321,11 +329,15 @@ bppy_set_ignore_count (PyObject *self, PyObject *newvalue, void *closure) if (value < 0) value = 0; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { set_ignore_count (self_bp->number, (int) value, 0); } - GDB_PY_SET_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_SET_HANDLE_EXCEPTION (except); + } + END_CATCH return 0; } @@ -429,7 +441,7 @@ bppy_set_condition (PyObject *self, PyObject *newvalue, void *closure) { char *exp; gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self; - volatile struct gdb_exception except; + struct gdb_exception except = exception_none; BPPY_SET_REQUIRE_VALID (self_bp); @@ -448,10 +460,15 @@ bppy_set_condition (PyObject *self, PyObject *newvalue, void *closure) return -1; } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { set_breakpoint_condition (self_bp->bp, exp, 0); } + CATCH (ex, RETURN_MASK_ALL) + { + except = ex; + } + END_CATCH if (newvalue != Py_None) xfree (exp); @@ -468,7 +485,6 @@ bppy_get_commands (PyObject *self, void *closure) gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self; struct breakpoint *bp = self_bp->bp; long length; - volatile struct gdb_exception except; struct ui_file *string_file; struct cleanup *chain; PyObject *result; @@ -483,17 +499,18 @@ bppy_get_commands (PyObject *self, void *closure) chain = make_cleanup_ui_file_delete (string_file); ui_out_redirect (current_uiout, string_file); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { print_command_lines (current_uiout, breakpoint_commands (bp), 0); } ui_out_redirect (current_uiout, NULL); - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { do_cleanups (chain); gdbpy_convert_exception (except); return NULL; } + END_CATCH cmdstr = ui_file_xstrdup (string_file, &length); make_cleanup (xfree, cmdstr); @@ -619,7 +636,6 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) PyObject *temporary = NULL; int internal_bp = 0; int temporary_bp = 0; - volatile struct gdb_exception except; if (! PyArg_ParseTupleAndKeywords (args, kwargs, "s|iiOO", keywords, &spec, &type, &access_type, @@ -644,7 +660,7 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) bppy_pending_object->number = -1; bppy_pending_object->bp = NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { char *copy = xstrdup (spec); struct cleanup *cleanup = make_cleanup (xfree, copy); @@ -681,13 +697,14 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) do_cleanups (cleanup); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { PyErr_Format (except.reason == RETURN_QUIT ? PyExc_KeyboardInterrupt : PyExc_RuntimeError, "%s", except.message); return -1; } + END_CATCH BPPY_SET_REQUIRE_VALID ((gdbpy_breakpoint_object *) self); return 0; diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c index a5e96d6..1d89912 100644 --- a/gdb/python/py-cmd.c +++ b/gdb/python/py-cmd.c @@ -537,7 +537,6 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw) int cmdtype; int completetype = -1; char *docstring = NULL; - volatile struct gdb_exception except; struct cmd_list_element **cmd_list; char *cmd_name, *pfx_name; static char *keywords[] = { "name", "command_class", "completer_class", @@ -637,7 +636,7 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw) Py_INCREF (self); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct cmd_list_element *cmd; @@ -668,7 +667,7 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw) set_cmd_completer_handle_brkchars (cmd, cmdpy_completer_handle_brkchars); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { xfree (cmd_name); xfree (docstring); @@ -679,6 +678,8 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw) "%s", except.message); return -1; } + END_CATCH + return 0; } diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c index 43f6807..34e9643 100644 --- a/gdb/python/py-finishbreakpoint.c +++ b/gdb/python/py-finishbreakpoint.c @@ -93,7 +93,6 @@ bpfinishpy_pre_stop_hook (struct gdbpy_breakpoint_object *bp_obj) { struct finish_breakpoint_object *self_finishbp = (struct finish_breakpoint_object *) bp_obj; - volatile struct gdb_exception except; /* Can compute return_value only once. */ gdb_assert (!self_finishbp->return_value); @@ -101,7 +100,7 @@ bpfinishpy_pre_stop_hook (struct gdbpy_breakpoint_object *bp_obj) if (!self_finishbp->return_type) return; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct value *function = value_object_to_value (self_finishbp->function_value); @@ -121,11 +120,12 @@ bpfinishpy_pre_stop_hook (struct gdbpy_breakpoint_object *bp_obj) self_finishbp->return_value = Py_None; } } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { gdbpy_convert_exception (except); gdbpy_print_stack (); } + END_CATCH } /* Triggered when gdbpy_should_stop has triggered the `stop' callback @@ -134,19 +134,19 @@ bpfinishpy_pre_stop_hook (struct gdbpy_breakpoint_object *bp_obj) void bpfinishpy_post_stop_hook (struct gdbpy_breakpoint_object *bp_obj) { - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { /* Can't delete it here, but it will be removed at the next stop. */ disable_breakpoint (bp_obj->bp); gdb_assert (bp_obj->bp->disposition == disp_del); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { gdbpy_convert_exception (except); gdbpy_print_stack (); } + END_CATCH } /* Python function to create a new breakpoint. */ @@ -166,7 +166,6 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) PyObject *internal = NULL; int internal_bp = 0; CORE_ADDR finish_pc, pc; - volatile struct gdb_exception except; char *addr_str, small_buf[100]; struct symbol *function; @@ -174,7 +173,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) &frame_obj, &internal)) return -1; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { /* Default frame to newest frame if necessary. */ if (frame_obj == NULL) @@ -212,12 +211,14 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) } } } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { gdbpy_convert_exception (except); return -1; } - else if (PyErr_Occurred ()) + END_CATCH + + if (PyErr_Occurred ()) return -1; thread = pid_to_thread_id (inferior_ptid); @@ -243,7 +244,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) self_bpfinish->return_type = NULL; self_bpfinish->function_value = NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (get_frame_pc_if_available (frame, &pc)) { @@ -269,11 +270,12 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) } } } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { /* Just swallow. Either the return type or the function value remain NULL. */ } + END_CATCH if (self_bpfinish->return_type == NULL || self_bpfinish->function_value == NULL) { @@ -289,7 +291,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) bppy_pending_object->number = -1; bppy_pending_object->bp = NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { /* Set a breakpoint on the return address. */ finish_pc = get_frame_pc (prev_frame); @@ -306,7 +308,11 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) &bkpt_breakpoint_ops, 0, 1, internal_bp, 0); } - GDB_PY_SET_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_SET_HANDLE_EXCEPTION (except); + } + END_CATCH self_bpfinish->py_bp.bp->frame_id = frame_id; self_bpfinish->py_bp.is_finish_bp = 1; @@ -347,7 +353,6 @@ bpfinishpy_out_of_scope (struct finish_breakpoint_object *bpfinish_obj) static int bpfinishpy_detect_out_scope_cb (struct breakpoint *b, void *args) { - volatile struct gdb_exception except; struct breakpoint *bp_stopped = (struct breakpoint *) args; PyObject *py_bp = (PyObject *) b->py_bp_object; struct gdbarch *garch = b->gdbarch ? b->gdbarch : get_current_arch (); @@ -362,18 +367,19 @@ bpfinishpy_detect_out_scope_cb (struct breakpoint *b, void *args) /* Check scope if not currently stopped at the FinishBreakpoint. */ if (b != bp_stopped) { - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (b->pspace == current_inferior ()->pspace && (!target_has_registers || frame_find_by_id (b->frame_id) == NULL)) bpfinishpy_out_of_scope (finish_bp); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { gdbpy_convert_exception (except); gdbpy_print_stack (); } + END_CATCH } } diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c index 9ef8608..cd6e859 100644 --- a/gdb/python/py-frame.c +++ b/gdb/python/py-frame.c @@ -101,13 +101,16 @@ static PyObject * frapy_is_valid (PyObject *self, PyObject *args) { struct frame_info *frame = NULL; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { frame = frame_object_to_frame_info (self); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (frame == NULL) Py_RETURN_FALSE; @@ -125,19 +128,19 @@ frapy_name (PyObject *self, PyObject *args) char *name = NULL; enum language lang; PyObject *result; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { FRAPY_REQUIRE_VALID (self, frame); find_frame_funname (frame, &name, &lang, NULL); } - - if (except.reason < 0) - xfree (name); - - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + xfree (name); + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (name) { @@ -161,15 +164,18 @@ frapy_type (PyObject *self, PyObject *args) { struct frame_info *frame; enum frame_type type = NORMAL_FRAME;/* Initialize to appease gcc warning. */ - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { FRAPY_REQUIRE_VALID (self, frame); type = get_frame_type (frame); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return PyInt_FromLong (type); } @@ -182,13 +188,16 @@ frapy_arch (PyObject *self, PyObject *args) { struct frame_info *frame = NULL; /* Initialize to appease gcc warning. */ frame_object *obj = (frame_object *) self; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { FRAPY_REQUIRE_VALID (self, frame); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return gdbarch_to_arch_object (obj->gdbarch); } @@ -200,14 +209,17 @@ static PyObject * frapy_unwind_stop_reason (PyObject *self, PyObject *args) { struct frame_info *frame = NULL; /* Initialize to appease gcc warning. */ - volatile struct gdb_exception except; enum unwind_stop_reason stop_reason; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { FRAPY_REQUIRE_VALID (self, frame); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH stop_reason = get_frame_unwind_stop_reason (frame); @@ -222,15 +234,18 @@ frapy_pc (PyObject *self, PyObject *args) { CORE_ADDR pc = 0; /* Initialize to appease gcc warning. */ struct frame_info *frame; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { FRAPY_REQUIRE_VALID (self, frame); pc = get_frame_pc (frame); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return gdb_py_long_from_ulongest (pc); } @@ -241,14 +256,13 @@ frapy_pc (PyObject *self, PyObject *args) static PyObject * frapy_read_register (PyObject *self, PyObject *args) { - volatile struct gdb_exception except; const char *regnum_str; struct value *val = NULL; if (!PyArg_ParseTuple (args, "s", ®num_str)) return NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct frame_info *frame; int regnum; @@ -264,7 +278,11 @@ frapy_read_register (PyObject *self, PyObject *args) if (val == NULL) PyErr_SetString (PyExc_ValueError, _("Unknown register.")); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return val == NULL ? NULL : value_to_value_object (val); } @@ -277,14 +295,17 @@ frapy_block (PyObject *self, PyObject *args) { struct frame_info *frame; const struct block *block = NULL, *fn_block; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { FRAPY_REQUIRE_VALID (self, frame); block = get_frame_block (frame, NULL); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH for (fn_block = block; fn_block != NULL && BLOCK_FUNCTION (fn_block) == NULL; @@ -316,15 +337,18 @@ frapy_function (PyObject *self, PyObject *args) { struct symbol *sym = NULL; struct frame_info *frame; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { FRAPY_REQUIRE_VALID (self, frame); sym = find_pc_function (get_frame_address_in_block (frame)); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (sym) return symbol_to_symbol_object (sym); @@ -339,13 +363,12 @@ PyObject * frame_info_to_frame_object (struct frame_info *frame) { frame_object *frame_obj; - volatile struct gdb_exception except; frame_obj = PyObject_New (frame_object, &frame_object_type); if (frame_obj == NULL) return NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { /* Try to get the previous frame, to determine if this is the last frame @@ -365,12 +388,14 @@ frame_info_to_frame_object (struct frame_info *frame) } frame_obj->gdbarch = get_frame_arch (frame); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { Py_DECREF (frame_obj); gdbpy_convert_exception (except); return NULL; } + END_CATCH + return (PyObject *) frame_obj; } @@ -382,16 +407,19 @@ static PyObject * frapy_older (PyObject *self, PyObject *args) { struct frame_info *frame, *prev = NULL; - volatile struct gdb_exception except; PyObject *prev_obj = NULL; /* Initialize to appease gcc warning. */ - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { FRAPY_REQUIRE_VALID (self, frame); prev = get_prev_frame (frame); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (prev) prev_obj = (PyObject *) frame_info_to_frame_object (prev); @@ -412,16 +440,19 @@ static PyObject * frapy_newer (PyObject *self, PyObject *args) { struct frame_info *frame, *next = NULL; - volatile struct gdb_exception except; PyObject *next_obj = NULL; /* Initialize to appease gcc warning. */ - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { FRAPY_REQUIRE_VALID (self, frame); next = get_next_frame (frame); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (next) next_obj = (PyObject *) frame_info_to_frame_object (next); @@ -442,17 +473,20 @@ frapy_find_sal (PyObject *self, PyObject *args) { struct frame_info *frame; struct symtab_and_line sal; - volatile struct gdb_exception except; PyObject *sal_obj = NULL; /* Initialize to appease gcc warning. */ - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { FRAPY_REQUIRE_VALID (self, frame); find_frame_sal (frame, &sal); sal_obj = symtab_and_line_to_sal_object (sal); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return sal_obj; } @@ -471,7 +505,6 @@ frapy_read_var (PyObject *self, PyObject *args) PyObject *sym_obj, *block_obj = NULL; struct symbol *var = NULL; /* gcc-4.3.2 false warning. */ struct value *val = NULL; - volatile struct gdb_exception except; if (!PyArg_ParseTuple (args, "O|O", &sym_obj, &block_obj)) return NULL; @@ -483,7 +516,6 @@ frapy_read_var (PyObject *self, PyObject *args) char *var_name; const struct block *block = NULL; struct cleanup *cleanup; - volatile struct gdb_exception except; var_name = python_string_to_target_string (sym_obj); if (!var_name) @@ -502,7 +534,7 @@ frapy_read_var (PyObject *self, PyObject *args) } } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { FRAPY_REQUIRE_VALID (self, frame); @@ -510,12 +542,13 @@ frapy_read_var (PyObject *self, PyObject *args) block = get_frame_block (frame, NULL); var = lookup_symbol (var_name, block, VAR_DOMAIN, NULL); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { do_cleanups (cleanup); gdbpy_convert_exception (except); return NULL; } + END_CATCH if (!var) { @@ -535,13 +568,17 @@ frapy_read_var (PyObject *self, PyObject *args) return NULL; } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { FRAPY_REQUIRE_VALID (self, frame); val = read_var_value (var, frame); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return value_to_value_object (val); } @@ -552,15 +589,18 @@ static PyObject * frapy_select (PyObject *self, PyObject *args) { struct frame_info *fi; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { FRAPY_REQUIRE_VALID (self, fi); select_frame (fi); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH Py_RETURN_NONE; } @@ -572,13 +612,16 @@ PyObject * gdbpy_newest_frame (PyObject *self, PyObject *args) { struct frame_info *frame = NULL; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { frame = get_current_frame (); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return frame_info_to_frame_object (frame); } @@ -590,13 +633,16 @@ PyObject * gdbpy_selected_frame (PyObject *self, PyObject *args) { struct frame_info *frame = NULL; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { frame = get_selected_frame ("No frame is currently selected."); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return frame_info_to_frame_object (frame); } diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c index 5531d2b..e3336b1 100644 --- a/gdb/python/py-framefilter.c +++ b/gdb/python/py-framefilter.c @@ -201,9 +201,8 @@ mi_should_print (struct symbol *sym, enum mi_print_types type) static enum ext_lang_bt_status py_print_type (struct ui_out *out, struct value *val) { - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct type *type; struct ui_file *stb; @@ -216,11 +215,12 @@ py_print_type (struct ui_out *out, struct value *val) ui_out_field_stream (out, "type", stb); do_cleanups (cleanup); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { gdbpy_convert_exception (except); return EXT_LANG_BT_ERROR; } + END_CATCH return EXT_LANG_BT_OK; } @@ -242,7 +242,6 @@ py_print_value (struct ui_out *out, struct value *val, const struct language_defn *language) { int should_print = 0; - volatile struct gdb_exception except; int local_indent = (4 * indent); /* Never set an indent level for common_val_print if MI. */ @@ -257,15 +256,16 @@ py_print_value (struct ui_out *out, struct value *val, { struct type *type = NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { type = check_typedef (value_type (val)); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { gdbpy_convert_exception (except); return EXT_LANG_BT_ERROR; } + END_CATCH if (args_type == MI_PRINT_ALL_VALUES) should_print = 1; @@ -280,7 +280,7 @@ py_print_value (struct ui_out *out, struct value *val, if (should_print) { - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct ui_file *stb; struct cleanup *cleanup; @@ -291,11 +291,12 @@ py_print_value (struct ui_out *out, struct value *val, ui_out_field_stream (out, "value", stb); do_cleanups (cleanup); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { gdbpy_convert_exception (except); return EXT_LANG_BT_ERROR; } + END_CATCH } return EXT_LANG_BT_OK; @@ -363,7 +364,6 @@ py_print_single_arg (struct ui_out *out, const struct language_defn *language) { struct value *val; - volatile struct gdb_exception except; enum ext_lang_bt_status retval = EXT_LANG_BT_OK; if (fa != NULL) @@ -376,7 +376,7 @@ py_print_single_arg (struct ui_out *out, else val = fv; - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { struct cleanup *cleanups = make_cleanup (null_cleanup, NULL); @@ -473,8 +473,11 @@ py_print_single_arg (struct ui_out *out, do_cleanups (cleanups); } - if (except.reason < 0) - gdbpy_convert_exception (except); + CATCH (except, RETURN_MASK_ERROR) + { + gdbpy_convert_exception (except); + } + END_CATCH return retval; } @@ -499,7 +502,6 @@ enumerate_args (PyObject *iter, { PyObject *item; struct value_print_options opts; - volatile struct gdb_exception except; get_user_print_options (&opts); @@ -511,15 +513,16 @@ enumerate_args (PyObject *iter, opts.deref_ref = 1; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { annotate_frame_args (); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { gdbpy_convert_exception (except); goto error; } + END_CATCH /* Collect the first argument outside of the loop, so output of commas in the argument output is correct. At the end of the @@ -578,16 +581,17 @@ enumerate_args (PyObject *iter, goto error; } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { read_frame_arg (sym, frame, &arg, &entryarg); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { xfree (sym_name); gdbpy_convert_exception (except); goto error; } + END_CATCH /* The object has not provided a value, so this is a frame argument to be read by GDB. In this case we have to @@ -612,12 +616,12 @@ enumerate_args (PyObject *iter, { if (arg.entry_kind != print_entry_values_only) { - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { ui_out_text (out, ", "); ui_out_wrap_hint (out, " "); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { xfree (arg.error); xfree (entryarg.error); @@ -625,6 +629,7 @@ enumerate_args (PyObject *iter, gdbpy_convert_exception (except); goto error; } + END_CATCH } if (py_print_single_arg (out, NULL, &entryarg, NULL, &opts, @@ -664,30 +669,32 @@ enumerate_args (PyObject *iter, item = PyIter_Next (iter); if (item != NULL) { - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { ui_out_text (out, ", "); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { Py_DECREF (item); gdbpy_convert_exception (except); goto error; } + END_CATCH } else if (PyErr_Occurred ()) goto error; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { annotate_arg_end (); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { Py_DECREF (item); gdbpy_convert_exception (except); goto error; } + END_CATCH } return EXT_LANG_BT_OK; @@ -729,7 +736,6 @@ enumerate_locals (PyObject *iter, struct value *val; enum ext_lang_bt_status success = EXT_LANG_BT_ERROR; struct symbol *sym; - volatile struct gdb_exception except; int local_indent = 8 + (8 * indent); struct cleanup *locals_cleanups; @@ -761,16 +767,17 @@ enumerate_locals (PyObject *iter, /* If the object did not provide a value, read it. */ if (val == NULL) { - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { val = read_var_value (sym, frame); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { gdbpy_convert_exception (except); do_cleanups (locals_cleanups); goto error; } + END_CATCH } /* With PRINT_NO_VALUES, MI does not emit a tuple normally as @@ -781,7 +788,7 @@ enumerate_locals (PyObject *iter, if (print_args_field || args_type != NO_VALUES) make_cleanup_ui_out_tuple_begin_end (out, NULL); } - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { if (! ui_out_is_mi_like_p (out)) { @@ -794,12 +801,13 @@ enumerate_locals (PyObject *iter, if (! ui_out_is_mi_like_p (out)) ui_out_text (out, " = "); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { gdbpy_convert_exception (except); do_cleanups (locals_cleanups); goto error; } + END_CATCH if (args_type == MI_PRINT_SIMPLE_VALUES) { @@ -838,15 +846,16 @@ enumerate_locals (PyObject *iter, do_cleanups (locals_cleanups); - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { ui_out_text (out, "\n"); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { gdbpy_convert_exception (except); goto error; } + END_CATCH } if (item == NULL && PyErr_Occurred ()) @@ -947,40 +956,41 @@ py_print_args (PyObject *filter, { PyObject *args_iter = get_py_iter_from_func (filter, "frame_args"); struct cleanup *old_chain = make_cleanup_py_xdecref (args_iter); - volatile struct gdb_exception except; if (args_iter == NULL) goto args_error; make_cleanup_ui_out_list_begin_end (out, "args"); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { annotate_frame_args (); if (! ui_out_is_mi_like_p (out)) ui_out_text (out, " ("); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { gdbpy_convert_exception (except); goto args_error; } + END_CATCH if (args_iter != Py_None) if (enumerate_args (args_iter, out, args_type, 0, frame) == EXT_LANG_BT_ERROR) goto args_error; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (! ui_out_is_mi_like_p (out)) ui_out_text (out, ")"); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { gdbpy_convert_exception (except); goto args_error; } + END_CATCH do_cleanups (old_chain); return EXT_LANG_BT_OK; @@ -1018,7 +1028,6 @@ py_print_frame (PyObject *filter, int flags, struct value_print_options opts; PyObject *py_inf_frame; int print_level, print_frame_info, print_args, print_locals; - volatile struct gdb_exception except; /* Extract print settings from FLAGS. */ print_level = (flags & PRINT_LEVEL) ? 1 : 0; @@ -1042,15 +1051,16 @@ py_print_frame (PyObject *filter, int flags, if (frame == NULL) return EXT_LANG_BT_ERROR; - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { gdbarch = get_frame_arch (frame); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { gdbpy_convert_exception (except); return EXT_LANG_BT_ERROR; } + END_CATCH /* stack-list-variables. */ if (print_locals && print_args && ! print_frame_info) @@ -1074,16 +1084,17 @@ py_print_frame (PyObject *filter, int flags, and are printed with indention. */ if (indent > 0) { - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { ui_out_spaces (out, indent*4); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { gdbpy_convert_exception (except); do_cleanups (cleanup_stack); return EXT_LANG_BT_ERROR; } + END_CATCH } /* The address is required for frame annotations, and also for @@ -1113,11 +1124,10 @@ py_print_frame (PyObject *filter, int flags, { struct frame_info **slot; int level; - volatile struct gdb_exception except; slot = (struct frame_info **) htab_find_slot (levels_printed, frame, INSERT); - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { level = frame_relative_level (frame); @@ -1137,12 +1147,13 @@ py_print_frame (PyObject *filter, int flags, level); } } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { gdbpy_convert_exception (except); do_cleanups (cleanup_stack); return EXT_LANG_BT_ERROR; } + END_CATCH } if (print_frame_info) @@ -1151,19 +1162,20 @@ py_print_frame (PyObject *filter, int flags, print nothing. */ if (opts.addressprint && has_addr) { - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { annotate_frame_address (); ui_out_field_core_addr (out, "addr", gdbarch, address); annotate_frame_address_end (); ui_out_text (out, " in "); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { gdbpy_convert_exception (except); do_cleanups (cleanup_stack); return EXT_LANG_BT_ERROR; } + END_CATCH } /* Print frame function name. */ @@ -1218,7 +1230,7 @@ py_print_frame (PyObject *filter, int flags, return EXT_LANG_BT_ERROR; } - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { annotate_frame_function_name (); if (function == NULL) @@ -1226,12 +1238,14 @@ py_print_frame (PyObject *filter, int flags, else ui_out_field_string (out, "func", function); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { gdbpy_convert_exception (except); do_cleanups (cleanup_stack); return EXT_LANG_BT_ERROR; } + END_CATCH + do_cleanups (py_func_cleanup); } } @@ -1251,16 +1265,17 @@ py_print_frame (PyObject *filter, int flags, /* File name/source/line number information. */ if (print_frame_info) { - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { annotate_frame_source_begin (); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { gdbpy_convert_exception (except); do_cleanups (cleanup_stack); return EXT_LANG_BT_ERROR; } + END_CATCH if (PyObject_HasAttrString (filter, "filename")) { @@ -1285,7 +1300,7 @@ py_print_frame (PyObject *filter, int flags, } make_cleanup (xfree, filename); - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { ui_out_wrap_hint (out, " "); ui_out_text (out, " at "); @@ -1293,12 +1308,13 @@ py_print_frame (PyObject *filter, int flags, ui_out_field_string (out, "file", filename); annotate_frame_source_file_end (); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { gdbpy_convert_exception (except); do_cleanups (cleanup_stack); return EXT_LANG_BT_ERROR; } + END_CATCH } do_cleanups (py_fn_cleanup); } @@ -1319,18 +1335,19 @@ py_print_frame (PyObject *filter, int flags, if (py_line != Py_None) { line = PyLong_AsLong (py_line); - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { ui_out_text (out, ":"); annotate_frame_source_line (); ui_out_field_int (out, "line", line); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { gdbpy_convert_exception (except); do_cleanups (cleanup_stack); return EXT_LANG_BT_ERROR; } + END_CATCH } do_cleanups (py_line_cleanup); } @@ -1340,17 +1357,18 @@ py_print_frame (PyObject *filter, int flags, elided frames, so if MI output detected do not send newline. */ if (! ui_out_is_mi_like_p (out)) { - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { annotate_frame_end (); ui_out_text (out, "\n"); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { gdbpy_convert_exception (except); do_cleanups (cleanup_stack); return EXT_LANG_BT_ERROR; } + END_CATCH } if (print_locals) @@ -1503,22 +1521,22 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang, struct cleanup *cleanups; enum ext_lang_bt_status success = EXT_LANG_BT_ERROR; PyObject *iterable; - volatile struct gdb_exception except; PyObject *item; htab_t levels_printed; if (!gdb_python_initialized) return EXT_LANG_BT_NO_FILTERS; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { gdbarch = get_frame_arch (frame); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { /* Let gdb try to print the stack trace. */ return EXT_LANG_BT_NO_FILTERS; } + END_CATCH cleanups = ensure_python_env (gdbarch, current_language); diff --git a/gdb/python/py-gdb-readline.c b/gdb/python/py-gdb-readline.c index 7a5c853..0cf4dfd 100644 --- a/gdb/python/py-gdb-readline.c +++ b/gdb/python/py-gdb-readline.c @@ -37,18 +37,18 @@ gdbpy_readline_wrapper (FILE *sys_stdin, FILE *sys_stdout, { int n; char *p = NULL, *q; - volatile struct gdb_exception except; - - TRY_CATCH (except, RETURN_MASK_ALL) - p = command_line_input (prompt, 0, "python"); - - /* Detect user interrupt (Ctrl-C). */ - if (except.reason == RETURN_QUIT) - return NULL; + TRY + { + p = command_line_input (prompt, 0, "python"); + } /* Handle errors by raising Python exceptions. */ - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { + /* Detect user interrupt (Ctrl-C). */ + if (except.reason == RETURN_QUIT) + return NULL; + /* The thread state is nulled during gdbpy_readline_wrapper, with the original value saved in the following undocumented variable (see Python's Parser/myreadline.c and @@ -58,6 +58,7 @@ gdbpy_readline_wrapper (FILE *sys_stdin, FILE *sys_stdout, PyEval_SaveThread (); return NULL; } + END_CATCH /* Detect EOF (Ctrl-D). */ if (p == NULL) diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c index 5d13e07..fe8a705 100644 --- a/gdb/python/py-inferior.c +++ b/gdb/python/py-inferior.c @@ -395,13 +395,18 @@ infpy_threads (PyObject *self, PyObject *args) struct threadlist_entry *entry; inferior_object *inf_obj = (inferior_object *) self; PyObject *tuple; - volatile struct gdb_exception except; INFPY_REQUIRE_VALID (inf_obj); - TRY_CATCH (except, RETURN_MASK_ALL) - update_thread_list (); - GDB_PY_HANDLE_EXCEPTION (except); + TRY + { + update_thread_list (); + } + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH tuple = PyTuple_New (inf_obj->nthreads); if (!tuple) @@ -503,7 +508,6 @@ infpy_read_memory (PyObject *self, PyObject *args, PyObject *kw) void *buffer = NULL; membuf_object *membuf_obj; PyObject *addr_obj, *length_obj, *result; - volatile struct gdb_exception except; static char *keywords[] = { "address", "length", NULL }; if (! PyArg_ParseTupleAndKeywords (args, kw, "OO", keywords, @@ -514,17 +518,18 @@ infpy_read_memory (PyObject *self, PyObject *args, PyObject *kw) || get_addr_from_python (length_obj, &length) < 0) return NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { buffer = xmalloc (length); read_memory (addr, buffer, length); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { xfree (buffer); GDB_PY_HANDLE_EXCEPTION (except); } + END_CATCH membuf_obj = PyObject_New (membuf_object, &membuf_object_type); if (membuf_obj == NULL) @@ -557,11 +562,11 @@ infpy_read_memory (PyObject *self, PyObject *args, PyObject *kw) static PyObject * infpy_write_memory (PyObject *self, PyObject *args, PyObject *kw) { + struct gdb_exception except = exception_none; Py_ssize_t buf_len; const char *buffer; CORE_ADDR addr, length; PyObject *addr_obj, *length_obj = NULL; - volatile struct gdb_exception except; static char *keywords[] = { "address", "buffer", "length", NULL }; #ifdef IS_PY3K Py_buffer pybuf; @@ -588,10 +593,16 @@ infpy_write_memory (PyObject *self, PyObject *args, PyObject *kw) else if (get_addr_from_python (length_obj, &length) < 0) goto fail; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { write_memory_with_notification (addr, (gdb_byte *) buffer, length); } + CATCH (ex, RETURN_MASK_ALL) + { + except = ex; + } + END_CATCH + #ifdef IS_PY3K PyBuffer_Release (&pybuf); #endif @@ -701,10 +712,10 @@ get_char_buffer (PyObject *self, Py_ssize_t segment, char **ptrptr) static PyObject * infpy_search_memory (PyObject *self, PyObject *args, PyObject *kw) { + struct gdb_exception except = exception_none; CORE_ADDR start_addr, length; static char *keywords[] = { "address", "length", "pattern", NULL }; PyObject *start_addr_obj, *length_obj; - volatile struct gdb_exception except; Py_ssize_t pattern_size; const void *buffer; CORE_ADDR found_addr; @@ -760,12 +771,18 @@ infpy_search_memory (PyObject *self, PyObject *args, PyObject *kw) goto fail; } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { found = target_search_memory (start_addr, length, buffer, pattern_size, &found_addr); } + CATCH (ex, RETURN_MASK_ALL) + { + except = ex; + } + END_CATCH + #ifdef IS_PY3K PyBuffer_Release (&pybuf); #endif diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c index 9a9a2e6..4d0a020 100644 --- a/gdb/python/py-infthread.c +++ b/gdb/python/py-infthread.c @@ -147,15 +147,18 @@ static PyObject * thpy_switch (PyObject *self, PyObject *args) { thread_object *thread_obj = (thread_object *) self; - volatile struct gdb_exception except; THPY_REQUIRE_VALID (thread_obj); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { switch_to_thread (thread_obj->thread->ptid); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH Py_RETURN_NONE; } diff --git a/gdb/python/py-lazy-string.c b/gdb/python/py-lazy-string.c index 9c0f7a4..c9774ab 100644 --- a/gdb/python/py-lazy-string.c +++ b/gdb/python/py-lazy-string.c @@ -96,7 +96,6 @@ stpy_convert_to_value (PyObject *self, PyObject *args) { lazy_string_object *self_string = (lazy_string_object *) self; struct value *val = NULL; - volatile struct gdb_exception except; if (self_string->address == 0) { @@ -105,11 +104,15 @@ stpy_convert_to_value (PyObject *self, PyObject *args) return NULL; } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { val = value_at_lazy (self_string->type, self_string->address); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return value_to_value_object (val); } diff --git a/gdb/python/py-linetable.c b/gdb/python/py-linetable.c index ff1716b..195a8b3 100644 --- a/gdb/python/py-linetable.c +++ b/gdb/python/py-linetable.c @@ -172,18 +172,21 @@ ltpy_get_pcs_for_line (PyObject *self, PyObject *args) linetable_entry_object *result; VEC (CORE_ADDR) *pcs = NULL; PyObject *tuple; - volatile struct gdb_exception except; LTPY_REQUIRE_VALID (self, symtab); if (! PyArg_ParseTuple (args, GDB_PY_LL_ARG, &py_line)) return NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { pcs = find_pcs_for_symtab_line (symtab, py_line, &best_entry); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH tuple = build_line_table_tuple_from_pcs (py_line, pcs); VEC_free (CORE_ADDR, pcs); diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c index 0a10623..157d200 100644 --- a/gdb/python/py-objfile.c +++ b/gdb/python/py-objfile.c @@ -131,15 +131,18 @@ objfpy_get_build_id (PyObject *self, void *closure) objfile_object *obj = (objfile_object *) self; struct objfile *objfile = obj->objfile; const struct elf_build_id *build_id = NULL; - volatile struct gdb_exception except; OBJFPY_REQUIRE_VALID (obj); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { build_id = build_id_bfd_get (objfile->obfd); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (build_id != NULL) { @@ -386,20 +389,23 @@ objfpy_add_separate_debug_file (PyObject *self, PyObject *args, PyObject *kw) objfile_object *obj = (objfile_object *) self; const char *file_name; int symfile_flags = 0; - volatile struct gdb_exception except; OBJFPY_REQUIRE_VALID (obj); if (!PyArg_ParseTupleAndKeywords (args, kw, "s", keywords, &file_name)) return NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { bfd *abfd = symfile_bfd_open (file_name); symbol_file_add_separate (abfd, file_name, symfile_flags, obj->objfile); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH Py_RETURN_NONE; } diff --git a/gdb/python/py-param.c b/gdb/python/py-param.c index 2fe5be6..06b9ae9 100644 --- a/gdb/python/py-param.c +++ b/gdb/python/py-param.c @@ -662,7 +662,6 @@ parmpy_init (PyObject *self, PyObject *args, PyObject *kwds) int parmclass, cmdtype; PyObject *enum_values = NULL; struct cmd_list_element **set_list, **show_list; - volatile struct gdb_exception except; if (! PyArg_ParseTuple (args, "sii|O", &name, &cmdtype, &parmclass, &enum_values)) @@ -724,14 +723,14 @@ parmpy_init (PyObject *self, PyObject *args, PyObject *kwds) Py_INCREF (self); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { add_setshow_generic (parmclass, (enum command_class) cmdtype, cmd_name, obj, set_doc, show_doc, doc, set_list, show_list); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { xfree (cmd_name); xfree (set_doc); @@ -743,6 +742,8 @@ parmpy_init (PyObject *self, PyObject *args, PyObject *kwds) "%s", except.message); return -1; } + END_CATCH + return 0; } diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c index f4c91d0..d8579fa 100644 --- a/gdb/python/py-prettyprint.c +++ b/gdb/python/py-prettyprint.c @@ -213,11 +213,10 @@ find_pretty_printer (PyObject *value) static PyObject * pretty_print_one_value (PyObject *printer, struct value **out_value) { - volatile struct gdb_exception except; PyObject *result = NULL; *out_value = NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { result = PyObject_CallMethodObjArgs (printer, gdbpy_to_string_cst, NULL); if (result) @@ -233,6 +232,10 @@ pretty_print_one_value (PyObject *printer, struct value **out_value) } } } + CATCH (except, RETURN_MASK_ALL) + { + } + END_CATCH return result; } @@ -803,13 +806,16 @@ gdbpy_get_varobj_pretty_printer (struct value *value) { PyObject *val_obj; PyObject *pretty_printer = NULL; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { value = value_copy (value); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH val_obj = value_to_value_object (value); if (! val_obj) diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c index 729bc64..4306f61 100644 --- a/gdb/python/py-symbol.c +++ b/gdb/python/py-symbol.c @@ -192,16 +192,19 @@ static PyObject * sympy_needs_frame (PyObject *self, void *closure) { struct symbol *symbol = NULL; - volatile struct gdb_exception except; int result = 0; SYMPY_REQUIRE_VALID (self, symbol); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { result = symbol_read_needs_frame (symbol); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (result) Py_RETURN_TRUE; @@ -246,7 +249,6 @@ sympy_value (PyObject *self, PyObject *args) struct frame_info *frame_info = NULL; PyObject *frame_obj = NULL; struct value *value = NULL; - volatile struct gdb_exception except; if (!PyArg_ParseTuple (args, "|O", &frame_obj)) return NULL; @@ -264,7 +266,7 @@ sympy_value (PyObject *self, PyObject *args) return NULL; } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (frame_obj != NULL) { @@ -278,7 +280,11 @@ sympy_value (PyObject *self, PyObject *args) value = read_var_value (symbol, frame_info); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return value_to_value_object (value); } @@ -365,7 +371,6 @@ gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw) struct symbol *symbol = NULL; PyObject *block_obj = NULL, *ret_tuple, *sym_obj, *bool_obj; const struct block *block = NULL; - volatile struct gdb_exception except; if (! PyArg_ParseTupleAndKeywords (args, kw, "s|O!i", keywords, &name, &block_object_type, &block_obj, &domain)) @@ -376,21 +381,28 @@ gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw) else { struct frame_info *selected_frame; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { selected_frame = get_selected_frame (_("No frame selected.")); block = get_frame_block (selected_frame, NULL); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { symbol = lookup_symbol (name, block, domain, &is_a_field_of_this); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH ret_tuple = PyTuple_New (2); if (!ret_tuple) @@ -430,17 +442,20 @@ gdbpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw) static char *keywords[] = { "name", "domain", NULL }; struct symbol *symbol = NULL; PyObject *sym_obj; - volatile struct gdb_exception except; if (! PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &name, &domain)) return NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { symbol = lookup_global_symbol (name, NULL, domain); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (symbol) { diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index 72d4dcf..39376a1 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -341,15 +341,18 @@ typy_fields_items (PyObject *self, enum gdbpy_iter_kind kind) { PyObject *py_type = self; PyObject *result = NULL, *iter = NULL; - volatile struct gdb_exception except; struct type *type = ((type_object *) py_type)->type; struct type *checked_type = type; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { CHECK_TYPEDEF (checked_type); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (checked_type != type) py_type = type_to_type_object (checked_type); @@ -449,13 +452,16 @@ static PyObject * typy_strip_typedefs (PyObject *self, PyObject *args) { struct type *type = ((type_object *) self)->type; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { type = check_typedef (type); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return type_to_type_object (type); } @@ -466,15 +472,18 @@ typy_strip_typedefs (PyObject *self, PyObject *args) static struct type * typy_get_composite (struct type *type) { - volatile struct gdb_exception except; for (;;) { - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { CHECK_TYPEDEF (type); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (TYPE_CODE (type) != TYPE_CODE_PTR && TYPE_CODE (type) != TYPE_CODE_REF) @@ -505,7 +514,6 @@ typy_array_1 (PyObject *self, PyObject *args, int is_vector) PyObject *n2_obj = NULL; struct type *array = NULL; struct type *type = ((type_object *) self)->type; - volatile struct gdb_exception except; if (! PyArg_ParseTuple (args, "l|O", &n1, &n2_obj)) return NULL; @@ -535,13 +543,17 @@ typy_array_1 (PyObject *self, PyObject *args, int is_vector) return NULL; } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { array = lookup_array_range_type (type, n1, n2); if (is_vector) make_vector_type (array); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return type_to_type_object (array); } @@ -567,13 +579,16 @@ static PyObject * typy_pointer (PyObject *self, PyObject *args) { struct type *type = ((type_object *) self)->type; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { type = lookup_pointer_type (type); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return type_to_type_object (type); } @@ -648,13 +663,16 @@ static PyObject * typy_reference (PyObject *self, PyObject *args) { struct type *type = ((type_object *) self)->type; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { type = lookup_reference_type (type); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return type_to_type_object (type); } @@ -680,13 +698,16 @@ static PyObject * typy_const (PyObject *self, PyObject *args) { struct type *type = ((type_object *) self)->type; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { type = make_cv_type (1, 0, type, NULL); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return type_to_type_object (type); } @@ -696,13 +717,16 @@ static PyObject * typy_volatile (PyObject *self, PyObject *args) { struct type *type = ((type_object *) self)->type; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { type = make_cv_type (0, 1, type, NULL); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return type_to_type_object (type); } @@ -712,13 +736,16 @@ static PyObject * typy_unqualified (PyObject *self, PyObject *args) { struct type *type = ((type_object *) self)->type; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { type = make_cv_type (0, 0, type, NULL); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return type_to_type_object (type); } @@ -728,12 +755,16 @@ static PyObject * typy_get_sizeof (PyObject *self, void *closure) { struct type *type = ((type_object *) self)->type; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { check_typedef (type); } + CATCH (except, RETURN_MASK_ALL) + { + } + END_CATCH + /* Ignore exceptions. */ return gdb_py_long_from_longest (TYPE_LENGTH (type)); @@ -743,9 +774,8 @@ static struct type * typy_lookup_typename (const char *type_name, const struct block *block) { struct type *type = NULL; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (startswith (type_name, "struct ")) type = lookup_struct (type_name + 7, NULL); @@ -757,7 +787,11 @@ typy_lookup_typename (const char *type_name, const struct block *block) type = lookup_typename (python_language, python_gdbarch, type_name, block, 0); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return type; } @@ -769,7 +803,6 @@ typy_lookup_type (struct demangle_component *demangled, struct type *type, *rtype = NULL; char *type_name = NULL; enum demangle_component_type demangled_type; - volatile struct gdb_exception except; /* Save the type: typy_lookup_type() may (indirectly) overwrite memory pointed by demangled. */ @@ -784,7 +817,7 @@ typy_lookup_type (struct demangle_component *demangled, if (! type) return NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { /* If the demangled_type matches with one of the types below, run the corresponding function and save the type @@ -806,7 +839,11 @@ typy_lookup_type (struct demangle_component *demangled, break; } } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH } /* If we have a type from the switch statement above, just return @@ -837,7 +874,6 @@ typy_legacy_template_argument (struct type *type, const struct block *block, const char *err; struct type *argtype; struct cleanup *cleanup; - volatile struct gdb_exception except; if (TYPE_NAME (type) == NULL) { @@ -845,12 +881,16 @@ typy_legacy_template_argument (struct type *type, const struct block *block, return NULL; } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { /* Note -- this is not thread-safe. */ info = cp_demangled_name_to_comp (TYPE_NAME (type), &err); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (! info) { @@ -903,7 +943,6 @@ typy_template_argument (PyObject *self, PyObject *args) PyObject *block_obj = NULL; struct symbol *sym; struct value *val = NULL; - volatile struct gdb_exception except; if (! PyArg_ParseTuple (args, "i|O", &argno, &block_obj)) return NULL; @@ -919,13 +958,17 @@ typy_template_argument (PyObject *self, PyObject *args) } } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { type = check_typedef (type); if (TYPE_CODE (type) == TYPE_CODE_REF) type = check_typedef (TYPE_TARGET_TYPE (type)); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + 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 -- @@ -950,11 +993,15 @@ typy_template_argument (PyObject *self, PyObject *args) return NULL; } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { val = value_of_variable (sym, block); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return value_to_value_object (val); } @@ -962,12 +1009,11 @@ typy_template_argument (PyObject *self, PyObject *args) static PyObject * typy_str (PyObject *self) { - volatile struct gdb_exception except; char *thetype = NULL; long length = 0; PyObject *result; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct cleanup *old_chain; struct ui_file *stb; @@ -981,11 +1027,12 @@ typy_str (PyObject *self) thetype = ui_file_xstrdup (stb, &length); do_cleanups (old_chain); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { xfree (thetype); GDB_PY_HANDLE_EXCEPTION (except); } + END_CATCH result = PyUnicode_Decode (thetype, length, host_charset (), NULL); xfree (thetype); @@ -1001,7 +1048,6 @@ typy_richcompare (PyObject *self, PyObject *other, int op) int result = Py_NE; struct type *type1 = type_object_to_type (self); struct type *type2 = type_object_to_type (other); - volatile struct gdb_exception except; /* We can only compare ourselves to another Type object, and only for equality or inequality. */ @@ -1015,13 +1061,17 @@ typy_richcompare (PyObject *self, PyObject *other, int op) result = Py_EQ; else { - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { result = types_deeply_equal (type1, type2); } - /* If there is a GDB exception, a comparison is not capable - (or trusted), so exit. */ - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + /* 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)) diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c index 58a5934..2e32f11 100644 --- a/gdb/python/py-utils.c +++ b/gdb/python/py-utils.c @@ -316,13 +316,16 @@ get_addr_from_python (PyObject *obj, CORE_ADDR *addr) { if (gdbpy_is_value_object (obj)) { - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { *addr = value_as_address (value_object_to_value (obj)); } - GDB_PY_SET_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_SET_HANDLE_EXCEPTION (except); + } + END_CATCH } else { diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index 5a13777..6622d11 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -172,10 +172,9 @@ gdbpy_preserve_values (const struct extension_language_defn *extlang, static PyObject * valpy_dereference (PyObject *self, PyObject *args) { - volatile struct gdb_exception except; PyObject *result = NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct value *res_val; struct cleanup *cleanup = make_cleanup_value_free_to_mark (value_mark ()); @@ -184,7 +183,11 @@ valpy_dereference (PyObject *self, PyObject *args) result = value_to_value_object (res_val); do_cleanups (cleanup); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return result; } @@ -200,10 +203,9 @@ valpy_dereference (PyObject *self, PyObject *args) static PyObject * valpy_referenced_value (PyObject *self, PyObject *args) { - volatile struct gdb_exception except; PyObject *result = NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct value *self_val, *res_val; struct cleanup *cleanup = make_cleanup_value_free_to_mark (value_mark ()); @@ -225,7 +227,11 @@ valpy_referenced_value (PyObject *self, PyObject *args) result = value_to_value_object (res_val); do_cleanups (cleanup); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return result; } @@ -235,11 +241,10 @@ static PyObject * valpy_get_address (PyObject *self, void *closure) { value_object *val_obj = (value_object *) self; - volatile struct gdb_exception except; if (!val_obj->address) { - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct value *res_val; struct cleanup *cleanup @@ -249,11 +254,12 @@ valpy_get_address (PyObject *self, void *closure) val_obj->address = value_to_value_object (res_val); do_cleanups (cleanup); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { val_obj->address = Py_None; Py_INCREF (Py_None); } + END_CATCH } Py_XINCREF (val_obj->address); @@ -283,7 +289,6 @@ static PyObject * valpy_get_dynamic_type (PyObject *self, void *closure) { value_object *obj = (value_object *) self; - volatile struct gdb_exception except; struct type *type = NULL; if (obj->dynamic_type != NULL) @@ -292,7 +297,7 @@ valpy_get_dynamic_type (PyObject *self, void *closure) return obj->dynamic_type; } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct value *val = obj->value; struct cleanup *cleanup = make_cleanup_value_free_to_mark (value_mark ()); @@ -331,7 +336,11 @@ valpy_get_dynamic_type (PyObject *self, void *closure) do_cleanups (cleanup); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (type == NULL) obj->dynamic_type = valpy_get_type (self, NULL); @@ -358,13 +367,12 @@ valpy_lazy_string (PyObject *self, PyObject *args, PyObject *kw) const char *user_encoding = NULL; static char *keywords[] = { "encoding", "length", NULL }; PyObject *str_obj = NULL; - volatile struct gdb_exception except; if (!PyArg_ParseTupleAndKeywords (args, kw, "|s" GDB_PY_LL_ARG, keywords, &user_encoding, &length)) return NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct cleanup *cleanup = make_cleanup_value_free_to_mark (value_mark ()); @@ -377,7 +385,11 @@ valpy_lazy_string (PyObject *self, PyObject *args, PyObject *kw) do_cleanups (cleanup); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return str_obj; } @@ -394,7 +406,6 @@ valpy_string (PyObject *self, PyObject *args, PyObject *kw) int length = -1; gdb_byte *buffer; struct value *value = ((value_object *) self)->value; - volatile struct gdb_exception except; PyObject *unicode; const char *encoding = NULL; const char *errors = NULL; @@ -407,11 +418,15 @@ valpy_string (PyObject *self, PyObject *args, PyObject *kw) &user_encoding, &errors, &length)) return NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { LA_GET_STRING (value, &buffer, &length, &char_type, &la_encoding); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH encoding = (user_encoding && *user_encoding) ? user_encoding : la_encoding; unicode = PyUnicode_Decode ((const char *) buffer, @@ -429,7 +444,6 @@ valpy_do_cast (PyObject *self, PyObject *args, enum exp_opcode op) { PyObject *type_obj, *result = NULL; struct type *type; - volatile struct gdb_exception except; if (! PyArg_ParseTuple (args, "O", &type_obj)) return NULL; @@ -442,7 +456,7 @@ valpy_do_cast (PyObject *self, PyObject *args, enum exp_opcode op) return NULL; } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct value *val = ((value_object *) self)->value; struct value *res_val; @@ -461,7 +475,11 @@ valpy_do_cast (PyObject *self, PyObject *args, enum exp_opcode op) result = value_to_value_object (res_val); do_cleanups (cleanup); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return result; } @@ -508,7 +526,6 @@ value_has_field (struct value *v, PyObject *field) struct type *parent_type, *val_type; enum type_code type_code; PyObject *type_object = PyObject_GetAttrString (field, "parent_type"); - volatile struct gdb_exception except; int has_field = 0; if (type_object == NULL) @@ -524,7 +541,7 @@ value_has_field (struct value *v, PyObject *field) return -1; } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { val_type = value_type (v); val_type = check_typedef (val_type); @@ -539,7 +556,11 @@ value_has_field (struct value *v, PyObject *field) else has_field = 0; } - GDB_PY_SET_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_SET_HANDLE_EXCEPTION (except); + } + END_CATCH return has_field; } @@ -591,11 +612,11 @@ get_field_type (PyObject *field) static PyObject * valpy_getitem (PyObject *self, PyObject *key) { + struct gdb_exception except = exception_none; value_object *self_value = (value_object *) self; char *field = NULL; struct type *base_class_type = NULL, *field_type = NULL; long bitpos = -1; - volatile struct gdb_exception except; PyObject *result = NULL; if (gdbpy_is_string (key)) @@ -673,7 +694,7 @@ valpy_getitem (PyObject *self, PyObject *key) } } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct value *tmp = self_value->value; struct cleanup *cleanup = make_cleanup_value_free_to_mark (value_mark ()); @@ -723,6 +744,11 @@ valpy_getitem (PyObject *self, PyObject *key) result = value_to_value_object (res_val); do_cleanups (cleanup); } + CATCH (ex, RETURN_MASK_ALL) + { + except = ex; + } + END_CATCH xfree (field); GDB_PY_HANDLE_EXCEPTION (except); @@ -744,18 +770,21 @@ static PyObject * valpy_call (PyObject *self, PyObject *args, PyObject *keywords) { Py_ssize_t args_count; - volatile struct gdb_exception except; struct value *function = ((value_object *) self)->value; struct value **vargs = NULL; struct type *ftype = NULL; struct value *mark = value_mark (); PyObject *result = NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { ftype = check_typedef (value_type (function)); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (TYPE_CODE (ftype) != TYPE_CODE_FUNC) { @@ -790,7 +819,7 @@ valpy_call (PyObject *self, PyObject *args, PyObject *keywords) } } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct cleanup *cleanup = make_cleanup_value_free_to_mark (mark); struct value *return_value; @@ -799,7 +828,11 @@ valpy_call (PyObject *self, PyObject *args, PyObject *keywords) result = value_to_value_object (return_value); do_cleanups (cleanup); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return result; } @@ -812,12 +845,11 @@ valpy_str (PyObject *self) char *s = NULL; PyObject *result; struct value_print_options opts; - volatile struct gdb_exception except; get_user_print_options (&opts); opts.deref_ref = 0; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct ui_file *stb = mem_fileopen (); struct cleanup *old_chain = make_cleanup_ui_file_delete (stb); @@ -828,7 +860,11 @@ valpy_str (PyObject *self) do_cleanups (old_chain); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH result = PyUnicode_Decode (s, strlen (s), host_charset (), NULL); xfree (s); @@ -842,13 +878,16 @@ valpy_get_is_optimized_out (PyObject *self, void *closure) { struct value *value = ((value_object *) self)->value; int opt = 0; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { opt = value_optimized_out (value); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (opt) Py_RETURN_TRUE; @@ -862,13 +901,16 @@ valpy_get_is_lazy (PyObject *self, void *closure) { struct value *value = ((value_object *) self)->value; int opt = 0; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { opt = value_lazy (value); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (opt) Py_RETURN_TRUE; @@ -881,14 +923,17 @@ static PyObject * valpy_fetch_lazy (PyObject *self, PyObject *args) { struct value *value = ((value_object *) self)->value; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (value_lazy (value)) value_fetch_lazy (value); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH Py_RETURN_NONE; } @@ -926,10 +971,9 @@ enum valpy_opcode static PyObject * valpy_binop (enum valpy_opcode opcode, PyObject *self, PyObject *other) { - volatile struct gdb_exception except; PyObject *result = NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct value *arg1, *arg2; struct cleanup *cleanup = make_cleanup_value_free_to_mark (value_mark ()); @@ -1049,7 +1093,11 @@ valpy_binop (enum valpy_opcode opcode, PyObject *self, PyObject *other) do_cleanups (cleanup); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return result; } @@ -1103,10 +1151,9 @@ valpy_power (PyObject *self, PyObject *other, PyObject *unused) static PyObject * valpy_negative (PyObject *self) { - volatile struct gdb_exception except; PyObject *result = NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { /* Perhaps overkill, but consistency has some virtue. */ struct cleanup *cleanup = make_cleanup_value_free_to_mark (value_mark ()); @@ -1116,7 +1163,11 @@ valpy_negative (PyObject *self) result = value_to_value_object (val); do_cleanups (cleanup); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return result; } @@ -1131,10 +1182,9 @@ static PyObject * valpy_absolute (PyObject *self) { struct value *value = ((value_object *) self)->value; - volatile struct gdb_exception except; int isabs = 1; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct cleanup *cleanup = make_cleanup_value_free_to_mark (value_mark ()); @@ -1143,7 +1193,11 @@ valpy_absolute (PyObject *self) do_cleanups (cleanup); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH if (isabs) return valpy_positive (self); @@ -1155,12 +1209,12 @@ valpy_absolute (PyObject *self) static int valpy_nonzero (PyObject *self) { - volatile struct gdb_exception except; + struct gdb_exception except = exception_none; value_object *self_value = (value_object *) self; struct type *type; int nonzero = 0; /* Appease GCC warning. */ - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { type = check_typedef (value_type (self_value->value)); @@ -1176,6 +1230,12 @@ valpy_nonzero (PyObject *self) /* All other values are True. */ nonzero = 1; } + CATCH (ex, RETURN_MASK_ALL) + { + except = ex; + } + END_CATCH + /* This is not documented in the Python documentation, but if this function fails, return -1 as slot_nb_nonzero does (the default Python nonzero function). */ @@ -1189,13 +1249,16 @@ static PyObject * valpy_invert (PyObject *self) { struct value *val = NULL; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { val = value_complement (((value_object *) self)->value); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return value_to_value_object (val); } @@ -1241,7 +1304,6 @@ static PyObject * valpy_richcompare (PyObject *self, PyObject *other, int op) { int result = 0; - volatile struct gdb_exception except; if (other == Py_None) /* Comparing with None is special. From what I can tell, in Python @@ -1262,7 +1324,7 @@ valpy_richcompare (PyObject *self, PyObject *other, int op) return NULL; } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct value *value_other, *mark = value_mark (); struct cleanup *cleanup; @@ -1307,7 +1369,11 @@ valpy_richcompare (PyObject *self, PyObject *other, int op) do_cleanups (cleanup); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH /* In this case, the Python exception has already been set. */ if (result < 0) @@ -1327,16 +1393,19 @@ valpy_int (PyObject *self) struct value *value = ((value_object *) self)->value; struct type *type = value_type (value); LONGEST l = 0; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (!is_integral_type (type)) error (_("Cannot convert value to int.")); l = value_as_long (value); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return gdb_py_object_from_longest (l); } @@ -1349,9 +1418,8 @@ valpy_long (PyObject *self) struct value *value = ((value_object *) self)->value; struct type *type = value_type (value); LONGEST l = 0; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { CHECK_TYPEDEF (type); @@ -1361,7 +1429,11 @@ valpy_long (PyObject *self) l = value_as_long (value); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return gdb_py_long_from_longest (l); } @@ -1373,9 +1445,8 @@ valpy_float (PyObject *self) struct value *value = ((value_object *) self)->value; struct type *type = value_type (value); double d = 0; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { CHECK_TYPEDEF (type); @@ -1384,7 +1455,11 @@ valpy_float (PyObject *self) d = value_as_double (value); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return PyFloat_FromDouble (d); } @@ -1431,12 +1506,11 @@ struct value * convert_value_from_python (PyObject *obj) { struct value *value = NULL; /* -Wall */ - volatile struct gdb_exception except; int cmp; gdb_assert (obj != NULL); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (PyBool_Check (obj)) { @@ -1532,13 +1606,14 @@ convert_value_from_python (PyObject *obj) PyString_AsString (PyObject_Str (obj))); #endif } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { PyErr_Format (except.reason == RETURN_QUIT ? PyExc_KeyboardInterrupt : PyExc_RuntimeError, "%s", except.message); return NULL; } + END_CATCH return value; } @@ -1549,16 +1624,19 @@ gdbpy_history (PyObject *self, PyObject *args) { int i; struct value *res_val = NULL; /* Initialize to appease gcc warning. */ - volatile struct gdb_exception except; if (!PyArg_ParseTuple (args, "i", &i)) return NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { res_val = access_value_history (i); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return value_to_value_object (res_val); } diff --git a/gdb/python/python.c b/gdb/python/python.c index c3ffbae..58c7c92 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -564,21 +564,27 @@ gdbpy_parameter_value (enum var_types type, void *var) PyObject * gdbpy_parameter (PyObject *self, PyObject *args) { + struct gdb_exception except = exception_none; struct cmd_list_element *alias, *prefix, *cmd; const char *arg; char *newarg; int found = -1; - volatile struct gdb_exception except; if (! PyArg_ParseTuple (args, "s", &arg)) return NULL; newarg = concat ("show ", arg, (char *) NULL); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { found = lookup_cmd_composition (newarg, &alias, &prefix, &cmd); } + CATCH (ex, RETURN_MASK_ALL) + { + except = ex; + } + END_CATCH + xfree (newarg); GDB_PY_HANDLE_EXCEPTION (except); if (!found) @@ -619,7 +625,6 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) const char *arg; PyObject *from_tty_obj = NULL, *to_string_obj = NULL; int from_tty, to_string; - volatile struct gdb_exception except; static char *keywords[] = {"command", "from_tty", "to_string", NULL }; char *result = NULL; @@ -646,7 +651,7 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) to_string = cmp; } - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { /* Copy the argument text in case the command modifies it. */ char *copy = xstrdup (arg); @@ -666,7 +671,11 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) do_cleanups (cleanup); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH /* Do any commands attached to breakpoint we stopped at. */ bpstat_do_actions (); @@ -710,6 +719,7 @@ gdbpy_solib_name (PyObject *self, PyObject *args) static PyObject * gdbpy_decode_line (PyObject *self, PyObject *args) { + struct gdb_exception except = exception_none; struct symtabs_and_lines sals = { NULL, 0 }; /* Initialize to appease gcc. */ struct symtab_and_line sal; @@ -719,7 +729,6 @@ gdbpy_decode_line (PyObject *self, PyObject *args) PyObject *result = NULL; PyObject *return_result = NULL; PyObject *unparsed = NULL; - volatile struct gdb_exception except; if (! PyArg_ParseTuple (args, "|s", &arg)) return NULL; @@ -727,7 +736,8 @@ gdbpy_decode_line (PyObject *self, PyObject *args) cleanups = make_cleanup (null_cleanup, NULL); sals.sals = NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + + TRY { if (arg) { @@ -743,6 +753,11 @@ gdbpy_decode_line (PyObject *self, PyObject *args) sals.nelts = 1; } } + CATCH (ex, RETURN_MASK_ALL) + { + except = ex; + } + END_CATCH if (sals.sals != NULL && sals.sals != &sal) { @@ -824,16 +839,19 @@ gdbpy_parse_and_eval (PyObject *self, PyObject *args) { const char *expr_str; struct value *result = NULL; - volatile struct gdb_exception except; if (!PyArg_ParseTuple (args, "s", &expr_str)) return NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { result = parse_and_eval (expr_str); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return value_to_value_object (result); } @@ -845,13 +863,12 @@ static PyObject * gdbpy_find_pc_line (PyObject *self, PyObject *args) { gdb_py_ulongest pc_llu; - volatile struct gdb_exception except; PyObject *result = NULL; /* init for gcc -Wall */ if (!PyArg_ParseTuple (args, GDB_PY_LLU_ARG, &pc_llu)) return NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct symtab_and_line sal; CORE_ADDR pc; @@ -860,7 +877,11 @@ gdbpy_find_pc_line (PyObject *self, PyObject *args) sal = find_pc_line (pc, 0); result = symtab_and_line_to_sal_object (sal); } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH return result; } @@ -1096,13 +1117,12 @@ gdbpy_write (PyObject *self, PyObject *args, PyObject *kw) const char *arg; static char *keywords[] = {"text", "stream", NULL }; int stream_type = 0; - volatile struct gdb_exception except; if (! PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &arg, &stream_type)) return NULL; - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { switch (stream_type) { @@ -1120,7 +1140,11 @@ gdbpy_write (PyObject *self, PyObject *args, PyObject *kw) fprintf_filtered (gdb_stdout, "%s", arg); } } - GDB_PY_HANDLE_EXCEPTION (except); + CATCH (except, RETURN_MASK_ALL) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + END_CATCH Py_RETURN_NONE; } @@ -1165,7 +1189,6 @@ gdbpy_flush (PyObject *self, PyObject *args, PyObject *kw) void gdbpy_print_stack (void) { - volatile struct gdb_exception except; /* Print "none", just clear exception. */ if (gdbpy_should_print_stack == python_excp_none) @@ -1179,10 +1202,14 @@ gdbpy_print_stack (void) /* PyErr_Print doesn't necessarily end output with a newline. This works because Python's stdout/stderr is fed through printf_filtered. */ - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { begin_line (); } + CATCH (except, RETURN_MASK_ALL) + { + } + END_CATCH } /* Print "message", just error print message. */ else @@ -1196,7 +1223,7 @@ gdbpy_print_stack (void) msg = gdbpy_exception_to_string (ptype, pvalue); type = gdbpy_obj_to_string (ptype); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { if (msg == NULL) { @@ -1210,6 +1237,10 @@ gdbpy_print_stack (void) fprintf_filtered (gdb_stderr, "Python Exception %s %s: \n", type, msg); } + CATCH (except, RETURN_MASK_ALL) + { + } + END_CATCH Py_XDECREF (ptype); Py_XDECREF (pvalue); diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index f2d35a3..6bd9d01 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -139,13 +139,15 @@ require_btrace (void) static void record_btrace_enable_warn (struct thread_info *tp) { - volatile struct gdb_exception error; - - TRY_CATCH (error, RETURN_MASK_ERROR) - btrace_enable (tp, &record_btrace_conf); - - if (error.message != NULL) - warning ("%s", error.message); + TRY + { + btrace_enable (tp, &record_btrace_conf); + } + CATCH (error, RETURN_MASK_ERROR) + { + warning ("%s", error.message); + } + END_CATCH } /* Callback function to disable branch tracing for one thread. */ @@ -1140,7 +1142,6 @@ record_btrace_insert_breakpoint (struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) { - volatile struct gdb_exception except; const char *old; int ret; @@ -1150,13 +1151,18 @@ record_btrace_insert_breakpoint (struct target_ops *ops, replay_memory_access = replay_memory_access_read_write; ret = 0; - TRY_CATCH (except, RETURN_MASK_ALL) - ret = ops->beneath->to_insert_breakpoint (ops->beneath, gdbarch, bp_tgt); + TRY + { + ret = ops->beneath->to_insert_breakpoint (ops->beneath, gdbarch, bp_tgt); + } replay_memory_access = old; - if (except.reason < 0) - throw_exception (except); + CATCH (except, RETURN_MASK_ALL) + { + throw_exception (except); + } + END_CATCH return ret; } @@ -1168,7 +1174,6 @@ record_btrace_remove_breakpoint (struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) { - volatile struct gdb_exception except; const char *old; int ret; @@ -1178,13 +1183,18 @@ record_btrace_remove_breakpoint (struct target_ops *ops, replay_memory_access = replay_memory_access_read_write; ret = 0; - TRY_CATCH (except, RETURN_MASK_ALL) - ret = ops->beneath->to_remove_breakpoint (ops->beneath, gdbarch, bp_tgt); + TRY + { + ret = ops->beneath->to_remove_breakpoint (ops->beneath, gdbarch, bp_tgt); + } replay_memory_access = old; - if (except.reason < 0) - throw_exception (except); + CATCH (except, RETURN_MASK_ALL) + { + throw_exception (except); + } + END_CATCH return ret; } @@ -1622,7 +1632,6 @@ record_btrace_find_resume_thread (ptid_t ptid) static struct btrace_insn_iterator * record_btrace_start_replaying (struct thread_info *tp) { - volatile struct gdb_exception except; struct btrace_insn_iterator *replay; struct btrace_thread_info *btinfo; int executing; @@ -1649,7 +1658,7 @@ record_btrace_start_replaying (struct thread_info *tp) Since frames are computed differently when we're replaying, we need to recompute those stored frames and fix them up so we can still detect subroutines after we started replaying. */ - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { struct frame_info *frame; struct frame_id frame_id; @@ -1701,7 +1710,7 @@ record_btrace_start_replaying (struct thread_info *tp) /* Restore the previous execution state. */ set_executing (tp->ptid, executing); - if (except.reason < 0) + CATCH (except, RETURN_MASK_ALL) { xfree (btinfo->replay); btinfo->replay = NULL; @@ -1710,6 +1719,7 @@ record_btrace_start_replaying (struct thread_info *tp) throw_exception (except); } + END_CATCH return replay; } @@ -2298,21 +2308,22 @@ init_record_btrace_ops (void) static void cmd_record_btrace_bts_start (char *args, int from_tty) { - volatile struct gdb_exception exception; if (args != NULL && *args != 0) error (_("Invalid argument.")); record_btrace_conf.format = BTRACE_FORMAT_BTS; - TRY_CATCH (exception, RETURN_MASK_ALL) - execute_command ("target record-btrace", from_tty); - - if (exception.error != 0) + TRY + { + execute_command ("target record-btrace", from_tty); + } + CATCH (exception, RETURN_MASK_ALL) { record_btrace_conf.format = BTRACE_FORMAT_NONE; throw_exception (exception); } + END_CATCH } /* Alias for "target record". */ @@ -2320,21 +2331,22 @@ cmd_record_btrace_bts_start (char *args, int from_tty) static void cmd_record_btrace_start (char *args, int from_tty) { - volatile struct gdb_exception exception; if (args != NULL && *args != 0) error (_("Invalid argument.")); record_btrace_conf.format = BTRACE_FORMAT_BTS; - TRY_CATCH (exception, RETURN_MASK_ALL) - execute_command ("target record-btrace", from_tty); - - if (exception.error == 0) - return; - - record_btrace_conf.format = BTRACE_FORMAT_NONE; - throw_exception (exception); + TRY + { + execute_command ("target record-btrace", from_tty); + } + CATCH (exception, RETURN_MASK_ALL) + { + record_btrace_conf.format = BTRACE_FORMAT_NONE; + throw_exception (exception); + } + END_CATCH } /* The "set record btrace" command. */ diff --git a/gdb/remote.c b/gdb/remote.c index eb1eb27..19f56a1 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -497,7 +497,6 @@ remote_get_noisy_reply (char **buf_p, CORE_ADDR from, to, org_to; char *p, *pp; int adjusted_size = 0; - volatile struct gdb_exception ex; int relocated = 0; p = buf + strlen ("qRelocInsn:"); @@ -512,12 +511,12 @@ remote_get_noisy_reply (char **buf_p, org_to = to; - TRY_CATCH (ex, RETURN_MASK_ALL) + TRY { gdbarch_relocate_instruction (target_gdbarch (), &to, from); relocated = 1; } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ALL) { if (ex.error == MEMORY_ERROR) { @@ -536,6 +535,7 @@ remote_get_noisy_reply (char **buf_p, } putpkt ("E01"); } + END_CATCH if (relocated) { @@ -4382,13 +4382,12 @@ remote_open_1 (const char *name, int from_tty, all the ``target ....'' commands to share a common callback function. See cli-dump.c. */ { - volatile struct gdb_exception ex; - TRY_CATCH (ex, RETURN_MASK_ALL) + TRY { remote_start_remote (from_tty, target, extended_p); } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ALL) { /* Pop the partially set up target - unless something else did already before throwing the exception. */ @@ -4398,6 +4397,7 @@ remote_open_1 (const char *name, int from_tty, wait_forever_enabled_p = 1; throw_exception (ex); } + END_CATCH } remote_btrace_reset (); @@ -7835,15 +7835,14 @@ getpkt_or_notif_sane (char **buf, long *sizeof_buf, int forever, static void remote_kill (struct target_ops *ops) { - volatile struct gdb_exception ex; /* Catch errors so the user can quit from gdb even when we aren't on speaking terms with the remote system. */ - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { putpkt ("k"); } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ERROR) { if (ex.error == TARGET_CLOSE_ERROR) { @@ -7861,6 +7860,7 @@ remote_kill (struct target_ops *ops) user or higher layers decide what to do. */ throw_exception (ex); } + END_CATCH /* We've killed the remote end, we get to mourn it. Since this is target remote, single-process, mourning the inferior also @@ -10948,7 +10948,6 @@ remote_get_trace_status (struct target_ops *self, struct trace_status *ts) char *p = NULL; /* FIXME we need to get register block size some other way. */ extern int trace_regblock_size; - volatile struct gdb_exception ex; enum packet_result result; if (packet_support (PACKET_qTStatus) == PACKET_DISABLE) @@ -10958,11 +10957,11 @@ remote_get_trace_status (struct target_ops *self, struct trace_status *ts) putpkt ("qTStatus"); - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { p = remote_get_noisy_reply (&target_buf, &target_buf_size); } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ERROR) { if (ex.error != TARGET_CLOSE_ERROR) { @@ -10971,6 +10970,7 @@ remote_get_trace_status (struct target_ops *self, struct trace_status *ts) } throw_exception (ex); } + END_CATCH result = packet_ok (p, &remote_protocol_packets[PACKET_qTStatus]); @@ -11537,7 +11537,6 @@ remote_enable_btrace (struct target_ops *self, ptid_t ptid, struct remote_state *rs = get_remote_state (); char *buf = rs->buf; char *endbuf = rs->buf + get_remote_packet_size (); - volatile struct gdb_exception err; if (packet_config_support (packet) != PACKET_ENABLE) error (_("Target does not support branch tracing.")); @@ -11565,11 +11564,16 @@ remote_enable_btrace (struct target_ops *self, ptid_t ptid, /* If we fail to read the configuration, we lose some information, but the tracing itself is not impacted. */ - TRY_CATCH (err, RETURN_MASK_ERROR) - btrace_read_config (&tinfo->conf); - - if (err.message != NULL) - warning ("%s", err.message); + TRY + { + btrace_read_config (&tinfo->conf); + } + CATCH (err, RETURN_MASK_ERROR) + { + if (err.message != NULL) + warning ("%s", err.message); + } + END_CATCH return tinfo; } diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c index 6940727..ca262e9 100644 --- a/gdb/rs6000-aix-tdep.c +++ b/gdb/rs6000-aix-tdep.c @@ -572,19 +572,20 @@ rs6000_convert_from_func_ptr_addr (struct gdbarch *gdbarch, { CORE_ADDR pc = 0; struct obj_section *pc_section; - volatile struct gdb_exception e; - TRY_CATCH (e, RETURN_MASK_ERROR) + TRY { pc = read_memory_unsigned_integer (addr, tdep->wordsize, byte_order); } - if (e.reason < 0) + CATCH (e, RETURN_MASK_ERROR) { /* An error occured during reading. Probably a memory error due to the section not being loaded yet. This address cannot be a function descriptor. */ return addr; } + END_CATCH + pc_section = find_pc_section (pc); if (pc_section && (pc_section->the_bfd_section->flags & SEC_CODE)) diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index 16ffaff..a125000 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -3355,7 +3355,6 @@ static const struct frame_unwind rs6000_frame_unwind = static struct rs6000_frame_cache * rs6000_epilogue_frame_cache (struct frame_info *this_frame, void **this_cache) { - volatile struct gdb_exception ex; struct rs6000_frame_cache *cache; struct gdbarch *gdbarch = get_frame_arch (this_frame); struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); @@ -3367,7 +3366,7 @@ rs6000_epilogue_frame_cache (struct frame_info *this_frame, void **this_cache) (*this_cache) = cache; cache->saved_regs = trad_frame_alloc_saved_regs (this_frame); - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { /* At this point the stack looks as if we just entered the function, and the return address is stored in LR. */ @@ -3382,11 +3381,12 @@ rs6000_epilogue_frame_cache (struct frame_info *this_frame, void **this_cache) trad_frame_set_value (cache->saved_regs, gdbarch_pc_regnum (gdbarch), lr); } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ERROR) { if (ex.error != NOT_AVAILABLE_ERROR) throw_exception (ex); } + END_CATCH return cache; } diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c index 769ec9b..e33eb8e 100644 --- a/gdb/s390-linux-tdep.c +++ b/gdb/s390-linux-tdep.c @@ -1950,7 +1950,6 @@ static struct s390_unwind_cache * s390_frame_unwind_cache (struct frame_info *this_frame, void **this_prologue_cache) { - volatile struct gdb_exception ex; struct s390_unwind_cache *info; if (*this_prologue_cache) @@ -1963,18 +1962,19 @@ s390_frame_unwind_cache (struct frame_info *this_frame, info->frame_base = -1; info->local_base = -1; - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { /* Try to use prologue analysis to fill the unwind cache. If this fails, fall back to reading the stack backchain. */ if (!s390_prologue_frame_unwind_cache (this_frame, info)) s390_backchain_frame_unwind_cache (this_frame, info); } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ERROR) { if (ex.error != NOT_AVAILABLE_ERROR) throw_exception (ex); } + END_CATCH return info; } diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c index 685534f..7da5833 100644 --- a/gdb/solib-dsbt.c +++ b/gdb/solib-dsbt.c @@ -820,7 +820,6 @@ enable_break (void) CORE_ADDR addr; gdb_byte addr_buf[TIC6X_PTR_SIZE]; struct int_elf32_dsbt_loadmap *ldm; - volatile struct gdb_exception ex; int ret; /* Read the contents of the .interp section into a local buffer; @@ -834,10 +833,15 @@ enable_break (void) loaded so that we can load its symbols and place a breakpoint in the dynamic linker itself. */ - TRY_CATCH (ex, RETURN_MASK_ALL) + TRY { tmp_bfd = solib_bfd_open (buf); } + CATCH (ex, RETURN_MASK_ALL) + { + } + END_CATCH + if (tmp_bfd == NULL) { enable_break_failure_warning (); diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c index 76f6527..f7ef38b 100644 --- a/gdb/solib-frv.c +++ b/gdb/solib-frv.c @@ -539,7 +539,6 @@ enable_break2 (void) CORE_ADDR addr, interp_loadmap_addr; gdb_byte addr_buf[FRV_PTR_SIZE]; struct int_elf32_fdpic_loadmap *ldm; - volatile struct gdb_exception ex; /* Read the contents of the .interp section into a local buffer; the contents specify the dynamic linker this program uses. */ @@ -557,10 +556,15 @@ enable_break2 (void) be trivial on GNU/Linux). Therefore, we have to try an alternate mechanism to find the dynamic linker's base address. */ - TRY_CATCH (ex, RETURN_MASK_ALL) + TRY { tmp_bfd = solib_bfd_open (buf); } + CATCH (ex, RETURN_MASK_ALL) + { + } + END_CATCH + if (tmp_bfd == NULL) { enable_break_failure_warning (); diff --git a/gdb/solib-ia64-hpux.c b/gdb/solib-ia64-hpux.c index 3b0bf48..b133c12 100644 --- a/gdb/solib-ia64-hpux.c +++ b/gdb/solib-ia64-hpux.c @@ -163,18 +163,20 @@ ia64_hpux_at_dld_breakpoint_1_p (ptid_t ptid) int ia64_hpux_at_dld_breakpoint_p (ptid_t ptid) { - volatile struct gdb_exception e; ptid_t saved_ptid = inferior_ptid; int result = 0; inferior_ptid = ptid; - TRY_CATCH (e, RETURN_MASK_ALL) + TRY { result = ia64_hpux_at_dld_breakpoint_1_p (ptid); } inferior_ptid = saved_ptid; - if (e.reason < 0) - warning (_("error while checking for dld breakpoint: %s"), e.message); + CATCH (e, RETURN_MASK_ALL) + { + warning (_("error while checking for dld breakpoint: %s"), e.message); + } + END_CATCH return result; } @@ -277,17 +279,19 @@ ia64_hpux_handle_dld_breakpoint_1 (ptid_t ptid) void ia64_hpux_handle_dld_breakpoint (ptid_t ptid) { - volatile struct gdb_exception e; ptid_t saved_ptid = inferior_ptid; inferior_ptid = ptid; - TRY_CATCH (e, RETURN_MASK_ALL) + TRY { ia64_hpux_handle_dld_breakpoint_1 (ptid); } inferior_ptid = saved_ptid; - if (e.reason < 0) - warning (_("error detected while handling dld breakpoint: %s"), e.message); + CATCH (e, RETURN_MASK_ALL) + { + warning (_("error detected while handling dld breakpoint: %s"), e.message); + } + END_CATCH } /* Find the address of the code and data segments in ABFD, and update diff --git a/gdb/solib-spu.c b/gdb/solib-spu.c index 3c8cd1a..250cf21 100644 --- a/gdb/solib-spu.c +++ b/gdb/solib-spu.c @@ -110,8 +110,7 @@ append_ocl_sos (struct so_list **link_ptr) { enum bfd_endian byte_order = bfd_big_endian (objfile->obfd)? BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE; - volatile struct gdb_exception ex; - TRY_CATCH (ex, RETURN_MASK_ALL) + TRY { CORE_ADDR data = read_memory_unsigned_integer (*ocl_program_addr_base, @@ -134,7 +133,7 @@ append_ocl_sos (struct so_list **link_ptr) link_ptr = &newobj->next; } } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ALL) { /* Ignore memory errors. */ switch (ex.error) @@ -146,6 +145,7 @@ append_ocl_sos (struct so_list **link_ptr) break; } } + END_CATCH } } } diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 3fa8d6f..0cecc2a 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -874,15 +874,18 @@ solib_svr4_r_map (struct svr4_info *info) struct link_map_offsets *lmo = svr4_fetch_link_map_offsets (); struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; CORE_ADDR addr = 0; - volatile struct gdb_exception ex; - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { addr = read_memory_typed_address (info->debug_base + lmo->r_map_offset, ptr_type); } - if (ex.reason < 0) - exception_print (gdb_stderr, ex); + CATCH (ex, RETURN_MASK_ERROR) + { + exception_print (gdb_stderr, ex); + } + END_CATCH + return addr; } @@ -2267,7 +2270,6 @@ enable_break (struct svr4_info *info, int from_tty) struct so_list *so; bfd *tmp_bfd = NULL; struct target_ops *tmp_bfd_target; - volatile struct gdb_exception ex; sym_addr = 0; @@ -2280,10 +2282,15 @@ enable_break (struct svr4_info *info, int from_tty) be trivial on GNU/Linux). Therefore, we have to try an alternate mechanism to find the dynamic linker's base address. */ - TRY_CATCH (ex, RETURN_MASK_ALL) + TRY { tmp_bfd = solib_bfd_open (interp_name); } + CATCH (ex, RETURN_MASK_ALL) + { + } + END_CATCH + if (tmp_bfd == NULL) goto bkpt_at_symbol; diff --git a/gdb/solib.c b/gdb/solib.c index 98d5cfd..8417f88 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -613,11 +613,10 @@ solib_read_symbols (struct so_list *so, int flags) } else { - volatile struct gdb_exception e; flags |= current_inferior ()->symfile_flags; - TRY_CATCH (e, RETURN_MASK_ERROR) + TRY { struct section_addr_info *sap; @@ -638,14 +637,17 @@ solib_read_symbols (struct so_list *so, int flags) NULL); so->objfile->addr_low = so->addr_low; free_section_addr_info (sap); + + so->symbols_loaded = 1; + } + CATCH (e, RETURN_MASK_ERROR) + { + exception_fprintf (gdb_stderr, e, _("Error while reading shared" + " library symbols for %s:\n"), + so->so_name); } + END_CATCH - if (e.reason < 0) - exception_fprintf (gdb_stderr, e, _("Error while reading shared" - " library symbols for %s:\n"), - so->so_name); - else - so->symbols_loaded = 1; return 1; } @@ -814,12 +816,11 @@ update_solib_list (int from_tty, struct target_ops *target) /* Fill in the rest of each of the `struct so_list' nodes. */ for (i = inferior; i; i = i->next) { - volatile struct gdb_exception e; i->pspace = current_program_space; VEC_safe_push (so_list_ptr, current_program_space->added_solibs, i); - TRY_CATCH (e, RETURN_MASK_ERROR) + TRY { /* Fill in the rest of the `struct so_list' node. */ if (!solib_map_sections (i)) @@ -830,10 +831,13 @@ update_solib_list (int from_tty, struct target_ops *target) } } - if (e.reason < 0) - exception_fprintf (gdb_stderr, e, - _("Error while mapping shared " - "library sections:\n")); + CATCH (e, RETURN_MASK_ERROR) + { + exception_fprintf (gdb_stderr, e, + _("Error while mapping shared " + "library sections:\n")); + } + END_CATCH /* Notify any observer that the shared object has been loaded now that we've added it to GDB's tables. */ @@ -1320,17 +1324,25 @@ reload_shared_libraries_1 (int from_tty) && (!was_loaded || filename_cmp (found_pathname, so->so_name) != 0)) { - volatile struct gdb_exception e; + int got_error = 0; - TRY_CATCH (e, RETURN_MASK_ERROR) - solib_map_sections (so); + TRY + { + solib_map_sections (so); + } + + CATCH (e, RETURN_MASK_ERROR) + { + exception_fprintf (gdb_stderr, e, + _("Error while mapping " + "shared library sections:\n")); + got_error = 1; + } + END_CATCH - if (e.reason < 0) - exception_fprintf (gdb_stderr, e, - _("Error while mapping " - "shared library sections:\n")); - else if (auto_solib_add || was_loaded || libpthread_solib_p (so)) - solib_read_symbols (so, flags); + if (!got_error + && (auto_solib_add || was_loaded || libpthread_solib_p (so))) + solib_read_symbols (so, flags); } } diff --git a/gdb/stack.c b/gdb/stack.c index 5831999..76a2360 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -154,19 +154,22 @@ print_stack_frame (struct frame_info *frame, int print_level, enum print_what print_what, int set_current_sal) { - volatile struct gdb_exception e; /* For mi, alway print location and address. */ if (ui_out_is_mi_like_p (current_uiout)) print_what = LOC_AND_ADDRESS; - TRY_CATCH (e, RETURN_MASK_ERROR) + TRY { print_frame_info (frame, print_level, print_what, 1 /* print_args */, set_current_sal); if (set_current_sal) set_current_sal_from_frame (frame); } + CATCH (e, RETURN_MASK_ERROR) + { + } + END_CATCH } /* Print nameless arguments of frame FRAME on STREAM, where START is @@ -210,9 +213,9 @@ static void print_frame_arg (const struct frame_arg *arg) { struct ui_out *uiout = current_uiout; - volatile struct gdb_exception except; struct cleanup *old_chain; struct ui_file *stb; + const char *error_message = NULL; stb = mem_fileopen (); old_chain = make_cleanup_ui_file_delete (stb); @@ -250,12 +253,10 @@ print_frame_arg (const struct frame_arg *arg) else { if (arg->error) - except.message = arg->error; + error_message = arg->error; else { - /* TRY_CATCH has two statements, wrap it in a block. */ - - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { const struct language_defn *language; struct value_print_options opts; @@ -284,10 +285,15 @@ print_frame_arg (const struct frame_arg *arg) common_val_print (arg->val, stb, 2, &opts, language); } + CATCH (except, RETURN_MASK_ERROR) + { + error_message = except.message; + } + END_CATCH } - if (except.message) + if (error_message != NULL) fprintf_filtered (stb, _("<error reading variable: %s>"), - except.message); + error_message); } ui_out_field_stream (uiout, "value", stb); @@ -306,17 +312,21 @@ void read_frame_local (struct symbol *sym, struct frame_info *frame, struct frame_arg *argp) { - volatile struct gdb_exception except; struct value *val = NULL; - TRY_CATCH (except, RETURN_MASK_ERROR) + argp->sym = sym; + argp->val = NULL; + argp->error = NULL; + + TRY { - val = read_var_value (sym, frame); + argp->val = read_var_value (sym, frame); } - - argp->error = (val == NULL) ? xstrdup (except.message) : NULL; - argp->sym = sym; - argp->val = val; + CATCH (except, RETURN_MASK_ERROR) + { + argp->error = xstrdup (except.message); + } + END_CATCH } /* Read in inferior function parameter SYM at FRAME into ARGP. Caller is @@ -330,20 +340,20 @@ read_frame_arg (struct symbol *sym, struct frame_info *frame, struct value *val = NULL, *entryval = NULL; char *val_error = NULL, *entryval_error = NULL; int val_equal = 0; - volatile struct gdb_exception except; if (print_entry_values != print_entry_values_only && print_entry_values != print_entry_values_preferred) { - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { val = read_var_value (sym, frame); } - if (!val) + CATCH (except, RETURN_MASK_ERROR) { val_error = alloca (strlen (except.message) + 1); strcpy (val_error, except.message); } + END_CATCH } if (SYMBOL_COMPUTED_OPS (sym) != NULL @@ -352,25 +362,25 @@ read_frame_arg (struct symbol *sym, struct frame_info *frame, && (print_entry_values != print_entry_values_if_needed || !val || value_optimized_out (val))) { - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { const struct symbol_computed_ops *ops; ops = SYMBOL_COMPUTED_OPS (sym); entryval = ops->read_variable_at_entry (sym, frame); } - if (!entryval) + CATCH (except, RETURN_MASK_ERROR) { - entryval_error = alloca (strlen (except.message) + 1); - strcpy (entryval_error, except.message); + if (except.error != NO_ENTRY_VALUE_ERROR) + { + entryval_error = (char *) alloca (strlen (except.message) + 1); + strcpy (entryval_error, except.message); + } } + END_CATCH - if (except.error == NO_ENTRY_VALUE_ERROR - || (entryval && value_optimized_out (entryval))) - { - entryval = NULL; - entryval_error = NULL; - } + if (entryval != NULL && value_optimized_out (entryval)) + entryval = NULL; if (print_entry_values == print_entry_values_compact || print_entry_values == print_entry_values_default) @@ -396,7 +406,7 @@ read_frame_arg (struct symbol *sym, struct frame_info *frame, dereferenced DW_AT_GNU_call_site_data_value does not differ. */ - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { struct type *type_deref; @@ -417,19 +427,23 @@ read_frame_arg (struct symbol *sym, struct frame_info *frame, TYPE_LENGTH (type_deref))) val_equal = 1; } + CATCH (except, RETURN_MASK_ERROR) + { + /* If the dereferenced content could not be + fetched do not display anything. */ + if (except.error == NO_ENTRY_VALUE_ERROR) + val_equal = 1; + else if (except.message != NULL) + { + entryval_error = (char *) alloca (strlen (except.message) + 1); + strcpy (entryval_error, except.message); + } + } + END_CATCH /* Value was not a reference; and its content matches. */ if (val == val_deref) val_equal = 1; - /* If the dereferenced content could not be fetched do not - display anything. */ - else if (except.error == NO_ENTRY_VALUE_ERROR) - val_equal = 1; - else if (except.message) - { - entryval_error = alloca (strlen (except.message) + 1); - strcpy (entryval_error, except.message); - } if (val_equal) entryval = NULL; @@ -455,15 +469,18 @@ read_frame_arg (struct symbol *sym, struct frame_info *frame, { if (print_entry_values == print_entry_values_preferred) { - TRY_CATCH (except, RETURN_MASK_ERROR) + gdb_assert (val == NULL); + + TRY { val = read_var_value (sym, frame); } - if (!val) + CATCH (except, RETURN_MASK_ERROR) { val_error = alloca (strlen (except.message) + 1); strcpy (val_error, except.message); } + END_CATCH } if (print_entry_values == print_entry_values_only || print_entry_values == print_entry_values_both @@ -748,20 +765,20 @@ static void do_gdb_disassembly (struct gdbarch *gdbarch, int how_many, CORE_ADDR low, CORE_ADDR high) { - volatile struct gdb_exception exception; - TRY_CATCH (exception, RETURN_MASK_ERROR) + TRY { gdb_disassembly (gdbarch, current_uiout, 0, DISASSEMBLY_RAW_INSN, how_many, low, high); } - if (exception.reason < 0) + CATCH (exception, RETURN_MASK_ERROR) { /* If an exception was thrown while doing the disassembly, print the error message, to give the user a clue of what happened. */ exception_print (gdb_stderr, exception); } + END_CATCH } /* Print information about frame FRAME. The output is format according @@ -1188,7 +1205,6 @@ print_frame (struct frame_info *frame, int print_level, struct gdbarch *gdbarch = get_frame_arch (frame); int numargs; struct cleanup *args_list_chain; - volatile struct gdb_exception e; if (gdbarch_frame_num_args_p (gdbarch)) { @@ -1199,10 +1215,15 @@ print_frame (struct frame_info *frame, int print_level, numargs = -1; args_list_chain = make_cleanup_ui_out_list_begin_end (uiout, "args"); - TRY_CATCH (e, RETURN_MASK_ERROR) + TRY { print_frame_args (func, frame, numargs, gdb_stdout); } + CATCH (e, RETURN_MASK_ERROR) + { + } + END_CATCH + /* FIXME: ARGS must be a list. If one argument is a string it will have " that will not be properly escaped. */ /* Invoke ui_out_tuple_end. */ @@ -1410,7 +1431,7 @@ frame_info (char *addr_exp, int from_tty) int frame_pc_p; /* Initialize it to avoid "may be used uninitialized" warning. */ CORE_ADDR caller_pc = 0; - volatile struct gdb_exception ex; + int caller_pc_p = 0; fi = parse_frame_specification_1 (addr_exp, "No stack.", &selected_frame_p); gdbarch = get_frame_arch (fi); @@ -1498,11 +1519,12 @@ frame_info (char *addr_exp, int from_tty) wrap_here (" "); printf_filtered ("saved %s = ", pc_regname); - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { caller_pc = frame_unwind_caller_pc (fi); + caller_pc_p = 1; } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ERROR) { switch (ex.error) { @@ -1517,7 +1539,9 @@ frame_info (char *addr_exp, int from_tty) break; } } - else + END_CATCH + + if (caller_pc_p) fputs_filtered (paddress (gdbarch, caller_pc), gdb_stdout); printf_filtered ("\n"); @@ -2571,8 +2595,8 @@ get_frame_language (void) if (frame) { - volatile struct gdb_exception ex; CORE_ADDR pc = 0; + int pc_p = 0; /* We determine the current frame language by looking up its associated symtab. To retrieve this symtab, we use the frame @@ -2583,16 +2607,19 @@ get_frame_language (void) a PC that is guaranteed to be inside the frame's code block. */ - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { pc = get_frame_address_in_block (frame); + pc_p = 1; } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ERROR) { if (ex.error != NOT_AVAILABLE_ERROR) throw_exception (ex); } - else + END_CATCH + + if (pc_p) { struct compunit_symtab *cust = find_pc_compunit_symtab (pc); diff --git a/gdb/symtab.c b/gdb/symtab.c index aebe2d9..634cf97 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -5500,21 +5500,21 @@ default_make_symbol_completion_list_break_on (const char *text, enum type_code code) { struct cleanup *back_to; - volatile struct gdb_exception except; return_val = NULL; back_to = make_cleanup (do_free_completion_list, &return_val); - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { default_make_symbol_completion_list_break_on_1 (text, word, break_on, code); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { if (except.error != MAX_COMPLETIONS_REACHED_ERROR) throw_exception (except); } + END_CATCH discard_cleanups (back_to); return return_val; diff --git a/gdb/target.c b/gdb/target.c index d66560a..af94f48 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -814,9 +814,8 @@ target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset) if (gdbarch_fetch_tls_load_module_address_p (target_gdbarch ())) { ptid_t ptid = inferior_ptid; - volatile struct gdb_exception ex; - TRY_CATCH (ex, RETURN_MASK_ALL) + TRY { CORE_ADDR lm_addr; @@ -829,7 +828,7 @@ target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset) } /* If an error occurred, print TLS related messages here. Otherwise, throw the error to some higher catcher. */ - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ALL) { int objfile_is_library = (objfile->flags & OBJF_SHARED); @@ -878,6 +877,7 @@ target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset) break; } } + END_CATCH } /* It wouldn't be wrong here to try a gdbarch method, too; finding TLS is an ABI-specific thing. But we don't do that yet. */ @@ -1465,7 +1465,6 @@ quit_force (char *args, int from_tty) { int exit_code = 0; struct qt_args qt; - volatile struct gdb_exception ex; /* An optional expression may be used to cause gdb to terminate with the value of that expression. */ @@ -1484,40 +1483,52 @@ quit_force (char *args, int from_tty) /* We want to handle any quit errors and exit regardless. */ /* Get out of tfind mode, and kill or detach all inferiors. */ - TRY_CATCH (ex, RETURN_MASK_ALL) + TRY { disconnect_tracing (); iterate_over_inferiors (kill_or_detach, &qt); } - if (ex.reason < 0) - exception_print (gdb_stderr, ex); + CATCH (ex, RETURN_MASK_ALL) + { + exception_print (gdb_stderr, ex); + } + END_CATCH /* Give all pushed targets a chance to do minimal cleanup, and pop them all out. */ - TRY_CATCH (ex, RETURN_MASK_ALL) + TRY { pop_all_targets (); } - if (ex.reason < 0) - exception_print (gdb_stderr, ex); + CATCH (ex, RETURN_MASK_ALL) + { + exception_print (gdb_stderr, ex); + } + END_CATCH /* Save the history information if it is appropriate to do so. */ - TRY_CATCH (ex, RETURN_MASK_ALL) + TRY { if (write_history_p && history_filename && input_from_terminal_p ()) gdb_safe_append_history (); } - if (ex.reason < 0) - exception_print (gdb_stderr, ex); + CATCH (ex, RETURN_MASK_ALL) + { + exception_print (gdb_stderr, ex); + } + END_CATCH /* Do any final cleanups before exiting. */ - TRY_CATCH (ex, RETURN_MASK_ALL) + TRY { do_final_cleanups (all_cleanups ()); } - if (ex.reason < 0) - exception_print (gdb_stderr, ex); + CATCH (ex, RETURN_MASK_ALL) + { + exception_print (gdb_stderr, ex); + } + END_CATCH exit (exit_code); } diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c index 3ee7243..9747036 100644 --- a/gdb/tracefile-tfile.c +++ b/gdb/tracefile-tfile.c @@ -378,7 +378,6 @@ tfile_read (gdb_byte *readbuf, int size) static void tfile_open (const char *arg, int from_tty) { - volatile struct gdb_exception ex; char *temp; struct cleanup *old_chain; int flags; @@ -443,7 +442,7 @@ tfile_open (const char *arg, int from_tty) ts->disconnected_tracing = 0; ts->circular_buffer = 0; - TRY_CATCH (ex, RETURN_MASK_ALL) + TRY { /* Read through a section of newline-terminated lines that define things like tracepoints. */ @@ -476,12 +475,13 @@ tfile_open (const char *arg, int from_tty) if (trace_regblock_size == 0) error (_("No register block size recorded in trace file")); } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ALL) { /* Remove the partially set up target. */ unpush_target (&tfile_ops); throw_exception (ex); } + END_CATCH inferior_appeared (current_inferior (), TFILE_PID); inferior_ptid = pid_to_ptid (TFILE_PID); diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c index 0397ee9..9fac06e 100644 --- a/gdb/tui/tui.c +++ b/gdb/tui/tui.c @@ -90,11 +90,10 @@ static Keymap tui_readline_standard_keymap; static int tui_rl_switch_mode (int notused1, int notused2) { - volatile struct gdb_exception ex; /* Don't let exceptions escape. We're in the middle of a readline callback that isn't prepared for that. */ - TRY_CATCH (ex, RETURN_MASK_ALL) + TRY { if (tui_active) { @@ -108,13 +107,14 @@ tui_rl_switch_mode (int notused1, int notused2) tui_enable (); } } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ALL) { exception_print (gdb_stderr, ex); if (!tui_active) rl_prep_terminal (0); } + END_CATCH /* Clear the readline in case switching occurred in middle of something. */ diff --git a/gdb/typeprint.c b/gdb/typeprint.c index 234be7f..5a97ace 100644 --- a/gdb/typeprint.c +++ b/gdb/typeprint.c @@ -372,18 +372,20 @@ type_to_string (struct type *type) char *s = NULL; struct ui_file *stb; struct cleanup *old_chain; - volatile struct gdb_exception except; stb = mem_fileopen (); old_chain = make_cleanup_ui_file_delete (stb); - TRY_CATCH (except, RETURN_MASK_ALL) + TRY { type_print (type, "", stb, -1); s = ui_file_xstrdup (stb, NULL); } - if (except.reason < 0) - s = NULL; + CATCH (except, RETURN_MASK_ALL) + { + s = NULL; + } + END_CATCH do_cleanups (old_chain); diff --git a/gdb/valops.c b/gdb/valops.c index b096a51..66c63c1 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -3601,13 +3601,12 @@ value_rtti_indirect_type (struct value *v, int *full, target = coerce_ref (v); else if (TYPE_CODE (type) == TYPE_CODE_PTR) { - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { target = value_ind (v); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { if (except.error == MEMORY_ERROR) { @@ -3618,6 +3617,7 @@ value_rtti_indirect_type (struct value *v, int *full, } throw_exception (except); } + END_CATCH } else return NULL; @@ -3754,12 +3754,15 @@ struct value * value_of_this_silent (const struct language_defn *lang) { struct value *ret = NULL; - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { ret = value_of_this (lang); } + CATCH (except, RETURN_MASK_ERROR) + { + } + END_CATCH return ret; } diff --git a/gdb/valprint.c b/gdb/valprint.c index 29a3473..9a70b2f 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -740,7 +740,6 @@ val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, const struct value_print_options *options, const struct language_defn *language) { - volatile struct gdb_exception except; int ret = 0; struct value_print_options local_opts = *options; struct type *real_type = check_typedef (type); @@ -782,14 +781,17 @@ val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, return; } - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { language->la_val_print (type, valaddr, embedded_offset, address, stream, recurse, val, &local_opts); } - if (except.reason < 0) - fprintf_filtered (stream, _("<error reading variable>")); + CATCH (except, RETURN_MASK_ERROR) + { + fprintf_filtered (stream, _("<error reading variable>")); + } + END_CATCH } /* Check whether the value VAL is printable. Return 1 if it is; diff --git a/gdb/value.c b/gdb/value.c index b9a45ef..cb56849 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -2545,7 +2545,6 @@ show_convenience (char *ignore, int from_tty) get_user_print_options (&opts); for (var = internalvars; var; var = var->next) { - volatile struct gdb_exception ex; if (!varseen) { @@ -2553,15 +2552,19 @@ show_convenience (char *ignore, int from_tty) } printf_filtered (("$%s = "), var->name); - TRY_CATCH (ex, RETURN_MASK_ERROR) + TRY { struct value *val; val = value_of_internalvar (gdbarch, var); value_print (val, gdb_stdout, &opts); } - if (ex.reason < 0) - fprintf_filtered (gdb_stdout, _("<error: %s>"), ex.message); + CATCH (ex, RETURN_MASK_ERROR) + { + fprintf_filtered (gdb_stdout, _("<error: %s>"), ex.message); + } + END_CATCH + printf_filtered (("\n")); } if (!varseen) diff --git a/gdb/varobj.c b/gdb/varobj.c index ce80bc7..b220fd8 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -298,7 +298,6 @@ varobj_create (char *objname, const struct block *block; const char *p; struct value *value = NULL; - volatile struct gdb_exception except; CORE_ADDR pc; /* Parse and evaluate the expression, filling in as much of the @@ -338,16 +337,17 @@ varobj_create (char *objname, innermost_block = NULL; /* Wrap the call to parse expression, so we can return a sensible error. */ - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { var->root->exp = parse_exp_1 (&p, pc, block, 0); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { do_cleanups (old_chain); return NULL; } + END_CATCH /* Don't allow variables to be created for types. */ if (var->root->exp->elts[0].opcode == OP_TYPE @@ -388,12 +388,11 @@ 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(). */ - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { value = evaluate_expression (var->root->exp); } - - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { /* Error getting the value. Try to at least get the right type. */ @@ -401,14 +400,16 @@ varobj_create (char *objname, var->type = value_type (type_only_value); } - else - { - int real_type_found = 0; + END_CATCH - var->type = value_actual_type (value, 0, &real_type_found); - if (real_type_found) - value = value_cast (var->type, value); - } + if (value != NULL) + { + int real_type_found = 0; + + var->type = value_actual_type (value, 0, &real_type_found); + if (real_type_found) + value = value_cast (var->type, value); + } /* Set language info */ var->root->lang_ops = var->root->exp->language_defn->la_varobj_ops; @@ -1103,23 +1104,23 @@ varobj_set_value (struct varobj *var, char *expression) struct value *value = NULL; /* Initialize to keep gcc happy. */ int saved_input_radix = input_radix; const 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, 0); - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { value = evaluate_expression (exp); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { /* We cannot proceed without a valid expression. */ xfree (exp); return 0; } + END_CATCH /* All types that are editable must also be changeable. */ gdb_assert (varobj_value_is_changeable_p (var)); @@ -1138,13 +1139,16 @@ varobj_set_value (struct varobj *var, char *expression) /* The new value may be lazy. value_assign, or rather value_contents, will take care of this. */ - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { val = value_assign (var->value, value); } - if (except.reason < 0) - return 0; + CATCH (except, RETURN_MASK_ERROR) + { + return 0; + } + END_CATCH /* 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 @@ -1395,20 +1399,20 @@ install_new_value (struct varobj *var, struct value *value, int initial) } else { - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { value_fetch_lazy (value); } - if (except.reason < 0) + CATCH (except, RETURN_MASK_ERROR) { /* 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; } + END_CATCH } } @@ -2369,14 +2373,17 @@ value_of_root_1 (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. */ - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { new_val = evaluate_expression (var->root->exp); } + CATCH (except, RETURN_MASK_ERROR) + { + } + END_CATCH } do_cleanups (back_to); diff --git a/gdb/xml-support.c b/gdb/xml-support.c index 4306c5c..9756acb 100644 --- a/gdb/xml-support.c +++ b/gdb/xml-support.c @@ -313,22 +313,22 @@ gdb_xml_start_element_wrapper (void *data, const XML_Char *name, const XML_Char **attrs) { struct gdb_xml_parser *parser = data; - volatile struct gdb_exception ex; if (parser->error.reason < 0) return; - TRY_CATCH (ex, RETURN_MASK_ALL) + TRY { gdb_xml_start_element (data, name, attrs); } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ALL) { parser->error = ex; #ifdef HAVE_XML_STOPPARSER XML_StopParser (parser->expat_parser, XML_FALSE); #endif } + END_CATCH } /* Handle the end of an element. DATA is our local XML parser, and @@ -396,22 +396,22 @@ static void gdb_xml_end_element_wrapper (void *data, const XML_Char *name) { struct gdb_xml_parser *parser = data; - volatile struct gdb_exception ex; if (parser->error.reason < 0) return; - TRY_CATCH (ex, RETURN_MASK_ALL) + TRY { gdb_xml_end_element (data, name); } - if (ex.reason < 0) + CATCH (ex, RETURN_MASK_ALL) { parser->error = ex; #ifdef HAVE_XML_STOPPARSER XML_StopParser (parser->expat_parser, XML_FALSE); #endif } + END_CATCH } /* Free a parser and all its associated state. */ |