X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fbreakpoint.c;h=00fd76220e272432c3744888d13be71aba9434ca;hb=268a13a5a3f7c6b9b6ffc5ac2d1b24eb41f3fbdc;hp=33c5bfef43d3b5e08c86790875fa3d2f16100763;hpb=89f8fb50fa16b0ef510dcd6de9088cee9820116d;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 33c5bfef43..00fd76220e 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -65,10 +65,11 @@ #include "ax-gdb.h" #include "dummy-frame.h" #include "interps.h" -#include "format.h" +#include "gdbsupport/format.h" #include "thread-fsm.h" #include "tid-parse.h" #include "cli/cli-style.h" +#include "mi/mi-main.h" /* readline include files */ #include "readline/readline.h" @@ -81,16 +82,8 @@ #include "extension.h" #include #include "progspace-and-thread.h" -#include "common/array-view.h" -#include "common/gdb_optional.h" - -/* Enums for exception-handling support. */ -enum exception_event_kind -{ - EX_EVENT_THROW, - EX_EVENT_RETHROW, - EX_EVENT_CATCH -}; +#include "gdbsupport/array-view.h" +#include "gdbsupport/gdb_optional.h" /* Prototypes for local functions. */ @@ -879,12 +872,12 @@ set_breakpoint_condition (struct breakpoint *b, const char *exp, { struct watchpoint *w = (struct watchpoint *) b; - innermost_block.reset (); + innermost_block_tracker tracker; arg = exp; - w->cond_exp = parse_exp_1 (&arg, 0, 0, 0); + w->cond_exp = parse_exp_1 (&arg, 0, 0, 0, &tracker); if (*arg) error (_("Junk at end of expression")); - w->cond_exp_valid_block = innermost_block.block (); + w->cond_exp_valid_block = tracker.block (); } else { @@ -940,10 +933,7 @@ condition_completer (struct cmd_list_element *cmd, xsnprintf (number, sizeof (number), "%d", b->number); if (strncmp (number, text, len) == 0) - { - gdb::unique_xmalloc_ptr copy (xstrdup (number)); - tracker.add_completion (std::move (copy)); - } + tracker.add_completion (make_unique_xstrdup (number)); } return; @@ -2096,18 +2086,17 @@ parse_cond_to_aexpr (CORE_ADDR scope, struct expression *cond) /* We don't want to stop processing, so catch any errors that may show up. */ - TRY + try { aexpr = gen_eval_for_expr (scope, cond); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_error &ex) { /* 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. */ } - END_CATCH /* We have a valid agent expression. */ return aexpr; @@ -2271,19 +2260,18 @@ 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 + try { aexpr = gen_printf (scope, gdbarch, 0, 0, format_start, format_end - format_start, argvec.size (), argvec.data ()); } - CATCH (ex, RETURN_MASK_ERROR) + catch (const gdb_exception_error &ex) { /* 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. */ } - END_CATCH /* We have a valid agent expression, return it. */ return aexpr; @@ -2435,7 +2423,7 @@ insert_bp_location (struct bp_location *bl, int *hw_breakpoint_error, int *hw_bp_error_explained_already) { - gdb_exception bp_excpt = exception_none; + gdb_exception bp_excpt; if (!should_be_inserted (bl) || (bl->inserted && !bl->needs_update)) return 0; @@ -2538,7 +2526,7 @@ insert_bp_location (struct bp_location *bl, || !(section_is_overlay (bl->section))) { /* No overlay handling: just set the breakpoint. */ - TRY + try { int val; @@ -2546,11 +2534,10 @@ insert_bp_location (struct bp_location *bl, if (val) bp_excpt = gdb_exception {RETURN_ERROR, GENERIC_ERROR}; } - CATCH (e, RETURN_MASK_ALL) + catch (gdb_exception &e) { - bp_excpt = e; + bp_excpt = std::move (e); } - END_CATCH } else { @@ -2573,7 +2560,7 @@ insert_bp_location (struct bp_location *bl, bl->overlay_target_info.reqstd_address = addr; /* No overlay handling: just set the breakpoint. */ - TRY + try { int val; @@ -2586,11 +2573,10 @@ insert_bp_location (struct bp_location *bl, bp_excpt = gdb_exception {RETURN_ERROR, GENERIC_ERROR}; } - CATCH (e, RETURN_MASK_ALL) + catch (gdb_exception &e) { - bp_excpt = e; + bp_excpt = std::move (e); } - END_CATCH if (bp_excpt.reason != 0) fprintf_unfiltered (tmp_error_stream, @@ -2603,7 +2589,7 @@ insert_bp_location (struct bp_location *bl, if (section_is_mapped (bl->section)) { /* Yes. This overlay section is mapped into memory. */ - TRY + try { int val; @@ -2611,11 +2597,10 @@ insert_bp_location (struct bp_location *bl, if (val) bp_excpt = gdb_exception {RETURN_ERROR, GENERIC_ERROR}; } - CATCH (e, RETURN_MASK_ALL) + catch (gdb_exception &e) { - bp_excpt = e; + bp_excpt = std::move (e); } - END_CATCH } else { @@ -2674,7 +2659,7 @@ insert_bp_location (struct bp_location *bl, bp_excpt.message ? ":" : ".\n"); if (bp_excpt.message != NULL) fprintf_unfiltered (tmp_error_stream, "%s.\n", - bp_excpt.message); + bp_excpt.what ()); } else { @@ -2694,7 +2679,7 @@ insert_bp_location (struct bp_location *bl, fprintf_unfiltered (tmp_error_stream, "Cannot insert breakpoint %d: %s\n", bl->owner->number, - bp_excpt.message); + bp_excpt.what ()); } } return 1; @@ -3064,9 +3049,9 @@ Thread-specific breakpoint %d deleted - thread %s no longer in the thread list.\ } } -/* Remove breakpoints of inferior INF. */ +/* See breakpoint.h. */ -int +void remove_breakpoints_inf (inferior *inf) { struct bp_location *bl, **blp_tmp; @@ -3081,10 +3066,9 @@ remove_breakpoints_inf (inferior *inf) { val = remove_breakpoint (bl); if (val != 0) - return val; + return; } } - return 0; } static int internal_breakpoint_number = -1; @@ -3160,7 +3144,8 @@ struct breakpoint_objfile_data std::vector exception_probes; }; -static const struct objfile_data *breakpoint_objfile_key; +static const struct objfile_key + breakpoint_objfile_key; /* Minimal symbol not found sentinel. */ static struct minimal_symbol msym_not_found; @@ -3181,25 +3166,12 @@ get_breakpoint_objfile_data (struct objfile *objfile) { struct breakpoint_objfile_data *bp_objfile_data; - bp_objfile_data = ((struct breakpoint_objfile_data *) - objfile_data (objfile, breakpoint_objfile_key)); + bp_objfile_data = breakpoint_objfile_key.get (objfile); if (bp_objfile_data == NULL) - { - bp_objfile_data = new breakpoint_objfile_data (); - set_objfile_data (objfile, breakpoint_objfile_key, bp_objfile_data); - } + bp_objfile_data = breakpoint_objfile_key.emplace (objfile); return bp_objfile_data; } -static void -free_breakpoint_objfile_data (struct objfile *obj, void *data) -{ - struct breakpoint_objfile_data *bp_objfile_data - = (struct breakpoint_objfile_data *) data; - - delete bp_objfile_data; -} - static void create_overlay_event_breakpoint (void) { @@ -4468,7 +4440,7 @@ get_bpstat_thread () void bpstat_do_actions (void) { - struct cleanup *cleanup_if_error = make_bpstat_clear_actions_cleanup (); + auto cleanup_if_error = make_scope_exit (bpstat_clear_actions); thread_info *tp; /* Do any commands attached to breakpoint we are stopped at. */ @@ -4482,7 +4454,7 @@ bpstat_do_actions (void) break; } - discard_cleanups (cleanup_if_error); + cleanup_if_error.release (); } /* Print out the (old or new) value associated with a watchpoint. */ @@ -5016,11 +4988,11 @@ bpstat_check_watchpoint (bpstat bs) { wp_check_result e; - TRY + try { e = watchpoint_check (bs); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception &ex) { exception_fprintf (gdb_stderr, ex, "Error evaluating expression " @@ -5035,7 +5007,6 @@ bpstat_check_watchpoint (bpstat bs) watchpoint_del_at_next_stop (b); e = WP_DELETED; } - END_CATCH switch (e) { @@ -5254,16 +5225,15 @@ bpstat_check_breakpoint_conditions (bpstat bs, thread_info *thread) } if (within_current_scope) { - TRY + try { condition_result = breakpoint_cond_eval (cond); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception &ex) { exception_fprintf (gdb_stderr, ex, "Error in testing breakpoint condition:\n"); } - END_CATCH } else { @@ -6355,18 +6325,27 @@ print_one_breakpoint_location (struct breakpoint *b, } } +/* See breakpoint.h. */ + +bool fix_multi_location_breakpoint_output_globally = false; + static void print_one_breakpoint (struct breakpoint *b, struct bp_location **last_loc, int allflag) { struct ui_out *uiout = current_uiout; + bool use_fixed_output + = (uiout->test_flags (fix_multi_location_breakpoint_output) + || fix_multi_location_breakpoint_output_globally); - { - ui_out_emit_tuple tuple_emitter (uiout, "bkpt"); + gdb::optional bkpt_tuple_emitter (gdb::in_place, uiout, "bkpt"); + print_one_breakpoint_location (b, NULL, 0, last_loc, allflag); - print_one_breakpoint_location (b, NULL, 0, last_loc, allflag); - } + /* The mi2 broken format: the main breakpoint tuple ends here, the locations + are outside. */ + if (!use_fixed_output) + bkpt_tuple_emitter.reset (); /* If this breakpoint has custom print function, it's already printed. Otherwise, print individual @@ -6384,12 +6363,18 @@ print_one_breakpoint (struct breakpoint *b, && !is_hardware_watchpoint (b) && (b->loc->next || !b->loc->enabled)) { - struct bp_location *loc; - int n = 1; + gdb::optional locations_list; + + /* For MI version <= 2, keep the behavior where GDB outputs an invalid + MI record. For later versions, place breakpoint locations in a + list. */ + if (uiout->is_mi_like_p () && use_fixed_output) + locations_list.emplace (uiout, "locations"); - for (loc = b->loc; loc; loc = loc->next, ++n) + int n = 1; + for (bp_location *loc = b->loc; loc != NULL; loc = loc->next, ++n) { - ui_out_emit_tuple tuple_emitter (uiout, NULL); + ui_out_emit_tuple loc_tuple_emitter (uiout, NULL); print_one_breakpoint_location (b, loc, n, last_loc, allflag); } } @@ -6701,7 +6686,7 @@ describe_other_breakpoints (struct gdbarch *gdbarch, : ((others == 1) ? " and" : "")); } printf_filtered (_("also set at pc ")); - fputs_filtered (paddress (gdbarch, pc), gdb_stdout); + fputs_styled (paddress (gdbarch, pc), address_style.style (), gdb_stdout); printf_filtered (".\n"); } } @@ -6958,13 +6943,10 @@ adjust_breakpoint_address (struct gdbarch *gdbarch, } } -bp_location::bp_location (const bp_location_ops *ops, breakpoint *owner) +bp_location::bp_location (breakpoint *owner) { bp_location *loc = this; - gdb_assert (ops != NULL); - - loc->ops = ops; loc->owner = owner; loc->cond_bytecode = NULL; loc->shlib_disabled = 0; @@ -7033,7 +7015,6 @@ allocate_bp_location (struct breakpoint *bpt) static void free_bp_location (struct bp_location *loc) { - loc->ops->dtor (loc); delete loc; } @@ -7114,12 +7095,10 @@ set_raw_breakpoint_without_location (struct gdbarch *gdbarch, return add_to_breakpoint_chain (std::move (b)); } -/* Initialize loc->function_name. EXPLICIT_LOC says no indirect function - resolutions should be made as the user specified the location explicitly - enough. */ +/* Initialize loc->function_name. */ static void -set_breakpoint_location_function (struct bp_location *loc, int explicit_loc) +set_breakpoint_location_function (struct bp_location *loc) { gdb_assert (loc->owner != NULL); @@ -7131,8 +7110,7 @@ set_breakpoint_location_function (struct bp_location *loc, int explicit_loc) if (loc->msymbol != NULL && (MSYMBOL_TYPE (loc->msymbol) == mst_text_gnu_ifunc - || MSYMBOL_TYPE (loc->msymbol) == mst_data_gnu_ifunc) - && !explicit_loc) + || MSYMBOL_TYPE (loc->msymbol) == mst_data_gnu_ifunc)) { struct breakpoint *b = loc->owner; @@ -8500,7 +8478,7 @@ momentary_breakpoint_from_master (struct breakpoint *orig, copy = set_raw_breakpoint_without_location (orig->gdbarch, type, ops); copy->loc = allocate_bp_location (copy); - set_breakpoint_location_function (copy->loc, 1); + set_breakpoint_location_function (copy->loc); copy->loc->gdbarch = orig->loc->gdbarch; copy->loc->requested_address = orig->loc->requested_address; @@ -8605,8 +8583,7 @@ add_location_to_breakpoint (struct breakpoint *b, loc->msymbol = sal->msymbol; loc->objfile = sal->objfile; - set_breakpoint_location_function (loc, - sal->explicit_pc || sal->explicit_line); + set_breakpoint_location_function (loc); /* While by definition, permanent breakpoints are already present in the code, we don't mark the location as inserted. Normally one would expect @@ -9240,11 +9217,11 @@ create_breakpoint (struct gdbarch *gdbarch, if (extra_string != NULL && *extra_string == '\0') extra_string = NULL; - TRY + try { ops->create_sals_from_location (location, &canonical, type_wanted); } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_error &e) { /* If caller is interested in rc value from parse, set value. */ @@ -9254,7 +9231,7 @@ create_breakpoint (struct gdbarch *gdbarch, error. */ if (pending_break_support == AUTO_BOOLEAN_FALSE) - throw_exception (e); + throw; exception_print (gdb_stderr, e); @@ -9272,9 +9249,8 @@ create_breakpoint (struct gdbarch *gdbarch, pending = 1; } else - throw_exception (e); + throw; } - END_CATCH if (!pending && canonical.lsals.empty ()) return 0; @@ -9512,7 +9488,7 @@ stopin_command (const char *arg, int from_tty) { int badInput = 0; - if (arg == (char *) NULL) + if (arg == NULL) badInput = 1; else if (*arg != '*') { @@ -9545,7 +9521,7 @@ stopat_command (const char *arg, int from_tty) { int badInput = 0; - if (arg == (char *) NULL || *arg == '*') /* no line number */ + if (arg == NULL || *arg == '*') /* no line number */ badInput = 1; else { @@ -10596,10 +10572,10 @@ watch_command_1 (const char *arg, int accessflag, int from_tty, /* Parse the rest of the arguments. From here on out, everything is in terms of a newly allocated string instead of the original ARG. */ - innermost_block.reset (); std::string expression (arg, exp_end - arg); exp_start = arg = expression.c_str (); - expression_up exp = parse_exp_1 (&arg, 0, 0, 0); + innermost_block_tracker tracker; + expression_up exp = parse_exp_1 (&arg, 0, 0, 0, &tracker); exp_end = arg; /* Remove trailing whitespace from the expression before saving it. This makes the eventual display of the expression string a bit @@ -10618,7 +10594,7 @@ watch_command_1 (const char *arg, int accessflag, int from_tty, error (_("Cannot watch constant value `%.*s'."), len, exp_start); } - exp_valid_block = innermost_block.block (); + exp_valid_block = tracker.block (); struct value *mark = value_mark (); struct value *val_as_value = nullptr; fetch_subexp_value (exp.get (), &pc, &val_as_value, &result, NULL, @@ -10658,13 +10634,13 @@ watch_command_1 (const char *arg, int accessflag, int from_tty, toklen = end_tok - tok; if (toklen >= 1 && strncmp (tok, "if", toklen) == 0) { - innermost_block.reset (); tok = cond_start = end_tok + 1; - parse_exp_1 (&tok, 0, 0, 0); + innermost_block_tracker if_tracker; + parse_exp_1 (&tok, 0, 0, 0, &if_tracker); /* The watchpoint expression may not be local, but the condition may still be. E.g.: `watch global if local > 0'. */ - cond_exp_valid_block = innermost_block.block (); + cond_exp_valid_block = if_tracker.block (); cond_end = tok; } @@ -10907,10 +10883,7 @@ watch_maybe_just_location (const char *arg, int accessflag, int from_tty) if (arg && (check_for_argument (&arg, "-location", sizeof ("-location") - 1) || check_for_argument (&arg, "-l", sizeof ("-l") - 1))) - { - arg = skip_spaces (arg); - just_location = 1; - } + just_location = 1; watch_command_1 (arg, accessflag, from_tty, just_location, 0); } @@ -10950,106 +10923,66 @@ awatch_command (const char *arg, int from_tty) in infcmd.c. Here because it uses the mechanisms of breakpoints. */ -struct until_break_fsm +struct until_break_fsm : public thread_fsm { - /* The base class. */ - struct thread_fsm thread_fsm; - - /* The thread that as current when the command was executed. */ + /* The thread that was current when the command was executed. */ int thread; /* The breakpoint set at the destination location. */ - struct breakpoint *location_breakpoint; + breakpoint_up location_breakpoint; /* Breakpoint set at the return address in the caller frame. May be NULL. */ - struct breakpoint *caller_breakpoint; -}; - -static void until_break_fsm_clean_up (struct thread_fsm *self, - struct thread_info *thread); -static int until_break_fsm_should_stop (struct thread_fsm *self, - struct thread_info *thread); -static enum async_reply_reason - until_break_fsm_async_reply_reason (struct thread_fsm *self); + breakpoint_up caller_breakpoint; -/* until_break_fsm's vtable. */ + until_break_fsm (struct interp *cmd_interp, int thread, + breakpoint_up &&location_breakpoint, + breakpoint_up &&caller_breakpoint) + : thread_fsm (cmd_interp), + thread (thread), + location_breakpoint (std::move (location_breakpoint)), + caller_breakpoint (std::move (caller_breakpoint)) + { + } -static struct thread_fsm_ops until_break_fsm_ops = -{ - NULL, /* dtor */ - until_break_fsm_clean_up, - until_break_fsm_should_stop, - NULL, /* return_value */ - until_break_fsm_async_reply_reason, + void clean_up (struct thread_info *thread) override; + bool should_stop (struct thread_info *thread) override; + enum async_reply_reason do_async_reply_reason () override; }; -/* Allocate a new until_break_command_fsm. */ - -static struct until_break_fsm * -new_until_break_fsm (struct interp *cmd_interp, int thread, - breakpoint_up &&location_breakpoint, - breakpoint_up &&caller_breakpoint) -{ - struct until_break_fsm *sm; - - sm = XCNEW (struct until_break_fsm); - thread_fsm_ctor (&sm->thread_fsm, &until_break_fsm_ops, cmd_interp); - - sm->thread = thread; - sm->location_breakpoint = location_breakpoint.release (); - sm->caller_breakpoint = caller_breakpoint.release (); - - return sm; -} - /* Implementation of the 'should_stop' FSM method for the until(location)/advance commands. */ -static int -until_break_fsm_should_stop (struct thread_fsm *self, - struct thread_info *tp) +bool +until_break_fsm::should_stop (struct thread_info *tp) { - struct until_break_fsm *sm = (struct until_break_fsm *) self; - if (bpstat_find_breakpoint (tp->control.stop_bpstat, - sm->location_breakpoint) != NULL - || (sm->caller_breakpoint != NULL + location_breakpoint.get ()) != NULL + || (caller_breakpoint != NULL && bpstat_find_breakpoint (tp->control.stop_bpstat, - sm->caller_breakpoint) != NULL)) - thread_fsm_set_finished (self); + caller_breakpoint.get ()) != NULL)) + set_finished (); - return 1; + return true; } /* Implementation of the 'clean_up' FSM method for the until(location)/advance commands. */ -static void -until_break_fsm_clean_up (struct thread_fsm *self, - struct thread_info *thread) +void +until_break_fsm::clean_up (struct thread_info *) { - struct until_break_fsm *sm = (struct until_break_fsm *) self; - /* Clean up our temporary breakpoints. */ - if (sm->location_breakpoint != NULL) - { - delete_breakpoint (sm->location_breakpoint); - sm->location_breakpoint = NULL; - } - if (sm->caller_breakpoint != NULL) - { - delete_breakpoint (sm->caller_breakpoint); - sm->caller_breakpoint = NULL; - } - delete_longjmp_breakpoint (sm->thread); + location_breakpoint.reset (); + caller_breakpoint.reset (); + delete_longjmp_breakpoint (thread); } /* Implementation of the 'async_reply_reason' FSM method for the until(location)/advance commands. */ -static enum async_reply_reason -until_break_fsm_async_reply_reason (struct thread_fsm *self) +enum async_reply_reason +until_break_fsm::do_async_reply_reason () { return EXEC_ASYNC_LOCATION_REACHED; } @@ -11063,7 +10996,6 @@ until_break_command (const char *arg, int from_tty, int anywhere) struct frame_id caller_frame_id; int thread; struct thread_info *tp; - struct until_break_fsm *sm; clear_proceed_status (0); @@ -11078,7 +11010,7 @@ until_break_command (const char *arg, int from_tty, int anywhere) get_last_displayed_symtab (), get_last_displayed_line ()) : decode_line_1 (location.get (), DECODE_LINE_FUNFIRSTLINE, - NULL, (struct symtab *) NULL, 0)); + NULL, NULL, 0)); if (sals.size () != 1) error (_("Couldn't get information on specified line.")); @@ -11142,10 +11074,9 @@ until_break_command (const char *arg, int from_tty, int anywhere) location_breakpoint = set_momentary_breakpoint (frame_gdbarch, sal, stack_frame_id, bp_until); - sm = new_until_break_fsm (command_interp (), tp->global_num, - std::move (location_breakpoint), - std::move (caller_breakpoint)); - tp->thread_fsm = &sm->thread_fsm; + tp->thread_fsm = new until_break_fsm (command_interp (), tp->global_num, + std::move (location_breakpoint), + std::move (caller_breakpoint)); if (lj_deleter) lj_deleter->release (); @@ -12096,14 +12027,13 @@ static void update_global_location_list_nothrow (enum ugll_insert_mode insert_mode) { - TRY + try { update_global_location_list (insert_mode); } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_error &e) { } - END_CATCH } /* Clear BKP from a BPS. */ @@ -12172,8 +12102,9 @@ say_where (struct breakpoint *b) if (opts.addressprint || b->loc->symtab == NULL) { printf_filtered (" at "); - fputs_filtered (paddress (b->loc->gdbarch, b->loc->address), - gdb_stdout); + fputs_styled (paddress (b->loc->gdbarch, b->loc->address), + address_style.style (), + gdb_stdout); } if (b->loc->symtab != NULL) { @@ -12207,19 +12138,11 @@ say_where (struct breakpoint *b) } } -/* Default bp_location_ops methods. */ - -static void -bp_location_dtor (struct bp_location *self) +bp_location::~bp_location () { - xfree (self->function_name); + xfree (function_name); } -static const struct bp_location_ops bp_location_ops = -{ - bp_location_dtor -}; - /* Destructor for the breakpoint base class. */ breakpoint::~breakpoint () @@ -12232,7 +12155,7 @@ breakpoint::~breakpoint () static struct bp_location * base_breakpoint_allocate_location (struct breakpoint *self) { - return new bp_location (&bp_location_ops, self); + return new bp_location (self); } static void @@ -13572,20 +13495,19 @@ update_breakpoint_locations (struct breakpoint *b, const char *s; s = b->cond_string; - TRY + try { new_loc->cond = parse_exp_1 (&s, sal.pc, block_for_pc (sal.pc), 0); } - CATCH (e, RETURN_MASK_ERROR) + catch (const gdb_exception_error &e) { warning (_("failed to reevaluate condition " "for breakpoint %d: %s"), - b->number, e.message); + b->number, e.what ()); new_loc->enabled = 0; } - END_CATCH } if (!sals_end.empty ()) @@ -13646,22 +13568,20 @@ static std::vector location_to_sals (struct breakpoint *b, struct event_location *location, struct program_space *search_pspace, int *found) { - struct gdb_exception exception = exception_none; + struct gdb_exception exception; gdb_assert (b->ops != NULL); std::vector sals; - TRY + try { sals = b->ops->decode_location (b, location, search_pspace); } - CATCH (e, RETURN_MASK_ERROR) + catch (gdb_exception_error &e) { 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 @@ -13688,10 +13608,11 @@ location_to_sals (struct breakpoint *b, struct event_location *location, happens only when a binary has changed, I don't know which approach is better. */ b->enable_state = bp_disabled; - throw_exception (e); + throw; } + + exception = std::move (e); } - END_CATCH if (exception.reason == 0 || exception.error != NOT_FOUND_ERROR) { @@ -13804,8 +13725,7 @@ decode_location_default (struct breakpoint *b, struct linespec_result canonical; decode_line_full (location, DECODE_LINE_FUNFIRSTLINE, search_pspace, - (struct symtab *) NULL, 0, - &canonical, multiple_symbols_all, + NULL, 0, &canonical, multiple_symbols_all, b->filter); /* We should get 0 or 1 resulting SALs. */ @@ -13863,17 +13783,16 @@ breakpoint_re_set (void) ALL_BREAKPOINTS_SAFE (b, b_tmp) { - TRY + try { breakpoint_re_set_one (b); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception &ex) { exception_fprintf (gdb_stderr, ex, "Error in re-setting breakpoint %d: ", b->number); } - END_CATCH } jit_breakpoint_re_set (); @@ -14340,7 +14259,7 @@ enable_breakpoint_disp (struct breakpoint *bpt, enum bpdisp disposition, /* Initialize it just to avoid a GCC false warning. */ enum enable_state orig_enable_state = bp_disabled; - TRY + try { struct watchpoint *w = (struct watchpoint *) bpt; @@ -14348,14 +14267,13 @@ enable_breakpoint_disp (struct breakpoint *bpt, enum bpdisp disposition, bpt->enable_state = bp_enabled; update_watchpoint (w, 1 /* reparse */); } - CATCH (e, RETURN_MASK_ALL) + catch (const gdb_exception &e) { 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; @@ -15083,16 +15001,15 @@ save_breakpoints (const char *filename, int from_tty, fp.puts (" commands\n"); current_uiout->redirect (&fp); - TRY + try { print_command_lines (current_uiout, tp->commands.get (), 2); } - CATCH (ex, RETURN_MASK_ALL) + catch (const gdb_exception &ex) { current_uiout->redirect (NULL); - throw_exception (ex); + throw; } - END_CATCH current_uiout->redirect (NULL); fp.puts (" end\n"); @@ -15180,7 +15097,7 @@ functions in all scopes. For C++, this means in all namespaces and\n\ classes. For Ada, this means in all packages. E.g., in C++,\n\ \"func()\" matches \"A::func()\", \"A::B::func()\", etc. The\n\ \"-qualified\" flag overrides this behavior, making GDB interpret the\n\ -specified name as a complete fully-qualified name instead.\n" +specified name as a complete fully-qualified name instead." /* This help string is used for the break, hbreak, tbreak and thbreak commands. It is defined as a macro to prevent duplication. @@ -15201,7 +15118,7 @@ stack frame. This is useful for breaking on return to a stack frame.\n\ \n\ THREADNUM is the number from \"info threads\".\n\ CONDITION is a boolean expression.\n\ -\n" LOCATION_HELP_STRING "\n\ +\n" LOCATION_HELP_STRING "\n\n\ Multiple breakpoints at one place are permitted, and useful if their\n\ conditions are different.\n\ \n\ @@ -15505,9 +15422,6 @@ _initialize_breakpoint (void) gdb::observers::free_objfile.attach (disable_breakpoints_in_freed_objfile); gdb::observers::memory_changed.attach (invalidate_bp_value_on_memory_change); - breakpoint_objfile_key - = register_objfile_data_with_cleanup (NULL, free_breakpoint_objfile_data); - breakpoint_chain = 0; /* Don't bother to call set_breakpoint_count. $bpnum isn't useful before a breakpoint is set. */ @@ -15576,7 +15490,7 @@ With a subcommand you can enable temporarily."), Enable some breakpoints.\n\ Give breakpoint numbers (separated by spaces) as arguments.\n\ This is used to cancel the effect of the \"disable\" command.\n\ -May be abbreviated to simply \"enable\".\n"), +May be abbreviated to simply \"enable\"."), &enablebreaklist, "enable breakpoints ", 1, &enablelist); add_cmd ("once", no_class, enable_once_command, _("\ @@ -15652,7 +15566,7 @@ Argument may be a linespec, explicit, or address location as described below.\n\ \n\ With no argument, clears all breakpoints in the line that the selected frame\n\ is executing in.\n" -"\n" LOCATION_HELP_STRING "\n\ +"\n" LOCATION_HELP_STRING "\n\n\ See also the \"delete\" command which clears breakpoints by number.")); add_com_alias ("cl", "clear", class_breakpoint, 1); @@ -15852,7 +15766,7 @@ tracing library. You can inspect it when analyzing the trace buffer,\n\ by printing the $_sdata variable like any other convenience variable.\n\ \n\ CONDITION is a boolean expression.\n\ -\n" LOCATION_HELP_STRING "\n\ +\n" LOCATION_HELP_STRING "\n\n\ Multiple tracepoints at one place are permitted, and useful if their\n\ conditions are different.\n\ \n\