X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fbreakpoint.c;h=6b6e1f6c257cfee7f507db2ddd5c71b1768eedb3;hb=d7154a8d08b142d1258dc2e4189ff0d00cd26493;hp=11b89bcf88202d7b7ac63e762ec230b9f395574b;hpb=a6535de1903d9caad8c10c1d81c51a29612456a6;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 11b89bcf88..6b6e1f6c25 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,14 +1009,12 @@ 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")); - for (i = 0; i < c->body_count; ++i) - check_no_tracepoint_commands ((c->body_list)[i]); + check_no_tracepoint_commands (c->body_list_0.get ()); + check_no_tracepoint_commands (c->body_list_1.get ()); /* Not that command parsing removes leading whitespace and comment lines and also empty lines. So, we only need to check for @@ -1127,8 +1125,8 @@ validate_commands_for_breakpoint (struct breakpoint *b, { struct command_line *c2; - gdb_assert (while_stepping->body_count == 1); - c2 = while_stepping->body_list[0]; + gdb_assert (while_stepping->body_list_1 == nullptr); + c2 = while_stepping->body_list_0.get (); for (; c2; c2 = c2->next) { if (c2->control_type == while_stepping_control) @@ -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; @@ -1168,7 +1166,7 @@ static_tracepoints_here (CORE_ADDR addr) void breakpoint_set_commands (struct breakpoint *b, - command_line_up &&commands) + counted_command_line &&commands) { validate_commands_for_breakpoint (b, commands.get ()); @@ -1216,14 +1214,6 @@ breakpoint_set_task (struct breakpoint *b, int task) gdb::observers::breakpoint_modified.notify (b); } -void -check_tracepoint_command (char *line, void *closure) -{ - struct breakpoint *b = (struct breakpoint *) closure; - - validate_actionline (line, b); -} - static void commands_command_1 (const char *arg, int from_tty, struct command_line *control) @@ -1248,7 +1238,7 @@ commands_command_1 (const char *arg, int from_tty, if (cmd == NULL) { if (control != NULL) - cmd = copy_command_lines (control->body_list[0]); + cmd = control->body_list_0; else { std::string str @@ -1256,11 +1246,15 @@ commands_command_1 (const char *arg, int from_tty, "%s, one per line."), arg); - cmd = read_command_lines (&str[0], - from_tty, 1, - (is_tracepoint (b) - ? check_tracepoint_command : 0), - b); + auto do_validate = [=] (const char *line) + { + validate_actionline (line, b); + }; + gdb::function_view validator; + if (is_tracepoint (b)) + validator = do_validate; + + cmd = read_command_lines (str.c_str (), from_tty, 1, validator); } } @@ -1550,9 +1544,9 @@ 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) - && !is_executing (inferior_ptid)))); + && (b->watchpoint_thread == null_ptid + || (inferior_ptid == b->watchpoint_thread + && !inferior_thread ()->executing))); } /* Set watchpoint B to disp_del_at_next_stop, even including its possible @@ -1779,7 +1773,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); @@ -2412,7 +2406,7 @@ breakpoint_kind (struct bp_location *bl, CORE_ADDR *addr) struct thread_info *thr = find_thread_global_id (bl->owner->thread); struct regcache *regcache; - regcache = get_thread_regcache (thr->ptid); + regcache = get_thread_regcache (thr); return gdbarch_breakpoint_kind_from_current_state (bl->gdbarch, regcache, addr); @@ -2908,7 +2902,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, @@ -2964,7 +2958,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, @@ -3065,14 +3059,13 @@ Thread-specific breakpoint %d deleted - thread %s no longer in the thread list.\ } } -/* Remove breakpoints of process PID. */ +/* Remove breakpoints of inferior INF. */ int -remove_breakpoints_pid (int pid) +remove_breakpoints_inf (inferior *inf) { struct bp_location *bl, **blp_tmp; int val; - struct inferior *inf = find_inferior_pid (pid); ALL_BP_LOCATIONS (bl, blp_tmp) { @@ -3494,7 +3487,7 @@ create_exception_master_breakpoint (void) addr = BMSYMBOL_VALUE_ADDRESS (bp_objfile_data->exception_msym); addr = gdbarch_convert_from_func_ptr_addr (gdbarch, addr, - ¤t_target); + current_top_target ()); b = create_internal_breakpoint (gdbarch, addr, bp_exception_master, &internal_breakpoint_ops); initialize_explicit_location (&explicit_loc); @@ -3642,7 +3635,7 @@ detach_breakpoints (ptid_t ptid) scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid); struct inferior *inf = current_inferior (); - if (ptid_get_pid (ptid) == ptid_get_pid (inferior_ptid)) + if (ptid.pid () == inferior_ptid.pid ()) error (_("Cannot detach breakpoints of inferior_ptid")); /* Set inferior_ptid; remove_breakpoint_1 uses this global. */ @@ -3865,8 +3858,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 @@ -3956,9 +3947,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 @@ -4046,10 +4037,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; @@ -4333,16 +4321,12 @@ bpstat_num (bpstat *bsp, int *num) void bpstat_clear_actions (void) { - struct thread_info *tp; bpstat bs; - if (ptid_equal (inferior_ptid, null_ptid)) - return; - - tp = find_thread_ptid (inferior_ptid); - if (tp == NULL) + if (inferior_ptid == null_ptid) return; + thread_info *tp = inferior_thread (); for (bs = tp->control.stop_bpstat; bs != NULL; bs = bs->next) { bs->commands = NULL; @@ -4355,7 +4339,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 (); @@ -4470,22 +4454,37 @@ bpstat_do_actions_1 (bpstat *bsp) return again; } +/* Helper for bpstat_do_actions. Get the current thread, if there's + one, is alive and has execution. Return NULL otherwise. */ + +static thread_info * +get_bpstat_thread () +{ + if (inferior_ptid == null_ptid || !target_has_execution) + return NULL; + + thread_info *tp = inferior_thread (); + if (tp->state == THREAD_EXITED || tp->executing) + return NULL; + return tp; +} + void bpstat_do_actions (void) { struct cleanup *cleanup_if_error = make_bpstat_clear_actions_cleanup (); + thread_info *tp; /* Do any commands attached to breakpoint we are stopped at. */ - while (!ptid_equal (inferior_ptid, null_ptid) - && target_has_execution - && !is_exited (inferior_ptid) - && !is_executing (inferior_ptid)) - /* Since in sync mode, bpstat_do_actions may resume the inferior, - and only return when it is stopped at the next breakpoint, we - keep doing breakpoint actions until it returns false to - indicate the inferior was not resumed. */ - if (!bpstat_do_actions_1 (&inferior_thread ()->control.stop_bpstat)) - break; + while ((tp = get_bpstat_thread ()) != NULL) + { + /* Since in sync mode, bpstat_do_actions may resume the + inferior, and only return when it is stopped at the next + breakpoint, we keep doing breakpoint actions until it returns + false to indicate the inferior was not resumed. */ + if (!bpstat_do_actions_1 (&tp->control.stop_bpstat)) + break; + } discard_cleanups (cleanup_if_error); } @@ -4585,8 +4584,7 @@ static void print_solib_event (int is_catchpoint) { bool any_deleted = !current_program_space->deleted_solibs.empty (); - int any_added - = !VEC_empty (so_list_ptr, current_program_space->added_solibs); + bool any_added = !current_program_space->added_solibs.empty (); if (!is_catchpoint) { @@ -4618,18 +4616,14 @@ print_solib_event (int is_catchpoint) if (any_added) { - struct so_list *iter; - int ix; - current_uiout->text (_(" Inferior loaded ")); ui_out_emit_list list_emitter (current_uiout, "added"); - for (ix = 0; - VEC_iterate (so_list_ptr, current_program_space->added_solibs, - ix, iter); - ++ix) + bool first = true; + for (so_list *iter : current_program_space->added_solibs) { - if (ix > 0) + if (!first) current_uiout->text (" "); + first = false; current_uiout->field_string ("library", iter->so_name); current_uiout->text ("\n"); } @@ -4734,7 +4728,7 @@ bpstats::bpstats () int watchpoints_triggered (struct target_waitstatus *ws) { - int stopped_by_watchpoint = target_stopped_by_watchpoint (); + bool stopped_by_watchpoint = target_stopped_by_watchpoint (); CORE_ADDR addr; struct breakpoint *b; @@ -4753,7 +4747,7 @@ watchpoints_triggered (struct target_waitstatus *ws) return 0; } - if (!target_stopped_data_address (¤t_target, &addr)) + if (!target_stopped_data_address (current_top_target (), &addr)) { /* We were stopped by a watchpoint, but we don't know where. Mark all watchpoints as unknown. */ @@ -4793,7 +4787,7 @@ watchpoints_triggered (struct target_waitstatus *ws) } } /* Exact match not required. Within range is sufficient. */ - else if (target_watchpoint_addr_within_range (¤t_target, + else if (target_watchpoint_addr_within_range (current_top_target (), addr, loc->address, loc->length)) { @@ -5163,7 +5157,7 @@ bpstat_check_watchpoint (bpstat bs) breakpoint, set BS->stop to 0. */ static void -bpstat_check_breakpoint_conditions (bpstat bs, ptid_t ptid) +bpstat_check_breakpoint_conditions (bpstat bs, thread_info *thread) { const struct bp_location *bl; struct breakpoint *b; @@ -5193,9 +5187,8 @@ bpstat_check_breakpoint_conditions (bpstat bs, ptid_t ptid) /* If this is a thread/task-specific breakpoint, don't waste cpu evaluating the condition if this isn't the specified thread/task. */ - if ((b->thread != -1 && b->thread != ptid_to_global_thread_id (ptid)) - || (b->task != 0 && b->task != ada_get_task_number (ptid))) - + if ((b->thread != -1 && b->thread != thread->global_num) + || (b->task != 0 && b->task != ada_get_task_number (thread))) { bs->stop = 0; return; @@ -5313,54 +5306,21 @@ need_moribund_for_location_type (struct bp_location *loc) && !target_supports_stopped_by_hw_breakpoint ())); } - -/* Get a bpstat associated with having just stopped at address - BP_ADDR in thread PTID. - - Determine whether we stopped at a breakpoint, etc, or whether we - don't understand this stop. Result is a chain of bpstat's such - that: - - if we don't understand the stop, the result is a null pointer. - - if we understand why we stopped, the result is not null. - - Each element of the chain refers to a particular breakpoint or - watchpoint at which we have stopped. (We may have stopped for - several reasons concurrently.) - - Each element of the chain has valid next, breakpoint_at, - commands, FIXME??? fields. */ +/* See breakpoint.h. */ bpstat -bpstat_stop_status (const address_space *aspace, - CORE_ADDR bp_addr, ptid_t ptid, +build_bpstat_chain (const address_space *aspace, CORE_ADDR bp_addr, const struct target_waitstatus *ws) { - struct breakpoint *b = NULL; - struct bp_location *bl; - struct bp_location *loc; - /* First item of allocated bpstat's. */ + struct breakpoint *b; bpstat bs_head = NULL, *bs_link = &bs_head; - /* Pointer to the last thing in the chain currently. */ - bpstat bs; - int ix; - int need_remove_insert; - int removed_any; - - /* First, build the bpstat chain with locations that explain a - target stop, while being careful to not set the target running, - as that may invalidate locations (in particular watchpoint - locations are recreated). Resuming will happen here with - breakpoint conditions or watchpoint expressions that include - inferior function calls. */ ALL_BREAKPOINTS (b) { if (!breakpoint_enabled (b)) continue; - for (bl = b->loc; bl != NULL; bl = bl->next) + for (bp_location *bl = b->loc; bl != NULL; bl = bl->next) { /* For hardware watchpoints, we look only at the first location. The watchpoint_check function will work on the @@ -5379,8 +5339,8 @@ bpstat_stop_status (const address_space *aspace, /* Come here if it's a watchpoint, or if the break address matches. */ - bs = new bpstats (bl, &bs_link); /* Alloc a bpstat to - explain stop. */ + bpstat bs = new bpstats (bl, &bs_link); /* Alloc a bpstat to + explain stop. */ /* Assume we stop. Should we find a watchpoint that is not actually triggered, or if the condition of the breakpoint @@ -5405,12 +5365,12 @@ bpstat_stop_status (const address_space *aspace, if (!target_supports_stopped_by_sw_breakpoint () || !target_supports_stopped_by_hw_breakpoint ()) { - 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, bp_addr) && need_moribund_for_location_type (loc)) { - bs = new bpstats (loc, &bs_link); + bpstat bs = new bpstats (loc, &bs_link); /* For hits of moribund locations, we should just proceed. */ bs->stop = 0; bs->print = 0; @@ -5419,6 +5379,33 @@ bpstat_stop_status (const address_space *aspace, } } + return bs_head; +} + +/* See breakpoint.h. */ + +bpstat +bpstat_stop_status (const address_space *aspace, + CORE_ADDR bp_addr, thread_info *thread, + const struct target_waitstatus *ws, + bpstat stop_chain) +{ + struct breakpoint *b = NULL; + /* First item of allocated bpstat's. */ + bpstat bs_head = stop_chain; + bpstat bs; + int need_remove_insert; + int removed_any; + + /* First, build the bpstat chain with locations that explain a + target stop, while being careful to not set the target running, + as that may invalidate locations (in particular watchpoint + locations are recreated). Resuming will happen here with + breakpoint conditions or watchpoint expressions that include + inferior function calls. */ + if (bs_head == NULL) + bs_head = build_bpstat_chain (aspace, bp_addr, ws); + /* A bit of special processing for shlib breakpoints. We need to process solib loading here, so that the lists of loaded and unloaded libraries are correct before we handle "catch load" and @@ -5447,7 +5434,7 @@ bpstat_stop_status (const address_space *aspace, b->ops->check_status (bs); if (bs->stop) { - bpstat_check_breakpoint_conditions (bs, ptid); + bpstat_check_breakpoint_conditions (bs, thread); if (bs->stop) { @@ -5870,9 +5857,6 @@ print_breakpoint_location (struct breakpoint *b, { const struct symbol *sym = loc->symbol; - if (sym == NULL) - sym = find_pc_sect_function (loc->address, loc->section); - if (sym) { uiout->text ("in "); @@ -7156,37 +7140,30 @@ set_breakpoint_location_function (struct bp_location *loc, int explicit_loc) || loc->owner->type == bp_hardware_breakpoint || is_tracepoint (loc->owner)) { - int is_gnu_ifunc; const char *function_name; - CORE_ADDR func_addr; - - find_pc_partial_function_gnu_ifunc (loc->address, &function_name, - &func_addr, NULL, &is_gnu_ifunc); - if (is_gnu_ifunc && !explicit_loc) + if (loc->msymbol != NULL + && (MSYMBOL_TYPE (loc->msymbol) == mst_text_gnu_ifunc + || MSYMBOL_TYPE (loc->msymbol) == mst_data_gnu_ifunc) + && !explicit_loc) { struct breakpoint *b = loc->owner; - gdb_assert (loc->pspace == current_program_space); - if (gnu_ifunc_resolve_name (function_name, - &loc->requested_address)) - { - /* Recalculate ADDRESS based on new REQUESTED_ADDRESS. */ - loc->address = adjust_breakpoint_address (loc->gdbarch, - loc->requested_address, - b->type); - } - else if (b->type == bp_breakpoint && b->loc == loc - && loc->next == NULL && b->related_breakpoint == b) + function_name = MSYMBOL_LINKAGE_NAME (loc->msymbol); + + if (b->type == bp_breakpoint && b->loc == loc + && loc->next == NULL && b->related_breakpoint == b) { /* Create only the whole new breakpoint of this type but do not mess more complicated breakpoints with multiple locations. */ b->type = bp_gnu_ifunc_resolver; /* Remember the resolver's address for use by the return breakpoint. */ - loc->related_address = func_addr; + loc->related_address = loc->address; } } + else + find_pc_partial_function (loc->address, &function_name, NULL, NULL); if (function_name) loc->function_name = xstrdup (function_name); @@ -7335,7 +7312,7 @@ set_longjmp_breakpoint_for_call_dummy (void) new_b = momentary_breakpoint_from_master (b, bp_longjmp_call_dummy, &momentary_breakpoint_ops, 1); - new_b->thread = ptid_to_global_thread_id (inferior_ptid); + new_b->thread = inferior_thread ()->global_num; /* Link NEW_B into the chain of RETVAL breakpoints. */ @@ -7375,7 +7352,7 @@ check_longjmp_breakpoint_for_call_dummy (struct thread_info *tp) || frame_find_by_id (dummy_b->frame_id) != NULL) continue; - dummy_frame_discard (dummy_b->frame_id, tp->ptid); + dummy_frame_discard (dummy_b->frame_id, tp); while (b->related_breakpoint != b) { @@ -7722,7 +7699,7 @@ struct fork_catchpoint : public breakpoint static int insert_catch_fork (struct bp_location *bl) { - return target_insert_fork_catchpoint (ptid_get_pid (inferior_ptid)); + return target_insert_fork_catchpoint (inferior_ptid.pid ()); } /* Implement the "remove" breakpoint_ops method for fork @@ -7731,7 +7708,7 @@ insert_catch_fork (struct bp_location *bl) static int remove_catch_fork (struct bp_location *bl, enum remove_bp_reason reason) { - return target_remove_fork_catchpoint (ptid_get_pid (inferior_ptid)); + return target_remove_fork_catchpoint (inferior_ptid.pid ()); } /* Implement the "breakpoint_hit" breakpoint_ops method for fork @@ -7774,7 +7751,7 @@ print_it_catch_fork (bpstat bs) } uiout->field_int ("bkptno", b->number); uiout->text (" (forked process "); - uiout->field_int ("newpid", ptid_get_pid (c->forked_inferior_pid)); + uiout->field_int ("newpid", c->forked_inferior_pid.pid ()); uiout->text ("), "); return PRINT_SRC_AND_LOC; } @@ -7798,10 +7775,10 @@ 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", ptid_get_pid (c->forked_inferior_pid)); + uiout->field_int ("what", c->forked_inferior_pid.pid ()); uiout->spaces (1); } @@ -7838,7 +7815,7 @@ static struct breakpoint_ops catch_fork_breakpoint_ops; static int insert_catch_vfork (struct bp_location *bl) { - return target_insert_vfork_catchpoint (ptid_get_pid (inferior_ptid)); + return target_insert_vfork_catchpoint (inferior_ptid.pid ()); } /* Implement the "remove" breakpoint_ops method for vfork @@ -7847,7 +7824,7 @@ insert_catch_vfork (struct bp_location *bl) static int remove_catch_vfork (struct bp_location *bl, enum remove_bp_reason reason) { - return target_remove_vfork_catchpoint (ptid_get_pid (inferior_ptid)); + return target_remove_vfork_catchpoint (inferior_ptid.pid ()); } /* Implement the "breakpoint_hit" breakpoint_ops method for vfork @@ -7890,7 +7867,7 @@ print_it_catch_vfork (bpstat bs) } uiout->field_int ("bkptno", b->number); uiout->text (" (vforked process "); - uiout->field_int ("newpid", ptid_get_pid (c->forked_inferior_pid)); + uiout->field_int ("newpid", c->forked_inferior_pid.pid ()); uiout->text ("), "); return PRINT_SRC_AND_LOC; } @@ -7913,10 +7890,10 @@ 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", ptid_get_pid (c->forked_inferior_pid)); + uiout->field_int ("what", c->forked_inferior_pid.pid ()); uiout->spaces (1); } @@ -8024,12 +8001,7 @@ check_status_catch_solib (struct bpstats *bs) if (self->is_load) { - struct so_list *iter; - - for (int ix = 0; - VEC_iterate (so_list_ptr, current_program_space->added_solibs, - ix, iter); - ++ix) + for (so_list *iter : current_program_space->added_solibs) { if (!self->regex || self->compiled->exec (iter->so_name, 0, NULL, 0) == 0) @@ -8272,13 +8244,13 @@ exec_catchpoint::~exec_catchpoint () static int insert_catch_exec (struct bp_location *bl) { - return target_insert_exec_catchpoint (ptid_get_pid (inferior_ptid)); + return target_insert_exec_catchpoint (inferior_ptid.pid ()); } static int remove_catch_exec (struct bp_location *bl, enum remove_bp_reason reason) { - return target_remove_exec_catchpoint (ptid_get_pid (inferior_ptid)); + return target_remove_exec_catchpoint (inferior_ptid.pid ()); } static int @@ -8521,11 +8493,7 @@ set_momentary_breakpoint (struct gdbarch *gdbarch, struct symtab_and_line sal, b->disposition = disp_donttouch; b->frame_id = frame_id; - /* If we're debugging a multi-threaded program, then we want - momentary breakpoints to be active in only a single thread of - control. */ - if (in_thread_list (inferior_ptid)) - b->thread = ptid_to_global_thread_id (inferior_ptid); + b->thread = inferior_thread ()->global_num; update_global_location_list_nothrow (UGLL_MAY_INSERT); @@ -8603,9 +8571,7 @@ static void mention (struct breakpoint *b) { b->ops->print_mention (b); - if (current_uiout->is_mi_like_p ()) - return; - printf_filtered ("\n"); + current_uiout->text ("\n"); } @@ -8650,6 +8616,8 @@ add_location_to_breakpoint (struct breakpoint *b, loc->line_number = sal->line; loc->symtab = sal->symtab; loc->symbol = sal->symbol; + loc->msymbol = sal->msymbol; + loc->objfile = sal->objfile; set_breakpoint_location_function (loc, sal->explicit_pc || sal->explicit_line); @@ -8781,18 +8749,12 @@ update_dprintf_command_list (struct breakpoint *b) _("Invalid dprintf style.")); gdb_assert (printf_line != NULL); - /* Manufacture a printf sequence. */ - { - struct command_line *printf_cmd_line = XNEW (struct command_line); - - printf_cmd_line->control_type = simple_control; - printf_cmd_line->body_count = 0; - printf_cmd_line->body_list = NULL; - printf_cmd_line->next = NULL; - printf_cmd_line->line = printf_line; - breakpoint_set_commands (b, command_line_up (printf_cmd_line)); - } + /* Manufacture a printf sequence. */ + struct command_line *printf_cmd_line + = new struct command_line (simple_control, printf_line); + breakpoint_set_commands (b, counted_command_line (printf_cmd_line, + command_lines_deleter ())); } /* Update all dprintf commands, making their command lists reflect @@ -9800,12 +9762,9 @@ print_mention_ranged_breakpoint (struct breakpoint *b) gdb_assert (bl); gdb_assert (b->type == bp_hardware_breakpoint); - if (uiout->is_mi_like_p ()) - return; - - printf_filtered (_("Hardware assisted ranged breakpoint %d from %s to %s."), - b->number, paddress (bl->gdbarch, bl->address), - paddress (bl->gdbarch, bl->address + bl->length - 1)); + uiout->message (_("Hardware assisted ranged breakpoint %d from %s to %s."), + b->number, paddress (bl->gdbarch, bl->address), + paddress (bl->gdbarch, bl->address + bl->length - 1)); } /* Implement the "print_recreate" breakpoint_ops method for @@ -12043,7 +12002,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 { @@ -12146,16 +12105,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 @@ -13902,6 +13861,19 @@ breakpoint_re_set (void) scoped_restore save_input_radix = make_scoped_restore (&input_radix); scoped_restore_current_pspace_and_thread restore_pspace_thread; + /* breakpoint_re_set_one sets the current_language to the language + of the breakpoint it is resetting (see prepare_re_set_context) + before re-evaluating the breakpoint's location. This change can + unfortunately get undone by accident if the language_mode is set + to auto, and we either switch frames, or more likely in this context, + we select the current frame. + + We prevent this by temporarily turning the language_mode to + language_mode_manual. We restore it once all breakpoints + have been reset. */ + scoped_restore save_language_mode = make_scoped_restore (&language_mode); + language_mode = language_mode_manual; + /* Note: we must not try to insert locations until after all breakpoints have been re-set. Otherwise, e.g., when re-setting breakpoint 1, we'd insert the locations of breakpoint 2, which @@ -13943,8 +13915,7 @@ breakpoint_re_set_thread (struct breakpoint *b) { if (b->thread != -1) { - if (in_thread_list (inferior_ptid)) - b->thread = ptid_to_global_thread_id (inferior_ptid); + b->thread = inferior_thread ()->global_num; /* We're being called after following a fork. The new fork is selected as current, and unless this was a vfork will have a @@ -14249,6 +14220,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 @@ -14796,12 +14769,12 @@ create_tracepoint_from_upload (struct uploaded_tp *utp) function. */ if (!utp->cmd_strings.empty ()) { - command_line_up cmd_list; + counted_command_line cmd_list; this_utp = utp; next_cmd = 0; - cmd_list = read_command_lines_1 (read_uploaded_action, 1, NULL, NULL); + cmd_list = read_command_lines_1 (read_uploaded_action, 1, NULL); breakpoint_set_commands (tp, std::move (cmd_list)); } @@ -15185,15 +15158,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;