X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fbreakpoint.c;h=7591648f5eb4dea4ec075e4b014bb71e141847ce;hb=e98ee8c458f3a8405eb93e71b00f801b4bbe3635;hp=41050b7778bbb2656c1f0f56431c06ad1593dbc4;hpb=e99b03dcf42606425eab8bd12eadb8aa4007f35a;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 41050b7778..7591648f5e 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -560,7 +560,7 @@ static CORE_ADDR bp_locations_shadow_len_after_address_max; /* The locations that no longer correspond to any breakpoint, unlinked from the bp_locations array, but for which a hit may still be reported by a target. */ -VEC(bp_location_p) *moribund_locations = NULL; +static std::vector moribund_locations; /* Number of last breakpoint made. */ @@ -1009,8 +1009,6 @@ check_no_tracepoint_commands (struct command_line *commands) for (c = commands; c; c = c->next) { - int i; - if (c->control_type == while_stepping_control) error (_("The 'while-stepping' command can " "only be used for tracepoints")); @@ -1145,11 +1143,11 @@ validate_commands_for_breakpoint (struct breakpoint *b, /* Return a vector of all the static tracepoints set at ADDR. The caller is responsible for releasing the vector. */ -VEC(breakpoint_p) * +std::vector static_tracepoints_here (CORE_ADDR addr) { struct breakpoint *b; - VEC(breakpoint_p) *found = 0; + std::vector found; struct bp_location *loc; ALL_BREAKPOINTS (b) @@ -1157,7 +1155,7 @@ static_tracepoints_here (CORE_ADDR addr) { for (loc = b->loc; loc; loc = loc->next) if (loc->address == addr) - VEC_safe_push(breakpoint_p, found, b); + found.push_back (b); } return found; @@ -1221,6 +1219,10 @@ commands_command_1 (const char *arg, int from_tty, struct command_line *control) { counted_command_line cmd; + /* cmd_read will be true once we have read cmd. Note that cmd might still be + NULL after the call to read_command_lines if the user provides an empty + list of command by just typing "end". */ + bool cmd_read = false; std::string new_arg; @@ -1237,8 +1239,9 @@ commands_command_1 (const char *arg, int from_tty, map_breakpoint_numbers (arg, [&] (breakpoint *b) { - if (cmd == NULL) + if (!cmd_read) { + gdb_assert (cmd == NULL); if (control != NULL) cmd = control->body_list_0; else @@ -1258,6 +1261,7 @@ commands_command_1 (const char *arg, int from_tty, cmd = read_command_lines (str.c_str (), from_tty, 1, validator); } + cmd_read = true; } /* If a breakpoint was on the list more than once, we don't need to @@ -1546,8 +1550,8 @@ static int watchpoint_in_thread_scope (struct watchpoint *b) { return (b->pspace == current_program_space - && (ptid_equal (b->watchpoint_thread, null_ptid) - || (ptid_equal (inferior_ptid, b->watchpoint_thread) + && (b->watchpoint_thread == null_ptid + || (inferior_ptid == b->watchpoint_thread && !inferior_thread ()->executing))); } @@ -1775,7 +1779,7 @@ update_watchpoint (struct watchpoint *b, int reparse) { int pc = 0; std::vector val_chain; - struct value *v, *result, *next; + struct value *v, *result; struct program_space *frame_pspace; fetch_subexp_value (b->exp.get (), &pc, &v, &result, &val_chain, 0); @@ -2904,7 +2908,7 @@ update_inserted_breakpoint_locations (void) if we aren't attached to any process yet, we should still insert breakpoints. */ if (!gdbarch_has_global_breakpoints (target_gdbarch ()) - && ptid_equal (inferior_ptid, null_ptid)) + && inferior_ptid == null_ptid) continue; val = insert_bp_location (bl, &tmp_error_stream, &disabled_breaks, @@ -2960,7 +2964,7 @@ insert_breakpoint_locations (void) if we aren't attached to any process yet, we should still insert breakpoints. */ if (!gdbarch_has_global_breakpoints (target_gdbarch ()) - && ptid_equal (inferior_ptid, null_ptid)) + && inferior_ptid == null_ptid) continue; val = insert_bp_location (bl, &tmp_error_stream, &disabled_breaks, @@ -3860,8 +3864,6 @@ void breakpoint_init_inferior (enum inf_context context) { struct breakpoint *b, *b_tmp; - struct bp_location *bl; - int ix; struct program_space *pspace = current_program_space; /* If breakpoint locations are shared across processes, then there's @@ -3951,9 +3953,9 @@ breakpoint_init_inferior (enum inf_context context) } /* Get rid of the moribund locations. */ - for (ix = 0; VEC_iterate (bp_location_p, moribund_locations, ix, bl); ++ix) + for (bp_location *bl : moribund_locations) decref_bp_location (&bl); - VEC_free (bp_location_p, moribund_locations); + moribund_locations.clear (); } /* These functions concern about actual breakpoints inserted in the @@ -4041,10 +4043,7 @@ breakpoint_in_range_p (const address_space *aspace, int moribund_breakpoint_here_p (const address_space *aspace, CORE_ADDR pc) { - struct bp_location *loc; - int ix; - - for (ix = 0; VEC_iterate (bp_location_p, moribund_locations, ix, loc); ++ix) + for (bp_location *loc : moribund_locations) if (breakpoint_location_address_match (loc, aspace, pc)) return 1; @@ -4346,7 +4345,7 @@ bpstat_clear_actions (void) static void breakpoint_about_to_proceed (void) { - if (!ptid_equal (inferior_ptid, null_ptid)) + if (inferior_ptid != null_ptid) { struct thread_info *tp = inferior_thread (); @@ -5372,10 +5371,7 @@ build_bpstat_chain (const address_space *aspace, CORE_ADDR bp_addr, if (!target_supports_stopped_by_sw_breakpoint () || !target_supports_stopped_by_hw_breakpoint ()) { - bp_location *loc; - - for (int ix = 0; - VEC_iterate (bp_location_p, moribund_locations, ix, loc); ++ix) + for (bp_location *loc : moribund_locations) { if (breakpoint_location_address_match (loc, aspace, bp_addr) && need_moribund_for_location_type (loc)) @@ -6048,16 +6044,9 @@ print_one_breakpoint_location (struct breakpoint *b, /* 1 */ annotate_field (0); if (part_of_multiple) - { - char *formatted; - formatted = xstrprintf ("%d.%d", b->number, loc_number); - uiout->field_string ("number", formatted); - xfree (formatted); - } + uiout->field_fmt ("number", "%d.%d", b->number, loc_number); else - { - uiout->field_int ("number", b->number); - } + uiout->field_int ("number", b->number); /* 2 */ annotate_field (1); @@ -7785,7 +7774,7 @@ print_one_catch_fork (struct breakpoint *b, struct bp_location **last_loc) uiout->field_skip ("addr"); annotate_field (5); uiout->text ("fork"); - if (!ptid_equal (c->forked_inferior_pid, null_ptid)) + if (c->forked_inferior_pid != null_ptid) { uiout->text (", process "); uiout->field_int ("what", c->forked_inferior_pid.pid ()); @@ -7900,7 +7889,7 @@ print_one_catch_vfork (struct breakpoint *b, struct bp_location **last_loc) uiout->field_skip ("addr"); annotate_field (5); uiout->text ("vfork"); - if (!ptid_equal (c->forked_inferior_pid, null_ptid)) + if (c->forked_inferior_pid != null_ptid) { uiout->text (", process "); uiout->field_int ("what", c->forked_inferior_pid.pid ()); @@ -8058,7 +8047,6 @@ print_one_catch_solib (struct breakpoint *b, struct bp_location **locs) struct solib_catchpoint *self = (struct solib_catchpoint *) b; struct value_print_options opts; struct ui_out *uiout = current_uiout; - char *msg; get_user_print_options (&opts); /* Field 4, the address, is omitted (which makes the columns not @@ -8070,23 +8058,23 @@ print_one_catch_solib (struct breakpoint *b, struct bp_location **locs) uiout->field_skip ("addr"); } + std::string msg; annotate_field (5); if (self->is_load) { if (self->regex) - msg = xstrprintf (_("load of library matching %s"), self->regex); + msg = string_printf (_("load of library matching %s"), self->regex); else - msg = xstrdup (_("load of library")); + msg = _("load of library"); } else { if (self->regex) - msg = xstrprintf (_("unload of library matching %s"), self->regex); + msg = string_printf (_("unload of library matching %s"), self->regex); else - msg = xstrdup (_("unload of library")); + msg = _("unload of library"); } uiout->field_string ("what", msg); - xfree (msg); if (uiout->is_mi_like_p ()) uiout->field_string ("catch-type", self->is_load ? "load" : "unload"); @@ -9603,7 +9591,7 @@ stopat_command (const char *arg, int from_tty) } if (badInput) - printf_filtered (_("Usage: stop at \n")); + printf_filtered (_("Usage: stop at LINE\n")); else break_command_1 (arg, 0, from_tty); } @@ -12012,7 +12000,7 @@ update_global_location_list (enum ugll_insert_mode insert_mode) old_loc->events_till_retirement = 3 * (thread_count () + 1); old_loc->owner = NULL; - VEC_safe_push (bp_location_p, moribund_locations, old_loc); + moribund_locations.push_back (old_loc); } else { @@ -12115,16 +12103,16 @@ update_global_location_list (enum ugll_insert_mode insert_mode) void breakpoint_retire_moribund (void) { - struct bp_location *loc; - int ix; - - for (ix = 0; VEC_iterate (bp_location_p, moribund_locations, ix, loc); ++ix) - if (--(loc->events_till_retirement) == 0) - { - decref_bp_location (&loc); - VEC_unordered_remove (bp_location_p, moribund_locations, ix); - --ix; - } + for (int ix = 0; ix < moribund_locations.size (); ++ix) + { + struct bp_location *loc = moribund_locations[ix]; + if (--(loc->events_till_retirement) == 0) + { + decref_bp_location (&loc); + unordered_remove (moribund_locations, ix); + --ix; + } + } } static void @@ -14230,6 +14218,8 @@ enable_disable_bp_num_loc (int bp_num, int loc_num, bool enable) target_disable_tracepoint (loc); } update_global_location_list (UGLL_DONT_INSERT); + + gdb::observers::breakpoint_modified.notify (loc->owner); } /* Enable or disable a range of breakpoint locations. BP_NUM is the @@ -15166,15 +15156,15 @@ save_tracepoints_command (const char *args, int from_tty) /* Create a vector of all tracepoints. */ -VEC(breakpoint_p) * +std::vector all_tracepoints (void) { - VEC(breakpoint_p) *tp_vec = 0; + std::vector tp_vec; struct breakpoint *tp; ALL_TRACEPOINTS (tp) { - VEC_safe_push (breakpoint_p, tp_vec, tp); + tp_vec.push_back (tp); } return tp_vec; @@ -15516,6 +15506,10 @@ initialize_breakpoint_ops (void) static struct cmd_list_element *enablebreaklist = NULL; +/* See breakpoint.h. */ + +cmd_list_element *commands_cmd_element = nullptr; + void _initialize_breakpoint (void) { @@ -15541,7 +15535,8 @@ _initialize_breakpoint (void) Set ignore-count of breakpoint number N to COUNT.\n\ Usage is `ignore N COUNT'.")); - add_com ("commands", class_breakpoint, commands_command, _("\ + commands_cmd_element = add_com ("commands", class_breakpoint, + commands_command, _("\ Set commands to be executed when the given breakpoints are hit.\n\ Give a space-separated breakpoint list as argument after \"commands\".\n\ A list element can be a breakpoint number (e.g. `5') or a range of numbers\n\