X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fbreakpoint.c;h=dd8fe4c86208543fe42acb92b88ab6cb1bf19f01;hb=e43b10e10eba9d9493a0ad40176b2aea9cfb62ab;hp=48a1c6414e32f90ef696887c337361a6ed5445a2;hpb=aed57c537116ae91f553ac835b3f96d1f87b3bb0;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 48a1c6414e..dd8fe4c862 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. */ @@ -224,15 +217,13 @@ static void update_global_location_list (enum ugll_insert_mode); static void update_global_location_list_nothrow (enum ugll_insert_mode); -static int is_hardware_watchpoint (const struct breakpoint *bpt); - static void insert_breakpoint_locations (void); static void trace_pass_command (const char *, int); static void set_tracepoint_count (int num); -static int is_masked_watchpoint (const struct breakpoint *b); +static bool is_masked_watchpoint (const struct breakpoint *b); static struct bp_location **get_first_locp_gte_addr (CORE_ADDR address); @@ -299,7 +290,7 @@ static char *dprintf_channel; /* True if dprintf commands should continue to operate even if GDB has disconnected. */ -static int disconnected_dprintf = 1; +static bool disconnected_dprintf = true; struct command_line * breakpoint_commands (struct breakpoint *b) @@ -310,7 +301,7 @@ breakpoint_commands (struct breakpoint *b) /* Flag indicating that a command has proceeded the inferior past the current breakpoint. */ -static int breakpoint_proceeded; +static bool breakpoint_proceeded; const char * bpdisp_text (enum bpdisp disp) @@ -355,11 +346,11 @@ show_pending_break_support (struct ui_file *file, int from_tty, value); } -/* If 1, gdb will automatically use hardware breakpoints for breakpoints +/* If true, gdb will automatically use hardware breakpoints for breakpoints set with "break" but falling in read-only memory. - If 0, gdb will warn about such breakpoints, but won't automatically + If false, gdb will warn about such breakpoints, but won't automatically use hardware breakpoints. */ -static int automatic_hardware_breakpoints; +static bool automatic_hardware_breakpoints; static void show_automatic_hardware_breakpoints (struct ui_file *file, int from_tty, struct cmd_list_element *c, @@ -377,7 +368,7 @@ show_automatic_hardware_breakpoints (struct ui_file *file, int from_tty, breakpoints until the next resume, and removes them again when the target fully stops. This is a bit safer in case GDB crashes while processing user input. */ -static int always_inserted_mode = 0; +static bool always_inserted_mode = false; static void show_always_inserted_mode (struct ui_file *file, int from_tty, @@ -486,7 +477,7 @@ static int executing_breakpoint_commands; static int overlay_events_enabled; /* See description in breakpoint.h. */ -int target_exact_watchpoints = 0; +bool target_exact_watchpoints = false; /* Walk the following statement or block through all breakpoints. ALL_BREAKPOINTS_SAFE does so even if the statement deletes the @@ -879,12 +870,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 +931,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; @@ -1047,7 +1035,9 @@ is_longjmp_type (bptype type) return type == bp_longjmp || type == bp_exception; } -int +/* See breakpoint.h. */ + +bool is_tracepoint (const struct breakpoint *b) { return is_tracepoint_type (b->type); @@ -1503,12 +1493,9 @@ breakpoint_xfer_memory (gdb_byte *readbuf, gdb_byte *writebuf, } } - - -/* Return true if BPT is either a software breakpoint or a hardware - breakpoint. */ +/* See breakpoint.h. */ -int +bool is_breakpoint (const struct breakpoint *bpt) { return (bpt->type == bp_breakpoint @@ -1518,7 +1505,7 @@ is_breakpoint (const struct breakpoint *bpt) /* Return true if BPT is of any hardware watchpoint kind. */ -static int +static bool is_hardware_watchpoint (const struct breakpoint *bpt) { return (bpt->type == bp_hardware_watchpoint @@ -1526,10 +1513,9 @@ is_hardware_watchpoint (const struct breakpoint *bpt) || bpt->type == bp_access_watchpoint); } -/* Return true if BPT is of any watchpoint kind, hardware or - software. */ +/* See breakpoint.h. */ -int +bool is_watchpoint (const struct breakpoint *bpt) { return (is_hardware_watchpoint (bpt) @@ -1614,7 +1600,7 @@ software_watchpoint_add_no_memory_location (struct breakpoint *b, /* Returns true if B is a software watchpoint that is not watching any memory (e.g., "watch $pc"). */ -static int +static bool is_no_memory_software_watchpoint (struct breakpoint *b) { return (b->type == bp_watchpoint @@ -1741,7 +1727,7 @@ update_watchpoint (struct watchpoint *b, int reparse) to the user when the old value and the new value may actually be completely different objects. */ b->val = NULL; - b->val_valid = 0; + b->val_valid = false; /* Note that unlike with breakpoints, the watchpoint's condition expression is stored in the breakpoint object, not in the @@ -1794,7 +1780,7 @@ update_watchpoint (struct watchpoint *b, int reparse) if (b->val_bitsize != 0) v = extract_bitfield_from_watchpoint_value (b, v); b->val = release_value (v); - b->val_valid = 1; + b->val_valid = true; } frame_pspace = get_frame_program_space (get_selected_frame (NULL)); @@ -2096,18 +2082,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 +2256,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 +2419,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 +2522,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 +2530,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 +2556,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 +2569,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 +2585,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 +2593,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 +2655,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 +2675,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 +3045,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 +3062,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 +3140,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,31 +3162,18 @@ 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) { const char *const func_name = "_ovly_debug_event"; - for (objfile *objfile : all_objfiles (current_program_space)) + for (objfile *objfile : current_program_space->objfiles ()) { struct breakpoint *b; struct breakpoint_objfile_data *bp_objfile_data; @@ -3263,7 +3231,7 @@ create_longjmp_master_breakpoint (void) { set_current_program_space (pspace); - for (objfile *objfile : all_objfiles (current_program_space)) + for (objfile *objfile : current_program_space->objfiles ()) { int i; struct gdbarch *gdbarch; @@ -3366,7 +3334,7 @@ create_std_terminate_master_breakpoint (void) set_current_program_space (pspace); - for (objfile *objfile : all_objfiles (current_program_space)) + for (objfile *objfile : current_program_space->objfiles ()) { struct breakpoint *b; struct breakpoint_objfile_data *bp_objfile_data; @@ -3411,7 +3379,7 @@ create_exception_master_breakpoint (void) { const char *const func_name = "_Unwind_DebugHook"; - for (objfile *objfile : all_objfiles (current_program_space)) + for (objfile *objfile : current_program_space->objfiles ()) { struct breakpoint *b; struct gdbarch *gdbarch; @@ -3932,7 +3900,7 @@ breakpoint_init_inferior (enum inf_context context) /* Reset val field to force reread of starting value in insert_breakpoints. */ w->val.reset (nullptr); - w->val_valid = 0; + w->val_valid = false; } } } @@ -4158,15 +4126,13 @@ hardware_watchpoint_inserted_in_range (const address_space *aspace, } return 0; } - -/* bpstat stuff. External routines' interfaces are documented - in breakpoint.h. */ +/* See breakpoint.h. */ -int -is_catchpoint (struct breakpoint *ep) +bool +is_catchpoint (struct breakpoint *b) { - return (ep->type == bp_catchpoint); + return (b->type == bp_catchpoint); } /* Frees any storage that is part of a bpstat. Does not walk the @@ -4259,7 +4225,7 @@ bpstat_find_breakpoint (bpstat bsp, struct breakpoint *breakpoint) /* See breakpoint.h. */ -int +bool bpstat_explains_signal (bpstat bsp, enum gdb_signal sig) { for (; bsp != NULL; bsp = bsp->next) @@ -4269,17 +4235,17 @@ bpstat_explains_signal (bpstat bsp, enum gdb_signal sig) /* A moribund location can never explain a signal other than GDB_SIGNAL_TRAP. */ if (sig == GDB_SIGNAL_TRAP) - return 1; + return true; } else { if (bsp->breakpoint_at->ops->explains_signal (bsp->breakpoint_at, sig)) - return 1; + return true; } } - return 0; + return false; } /* Put in *NUM the breakpoint number of the first breakpoint we are @@ -4468,7 +4434,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 +4448,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. */ @@ -4517,13 +4483,13 @@ maybe_print_thread_hit_breakpoint (struct ui_out *uiout) struct thread_info *thr = inferior_thread (); uiout->text ("Thread "); - uiout->field_fmt ("thread-id", "%s", print_thread_id (thr)); + uiout->field_string ("thread-id", print_thread_id (thr)); name = thr->name != NULL ? thr->name : target_thread_name (thr); if (name != NULL) { uiout->text (" \""); - uiout->field_fmt ("name", "%s", name); + uiout->field_string ("name", name); uiout->text ("\""); } @@ -4911,7 +4877,7 @@ watchpoint_check (bpstat bs) { bs->old_val = b->val; b->val = release_value (new_val); - b->val_valid = 1; + b->val_valid = true; if (new_val != NULL) value_free_to_mark (mark); return WP_VALUE_CHANGED; @@ -4947,7 +4913,7 @@ watchpoint_check (bpstat bs) uiout->field_string ("reason", async_reason_lookup (EXEC_ASYNC_WATCHPOINT_SCOPE)); uiout->text ("\nWatchpoint "); - uiout->field_int ("wpnum", b->number); + uiout->field_signed ("wpnum", b->number); uiout->text (" deleted because the program has left the block in\n" "which its expression is valid.\n"); } @@ -5016,11 +4982,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 +5001,6 @@ bpstat_check_watchpoint (bpstat bs) watchpoint_del_at_next_stop (b); e = WP_DELETED; } - END_CATCH switch (e) { @@ -5254,16 +5219,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 { @@ -5521,7 +5485,7 @@ bpstat_what (bpstat bs_head) retval.main_action = BPSTAT_WHAT_KEEP_CHECKING; retval.call_dummy = STOP_NONE; - retval.is_longjmp = 0; + retval.is_longjmp = false; for (bs = bs_head; bs != NULL; bs = bs->next) { @@ -5633,8 +5597,10 @@ bpstat_what (bpstat bs_head) } else { - /* There was a catchpoint, but we're not stopping. - This requires no further action. */ + /* Some catchpoints are implemented with breakpoints. + For those, we need to step over the breakpoint. */ + if (bs->bp_location_at->loc_type != bp_loc_other) + this_action = BPSTAT_WHAT_SINGLE; } break; case bp_jit_event: @@ -5715,29 +5681,29 @@ bpstat_run_callbacks (bpstat bs_head) } } -/* Nonzero if we should step constantly (e.g. watchpoints on machines - without hardware support). This isn't related to a specific bpstat, - just to things like whether watchpoints are set. */ +/* See breakpoint.h. */ -int -bpstat_should_step (void) +bool +bpstat_should_step () { struct breakpoint *b; ALL_BREAKPOINTS (b) if (breakpoint_enabled (b) && b->type == bp_watchpoint && b->loc != NULL) - return 1; - return 0; + return true; + return false; } -int +/* See breakpoint.h. */ + +bool bpstat_causes_stop (bpstat bs) { for (; bs != NULL; bs = bs->next) if (bs->stop) - return 1; + return true; - return 0; + return false; } @@ -5857,20 +5823,20 @@ print_breakpoint_location (struct breakpoint *b, { uiout->text ("in "); uiout->field_string ("func", SYMBOL_PRINT_NAME (sym), - ui_out_style_kind::FUNCTION); + function_name_style.style ()); uiout->text (" "); uiout->wrap_hint (wrap_indent_at_field (uiout, "what")); uiout->text ("at "); } uiout->field_string ("file", symtab_to_filename_for_display (loc->symtab), - ui_out_style_kind::FILE); + file_name_style.style ()); uiout->text (":"); if (uiout->is_mi_like_p ()) uiout->field_string ("fullname", symtab_to_fullname (loc->symtab)); - uiout->field_int ("line", loc->line_number); + uiout->field_signed ("line", loc->line_number); } else if (loc) { @@ -6002,14 +5968,18 @@ output_thread_groups (struct ui_out *uiout, } } -/* Print B to gdb_stdout. */ +/* Print B to gdb_stdout. If RAW_LOC, print raw breakpoint locations + instead of going via breakpoint_ops::print_one. This makes "maint + info breakpoints" show the software breakpoint locations of + catchpoints, which are considered internal implementation + detail. */ static void print_one_breakpoint_location (struct breakpoint *b, struct bp_location *loc, int loc_number, struct bp_location **last_loc, - int allflag) + int allflag, bool raw_loc) { struct command_line *l; static char bpenables[] = "nynny"; @@ -6038,7 +6008,7 @@ print_one_breakpoint_location (struct breakpoint *b, if (part_of_multiple) uiout->field_fmt ("number", "%d.%d", b->number, loc_number); else - uiout->field_int ("number", b->number); + uiout->field_signed ("number", b->number); /* 2 */ annotate_field (1); @@ -6062,26 +6032,11 @@ print_one_breakpoint_location (struct breakpoint *b, uiout->field_fmt ("enabled", "%c", bpenables[(int) b->enable_state]); /* 5 and 6 */ - if (b->ops != NULL && b->ops->print_one != NULL) - { - /* Although the print_one can possibly print all locations, - calling it here is not likely to get any nice result. So, - make sure there's just one location. */ - gdb_assert (b->loc == NULL || b->loc->next == NULL); - b->ops->print_one (b, last_loc); - } + if (!raw_loc && b->ops != NULL && b->ops->print_one != NULL) + b->ops->print_one (b, last_loc); else - switch (b->type) - { - case bp_none: - internal_error (__FILE__, __LINE__, - _("print_one_breakpoint: bp_none encountered\n")); - break; - - case bp_watchpoint: - case bp_hardware_watchpoint: - case bp_read_watchpoint: - case bp_access_watchpoint: + { + if (is_watchpoint (b)) { struct watchpoint *w = (struct watchpoint *) b; @@ -6093,55 +6048,27 @@ print_one_breakpoint_location (struct breakpoint *b, annotate_field (5); uiout->field_string ("what", w->exp_string); } - break; - - case bp_breakpoint: - case bp_hardware_breakpoint: - case bp_single_step: - case bp_until: - case bp_finish: - case bp_longjmp: - case bp_longjmp_resume: - case bp_longjmp_call_dummy: - case bp_exception: - case bp_exception_resume: - case bp_step_resume: - case bp_hp_step_resume: - case bp_watchpoint_scope: - case bp_call_dummy: - case bp_std_terminate: - case bp_shlib_event: - case bp_thread_event: - case bp_overlay_event: - case bp_longjmp_master: - case bp_std_terminate_master: - case bp_exception_master: - case bp_tracepoint: - case bp_fast_tracepoint: - case bp_static_tracepoint: - case bp_dprintf: - case bp_jit_event: - case bp_gnu_ifunc_resolver: - case bp_gnu_ifunc_resolver_return: - if (opts.addressprint) - { - annotate_field (4); - if (header_of_multiple) - uiout->field_string ("addr", ""); - else if (b->loc == NULL || loc->shlib_disabled) - uiout->field_string ("addr", ""); - else - uiout->field_core_addr ("addr", - loc->gdbarch, loc->address); - } - annotate_field (5); - if (!header_of_multiple) - print_breakpoint_location (b, loc); - if (b->loc) - *last_loc = b->loc; - break; - } - + else if (!is_catchpoint (b) || is_exception_catchpoint (b) + || is_ada_exception_catchpoint (b)) + { + if (opts.addressprint) + { + annotate_field (4); + if (header_of_multiple) + uiout->field_string ("addr", ""); + else if (b->loc == NULL || loc->shlib_disabled) + uiout->field_string ("addr", ""); + else + uiout->field_core_addr ("addr", + loc->gdbarch, loc->address); + } + annotate_field (5); + if (!header_of_multiple) + print_breakpoint_location (b, loc); + if (b->loc) + *last_loc = b->loc; + } + } if (loc != NULL && !header_of_multiple) { @@ -6174,12 +6101,12 @@ print_one_breakpoint_location (struct breakpoint *b, /* FIXME: This seems to be redundant and lost here; see the "stop only in" line a little further down. */ uiout->text (" thread "); - uiout->field_int ("thread", b->thread); + uiout->field_signed ("thread", b->thread); } else if (b->task != 0) { uiout->text (" task "); - uiout->field_int ("task", b->task); + uiout->field_signed ("task", b->task); } } @@ -6227,7 +6154,7 @@ print_one_breakpoint_location (struct breakpoint *b, /* FIXME should make an annotation for this. */ uiout->text ("\tstop only in thread "); if (uiout->is_mi_like_p ()) - uiout->field_int ("thread", b->thread); + uiout->field_signed ("thread", b->thread); else { struct thread_info *thr = find_thread_global_id (b->thread); @@ -6249,7 +6176,7 @@ print_one_breakpoint_location (struct breakpoint *b, else uiout->text ("\tbreakpoint"); uiout->text (" already hit "); - uiout->field_int ("times", b->hit_count); + uiout->field_signed ("times", b->hit_count); if (b->hit_count == 1) uiout->text (" time\n"); else @@ -6259,7 +6186,7 @@ print_one_breakpoint_location (struct breakpoint *b, { /* Output the count also if it is zero, but only if this is mi. */ if (uiout->is_mi_like_p ()) - uiout->field_int ("times", b->hit_count); + uiout->field_signed ("times", b->hit_count); } } @@ -6267,7 +6194,7 @@ print_one_breakpoint_location (struct breakpoint *b, { annotate_field (8); uiout->text ("\tignore next "); - uiout->field_int ("ignore", b->ignore_count); + uiout->field_signed ("ignore", b->ignore_count); uiout->text (" hits\n"); } @@ -6284,7 +6211,7 @@ print_one_breakpoint_location (struct breakpoint *b, uiout->text ("additional "); else uiout->text ("next "); - uiout->field_int ("enable", b->enable_count); + uiout->field_signed ("enable", b->enable_count); uiout->text (" hits\n"); } @@ -6295,7 +6222,7 @@ print_one_breakpoint_location (struct breakpoint *b, if (tp->traceframe_usage) { uiout->text ("\ttrace buffer usage "); - uiout->field_int ("traceframe-usage", tp->traceframe_usage); + uiout->field_signed ("traceframe-usage", tp->traceframe_usage); uiout->text (" bytes\n"); } } @@ -6316,7 +6243,7 @@ print_one_breakpoint_location (struct breakpoint *b, { annotate_field (10); uiout->text ("\tpass count "); - uiout->field_int ("pass", t->pass_count); + uiout->field_signed ("pass", t->pass_count); uiout->text (" \n"); } @@ -6355,23 +6282,34 @@ 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, false); - 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 locations, if any. */ - if (b->ops == NULL || b->ops->print_one == NULL) + if (b->ops == NULL + || b->ops->print_one == NULL + || allflag) { /* If breakpoint has a single location that is disabled, we print it as if it had several locations, since otherwise it's @@ -6379,18 +6317,32 @@ print_one_breakpoint (struct breakpoint *b, situation. Note that while hardware watchpoints have several locations - internally, that's not a property exposed to user. */ - if (b->loc - && !is_hardware_watchpoint (b) - && (b->loc->next || !b->loc->enabled)) - { - struct bp_location *loc; - int n = 1; + internally, that's not a property exposed to users. + + Likewise, while catchpoints may be implemented with + breakpoints (e.g., catch throw), that's not a property + exposed to users. We do however display the internal + breakpoint locations with "maint info breakpoints". */ + if (!is_hardware_watchpoint (b) + && (!is_catchpoint (b) || is_exception_catchpoint (b) + || is_ada_exception_catchpoint (b)) + && (allflag + || (b->loc && (b->loc->next || !b->loc->enabled)))) + { + 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); - print_one_breakpoint_location (b, loc, n, last_loc, allflag); + ui_out_emit_tuple loc_tuple_emitter (uiout, NULL); + print_one_breakpoint_location (b, loc, n, last_loc, + allflag, allflag); } } } @@ -6445,16 +6397,22 @@ pending_breakpoint_p (struct breakpoint *b) return b->loc == NULL; } -/* Print information on user settable breakpoint (watchpoint, etc) - number BNUM. If BNUM is -1 print all user-settable breakpoints. - If ALLFLAG is non-zero, include non-user-settable breakpoints. If - FILTER is non-NULL, call it on each breakpoint and only include the - ones for which it returns non-zero. Return the total number of - breakpoints listed. */ +/* Print information on breakpoints (including watchpoints and tracepoints). + + If non-NULL, BP_NUM_LIST is a list of numbers and number ranges as + understood by number_or_range_parser. Only breakpoints included in this + list are then printed. + + If SHOW_INTERNAL is true, print internal breakpoints. + + If FILTER is non-NULL, call it on each breakpoint and only include the + ones for which it returns true. + + Return the total number of breakpoints listed. */ static int -breakpoint_1 (const char *args, int allflag, - int (*filter) (const struct breakpoint *)) +breakpoint_1 (const char *bp_num_list, bool show_internal, + bool (*filter) (const struct breakpoint *)) { struct breakpoint *b; struct bp_location *last_loc = NULL; @@ -6475,17 +6433,17 @@ breakpoint_1 (const char *args, int allflag, if (filter && !filter (b)) continue; - /* If we have an "args" string, it is a list of breakpoints to + /* If we have a BP_NUM_LIST string, it is a list of breakpoints to accept. Skip the others. */ - if (args != NULL && *args != '\0') + if (bp_num_list != NULL && *bp_num_list != '\0') { - if (allflag && parse_and_eval_long (args) != b->number) + if (show_internal && parse_and_eval_long (bp_num_list) != b->number) continue; - if (!allflag && !number_is_in_list (args, b->number)) + if (!show_internal && !number_is_in_list (bp_num_list, b->number)) continue; } - if (allflag || user_breakpoint_p (b)) + if (show_internal || user_breakpoint_p (b)) { int addr_bit, type_len; @@ -6544,26 +6502,26 @@ breakpoint_1 (const char *args, int allflag, if (filter && !filter (b)) continue; - /* If we have an "args" string, it is a list of breakpoints to + /* If we have a BP_NUM_LIST string, it is a list of breakpoints to accept. Skip the others. */ - if (args != NULL && *args != '\0') + if (bp_num_list != NULL && *bp_num_list != '\0') { - if (allflag) /* maintenance info breakpoint */ + if (show_internal) /* maintenance info breakpoint */ { - if (parse_and_eval_long (args) != b->number) + if (parse_and_eval_long (bp_num_list) != b->number) continue; } else /* all others */ { - if (!number_is_in_list (args, b->number)) + if (!number_is_in_list (bp_num_list, b->number)) continue; } } /* We only print out user settable breakpoints unless the - allflag is set. */ - if (allflag || user_breakpoint_p (b)) - print_one_breakpoint (b, &last_loc, allflag); + show_internal is set. */ + if (show_internal || user_breakpoint_p (b)) + print_one_breakpoint (b, &last_loc, show_internal); } } @@ -6573,11 +6531,11 @@ breakpoint_1 (const char *args, int allflag, empty list. */ if (!filter) { - if (args == NULL || *args == '\0') + if (bp_num_list == NULL || *bp_num_list == '\0') uiout->message ("No breakpoints or watchpoints.\n"); else uiout->message ("No breakpoint or watchpoint matching '%s'.\n", - args); + bp_num_list); } } else @@ -6617,7 +6575,7 @@ default_collect_info (void) static void info_breakpoints_command (const char *args, int from_tty) { - breakpoint_1 (args, 0, NULL); + breakpoint_1 (args, false, NULL); default_collect_info (); } @@ -6625,7 +6583,7 @@ info_breakpoints_command (const char *args, int from_tty) static void info_watchpoints_command (const char *args, int from_tty) { - int num_printed = breakpoint_1 (args, 0, is_watchpoint); + int num_printed = breakpoint_1 (args, false, is_watchpoint); struct ui_out *uiout = current_uiout; if (num_printed == 0) @@ -6640,7 +6598,7 @@ info_watchpoints_command (const char *args, int from_tty) static void maintenance_info_breakpoints (const char *args, int from_tty) { - breakpoint_1 (args, 1, NULL); + breakpoint_1 (args, true, NULL); default_collect_info (); } @@ -6701,33 +6659,27 @@ 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"); } } -/* Return true iff it is meaningful to use the address member of - BPT locations. For some breakpoint types, the locations' address members - are irrelevant and it makes no sense to attempt to compare them to other - addresses (or use them for any other purpose either). - - More specifically, each of the following breakpoint types will - always have a zero valued location address and we don't want to mark - breakpoints of any of these types to be a duplicate of an actual - breakpoint location at address zero: +/* Return true iff it is meaningful to use the address member of LOC. + For some breakpoint types, the locations' address members are + irrelevant and it makes no sense to attempt to compare them to + other addresses (or use them for any other purpose either). - bp_watchpoint - bp_catchpoint + More specifically, software watchpoints and catchpoints that are + not backed by breakpoints always have a zero valued location + address and we don't want to mark breakpoints of any of these types + to be a duplicate of an actual breakpoint location at address + zero. */ -*/ - -static int -breakpoint_address_is_meaningful (struct breakpoint *bpt) +static bool +bl_address_is_meaningful (bp_location *loc) { - enum bptype type = bpt->type; - - return (type != bp_watchpoint && type != bp_catchpoint); + return loc->loc_type != bp_loc_other; } /* Assuming LOC1 and LOC2's owners are hardware watchpoints, returns @@ -6859,8 +6811,8 @@ tracepoint_locations_match (struct bp_location *loc1, } /* Assuming LOC1 and LOC2's types' have meaningful target addresses - (breakpoint_address_is_meaningful), returns true if LOC1 and LOC2 - represent the same location. */ + (bl_address_is_meaningful), returns true if LOC1 and LOC2 represent + the same location. */ static int breakpoint_locations_match (struct bp_location *loc1, @@ -6958,19 +6910,10 @@ adjust_breakpoint_address (struct gdbarch *gdbarch, } } -bp_location::bp_location (const bp_location_ops *ops, breakpoint *owner) +static bp_loc_type +bp_location_from_bp_type (bptype type) { - bp_location *loc = this; - - gdb_assert (ops != NULL); - - loc->ops = ops; - loc->owner = owner; - loc->cond_bytecode = NULL; - loc->shlib_disabled = 0; - loc->enabled = 1; - - switch (owner->type) + switch (type) { case bp_breakpoint: case bp_single_step: @@ -6996,30 +6939,44 @@ bp_location::bp_location (const bp_location_ops *ops, breakpoint *owner) case bp_gnu_ifunc_resolver: case bp_gnu_ifunc_resolver_return: case bp_dprintf: - loc->loc_type = bp_loc_software_breakpoint; - mark_breakpoint_location_modified (loc); - break; + return bp_loc_software_breakpoint; case bp_hardware_breakpoint: - loc->loc_type = bp_loc_hardware_breakpoint; - mark_breakpoint_location_modified (loc); - break; + return bp_loc_hardware_breakpoint; case bp_hardware_watchpoint: case bp_read_watchpoint: case bp_access_watchpoint: - loc->loc_type = bp_loc_hardware_watchpoint; - break; + return bp_loc_hardware_watchpoint; case bp_watchpoint: case bp_catchpoint: case bp_tracepoint: case bp_fast_tracepoint: case bp_static_tracepoint: - loc->loc_type = bp_loc_other; - break; + return bp_loc_other; default: internal_error (__FILE__, __LINE__, _("unknown breakpoint type")); } +} + +bp_location::bp_location (breakpoint *owner, bp_loc_type type) +{ + this->owner = owner; + this->cond_bytecode = NULL; + this->shlib_disabled = 0; + this->enabled = 1; + + this->loc_type = type; + + if (this->loc_type == bp_loc_software_breakpoint + || this->loc_type == bp_loc_hardware_breakpoint) + mark_breakpoint_location_modified (this); + + this->refc = 1; +} - loc->refc = 1; +bp_location::bp_location (breakpoint *owner) + : bp_location::bp_location (owner, + bp_location_from_bp_type (owner->type)) +{ } /* Allocate a struct bp_location. */ @@ -7033,7 +6990,6 @@ allocate_bp_location (struct breakpoint *bpt) static void free_bp_location (struct bp_location *loc) { - loc->ops->dtor (loc); delete loc; } @@ -7114,12 +7070,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 +7085,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; @@ -7736,9 +7689,9 @@ print_it_catch_fork (bpstat bs) uiout->field_string ("reason", async_reason_lookup (EXEC_ASYNC_FORK)); uiout->field_string ("disp", bpdisp_text (b->disposition)); } - uiout->field_int ("bkptno", b->number); + uiout->field_signed ("bkptno", b->number); uiout->text (" (forked process "); - uiout->field_int ("newpid", c->forked_inferior_pid.pid ()); + uiout->field_signed ("newpid", c->forked_inferior_pid.pid ()); uiout->text ("), "); return PRINT_SRC_AND_LOC; } @@ -7765,7 +7718,7 @@ print_one_catch_fork (struct breakpoint *b, struct bp_location **last_loc) if (c->forked_inferior_pid != null_ptid) { uiout->text (", process "); - uiout->field_int ("what", c->forked_inferior_pid.pid ()); + uiout->field_signed ("what", c->forked_inferior_pid.pid ()); uiout->spaces (1); } @@ -7852,9 +7805,9 @@ print_it_catch_vfork (bpstat bs) uiout->field_string ("reason", async_reason_lookup (EXEC_ASYNC_VFORK)); uiout->field_string ("disp", bpdisp_text (b->disposition)); } - uiout->field_int ("bkptno", b->number); + uiout->field_signed ("bkptno", b->number); uiout->text (" (vforked process "); - uiout->field_int ("newpid", c->forked_inferior_pid.pid ()); + uiout->field_signed ("newpid", c->forked_inferior_pid.pid ()); uiout->text ("), "); return PRINT_SRC_AND_LOC; } @@ -7880,7 +7833,7 @@ print_one_catch_vfork (struct breakpoint *b, struct bp_location **last_loc) if (c->forked_inferior_pid != null_ptid) { uiout->text (", process "); - uiout->field_int ("what", c->forked_inferior_pid.pid ()); + uiout->field_signed ("what", c->forked_inferior_pid.pid ()); uiout->spaces (1); } @@ -8021,7 +7974,7 @@ print_it_catch_solib (bpstat bs) uiout->text ("Temporary catchpoint "); else uiout->text ("Catchpoint "); - uiout->field_int ("bkptno", b->number); + uiout->field_signed ("bkptno", b->number); uiout->text ("\n"); if (uiout->is_mi_like_p ()) uiout->field_string ("disp", bpdisp_text (b->disposition)); @@ -8271,7 +8224,7 @@ print_it_catch_exec (bpstat bs) uiout->field_string ("reason", async_reason_lookup (EXEC_ASYNC_EXEC)); uiout->field_string ("disp", bpdisp_text (b->disposition)); } - uiout->field_int ("bkptno", b->number); + uiout->field_signed ("bkptno", b->number); uiout->text (" (exec'd "); uiout->field_string ("new-exec", c->exec_pathname); uiout->text ("), "); @@ -8500,7 +8453,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 +8558,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 @@ -8668,11 +8620,12 @@ bp_loc_is_permanent (struct bp_location *loc) { gdb_assert (loc != NULL); - /* If we have a catchpoint or a watchpoint, just return 0. We should not - attempt to read from the addresses the locations of these breakpoint types - point to. program_breakpoint_here_p, below, will attempt to read + /* If we have a non-breakpoint-backed catchpoint or a software + watchpoint, just return 0. We should not attempt to read from + the addresses the locations of these breakpoint types point to. + program_breakpoint_here_p, below, will attempt to read memory. */ - if (!breakpoint_address_is_meaningful (loc->owner)) + if (!bl_address_is_meaningful (loc)) return 0; scoped_restore_current_pspace_and_thread restore_pspace_thread; @@ -8897,7 +8850,7 @@ init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch, b->location = std::move (location); else b->location = new_address_location (b->loc->address, NULL, 0); - b->filter = filter.release (); + b->filter = std::move (filter); } static void @@ -9230,7 +9183,6 @@ create_breakpoint (struct gdbarch *gdbarch, unsigned flags) { struct linespec_result canonical; - struct cleanup *bkpt_chain = NULL; int pending = 0; int task = 0; int prev_bkpt_count = breakpoint_count; @@ -9241,11 +9193,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. */ @@ -9255,7 +9207,7 @@ create_breakpoint (struct gdbarch *gdbarch, error. */ if (pending_break_support == AUTO_BOOLEAN_FALSE) - throw_exception (e); + throw; exception_print (gdb_stderr, e); @@ -9273,19 +9225,12 @@ create_breakpoint (struct gdbarch *gdbarch, pending = 1; } else - throw_exception (e); + throw; } - END_CATCH if (!pending && canonical.lsals.empty ()) return 0; - /* ----------------------------- SNIP ----------------------------- - Anything added to the cleanup chain beyond this point is assumed - to be part of a breakpoint. If the breakpoint create succeeds - then the memory is not reclaimed. */ - bkpt_chain = make_cleanup (null_cleanup, 0); - /* Resolve all line numbers to PC's and verify that the addresses are ok for the target. */ if (!pending) @@ -9384,11 +9329,6 @@ create_breakpoint (struct gdbarch *gdbarch, prev_breakpoint_count = prev_bkpt_count; } - /* That's it. Discard the cleanups for data inserted into the - breakpoint. */ - discard_cleanups (bkpt_chain); - - /* error call may happen here - have BKPT_CHAIN already discarded. */ update_global_location_list (UGLL_MAY_INSERT); return 1; @@ -9524,7 +9464,7 @@ stopin_command (const char *arg, int from_tty) { int badInput = 0; - if (arg == (char *) NULL) + if (arg == NULL) badInput = 1; else if (*arg != '*') { @@ -9557,7 +9497,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 { @@ -9681,7 +9621,7 @@ print_it_ranged_breakpoint (bpstat bs) async_reason_lookup (EXEC_ASYNC_BREAKPOINT_HIT)); uiout->field_string ("disp", bpdisp_text (b->disposition)); } - uiout->field_int ("bkptno", b->number); + uiout->field_signed ("bkptno", b->number); uiout->text (", "); return PRINT_SRC_AND_LOC; @@ -10257,7 +10197,7 @@ print_mention_watchpoint (struct breakpoint *b) } ui_out_emit_tuple tuple_emitter (uiout, tuple_name); - uiout->field_int ("number", b->number); + uiout->field_signed ("number", b->number); uiout->text (": "); uiout->field_string ("exp", w->exp_string); } @@ -10450,7 +10390,7 @@ print_mention_masked_watchpoint (struct breakpoint *b) } ui_out_emit_tuple tuple_emitter (uiout, tuple_name); - uiout->field_int ("number", b->number); + uiout->field_signed ("number", b->number); uiout->text (": "); uiout->field_string ("exp", w->exp_string); } @@ -10491,7 +10431,7 @@ static struct breakpoint_ops masked_watchpoint_breakpoint_ops; /* Tell whether the given watchpoint is a masked hardware watchpoint. */ -static int +static bool is_masked_watchpoint (const struct breakpoint *b) { return b->ops == &masked_watchpoint_breakpoint_ops; @@ -10608,10 +10548,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 @@ -10630,7 +10570,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, @@ -10670,13 +10610,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; } @@ -10777,7 +10717,7 @@ watch_command_1 (const char *arg, int accessflag, int from_tty, w->val = val; w->val_bitpos = saved_bitpos; w->val_bitsize = saved_bitsize; - w->val_valid = 1; + w->val_valid = true; } if (cond_start) @@ -10919,10 +10859,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); } @@ -10962,106 +10899,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; } @@ -11073,10 +10970,8 @@ until_break_command (const char *arg, int from_tty, int anywhere) struct gdbarch *frame_gdbarch; struct frame_id stack_frame_id; struct frame_id caller_frame_id; - struct cleanup *old_chain; int thread; struct thread_info *tp; - struct until_break_fsm *sm; clear_proceed_status (0); @@ -11091,7 +10986,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.")); @@ -11106,8 +11001,6 @@ until_break_command (const char *arg, int from_tty, int anywhere) tp = inferior_thread (); thread = tp->global_num; - old_chain = make_cleanup (null_cleanup, NULL); - /* Note linespec handling above invalidates the frame chain. Installing a breakpoint also invalidates the frame chain (as it may need to switch threads), so do any frame handling before @@ -11122,6 +11015,9 @@ until_break_command (const char *arg, int from_tty, int anywhere) one. */ breakpoint_up caller_breakpoint; + + gdb::optional lj_deleter; + if (frame_id_p (caller_frame_id)) { struct symtab_and_line sal2; @@ -11136,7 +11032,7 @@ until_break_command (const char *arg, int from_tty, int anywhere) bp_until); set_longjmp_breakpoint (tp, caller_frame_id); - make_cleanup (delete_longjmp_breakpoint_cleanup, &thread); + lj_deleter.emplace (thread); } /* set_momentary_breakpoint could invalidate FRAME. */ @@ -11154,12 +11050,12 @@ 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)); - discard_cleanups (old_chain); + if (lj_deleter) + lj_deleter->release (); proceed (-1, GDB_SIGNAL_DEFAULT); } @@ -11312,7 +11208,7 @@ init_ada_exception_breakpoint (struct breakpoint *b, enough for now, though. */ } - init_raw_breakpoint (b, gdbarch, sal, bp_breakpoint, ops); + init_raw_breakpoint (b, gdbarch, sal, bp_catchpoint, ops); b->enable_state = enabled ? bp_enabled : bp_disabled; b->disposition = tempflag ? disp_del : disp_donttouch; @@ -11537,10 +11433,9 @@ breakpoint_auto_delete (bpstat bs) /* A comparison function for bp_location AP and BP being interfaced to qsort. Sort elements primarily by their ADDRESS (no matter what - does breakpoint_address_is_meaningful say for its OWNER), - secondarily by ordering first permanent elements and - terciarily just ensuring the array is sorted stable way despite - qsort being an unstable algorithm. */ + bl_address_is_meaningful says), secondarily by ordering first + permanent elements and terciarily just ensuring the array is sorted + stable way despite qsort being an unstable algorithm. */ static int bp_locations_compare (const void *ap, const void *bp) @@ -11880,7 +11775,7 @@ update_global_location_list (enum ugll_insert_mode insert_mode) this one from the target. */ /* OLD_LOC comes from existing struct breakpoint. */ - if (breakpoint_address_is_meaningful (old_loc->owner)) + if (bl_address_is_meaningful (old_loc)) { for (loc2p = locp; (loc2p < bp_locations + bp_locations_count @@ -12020,7 +11915,7 @@ update_global_location_list (enum ugll_insert_mode insert_mode) b = loc->owner; if (!unduplicated_should_be_inserted (loc) - || !breakpoint_address_is_meaningful (b) + || !bl_address_is_meaningful (loc) /* Don't detect duplicate for tracepoint locations because they are never duplicated. See the comments in field `duplicate' of `struct bp_location'. */ @@ -12107,14 +12002,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. */ @@ -12183,8 +12077,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) { @@ -12218,32 +12113,23 @@ 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 () { xfree (this->cond_string); xfree (this->extra_string); - xfree (this->filter); } 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 @@ -12513,7 +12399,7 @@ bkpt_print_it (bpstat bs) async_reason_lookup (EXEC_ASYNC_BREAKPOINT_HIT)); uiout->field_string ("disp", bpdisp_text (b->disposition)); } - uiout->field_int ("bkptno", b->number); + uiout->field_signed ("bkptno", b->number); uiout->text (", "); return PRINT_SRC_AND_LOC; @@ -13431,12 +13317,12 @@ update_static_tracepoint (struct breakpoint *b, struct symtab_and_line sal) if (sym) { uiout->field_string ("func", SYMBOL_PRINT_NAME (sym), - ui_out_style_kind::FUNCTION); + function_name_style.style ()); uiout->text (" at "); } uiout->field_string ("file", symtab_to_filename_for_display (sal2.symtab), - ui_out_style_kind::FILE); + file_name_style.style ()); uiout->text (":"); if (uiout->is_mi_like_p ()) @@ -13446,7 +13332,7 @@ update_static_tracepoint (struct breakpoint *b, struct symtab_and_line sal) uiout->field_string ("fullname", fullname); } - uiout->field_int ("line", sal2.line); + uiout->field_signed ("line", sal2.line); uiout->text ("\n"); b->loc->line_number = sal2.line; @@ -13583,20 +13469,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 ()) @@ -13657,22 +13542,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 @@ -13699,10 +13582,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) { @@ -13815,9 +13699,8 @@ 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, - b->filter); + NULL, 0, &canonical, multiple_symbols_all, + b->filter.get ()); /* We should get 0 or 1 resulting SALs. */ gdb_assert (canonical.lsals.size () < 2); @@ -13874,17 +13757,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 (); @@ -14351,7 +14233,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; @@ -14359,14 +14241,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; @@ -14494,7 +14375,7 @@ invalidate_bp_value_on_memory_change (struct inferior *inferior, && addr + len > loc->address) { wp->val = NULL; - wp->val_valid = 0; + wp->val_valid = false; } } } @@ -14686,7 +14567,7 @@ read_uploaded_action (void) if (next_cmd < this_utp->cmd_strings.size ()) { - rslt = this_utp->cmd_strings[next_cmd]; + rslt = this_utp->cmd_strings[next_cmd].get (); next_cmd++; } @@ -14707,7 +14588,7 @@ create_tracepoint_from_upload (struct uploaded_tp *utp) struct tracepoint *tp; if (utp->at_string) - addr_str = utp->at_string; + addr_str = utp->at_string.get (); else { /* In the absence of a source location, fall back to raw @@ -14731,7 +14612,7 @@ create_tracepoint_from_upload (struct uploaded_tp *utp) current_language); if (!create_breakpoint (get_current_arch (), location.get (), - utp->cond_string, -1, addr_str, + utp->cond_string.get (), -1, addr_str, 0 /* parse cond/thread */, 0 /* tempflag */, utp->type /* type_wanted */, @@ -14793,7 +14674,7 @@ info_tracepoints_command (const char *args, int from_tty) struct ui_out *uiout = current_uiout; int num_printed; - num_printed = breakpoint_1 (args, 0, is_tracepoint); + num_printed = breakpoint_1 (args, false, is_tracepoint); if (num_printed == 0) { @@ -15015,11 +14896,11 @@ print_recreate_thread (struct breakpoint *b, struct ui_file *fp) /* Save information on user settable breakpoints (watchpoints, etc) to a new script file named FILENAME. If FILTER is non-NULL, call it on each breakpoint and only include the ones for which it returns - non-zero. */ + true. */ static void save_breakpoints (const char *filename, int from_tty, - int (*filter) (const struct breakpoint *)) + bool (*filter) (const struct breakpoint *)) { struct breakpoint *tp; int any = 0; @@ -15094,16 +14975,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"); @@ -15191,7 +15071,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. @@ -15212,7 +15092,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\ @@ -15516,9 +15396,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. */ @@ -15574,7 +15451,8 @@ BREAK_ARGS_HELP ("thbreak"))); set_cmd_completer (c, location_completer); add_prefix_cmd ("enable", class_breakpoint, enable_command, _("\ -Enable some breakpoints.\n\ +Enable all or some breakpoints.\n\ +Usage: enable [BREAKPOINTNUM]...\n\ Give breakpoint numbers (separated by spaces) as arguments.\n\ With no subcommand, breakpoints are enabled until you command otherwise.\n\ This is used to cancel the effect of the \"disable\" command.\n\ @@ -15584,46 +15462,54 @@ With a subcommand you can enable temporarily."), add_com_alias ("en", "enable", class_breakpoint, 1); add_prefix_cmd ("breakpoints", class_breakpoint, enable_command, _("\ -Enable some breakpoints.\n\ +Enable all or some breakpoints.\n\ +Usage: enable breakpoints [BREAKPOINTNUM]...\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, _("\ -Enable breakpoints for one hit. Give breakpoint numbers.\n\ +Enable some breakpoints for one hit.\n\ +Usage: enable breakpoints once BREAKPOINTNUM...\n\ If a breakpoint is hit while enabled in this fashion, it becomes disabled."), &enablebreaklist); add_cmd ("delete", no_class, enable_delete_command, _("\ -Enable breakpoints and delete when hit. Give breakpoint numbers.\n\ +Enable some breakpoints and delete when hit.\n\ +Usage: enable breakpoints delete BREAKPOINTNUM...\n\ If a breakpoint is hit while enabled in this fashion, it is deleted."), &enablebreaklist); add_cmd ("count", no_class, enable_count_command, _("\ -Enable breakpoints for COUNT hits. Give count and then breakpoint numbers.\n\ +Enable some breakpoints for COUNT hits.\n\ +Usage: enable breakpoints count COUNT BREAKPOINTNUM...\n\ If a breakpoint is hit while enabled in this fashion,\n\ the count is decremented; when it reaches zero, the breakpoint is disabled."), &enablebreaklist); add_cmd ("delete", no_class, enable_delete_command, _("\ -Enable breakpoints and delete when hit. Give breakpoint numbers.\n\ +Enable some breakpoints and delete when hit.\n\ +Usage: enable delete BREAKPOINTNUM...\n\ If a breakpoint is hit while enabled in this fashion, it is deleted."), &enablelist); add_cmd ("once", no_class, enable_once_command, _("\ -Enable breakpoints for one hit. Give breakpoint numbers.\n\ +Enable some breakpoints for one hit.\n\ +Usage: enable once BREAKPOINTNUM...\n\ If a breakpoint is hit while enabled in this fashion, it becomes disabled."), &enablelist); add_cmd ("count", no_class, enable_count_command, _("\ -Enable breakpoints for COUNT hits. Give count and then breakpoint numbers.\n\ +Enable some breakpoints for COUNT hits.\n\ +Usage: enable count COUNT BREAKPOINTNUM...\n\ If a breakpoint is hit while enabled in this fashion,\n\ the count is decremented; when it reaches zero, the breakpoint is disabled."), &enablelist); add_prefix_cmd ("disable", class_breakpoint, disable_command, _("\ -Disable some breakpoints.\n\ +Disable all or some breakpoints.\n\ +Usage: disable [BREAKPOINTNUM]...\n\ Arguments are breakpoint numbers with spaces in between.\n\ To disable all breakpoints, give no argument.\n\ A disabled breakpoint is not forgotten, but has no effect until re-enabled."), @@ -15632,7 +15518,8 @@ A disabled breakpoint is not forgotten, but has no effect until re-enabled."), add_com_alias ("disa", "disable", class_breakpoint, 1); add_cmd ("breakpoints", class_alias, disable_command, _("\ -Disable some breakpoints.\n\ +Disable all or some breakpoints.\n\ +Usage: disable breakpoints [BREAKPOINTNUM]...\n\ Arguments are breakpoint numbers with spaces in between.\n\ To disable all breakpoints, give no argument.\n\ A disabled breakpoint is not forgotten, but has no effect until re-enabled.\n\ @@ -15640,18 +15527,19 @@ This command may be abbreviated \"disable\"."), &disablelist); add_prefix_cmd ("delete", class_breakpoint, delete_command, _("\ -Delete some breakpoints or auto-display expressions.\n\ +Delete all or some breakpoints.\n\ +Usage: delete [BREAKPOINTNUM]...\n\ Arguments are breakpoint numbers with spaces in between.\n\ To delete all breakpoints, give no argument.\n\ \n\ -Also a prefix command for deletion of other GDB objects.\n\ -The \"unset\" command is also an alias for \"delete\"."), +Also a prefix command for deletion of other GDB objects."), &deletelist, "delete ", 1, &cmdlist); add_com_alias ("d", "delete", class_breakpoint, 1); add_com_alias ("del", "delete", class_breakpoint, 1); add_cmd ("breakpoints", class_alias, delete_command, _("\ -Delete some breakpoints or auto-display expressions.\n\ +Delete all or some breakpoints or auto-display expressions.\n\ +Usage: delete breakpoints [BREAKPOINTNUM]...\n\ Arguments are breakpoint numbers with spaces in between.\n\ To delete all breakpoints, give no argument.\n\ This command may be abbreviated \"delete\"."), @@ -15663,7 +15551,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); @@ -15863,7 +15751,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\ @@ -15928,15 +15816,15 @@ Use the 'source' command in another debug session to restore them."), deprecate_cmd (c, "save tracepoints"); add_prefix_cmd ("breakpoint", class_maintenance, set_breakpoint_cmd, _("\ -Breakpoint specific settings\n\ +Breakpoint specific settings.\n\ Configure various breakpoint-specific variables such as\n\ -pending breakpoint behavior"), +pending breakpoint behavior."), &breakpoint_set_cmdlist, "set breakpoint ", 0/*allow-unknown*/, &setlist); add_prefix_cmd ("breakpoint", class_maintenance, show_breakpoint_cmd, _("\ -Breakpoint specific settings\n\ +Breakpoint specific settings.\n\ Configure various breakpoint-specific variables such as\n\ -pending breakpoint behavior"), +pending breakpoint behavior."), &breakpoint_show_cmdlist, "show breakpoint ", 0/*allow-unknown*/, &showlist); @@ -16037,16 +15925,16 @@ output stream by setting dprintf-function and dprintf-channel."), dprintf_function = xstrdup ("printf"); add_setshow_string_cmd ("dprintf-function", class_support, &dprintf_function, _("\ -Set the function to use for dynamic printf"), _("\ -Show the function to use for dynamic printf"), NULL, +Set the function to use for dynamic printf."), _("\ +Show the function to use for dynamic printf."), NULL, update_dprintf_commands, NULL, &setlist, &showlist); dprintf_channel = xstrdup (""); add_setshow_string_cmd ("dprintf-channel", class_support, &dprintf_channel, _("\ -Set the channel to use for dynamic printf"), _("\ -Show the channel to use for dynamic printf"), NULL, +Set the channel to use for dynamic printf."), _("\ +Show the channel to use for dynamic printf."), NULL, update_dprintf_commands, NULL, &setlist, &showlist); @@ -16061,10 +15949,12 @@ even if GDB disconnects or detaches from the target."), &setlist, &showlist); add_com ("agent-printf", class_vars, agent_printf_command, _("\ -agent-printf \"printf format string\", arg1, arg2, arg3, ..., argn\n\ -(target agent only) This is useful for formatted output in user-defined commands.")); +Target agent only formatted printing, like the C \"printf\" function.\n\ +Usage: agent-printf \"format string\", ARG1, ARG2, ARG3, ..., ARGN\n\ +This supports most C printf format specifications, like %s, %d, etc.\n\ +This is useful for formatted output in user-defined commands.")); - automatic_hardware_breakpoints = 1; + automatic_hardware_breakpoints = true; gdb::observers::about_to_proceed.attach (breakpoint_about_to_proceed); gdb::observers::thread_exit.attach (remove_threaded_breakpoints);