[12/12] gdb: remove breakpoint_pointer_iterator
Commit Message
Remove the breakpoint_pointer_iterator layer. Adjust all users of
all_breakpoints and all_tracepoints to use references instead of
pointers.
Change-Id: I376826f812117cee1e6b199c384a10376973af5d
---
gdb/break-catch-load.c | 12 +-
gdb/break-catch-syscall.c | 4 +-
gdb/breakpoint.c | 605 +++++++++++++++----------------
gdb/breakpoint.h | 10 +-
gdb/dummy-frame.c | 4 +-
gdb/guile/scm-breakpoint.c | 4 +-
gdb/python/py-breakpoint.c | 4 +-
gdb/python/py-finishbreakpoint.c | 8 +-
gdb/solib-svr4.c | 4 +-
gdb/tracepoint.c | 56 +--
gdb/tui/tui-winsource.c | 14 +-
11 files changed, 360 insertions(+), 365 deletions(-)
Comments
Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
> Remove the breakpoint_pointer_iterator layer. Adjust all users of
> all_breakpoints and all_tracepoints to use references instead of
> pointers.
>
> Change-Id: I376826f812117cee1e6b199c384a10376973af5d
> ---
> gdb/break-catch-load.c | 12 +-
> gdb/break-catch-syscall.c | 4 +-
> gdb/breakpoint.c | 605 +++++++++++++++----------------
> gdb/breakpoint.h | 10 +-
> gdb/dummy-frame.c | 4 +-
> gdb/guile/scm-breakpoint.c | 4 +-
> gdb/python/py-breakpoint.c | 4 +-
> gdb/python/py-finishbreakpoint.c | 8 +-
> gdb/solib-svr4.c | 4 +-
> gdb/tracepoint.c | 56 +--
> gdb/tui/tui-winsource.c | 14 +-
> 11 files changed, 360 insertions(+), 365 deletions(-)
>
> diff --git a/gdb/break-catch-load.c b/gdb/break-catch-load.c
> index 43962880cd96..440b42852bbf 100644
> --- a/gdb/break-catch-load.c
> +++ b/gdb/break-catch-load.c
> @@ -91,20 +91,20 @@ solib_catchpoint::breakpoint_hit (const struct bp_location *bl,
> if (ws.kind () == TARGET_WAITKIND_LOADED)
> return 1;
>
> - for (breakpoint *other : all_breakpoints ())
> + for (breakpoint &other : all_breakpoints ())
> {
> - if (other == bl->owner)
> + if (&other == bl->owner)
> continue;
>
> - if (other->type != bp_shlib_event)
> + if (other.type != bp_shlib_event)
> continue;
>
> - if (pspace != NULL && other->pspace != pspace)
> + if (pspace != NULL && other.pspace != pspace)
> continue;
>
> - for (bp_location &other_bl : other->locations ())
> + for (bp_location &other_bl : other.locations ())
> {
> - if (other->breakpoint_hit (&other_bl, aspace, bp_addr, ws))
> + if (other.breakpoint_hit (&other_bl, aspace, bp_addr, ws))
> return 1;
> }
> }
> diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c
> index 18e2b20c1385..9abf8183984f 100644
> --- a/gdb/break-catch-syscall.c
> +++ b/gdb/break-catch-syscall.c
> @@ -501,8 +501,8 @@ catching_syscall_number_1 (struct breakpoint *b, int syscall_number)
> bool
> catching_syscall_number (int syscall_number)
> {
> - for (breakpoint *b : all_breakpoints ())
> - if (catching_syscall_number_1 (b, syscall_number))
> + for (breakpoint &b : all_breakpoints ())
> + if (catching_syscall_number_1 (&b, syscall_number))
> return true;
>
> return false;
> diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
> index 5f47dc777438..4de3716a0987 100644
> --- a/gdb/breakpoint.c
> +++ b/gdb/breakpoint.c
> @@ -621,9 +621,7 @@ static intrusive_list<breakpoint> breakpoint_chain;
> breakpoint_range
> all_breakpoints ()
> {
> - return breakpoint_range
> - (breakpoint_pointer_iterator (breakpoint_chain.begin ()),
> - breakpoint_pointer_iterator (breakpoint_chain.end ()));
> + return breakpoint_range (breakpoint_chain.begin (), breakpoint_chain.end ());
> }
>
> /* See breakpoint.h. */
> @@ -639,9 +637,8 @@ all_breakpoints_safe ()
> tracepoint_range
> all_tracepoints ()
> {
> - return tracepoint_range
> - (tracepoint_iterator (breakpoint_pointer_iterator (breakpoint_chain.begin ())),
> - tracepoint_iterator (breakpoint_pointer_iterator (breakpoint_chain.end ())));
> + return tracepoint_range (tracepoint_iterator (breakpoint_chain.begin ()),
> + tracepoint_iterator (breakpoint_chain.end ()));
> }
>
> /* Array is sorted by bp_location_is_less_than - primarily by the ADDRESS. */
> @@ -796,8 +793,8 @@ scoped_rbreak_breakpoints::~scoped_rbreak_breakpoints ()
> void
> clear_breakpoint_hit_counts (void)
> {
> - for (breakpoint *b : all_breakpoints ())
> - b->hit_count = 0;
> + for (breakpoint &b : all_breakpoints ())
> + b.hit_count = 0;
> }
>
>
> @@ -807,9 +804,9 @@ clear_breakpoint_hit_counts (void)
> struct breakpoint *
> get_breakpoint (int num)
> {
> - for (breakpoint *b : all_breakpoints ())
> - if (b->number == num)
> - return b;
> + for (breakpoint &b : all_breakpoints ())
> + if (b.number == num)
> + return &b;
>
> return nullptr;
> }
> @@ -820,9 +817,9 @@ get_breakpoint (int num)
> static bool
> has_multiple_locations (int num)
> {
> - for (breakpoint *b : all_breakpoints ())
> - if (b->number == num)
> - return b->has_multiple_locations ();
> + for (breakpoint &b : all_breakpoints ())
> + if (b.number == num)
> + return b.has_multiple_locations ();
>
> return false;
> }
> @@ -1104,14 +1101,14 @@ void
> set_breakpoint_condition (int bpnum, const char *exp, int from_tty,
> bool force)
> {
> - for (breakpoint *b : all_breakpoints ())
> - if (b->number == bpnum)
> + for (breakpoint &b : all_breakpoints ())
> + if (b.number == bpnum)
> {
> /* Check if this breakpoint has a "stop" method implemented in an
> extension language. This method and conditions entered into GDB
> from the CLI are mutually exclusive. */
> const struct extension_language_defn *extlang
> - = get_breakpoint_cond_ext_lang (b, EXT_LANG_NONE);
> + = get_breakpoint_cond_ext_lang (&b, EXT_LANG_NONE);
>
> if (extlang != NULL)
> {
> @@ -1119,9 +1116,9 @@ set_breakpoint_condition (int bpnum, const char *exp, int from_tty,
> " a %s stop condition defined for this breakpoint."),
> ext_lang_capitalized_name (extlang));
> }
> - set_breakpoint_condition (b, exp, from_tty, force);
> + set_breakpoint_condition (&b, exp, from_tty, force);
>
> - if (is_breakpoint (b))
> + if (is_breakpoint (&b))
> update_global_location_list (UGLL_MAY_INSERT);
>
> return;
> @@ -1196,11 +1193,11 @@ condition_completer (struct cmd_list_element *cmd,
> /* We're completing the breakpoint number. */
> len = strlen (text);
>
> - for (breakpoint *b : all_breakpoints ())
> + for (breakpoint &b : all_breakpoints ())
> {
> char number[50];
>
> - xsnprintf (number, sizeof (number), "%d", b->number);
> + xsnprintf (number, sizeof (number), "%d", b.number);
>
> if (strncmp (number, text, len) == 0)
> tracker.add_completion (make_unique_xstrdup (number));
> @@ -1417,13 +1414,13 @@ static_tracepoints_here (CORE_ADDR addr)
> {
> std::vector<breakpoint *> found;
>
> - for (breakpoint *b : all_breakpoints ())
> - if (b->type == bp_static_tracepoint
> - || b->type == bp_static_marker_tracepoint)
> + for (breakpoint &b : all_breakpoints ())
> + if (b.type == bp_static_tracepoint
> + || b.type == bp_static_marker_tracepoint)
> {
> - for (bp_location &loc : b->locations ())
> + for (bp_location &loc : b.locations ())
> if (loc.address == addr)
> - found.push_back (b);
> + found.push_back (&b);
> }
>
> return found;
> @@ -3030,9 +3027,9 @@ void
> breakpoint_program_space_exit (struct program_space *pspace)
> {
> /* Remove any breakpoint that was set through this program space. */
> - for (breakpoint *b : all_breakpoints_safe ())
> - if (b->pspace == pspace)
> - delete_breakpoint (b);
> + for (breakpoint &b : all_breakpoints_safe ())
> + if (b.pspace == pspace)
> + delete_breakpoint (&b);
>
> /* Breakpoints set through other program spaces could have locations
> bound to PSPACE as well. Remove those. */
> @@ -3055,12 +3052,12 @@ breakpoint_program_space_exit (struct program_space *pspace)
> void
> insert_breakpoints (void)
> {
> - for (breakpoint *bpt : all_breakpoints ())
> - if (is_hardware_watchpoint (bpt))
> + for (breakpoint &bpt : all_breakpoints ())
> + if (is_hardware_watchpoint (&bpt))
> {
> - struct watchpoint *w = (struct watchpoint *) bpt;
> + watchpoint &w = static_cast<watchpoint &> (bpt);
Could possibly use gdb::checked_static_cast here? And in other places
throughout this patch?
>
> - update_watchpoint (w, false /* don't reparse. */);
> + update_watchpoint (&w, false /* don't reparse. */);
> }
>
> /* Updating watchpoints creates new locations, so update the global
> @@ -3179,20 +3176,20 @@ insert_breakpoint_locations (void)
>
> /* If we failed to insert all locations of a watchpoint, remove
> them, as half-inserted watchpoint is of limited use. */
> - for (breakpoint *bpt : all_breakpoints ())
> + for (breakpoint &bpt : all_breakpoints ())
> {
> bool some_failed = false;
>
> - if (!is_hardware_watchpoint (bpt))
> + if (!is_hardware_watchpoint (&bpt))
> continue;
>
> - if (!breakpoint_enabled (bpt))
> + if (!breakpoint_enabled (&bpt))
> continue;
>
> - if (bpt->disposition == disp_del_at_next_stop)
> + if (bpt.disposition == disp_del_at_next_stop)
> continue;
>
> - for (bp_location &loc : bpt->locations ())
> + for (bp_location &loc : bpt.locations ())
> if (!loc.inserted && should_be_inserted (&loc))
> {
> some_failed = true;
> @@ -3201,14 +3198,14 @@ insert_breakpoint_locations (void)
>
> if (some_failed)
> {
> - for (bp_location &loc : bpt->locations ())
> + for (bp_location &loc : bpt.locations ())
> if (loc.inserted)
> remove_breakpoint (&loc);
>
> hw_breakpoint_error = 1;
> tmp_error_stream.printf ("Could not insert "
> "hardware watchpoint %d.\n",
> - bpt->number);
> + bpt.number);
> error_flag = -1;
> }
> }
> @@ -3249,14 +3246,14 @@ remove_breakpoints (void)
> static void
> remove_threaded_breakpoints (struct thread_info *tp, int silent)
> {
> - for (breakpoint *b : all_breakpoints_safe ())
> + for (breakpoint &b : all_breakpoints_safe ())
> {
> - if (b->thread == tp->global_num && user_breakpoint_p (b))
> + if (b.thread == tp->global_num && user_breakpoint_p (&b))
> {
> gdb_printf (_("\
> Thread-specific breakpoint %d deleted - thread %s no longer in the thread list.\n"),
> - b->number, print_thread_id (tp));
> - delete_breakpoint (b);
> + b.number, print_thread_id (tp));
> + delete_breakpoint (&b);
> }
> }
> }
> @@ -3765,60 +3762,60 @@ update_breakpoints_after_exec (void)
> if (bploc->pspace == current_program_space)
> gdb_assert (!bploc->inserted);
>
> - for (breakpoint *b : all_breakpoints_safe ())
> + for (breakpoint &b : all_breakpoints_safe ())
> {
> - if (b->pspace != current_program_space)
> + if (b.pspace != current_program_space)
> continue;
>
> /* Solib breakpoints must be explicitly reset after an exec(). */
> - if (b->type == bp_shlib_event)
> + if (b.type == bp_shlib_event)
> {
> - delete_breakpoint (b);
> + delete_breakpoint (&b);
> continue;
> }
>
> /* JIT breakpoints must be explicitly reset after an exec(). */
> - if (b->type == bp_jit_event)
> + if (b.type == bp_jit_event)
> {
> - delete_breakpoint (b);
> + delete_breakpoint (&b);
> continue;
> }
>
> /* Thread event breakpoints must be set anew after an exec(),
> as must overlay event and longjmp master breakpoints. */
> - if (b->type == bp_thread_event || b->type == bp_overlay_event
> - || b->type == bp_longjmp_master || b->type == bp_std_terminate_master
> - || b->type == bp_exception_master)
> + if (b.type == bp_thread_event || b.type == bp_overlay_event
> + || b.type == bp_longjmp_master || b.type == bp_std_terminate_master
> + || b.type == bp_exception_master)
> {
> - delete_breakpoint (b);
> + delete_breakpoint (&b);
> continue;
> }
>
> /* Step-resume breakpoints are meaningless after an exec(). */
> - if (b->type == bp_step_resume || b->type == bp_hp_step_resume)
> + if (b.type == bp_step_resume || b.type == bp_hp_step_resume)
> {
> - delete_breakpoint (b);
> + delete_breakpoint (&b);
> continue;
> }
>
> /* Just like single-step breakpoints. */
> - if (b->type == bp_single_step)
> + if (b.type == bp_single_step)
> {
> - delete_breakpoint (b);
> + delete_breakpoint (&b);
> continue;
> }
>
> /* Longjmp and longjmp-resume breakpoints are also meaningless
> after an exec. */
> - if (b->type == bp_longjmp || b->type == bp_longjmp_resume
> - || b->type == bp_longjmp_call_dummy
> - || b->type == bp_exception || b->type == bp_exception_resume)
> + if (b.type == bp_longjmp || b.type == bp_longjmp_resume
> + || b.type == bp_longjmp_call_dummy
> + || b.type == bp_exception || b.type == bp_exception_resume)
> {
> - delete_breakpoint (b);
> + delete_breakpoint (&b);
> continue;
> }
>
> - if (b->type == bp_catchpoint)
> + if (b.type == bp_catchpoint)
> {
> /* For now, none of the bp_catchpoint breakpoints need to
> do anything at this point. In the future, if some of
> @@ -3853,7 +3850,7 @@ update_breakpoints_after_exec (void)
> address is probably bogus in the new a.out, unlike e.g., the
> solib breakpoints.) */
>
> - if (b->type == bp_finish)
> + if (b.type == bp_finish)
> {
> continue;
> }
> @@ -3861,9 +3858,9 @@ update_breakpoints_after_exec (void)
> /* Without a symbolic address, we have little hope of the
> pre-exec() address meaning the same thing in the post-exec()
> a.out. */
> - if (breakpoint_location_spec_empty_p (b))
> + if (breakpoint_location_spec_empty_p (&b))
> {
> - delete_breakpoint (b);
> + delete_breakpoint (&b);
> continue;
> }
> }
> @@ -4100,12 +4097,12 @@ breakpoint_init_inferior (enum inf_context context)
>
> mark_breakpoints_out ();
>
> - for (breakpoint *b : all_breakpoints_safe ())
> + for (breakpoint &b : all_breakpoints_safe ())
> {
> - if (b->has_locations () && b->first_loc ().pspace != pspace)
> + if (b.has_locations () && b.first_loc ().pspace != pspace)
> continue;
>
> - switch (b->type)
> + switch (b.type)
> {
> case bp_call_dummy:
> case bp_longjmp_call_dummy:
> @@ -4142,7 +4139,7 @@ breakpoint_init_inferior (enum inf_context context)
>
> /* Also remove single-step breakpoints. */
>
> - delete_breakpoint (b);
> + delete_breakpoint (&b);
> break;
>
> case bp_watchpoint:
> @@ -4150,11 +4147,11 @@ breakpoint_init_inferior (enum inf_context context)
> case bp_read_watchpoint:
> case bp_access_watchpoint:
> {
> - struct watchpoint *w = (struct watchpoint *) b;
> + watchpoint &w = static_cast<watchpoint &> (b);
>
> /* Likewise for watchpoints on local expressions. */
> - if (w->exp_valid_block != NULL)
> - delete_breakpoint (b);
> + if (w.exp_valid_block != NULL)
> + delete_breakpoint (&b);
> else
> {
> /* Get rid of existing locations, which are no longer
> @@ -4162,14 +4159,14 @@ breakpoint_init_inferior (enum inf_context context)
> update_watchpoint, when the inferior is restarted.
> The next update_global_location_list call will
> garbage collect them. */
> - b->clear_locations ();
> + b.clear_locations ();
>
> if (context == inf_starting)
> {
> /* Reset val field to force reread of starting value in
> insert_breakpoints. */
> - w->val.reset (nullptr);
> - w->val_valid = false;
> + w.val.reset (nullptr);
> + w.val_valid = false;
> }
> }
> }
> @@ -4350,16 +4347,16 @@ int
> hardware_watchpoint_inserted_in_range (const address_space *aspace,
> CORE_ADDR addr, ULONGEST len)
> {
> - for (breakpoint *bpt : all_breakpoints ())
> + for (breakpoint &bpt : all_breakpoints ())
> {
> - if (bpt->type != bp_hardware_watchpoint
> - && bpt->type != bp_access_watchpoint)
> + if (bpt.type != bp_hardware_watchpoint
> + && bpt.type != bp_access_watchpoint)
> continue;
>
> - if (!breakpoint_enabled (bpt))
> + if (!breakpoint_enabled (&bpt))
> continue;
>
> - for (bp_location &loc : bpt->locations ())
> + for (bp_location &loc : bpt.locations ())
> if (loc.pspace->aspace == aspace && loc.inserted)
> {
> CORE_ADDR l, h;
> @@ -5009,12 +5006,12 @@ watchpoints_triggered (const target_waitstatus &ws)
> {
> /* We were not stopped by a watchpoint. Mark all watchpoints
> as not triggered. */
> - for (breakpoint *b : all_breakpoints ())
> - if (is_hardware_watchpoint (b))
> + for (breakpoint &b : all_breakpoints ())
> + if (is_hardware_watchpoint (&b))
> {
> - struct watchpoint *w = (struct watchpoint *) b;
> + watchpoint &w = static_cast<watchpoint &> (b);
>
> - w->watchpoint_triggered = watch_triggered_no;
> + w.watchpoint_triggered = watch_triggered_no;
> }
>
> return 0;
> @@ -5024,12 +5021,12 @@ watchpoints_triggered (const target_waitstatus &ws)
> {
> /* We were stopped by a watchpoint, but we don't know where.
> Mark all watchpoints as unknown. */
> - for (breakpoint *b : all_breakpoints ())
> - if (is_hardware_watchpoint (b))
> + for (breakpoint &b : all_breakpoints ())
> + if (is_hardware_watchpoint (&b))
> {
> - struct watchpoint *w = (struct watchpoint *) b;
> + watchpoint &w = static_cast<watchpoint &> (b);
>
> - w->watchpoint_triggered = watch_triggered_unknown;
> + w.watchpoint_triggered = watch_triggered_unknown;
> }
>
> return 1;
> @@ -5039,22 +5036,22 @@ watchpoints_triggered (const target_waitstatus &ws)
> affected by this data address as triggered, and all others as not
> triggered. */
>
> - for (breakpoint *b : all_breakpoints ())
> - if (is_hardware_watchpoint (b))
> + for (breakpoint &b : all_breakpoints ())
> + if (is_hardware_watchpoint (&b))
> {
> - struct watchpoint *w = (struct watchpoint *) b;
> + watchpoint &w = static_cast<watchpoint &> (b);
>
> - w->watchpoint_triggered = watch_triggered_no;
> - for (bp_location &loc : b->locations ())
> + w.watchpoint_triggered = watch_triggered_no;
> + for (bp_location &loc : b.locations ())
> {
> - if (is_masked_watchpoint (b))
> + if (is_masked_watchpoint (&b))
> {
> - CORE_ADDR newaddr = addr & w->hw_wp_mask;
> - CORE_ADDR start = loc.address & w->hw_wp_mask;
> + CORE_ADDR newaddr = addr & w.hw_wp_mask;
> + CORE_ADDR start = loc.address & w.hw_wp_mask;
>
> if (newaddr == start)
> {
> - w->watchpoint_triggered = watch_triggered_yes;
> + w.watchpoint_triggered = watch_triggered_yes;
> break;
> }
> }
> @@ -5063,7 +5060,7 @@ watchpoints_triggered (const target_waitstatus &ws)
> (current_inferior ()->top_target (), addr, loc.address,
> loc.length))
> {
> - w->watchpoint_triggered = watch_triggered_yes;
> + w.watchpoint_triggered = watch_triggered_yes;
> break;
> }
> }
> @@ -5363,14 +5360,14 @@ bpstat_check_watchpoint (bpstat *bs)
>
> if (bl->watchpoint_type == hw_read)
> {
> - for (breakpoint *other_b : all_breakpoints ())
> - if (other_b->type == bp_hardware_watchpoint
> - || other_b->type == bp_access_watchpoint)
> + for (breakpoint &other_b : all_breakpoints ())
> + if (other_b.type == bp_hardware_watchpoint
> + || other_b.type == bp_access_watchpoint)
> {
> - struct watchpoint *other_w =
> - (struct watchpoint *) other_b;
> + watchpoint &other_w =
> + static_cast<watchpoint &> (other_b);
>
> - if (other_w->watchpoint_triggered
> + if (other_w.watchpoint_triggered
> == watch_triggered_yes)
> {
> other_write_watchpoint = 1;
> @@ -5612,19 +5609,19 @@ build_bpstat_chain (const address_space *aspace, CORE_ADDR bp_addr,
> {
> bpstat *bs_head = nullptr, **bs_link = &bs_head;
>
> - for (breakpoint *b : all_breakpoints ())
> + for (breakpoint &b : all_breakpoints ())
> {
> - if (!breakpoint_enabled (b))
> + if (!breakpoint_enabled (&b))
> continue;
>
> - for (bp_location &bl : b->locations ())
> + for (bp_location &bl : b.locations ())
> {
> /* For hardware watchpoints, we look only at the first
> location. The watchpoint_check function will work on the
> entire expression, not the individual locations. For
> read watchpoints, the watchpoints_triggered function has
> checked all locations already. */
> - if (b->type == bp_hardware_watchpoint && &bl != &b->first_loc ())
> + if (b.type == bp_hardware_watchpoint && &bl != &b.first_loc ())
> break;
>
> if (!bl.enabled || bl.disabled_by_cond || bl.shlib_disabled)
> @@ -5649,9 +5646,9 @@ build_bpstat_chain (const address_space *aspace, CORE_ADDR bp_addr,
> watchpoint as triggered so that we will handle the
> out-of-scope event. We'll get to the watchpoint next
> iteration. */
> - if (b->type == bp_watchpoint_scope && b->related_breakpoint != b)
> + if (b.type == bp_watchpoint_scope && b.related_breakpoint != &b)
> {
> - struct watchpoint *w = (struct watchpoint *) b->related_breakpoint;
> + struct watchpoint *w = (struct watchpoint *) b.related_breakpoint;
>
> w->watchpoint_triggered = watch_triggered_yes;
> }
> @@ -6044,10 +6041,10 @@ bpstat_run_callbacks (bpstat *bs_head)
> bool
> bpstat_should_step ()
> {
> - for (breakpoint *b : all_breakpoints ())
> - if (breakpoint_enabled (b)
> - && b->type == bp_watchpoint
> - && b->has_locations ())
> + for (breakpoint &b : all_breakpoints ())
> + if (breakpoint_enabled (&b)
> + && b.type == bp_watchpoint
> + && b.has_locations ())
> return true;
>
> return false;
> @@ -6832,31 +6829,31 @@ breakpoint_1 (const char *bp_num_list, bool show_internal,
> /* Compute the number of rows in the table, as well as the size
> required for address fields. */
> nr_printable_breakpoints = 0;
> - for (breakpoint *b : all_breakpoints ())
> + for (breakpoint &b : all_breakpoints ())
> {
> /* If we have a filter, only list the breakpoints it accepts. */
> - if (filter && !filter (b))
> + if (filter && !filter (&b))
> continue;
>
> /* If we have a BP_NUM_LIST string, it is a list of breakpoints to
> accept. Skip the others. */
> if (bp_num_list != NULL && *bp_num_list != '\0')
> {
> - if (show_internal && parse_and_eval_long (bp_num_list) != b->number)
> + if (show_internal && parse_and_eval_long (bp_num_list) != b.number)
> continue;
> - if (!show_internal && !number_is_in_list (bp_num_list, b->number))
> + if (!show_internal && !number_is_in_list (bp_num_list, b.number))
> continue;
> }
>
> - if (show_internal || user_breakpoint_p (b))
> + if (show_internal || user_breakpoint_p (&b))
> {
> int addr_bit, type_len;
>
> - addr_bit = breakpoint_address_bits (b);
> + addr_bit = breakpoint_address_bits (&b);
> if (addr_bit > print_address_bits)
> print_address_bits = addr_bit;
>
> - type_len = strlen (bptype_string (b->type));
> + type_len = strlen (bptype_string (b.type));
> if (type_len > print_type_col_width)
> print_type_col_width = type_len;
>
> @@ -6900,11 +6897,11 @@ breakpoint_1 (const char *bp_num_list, bool show_internal,
> if (nr_printable_breakpoints > 0)
> annotate_breakpoints_table ();
>
> - for (breakpoint *b : all_breakpoints ())
> + for (breakpoint &b : all_breakpoints ())
> {
> QUIT;
> /* If we have a filter, only list the breakpoints it accepts. */
> - if (filter && !filter (b))
> + if (filter && !filter (&b))
> continue;
>
> /* If we have a BP_NUM_LIST string, it is a list of breakpoints to
> @@ -6914,21 +6911,21 @@ breakpoint_1 (const char *bp_num_list, bool show_internal,
> {
> if (show_internal) /* maintenance info breakpoint */
> {
> - if (parse_and_eval_long (bp_num_list) != b->number)
> + if (parse_and_eval_long (bp_num_list) != b.number)
> continue;
> }
> else /* all others */
> {
> - if (!number_is_in_list (bp_num_list, b->number))
> + if (!number_is_in_list (bp_num_list, b.number))
> continue;
> }
> }
> /* We only print out user settable breakpoints unless the
> show_internal is set. */
> - if (show_internal || user_breakpoint_p (b))
> + if (show_internal || user_breakpoint_p (&b))
> {
> - print_one_breakpoint (b, &last_loc, show_internal);
> - for (bp_location &loc : b->locations ())
> + print_one_breakpoint (&b, &last_loc, show_internal);
> + for (bp_location &loc : b.locations ())
> if (loc.disabled_by_cond)
> has_disabled_by_cond_location = true;
> }
> @@ -7041,9 +7038,9 @@ describe_other_breakpoints (struct gdbarch *gdbarch,
> {
> int others = 0;
>
> - for (breakpoint *b : all_breakpoints ())
> - others += (user_breakpoint_p (b)
> - && breakpoint_has_pc (b, pspace, pc, section));
> + for (breakpoint &b : all_breakpoints ())
> + others += (user_breakpoint_p (&b)
> + && breakpoint_has_pc (&b, pspace, pc, section));
>
> if (others > 0)
> {
> @@ -7051,23 +7048,24 @@ describe_other_breakpoints (struct gdbarch *gdbarch,
> gdb_printf (_("Note: breakpoint "));
> else /* if (others == ???) */
> gdb_printf (_("Note: breakpoints "));
> - for (breakpoint *b : all_breakpoints ())
> - if (user_breakpoint_p (b) && breakpoint_has_pc (b, pspace, pc, section))
> + for (breakpoint &b : all_breakpoints ())
> + if (user_breakpoint_p (&b)
> + && breakpoint_has_pc (&b, pspace, pc, section))
> {
> others--;
> - gdb_printf ("%d", b->number);
> - if (b->thread == -1 && thread != -1)
> + gdb_printf ("%d", b.number);
> + if (b.thread == -1 && thread != -1)
> gdb_printf (" (all threads)");
> - else if (b->thread != -1)
> + else if (b.thread != -1)
> {
> - struct thread_info *thr = find_thread_global_id (b->thread);
> + struct thread_info *thr = find_thread_global_id (b.thread);
> gdb_printf (" (thread %s)", print_thread_id (thr));
> }
> - else if (b->task != -1)
> - gdb_printf (" (task %d)", b->task);
> + else if (b.task != -1)
> + gdb_printf (" (task %d)", b.task);
> gdb_printf ("%s%s ",
> - ((b->enable_state == bp_disabled
> - || b->enable_state == bp_call_disabled)
> + ((b.enable_state == bp_disabled
> + || b.enable_state == bp_call_disabled)
> ? " (disabled)"
> : ""),
> (others > 1) ? ","
> @@ -7510,15 +7508,15 @@ set_longjmp_breakpoint (struct thread_info *tp, struct frame_id frame)
> we maintain a list of continually-inserted but always disabled
> longjmp "master" breakpoints. Here, we simply create momentary
> clones of those and enable them for the requested thread. */
> - for (breakpoint *b : all_breakpoints_safe ())
> - if (b->pspace == current_program_space
> - && (b->type == bp_longjmp_master
> - || b->type == bp_exception_master))
> + for (breakpoint &b : all_breakpoints_safe ())
> + if (b.pspace == current_program_space
> + && (b.type == bp_longjmp_master
> + || b.type == bp_exception_master))
> {
> - enum bptype type = b->type == bp_longjmp_master ? bp_longjmp : bp_exception;
> + bptype type = b.type == bp_longjmp_master ? bp_longjmp : bp_exception;
> /* longjmp_breakpoint_ops ensures INITIATING_FRAME is cleared again
> after their removal. */
> - momentary_breakpoint_from_master (b, type, 1, thread);
> + momentary_breakpoint_from_master (&b, type, 1, thread);
> }
>
> tp->initiating_frame = frame;
> @@ -7528,22 +7526,22 @@ set_longjmp_breakpoint (struct thread_info *tp, struct frame_id frame)
> void
> delete_longjmp_breakpoint (int thread)
> {
> - for (breakpoint *b : all_breakpoints_safe ())
> - if (b->type == bp_longjmp || b->type == bp_exception)
> + for (breakpoint &b : all_breakpoints_safe ())
> + if (b.type == bp_longjmp || b.type == bp_exception)
> {
> - if (b->thread == thread)
> - delete_breakpoint (b);
> + if (b.thread == thread)
> + delete_breakpoint (&b);
> }
> }
>
> void
> delete_longjmp_breakpoint_at_next_stop (int thread)
> {
> - for (breakpoint *b : all_breakpoints_safe ())
> - if (b->type == bp_longjmp || b->type == bp_exception)
> + for (breakpoint &b : all_breakpoints_safe ())
> + if (b.type == bp_longjmp || b.type == bp_exception)
> {
> - if (b->thread == thread)
> - b->disposition = disp_del_at_next_stop;
> + if (b.thread == thread)
> + b.disposition = disp_del_at_next_stop;
> }
> }
>
> @@ -7557,12 +7555,12 @@ set_longjmp_breakpoint_for_call_dummy (void)
> {
> breakpoint *retval = nullptr;
>
> - for (breakpoint *b : all_breakpoints ())
> - if (b->pspace == current_program_space && b->type == bp_longjmp_master)
> + for (breakpoint &b : all_breakpoints ())
> + if (b.pspace == current_program_space && b.type == bp_longjmp_master)
> {
> int thread = inferior_thread ()->global_num;
> breakpoint *new_b
> - = momentary_breakpoint_from_master (b, bp_longjmp_call_dummy,
> + = momentary_breakpoint_from_master (&b, bp_longjmp_call_dummy,
> 1, thread);
>
> /* Link NEW_B into the chain of RETVAL breakpoints. */
> @@ -7596,15 +7594,15 @@ check_longjmp_breakpoint_for_call_dummy (struct thread_info *tp)
> Save all breakpoints to delete in that set and delete them at the end. */
> std::unordered_set<breakpoint *> to_delete;
>
> - for (struct breakpoint *b : all_breakpoints ())
> + for (struct breakpoint &b : all_breakpoints ())
> {
> - if (b->type == bp_longjmp_call_dummy && b->thread == tp->global_num)
> + if (b.type == bp_longjmp_call_dummy && b.thread == tp->global_num)
> {
> - struct breakpoint *dummy_b = b->related_breakpoint;
> + struct breakpoint *dummy_b = b.related_breakpoint;
>
> /* Find the bp_call_dummy breakpoint in the list of breakpoints
> chained off b->related_breakpoint. */
> - while (dummy_b != b && dummy_b->type != bp_call_dummy)
> + while (dummy_b != &b && dummy_b->type != bp_call_dummy)
> dummy_b = dummy_b->related_breakpoint;
>
> /* If there was no bp_call_dummy breakpoint then there's nothing
> @@ -7653,12 +7651,12 @@ check_longjmp_breakpoint_for_call_dummy (struct thread_info *tp)
>
> dummy_frame_discard (dummy_b->frame_id, tp);
>
> - for (breakpoint *related_breakpoint = b->related_breakpoint;
> - related_breakpoint != b;
> + for (breakpoint *related_breakpoint = b.related_breakpoint;
> + related_breakpoint != &b;
> related_breakpoint = related_breakpoint->related_breakpoint)
> - to_delete.insert (b->related_breakpoint);
> + to_delete.insert (b.related_breakpoint);
>
> - to_delete.insert (b);
> + to_delete.insert (&b);
> }
> }
>
> @@ -7669,10 +7667,10 @@ check_longjmp_breakpoint_for_call_dummy (struct thread_info *tp)
> void
> enable_overlay_breakpoints (void)
> {
> - for (breakpoint *b : all_breakpoints ())
> - if (b->type == bp_overlay_event)
> + for (breakpoint &b : all_breakpoints ())
> + if (b.type == bp_overlay_event)
> {
> - b->enable_state = bp_enabled;
> + b.enable_state = bp_enabled;
> update_global_location_list (UGLL_MAY_INSERT);
> overlay_events_enabled = 1;
> }
> @@ -7681,10 +7679,10 @@ enable_overlay_breakpoints (void)
> void
> disable_overlay_breakpoints (void)
> {
> - for (breakpoint *b : all_breakpoints ())
> - if (b->type == bp_overlay_event)
> + for (breakpoint &b : all_breakpoints ())
> + if (b.type == bp_overlay_event)
> {
> - b->enable_state = bp_disabled;
> + b.enable_state = bp_disabled;
> update_global_location_list (UGLL_DONT_INSERT);
> overlay_events_enabled = 0;
> }
> @@ -7695,11 +7693,11 @@ disable_overlay_breakpoints (void)
> void
> set_std_terminate_breakpoint (void)
> {
> - for (breakpoint *b : all_breakpoints_safe ())
> - if (b->pspace == current_program_space
> - && b->type == bp_std_terminate_master)
> + for (breakpoint &b : all_breakpoints_safe ())
> + if (b.pspace == current_program_space
> + && b.type == bp_std_terminate_master)
> {
> - momentary_breakpoint_from_master (b, bp_std_terminate, 1,
> + momentary_breakpoint_from_master (&b, bp_std_terminate, 1,
> inferior_thread ()->global_num);
> }
> }
> @@ -7708,9 +7706,9 @@ set_std_terminate_breakpoint (void)
> void
> delete_std_terminate_breakpoint (void)
> {
> - for (breakpoint *b : all_breakpoints_safe ())
> - if (b->type == bp_std_terminate)
> - delete_breakpoint (b);
> + for (breakpoint &b : all_breakpoints_safe ())
> + if (b.type == bp_std_terminate)
> + delete_breakpoint (&b);
> }
>
> struct breakpoint *
> @@ -7748,19 +7746,19 @@ create_jit_event_breakpoint (struct gdbarch *gdbarch, CORE_ADDR address)
> void
> remove_jit_event_breakpoints (void)
> {
> - for (breakpoint *b : all_breakpoints_safe ())
> - if (b->type == bp_jit_event
> - && b->first_loc ().pspace == current_program_space)
> - delete_breakpoint (b);
> + for (breakpoint &b : all_breakpoints_safe ())
> + if (b.type == bp_jit_event
> + && b.first_loc ().pspace == current_program_space)
> + delete_breakpoint (&b);
> }
>
> void
> remove_solib_event_breakpoints (void)
> {
> - for (breakpoint *b : all_breakpoints_safe ())
> - if (b->type == bp_shlib_event
> - && b->first_loc ().pspace == current_program_space)
> - delete_breakpoint (b);
> + for (breakpoint &b : all_breakpoints_safe ())
> + if (b.type == bp_shlib_event
> + && b.first_loc ().pspace == current_program_space)
> + delete_breakpoint (&b);
> }
>
> /* See breakpoint.h. */
> @@ -7768,10 +7766,10 @@ remove_solib_event_breakpoints (void)
> void
> remove_solib_event_breakpoints_at_next_stop (void)
> {
> - for (breakpoint *b : all_breakpoints_safe ())
> - if (b->type == bp_shlib_event
> - && b->first_loc ().pspace == current_program_space)
> - b->disposition = disp_del_at_next_stop;
> + for (breakpoint &b : all_breakpoints_safe ())
> + if (b.type == bp_shlib_event
> + && b.first_loc ().pspace == current_program_space)
> + b.disposition = disp_del_at_next_stop;
> }
>
> /* Helper for create_solib_event_breakpoint /
> @@ -7913,14 +7911,14 @@ disable_breakpoints_in_freed_objfile (struct objfile *objfile)
> || (objfile->flags & OBJF_USERLOADED) == 0)
> return;
>
> - for (breakpoint *b : all_breakpoints ())
> + for (breakpoint &b : all_breakpoints ())
> {
> bool bp_modified = false;
>
> - if (!is_breakpoint (b) && !is_tracepoint (b))
> + if (!is_breakpoint (&b) && !is_tracepoint (&b))
> continue;
>
> - for (bp_location &loc : b->locations ())
> + for (bp_location &loc : b.locations ())
> {
> CORE_ADDR loc_addr = loc.address;
>
> @@ -7954,7 +7952,7 @@ disable_breakpoints_in_freed_objfile (struct objfile *objfile)
> }
>
> if (bp_modified)
> - gdb::observers::breakpoint_modified.notify (b);
> + gdb::observers::breakpoint_modified.notify (&b);
> }
> }
>
> @@ -8007,13 +8005,13 @@ hw_breakpoint_used_count (void)
> {
> int i = 0;
>
> - for (breakpoint *b : all_breakpoints ())
> - if (b->type == bp_hardware_breakpoint && breakpoint_enabled (b))
> - for (bp_location &bl : b->locations ())
> + for (breakpoint &b : all_breakpoints ())
> + if (b.type == bp_hardware_breakpoint && breakpoint_enabled (&b))
> + for (bp_location &bl : b.locations ())
> {
> /* Special types of hardware breakpoints may use more than
> one register. */
> - i += b->resources_needed (&bl);
> + i += b.resources_needed (&bl);
> }
>
> return i;
> @@ -8052,16 +8050,16 @@ hw_watchpoint_used_count_others (struct breakpoint *except,
> int i = 0;
>
> *other_type_used = 0;
> - for (breakpoint *b : all_breakpoints ())
> + for (breakpoint &b : all_breakpoints ())
> {
> - if (b == except)
> + if (&b == except)
> continue;
> - if (!breakpoint_enabled (b))
> + if (!breakpoint_enabled (&b))
> continue;
>
> - if (b->type == type)
> - i += hw_watchpoint_use_count (b);
> - else if (is_hardware_watchpoint (b))
> + if (b.type == type)
> + i += hw_watchpoint_use_count (&b);
> + else if (is_hardware_watchpoint (&b))
> *other_type_used = 1;
> }
>
> @@ -8071,10 +8069,10 @@ hw_watchpoint_used_count_others (struct breakpoint *except,
> void
> disable_watchpoints_before_interactive_call_start (void)
> {
> - for (breakpoint *b : all_breakpoints ())
> - if (is_watchpoint (b) && breakpoint_enabled (b))
> + for (breakpoint &b : all_breakpoints ())
> + if (is_watchpoint (&b) && breakpoint_enabled (&b))
> {
> - b->enable_state = bp_call_disabled;
> + b.enable_state = bp_call_disabled;
> update_global_location_list (UGLL_DONT_INSERT);
> }
> }
> @@ -8082,10 +8080,10 @@ disable_watchpoints_before_interactive_call_start (void)
> void
> enable_watchpoints_after_interactive_call_stop (void)
> {
> - for (breakpoint *b : all_breakpoints ())
> - if (is_watchpoint (b) && b->enable_state == bp_call_disabled)
> + for (breakpoint &b : all_breakpoints ())
> + if (is_watchpoint (&b) && b.enable_state == bp_call_disabled)
> {
> - b->enable_state = bp_enabled;
> + b.enable_state = bp_enabled;
> update_global_location_list (UGLL_MAY_INSERT);
> }
> }
> @@ -8421,9 +8419,9 @@ static void
> update_dprintf_commands (const char *args, int from_tty,
> struct cmd_list_element *c)
> {
> - for (breakpoint *b : all_breakpoints ())
> - if (b->type == bp_dprintf)
> - update_dprintf_command_list (b);
> + for (breakpoint &b : all_breakpoints ())
> + if (b.type == bp_dprintf)
> + update_dprintf_command_list (&b);
> }
>
> code_breakpoint::code_breakpoint (struct gdbarch *gdbarch_,
> @@ -10824,14 +10822,14 @@ clear_command (const char *arg, int from_tty)
> ? NULL : symtab_to_fullname (sal.symtab));
>
> /* Find all matching breakpoints and add them to 'found'. */
> - for (breakpoint *b : all_breakpoints ())
> + for (breakpoint &b : all_breakpoints ())
> {
> int match = 0;
> /* Are we going to delete b? */
> - if (b->type != bp_none && !is_watchpoint (b)
> - && user_breakpoint_p (b))
> + if (b.type != bp_none && !is_watchpoint (&b)
> + && user_breakpoint_p (&b))
> {
> - for (bp_location &loc : b->locations ())
> + for (bp_location &loc : b.locations ())
> {
> /* If the user specified file:line, don't allow a PC
> match. This matches historical gdb behavior. */
> @@ -10861,7 +10859,7 @@ clear_command (const char *arg, int from_tty)
> }
>
> if (match)
> - found.push_back (b);
> + found.push_back (&b);
> }
> }
>
> @@ -10920,9 +10918,9 @@ breakpoint_auto_delete (bpstat *bs)
> && bs->stop)
> delete_breakpoint (bs->breakpoint_at);
>
> - for (breakpoint *b : all_breakpoints_safe ())
> - if (b->disposition == disp_del_at_next_stop)
> - delete_breakpoint (b);
> + for (breakpoint &b : all_breakpoints_safe ())
> + if (b.disposition == disp_del_at_next_stop)
> + delete_breakpoint (&b);
> }
>
> /* A comparison function for bp_location AP and BP being interfaced to
> @@ -11013,12 +11011,11 @@ download_tracepoint_locations (void)
>
> scoped_restore_current_pspace_and_thread restore_pspace_thread;
>
> - for (breakpoint *b : all_tracepoints ())
> + for (breakpoint &b : all_tracepoints ())
> {
> - struct tracepoint *t;
> bool bp_location_downloaded = false;
>
> - if ((b->type == bp_fast_tracepoint
> + if ((b.type == bp_fast_tracepoint
> ? !may_insert_fast_tracepoints
> : !may_insert_tracepoints))
> continue;
> @@ -11034,7 +11031,7 @@ download_tracepoint_locations (void)
> if (can_download_tracepoint == TRIBOOL_FALSE)
> break;
>
> - for (bp_location &bl : b->locations ())
> + for (bp_location &bl : b.locations ())
> {
> /* In tracepoint, locations are _never_ duplicated, so
> should_be_inserted is equivalent to
> @@ -11049,10 +11046,11 @@ download_tracepoint_locations (void)
> bl.inserted = 1;
> bp_location_downloaded = true;
> }
> - t = (struct tracepoint *) b;
> - t->number_on_target = b->number;
> +
> + tracepoint &t = static_cast<tracepoint &> (b);
> + t.number_on_target = b.number;
> if (bp_location_downloaded)
> - gdb::observers::breakpoint_modified.notify (b);
> + gdb::observers::breakpoint_modified.notify (&b);
> }
> }
>
> @@ -11159,8 +11157,8 @@ update_global_location_list (enum ugll_insert_mode insert_mode)
> std::vector<bp_location *> old_locations = std::move (bp_locations);
> bp_locations.clear ();
>
> - for (breakpoint *b : all_breakpoints ())
> - for (bp_location &loc : b->locations ())
> + for (breakpoint &b : all_breakpoints ())
> + for (bp_location &loc : b.locations ())
> bp_locations.push_back (&loc);
>
> /* See if we need to "upgrade" a software breakpoint to a hardware
> @@ -12458,8 +12456,8 @@ delete_command (const char *arg, int from_tty)
> /* Delete all breakpoints if no argument. Do not delete
> internal breakpoints, these have to be deleted with an
> explicit breakpoint number argument. */
> - for (breakpoint *b : all_breakpoints ())
> - if (user_breakpoint_p (b))
> + for (breakpoint &b : all_breakpoints ())
> + if (user_breakpoint_p (&b))
> {
> breaks_to_delete = 1;
> break;
> @@ -12468,9 +12466,9 @@ delete_command (const char *arg, int from_tty)
> /* Ask user only if there are some breakpoints to delete. */
> if (!from_tty
> || (breaks_to_delete && query (_("Delete all breakpoints? "))))
> - for (breakpoint *b : all_breakpoints_safe ())
> - if (user_breakpoint_p (b))
> - delete_breakpoint (b);
> + for (breakpoint &b : all_breakpoints_safe ())
> + if (user_breakpoint_p (&b))
> + delete_breakpoint (&b);
> }
> else
> map_breakpoint_numbers
> @@ -12991,17 +12989,17 @@ breakpoint_re_set (void)
> breakpoint 1, we'd insert the locations of breakpoint 2, which
> hadn't been re-set yet, and thus may have stale locations. */
>
> - for (breakpoint *b : all_breakpoints_safe ())
> + for (breakpoint &b : all_breakpoints_safe ())
> {
> try
> {
> - breakpoint_re_set_one (b);
> + breakpoint_re_set_one (&b);
> }
> catch (const gdb_exception &ex)
> {
> exception_fprintf (gdb_stderr, ex,
> "Error in re-setting breakpoint %d: ",
> - b->number);
> + b.number);
> }
> }
>
> @@ -13046,10 +13044,10 @@ set_ignore_count (int bptnum, int count, int from_tty)
> if (count < 0)
> count = 0;
>
> - for (breakpoint *b : all_breakpoints ())
> - if (b->number == bptnum)
> + for (breakpoint &b : all_breakpoints ())
> + if (b.number == bptnum)
> {
> - if (is_tracepoint (b))
> + if (is_tracepoint (&b))
> {
> if (from_tty && count != 0)
> gdb_printf (_("Ignore count ignored for tracepoint %d."),
> @@ -13057,7 +13055,7 @@ set_ignore_count (int bptnum, int count, int from_tty)
> return;
> }
>
> - b->ignore_count = count;
> + b.ignore_count = count;
> if (from_tty)
> {
> if (count == 0)
> @@ -13072,7 +13070,7 @@ set_ignore_count (int bptnum, int count, int from_tty)
> "crossings of breakpoint %d."),
> count, bptnum);
> }
> - gdb::observers::breakpoint_modified.notify (b);
> + gdb::observers::breakpoint_modified.notify (&b);
> return;
> }
>
> @@ -13122,11 +13120,11 @@ map_breakpoint_number_range (std::pair<int, int> bp_num_range,
> {
> bool match = false;
>
> - for (breakpoint *b : all_breakpoints_safe ())
> - if (b->number == i)
> + for (breakpoint &b : all_breakpoints_safe ())
> + if (b.number == i)
> {
> match = true;
> - function (b);
> + function (&b);
> break;
> }
> if (!match)
> @@ -13441,13 +13439,13 @@ enable_disable_command (const char *args, int from_tty, bool enable)
> {
> if (args == 0)
> {
> - for (breakpoint *bpt : all_breakpoints ())
> - if (user_breakpoint_p (bpt))
> + for (breakpoint &bpt : all_breakpoints ())
> + if (user_breakpoint_p (&bpt))
> {
> if (enable)
> - enable_breakpoint (bpt);
> + enable_breakpoint (&bpt);
> else
> - disable_breakpoint (bpt);
> + disable_breakpoint (&bpt);
> }
> }
> else
> @@ -13632,21 +13630,21 @@ invalidate_bp_value_on_memory_change (struct inferior *inferior,
> CORE_ADDR addr, ssize_t len,
> const bfd_byte *data)
> {
> - for (breakpoint *bp : all_breakpoints ())
> - if (bp->enable_state == bp_enabled
> - && bp->type == bp_hardware_watchpoint)
> + for (breakpoint &bp : all_breakpoints ())
> + if (bp.enable_state == bp_enabled
> + && bp.type == bp_hardware_watchpoint)
> {
> - struct watchpoint *wp = (struct watchpoint *) bp;
> + watchpoint &wp = static_cast<watchpoint &> (bp);
>
> - if (wp->val_valid && wp->val != nullptr)
> + if (wp.val_valid && wp.val != nullptr)
> {
> - for (bp_location &loc : bp->locations ())
> + for (bp_location &loc : bp.locations ())
> if (loc.loc_type == bp_loc_hardware_watchpoint
> && loc.address + loc.length > addr
> && addr + len > loc.address)
> {
> - wp->val = NULL;
> - wp->val_valid = false;
> + wp.val = NULL;
> + wp.val_valid = false;
> }
> }
> }
> @@ -13734,10 +13732,10 @@ int
> single_step_breakpoint_inserted_here_p (const address_space *aspace,
> CORE_ADDR pc)
> {
> - for (breakpoint *bpt : all_breakpoints ())
> + for (breakpoint &bpt : all_breakpoints ())
> {
> - if (bpt->type == bp_single_step
> - && breakpoint_has_location_inserted_here (bpt, aspace, pc))
> + if (bpt.type == bp_single_step
> + && breakpoint_has_location_inserted_here (&bpt, aspace, pc))
> return 1;
> }
> return 0;
> @@ -13994,8 +13992,8 @@ delete_trace_command (const char *arg, int from_tty)
> Do not delete internal or call-dummy breakpoints, these
> have to be deleted with an explicit breakpoint number
> argument. */
> - for (breakpoint *tp : all_tracepoints ())
> - if (is_tracepoint (tp) && user_breakpoint_p (tp))
> + for (breakpoint &tp : all_tracepoints ())
> + if (is_tracepoint (&tp) && user_breakpoint_p (&tp))
> {
> breaks_to_delete = 1;
> break;
> @@ -14005,9 +14003,9 @@ delete_trace_command (const char *arg, int from_tty)
> if (!from_tty
> || (breaks_to_delete && query (_("Delete all tracepoints? "))))
> {
> - for (breakpoint *b : all_breakpoints_safe ())
> - if (is_tracepoint (b) && user_breakpoint_p (b))
> - delete_breakpoint (b);
> + for (breakpoint &b : all_breakpoints_safe ())
> + if (is_tracepoint (&b) && user_breakpoint_p (&b))
> + delete_breakpoint (&b);
> }
> }
> else
> @@ -14039,7 +14037,6 @@ trace_pass_set_count (struct tracepoint *tp, int count, int from_tty)
> static void
> trace_pass_command (const char *args, int from_tty)
> {
> - struct tracepoint *t1;
> ULONGEST count;
>
> if (args == 0 || *args == 0)
> @@ -14055,15 +14052,15 @@ trace_pass_command (const char *args, int from_tty)
> if (*args)
> error (_("Junk at end of arguments."));
>
> - for (breakpoint *b : all_tracepoints ())
> + for (breakpoint &b : all_tracepoints ())
> {
> - t1 = (struct tracepoint *) b;
> - trace_pass_set_count (t1, count, from_tty);
> + tracepoint &t1 = static_cast<tracepoint &> (b);
> + trace_pass_set_count (&t1, count, from_tty);
> }
> }
> else if (*args == '\0')
> {
> - t1 = get_tracepoint_by_number (&args, NULL);
> + tracepoint *t1 = get_tracepoint_by_number (&args, NULL);
> if (t1)
> trace_pass_set_count (t1, count, from_tty);
> }
> @@ -14072,7 +14069,7 @@ trace_pass_command (const char *args, int from_tty)
> number_or_range_parser parser (args);
> while (!parser.finished ())
> {
> - t1 = get_tracepoint_by_number (&args, &parser);
> + tracepoint *t1 = get_tracepoint_by_number (&args, &parser);
> if (t1)
> trace_pass_set_count (t1, count, from_tty);
> }
> @@ -14082,9 +14079,9 @@ trace_pass_command (const char *args, int from_tty)
> struct tracepoint *
> get_tracepoint (int num)
> {
> - for (breakpoint *t : all_tracepoints ())
> - if (t->number == num)
> - return (struct tracepoint *) t;
> + for (breakpoint &t : all_tracepoints ())
> + if (t.number == num)
> + return static_cast<tracepoint *> (&t);
>
> return NULL;
> }
> @@ -14096,12 +14093,12 @@ get_tracepoint (int num)
> struct tracepoint *
> get_tracepoint_by_number_on_target (int num)
> {
> - for (breakpoint *b : all_tracepoints ())
> + for (breakpoint &b : all_tracepoints ())
> {
> - struct tracepoint *t = (struct tracepoint *) b;
> + tracepoint &t = static_cast<tracepoint &> (b);
>
> - if (t->number_on_target == num)
> - return t;
> + if (t.number_on_target == num)
> + return &t;
> }
>
> return NULL;
> @@ -14139,9 +14136,9 @@ get_tracepoint_by_number (const char **arg,
> return NULL;
> }
>
> - for (breakpoint *t : all_tracepoints ())
> - if (t->number == tpnum)
> - return (struct tracepoint *) t;
> + for (breakpoint &t : all_tracepoints ())
> + if (t.number == tpnum)
> + return static_cast<tracepoint *> (&t);
>
> gdb_printf ("No tracepoint number %d.\n", tpnum);
> return NULL;
> @@ -14178,19 +14175,19 @@ save_breakpoints (const char *filename, int from_tty,
> error (_("Argument required (file name in which to save)"));
>
> /* See if we have anything to save. */
> - for (breakpoint *tp : all_breakpoints ())
> + for (breakpoint &tp : all_breakpoints ())
> {
> /* Skip internal and momentary breakpoints. */
> - if (!user_breakpoint_p (tp))
> + if (!user_breakpoint_p (&tp))
> continue;
>
> /* If we have a filter, only save the breakpoints it accepts. */
> - if (filter && !filter (tp))
> + if (filter && !filter (&tp))
> continue;
>
> any = true;
>
> - if (is_tracepoint (tp))
> + if (is_tracepoint (&tp))
> {
> extra_trace_bits = 1;
>
> @@ -14216,49 +14213,49 @@ save_breakpoints (const char *filename, int from_tty,
> if (extra_trace_bits)
> save_trace_state_variables (&fp);
>
> - for (breakpoint *tp : all_breakpoints ())
> + for (breakpoint &tp : all_breakpoints ())
> {
> /* Skip internal and momentary breakpoints. */
> - if (!user_breakpoint_p (tp))
> + if (!user_breakpoint_p (&tp))
> continue;
>
> /* If we have a filter, only save the breakpoints it accepts. */
> - if (filter && !filter (tp))
> + if (filter && !filter (&tp))
> continue;
>
> - tp->print_recreate (&fp);
> + tp.print_recreate (&fp);
>
> /* Note, we can't rely on tp->number for anything, as we can't
> assume the recreated breakpoint numbers will match. Use $bpnum
> instead. */
>
> - if (tp->cond_string)
> - fp.printf (" condition $bpnum %s\n", tp->cond_string.get ());
> + if (tp.cond_string)
> + fp.printf (" condition $bpnum %s\n", tp.cond_string.get ());
>
> - if (tp->ignore_count)
> - fp.printf (" ignore $bpnum %d\n", tp->ignore_count);
> + if (tp.ignore_count)
> + fp.printf (" ignore $bpnum %d\n", tp.ignore_count);
>
> - if (tp->type != bp_dprintf && tp->commands)
> + if (tp.type != bp_dprintf && tp.commands)
> {
> fp.puts (" commands\n");
>
> ui_out_redirect_pop redir (current_uiout, &fp);
> - print_command_lines (current_uiout, tp->commands.get (), 2);
> + print_command_lines (current_uiout, tp.commands.get (), 2);
>
> fp.puts (" end\n");
> }
>
> - if (tp->enable_state == bp_disabled)
> + if (tp.enable_state == bp_disabled)
> fp.puts ("disable $bpnum\n");
>
> /* If this is a multi-location breakpoint, check if the locations
> should be individually disabled. Watchpoint locations are
> special, and not user visible. */
> - if (!is_watchpoint (tp) && tp->has_multiple_locations ())
> + if (!is_watchpoint (&tp) && tp.has_multiple_locations ())
> {
> int n = 1;
>
> - for (bp_location &loc : tp->locations ())
> + for (bp_location &loc : tp.locations ())
> {
> if (!loc.enabled)
> fp.printf ("disable $bpnum.%d\n", n);
> @@ -14394,12 +14391,12 @@ int
> pc_at_non_inline_function (const address_space *aspace, CORE_ADDR pc,
> const target_waitstatus &ws)
> {
> - for (breakpoint *b : all_breakpoints ())
> + for (breakpoint &b : all_breakpoints ())
> {
> - if (!is_non_inline_function (b))
> + if (!is_non_inline_function (&b))
> continue;
>
> - for (bp_location &bl : b->locations ())
> + for (bp_location &bl : b.locations ())
> {
> if (!bl.shlib_disabled
> && bpstat_check_location (&bl, aspace, pc, ws))
> diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
> index a03b57734b9d..c0d73d374cb0 100644
> --- a/gdb/breakpoint.h
> +++ b/gdb/breakpoint.h
In patch #7 you added:
#include "gdbsupport/reference-to-pointer-iterator.h"
Is this still needed after this patch? I haven't checked, but it feels
like maybe it could be removed now.
Thanks,
Andrew
> @@ -1895,11 +1895,9 @@ using breakpoint_list = intrusive_list<breakpoint>;
>
> using breakpoint_iterator = breakpoint_list::iterator;
>
> -using breakpoint_pointer_iterator = reference_to_pointer_iterator<breakpoint_iterator>;
> -
> /* Breakpoint linked list range. */
>
> -using breakpoint_range = iterator_range<breakpoint_pointer_iterator>;
> +using breakpoint_range = iterator_range<breakpoint_iterator>;
>
> /* Return a range to iterate over all breakpoints. */
>
> @@ -1919,14 +1917,14 @@ breakpoint_safe_range all_breakpoints_safe ();
>
> struct tracepoint_filter
> {
> - bool operator() (breakpoint *b)
> - { return is_tracepoint (b); }
> + bool operator() (breakpoint &b)
> + { return is_tracepoint (&b); }
> };
>
> /* Breakpoint linked list iterator, filtering to only keep tracepoints. */
>
> using tracepoint_iterator
> - = filtered_iterator<breakpoint_pointer_iterator, tracepoint_filter>;
> + = filtered_iterator<breakpoint_iterator, tracepoint_filter>;
>
> /* Breakpoint linked list range, filtering to only keep tracepoints. */
>
> diff --git a/gdb/dummy-frame.c b/gdb/dummy-frame.c
> index 961b3ac7a25f..520450125a84 100644
> --- a/gdb/dummy-frame.c
> +++ b/gdb/dummy-frame.c
> @@ -166,8 +166,8 @@ pop_dummy_frame (struct dummy_frame **dummy_ptr)
>
> restore_infcall_suspend_state (dummy->caller_state);
>
> - for (breakpoint *bp : all_breakpoints_safe ())
> - if (pop_dummy_frame_bpt (bp, dummy))
> + for (breakpoint &bp : all_breakpoints_safe ())
> + if (pop_dummy_frame_bpt (&bp, dummy))
> break;
>
> /* restore_infcall_control_state frees inf_state,
> diff --git a/gdb/guile/scm-breakpoint.c b/gdb/guile/scm-breakpoint.c
> index 2931df265d74..6c6dacb38836 100644
> --- a/gdb/guile/scm-breakpoint.c
> +++ b/gdb/guile/scm-breakpoint.c
> @@ -569,8 +569,8 @@ gdbscm_breakpoints (void)
> {
> SCM list = SCM_EOL;
>
> - for (breakpoint *bp : all_breakpoints ())
> - bpscm_build_bp_list (bp, &list);
> + for (breakpoint &bp : all_breakpoints ())
> + bpscm_build_bp_list (&bp, &list);
>
> return scm_reverse_x (list, SCM_EOL);
> }
> diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
> index 8a306c6b3318..d11fc64df204 100644
> --- a/gdb/python/py-breakpoint.c
> +++ b/gdb/python/py-breakpoint.c
> @@ -1035,8 +1035,8 @@ gdbpy_breakpoints (PyObject *self, PyObject *args)
>
> /* If build_bp_list returns false, it signals an error condition. In that
> case abandon building the list and return nullptr. */
> - for (breakpoint *bp : all_breakpoints ())
> - if (!build_bp_list (bp, list.get ()))
> + for (breakpoint &bp : all_breakpoints ())
> + if (!build_bp_list (&bp, list.get ()))
> return nullptr;
>
> return PyList_AsTuple (list.get ());
> diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c
> index bb4591e3a6ba..b71e5fafc461 100644
> --- a/gdb/python/py-finishbreakpoint.c
> +++ b/gdb/python/py-finishbreakpoint.c
> @@ -416,9 +416,9 @@ bpfinishpy_handle_stop (struct bpstat *bs, int print_frame)
> {
> gdbpy_enter enter_py;
>
> - for (breakpoint *bp : all_breakpoints_safe ())
> + for (breakpoint &bp : all_breakpoints_safe ())
> bpfinishpy_detect_out_scope_cb
> - (bp, bs == NULL ? NULL : bs->breakpoint_at, true);
> + (&bp, bs == NULL ? NULL : bs->breakpoint_at, true);
> }
>
> /* Attached to `exit' notifications, triggers all the necessary out of
> @@ -429,8 +429,8 @@ bpfinishpy_handle_exit (struct inferior *inf)
> {
> gdbpy_enter enter_py (target_gdbarch ());
>
> - for (breakpoint *bp : all_breakpoints_safe ())
> - bpfinishpy_detect_out_scope_cb (bp, nullptr, true);
> + for (breakpoint &bp : all_breakpoints_safe ())
> + bpfinishpy_detect_out_scope_cb (&bp, nullptr, true);
> }
>
> /* Initialize the Python finish breakpoint code. */
> diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
> index 46f09a7e63ce..59bb086821e5 100644
> --- a/gdb/solib-svr4.c
> +++ b/gdb/solib-svr4.c
> @@ -2151,8 +2151,8 @@ svr4_update_solib_event_breakpoint (struct breakpoint *b)
> static void
> svr4_update_solib_event_breakpoints (void)
> {
> - for (breakpoint *bp : all_breakpoints_safe ())
> - svr4_update_solib_event_breakpoint (bp);
> + for (breakpoint &bp : all_breakpoints_safe ())
> + svr4_update_solib_event_breakpoint (&bp);
> }
>
> /* Create and register solib event breakpoints. PROBES is an array
> diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
> index fa65e0493720..36cbd1f5bb64 100644
> --- a/gdb/tracepoint.c
> +++ b/gdb/tracepoint.c
> @@ -1520,16 +1520,16 @@ process_tracepoint_on_disconnect (void)
>
> /* Check whether we still have pending tracepoint. If we have, warn the
> user that pending tracepoint will no longer work. */
> - for (breakpoint *b : all_tracepoints ())
> + for (breakpoint &b : all_tracepoints ())
> {
> - if (!b->has_locations ())
> + if (!b.has_locations ())
> {
> has_pending_p = 1;
> break;
> }
> else
> {
> - for (bp_location &loc1 : b->locations ())
> + for (bp_location &loc1 : b.locations ())
> {
> if (loc1.shlib_disabled)
> {
> @@ -1571,18 +1571,18 @@ start_tracing (const char *notes)
> if (tracepoint_range.begin () == tracepoint_range.end ())
> error (_("No tracepoints defined, not starting trace"));
>
> - for (breakpoint *b : tracepoint_range)
> + for (breakpoint &b : tracepoint_range)
> {
> - if (b->enable_state == bp_enabled)
> + if (b.enable_state == bp_enabled)
> any_enabled = 1;
>
> - if ((b->type == bp_fast_tracepoint
> + if ((b.type == bp_fast_tracepoint
> ? may_insert_fast_tracepoints
> : may_insert_tracepoints))
> ++num_to_download;
> else
> warning (_("May not insert %stracepoints, skipping tracepoint %d"),
> - (b->type == bp_fast_tracepoint ? "fast " : ""), b->number);
> + (b.type == bp_fast_tracepoint ? "fast " : ""), b.number);
> }
>
> if (!any_enabled)
> @@ -1602,23 +1602,23 @@ start_tracing (const char *notes)
>
> target_trace_init ();
>
> - for (breakpoint *b : tracepoint_range)
> + for (breakpoint &b : tracepoint_range)
> {
> - struct tracepoint *t = (struct tracepoint *) b;
> + tracepoint &t = static_cast<tracepoint &> (b);
> int bp_location_downloaded = 0;
>
> /* Clear `inserted' flag. */
> - for (bp_location &loc : b->locations ())
> + for (bp_location &loc : b.locations ())
> loc.inserted = 0;
>
> - if ((b->type == bp_fast_tracepoint
> + if ((b.type == bp_fast_tracepoint
> ? !may_insert_fast_tracepoints
> : !may_insert_tracepoints))
> continue;
>
> - t->number_on_target = 0;
> + t.number_on_target = 0;
>
> - for (bp_location &loc : b->locations ())
> + for (bp_location &loc : b.locations ())
> {
> /* Since tracepoint locations are never duplicated, `inserted'
> flag should be zero. */
> @@ -1630,14 +1630,14 @@ start_tracing (const char *notes)
> bp_location_downloaded = 1;
> }
>
> - t->number_on_target = b->number;
> + t.number_on_target = b.number;
>
> - for (bp_location &loc : b->locations ())
> + for (bp_location &loc : b.locations ())
> if (loc.probe.prob != NULL)
> loc.probe.prob->set_semaphore (loc.probe.objfile, loc.gdbarch);
>
> if (bp_location_downloaded)
> - gdb::observers::breakpoint_modified.notify (b);
> + gdb::observers::breakpoint_modified.notify (&b);
> }
>
> /* Send down all the trace state variables too. */
> @@ -1709,14 +1709,14 @@ stop_tracing (const char *note)
>
> target_trace_stop ();
>
> - for (breakpoint *t : all_tracepoints ())
> + for (breakpoint &t : all_tracepoints ())
> {
> - if ((t->type == bp_fast_tracepoint
> + if ((t.type == bp_fast_tracepoint
> ? !may_insert_fast_tracepoints
> : !may_insert_tracepoints))
> continue;
>
> - for (bp_location &loc : t->locations ())
> + for (bp_location &loc : t.locations ())
> {
> /* GDB can be totally absent in some disconnected trace scenarios,
> but we don't really care if this semaphore goes out of sync.
> @@ -1887,8 +1887,8 @@ tstatus_command (const char *args, int from_tty)
> (long int) (ts->stop_time % 1000000));
>
> /* Now report any per-tracepoint status available. */
> - for (breakpoint *t : all_tracepoints ())
> - target_get_tracepoint_status (t, NULL);
> + for (breakpoint &t : all_tracepoints ())
> + target_get_tracepoint_status (&t, NULL);
> }
>
> /* Report the trace status to uiout, in a way suitable for MI, and not
> @@ -3042,20 +3042,20 @@ cond_string_is_same (char *str1, char *str2)
> static struct bp_location *
> find_matching_tracepoint_location (struct uploaded_tp *utp)
> {
> - for (breakpoint *b : all_tracepoints ())
> + for (breakpoint &b : all_tracepoints ())
> {
> - struct tracepoint *t = (struct tracepoint *) b;
> + tracepoint &t = static_cast<tracepoint &> (b);
>
> - if (b->type == utp->type
> - && t->step_count == utp->step
> - && t->pass_count == utp->pass
> - && cond_string_is_same (t->cond_string.get (),
> + if (b.type == utp->type
> + && t.step_count == utp->step
> + && t.pass_count == utp->pass
> + && cond_string_is_same (t.cond_string.get (),
> utp->cond_string.get ())
> /* FIXME also test actions. */
> )
> {
> /* Scan the locations for an address match. */
> - for (bp_location &loc : b->locations ())
> + for (bp_location &loc : b.locations ())
> if (loc.address == utp->addr)
> return &loc;
> }
> diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
> index 9e4760618187..a3714fce46fe 100644
> --- a/gdb/tui/tui-winsource.c
> +++ b/gdb/tui/tui-winsource.c
> @@ -625,24 +625,24 @@ tui_source_window_base::update_breakpoint_info
> do with it. Identify enable/disabled breakpoints as well as
> those that we already hit. */
> tui_bp_flags mode = 0;
> - for (breakpoint *bp : all_breakpoints ())
> + for (breakpoint &bp : all_breakpoints ())
> {
> - if (bp == being_deleted)
> + if (&bp == being_deleted)
> continue;
>
> - for (bp_location &loc : bp->locations ())
> + for (bp_location &loc : bp.locations ())
> {
> if (location_matches_p (&loc, i))
> {
> - if (bp->enable_state == bp_disabled)
> + if (bp.enable_state == bp_disabled)
> mode |= TUI_BP_DISABLED;
> else
> mode |= TUI_BP_ENABLED;
> - if (bp->hit_count)
> + if (bp.hit_count)
> mode |= TUI_BP_HIT;
> - if (bp->first_loc ().cond)
> + if (bp.first_loc ().cond)
> mode |= TUI_BP_CONDITIONAL;
> - if (bp->type == bp_hardware_breakpoint)
> + if (bp.type == bp_hardware_breakpoint)
> mode |= TUI_BP_HARDWARE;
> }
> }
> --
> 2.40.1
>> @@ -3055,12 +3052,12 @@ breakpoint_program_space_exit (struct program_space *pspace)
>> void
>> insert_breakpoints (void)
>> {
>> - for (breakpoint *bpt : all_breakpoints ())
>> - if (is_hardware_watchpoint (bpt))
>> + for (breakpoint &bpt : all_breakpoints ())
>> + if (is_hardware_watchpoint (&bpt))
>> {
>> - struct watchpoint *w = (struct watchpoint *) bpt;
>> + watchpoint &w = static_cast<watchpoint &> (bpt);
>
> Could possibly use gdb::checked_static_cast here? And in other places
> throughout this patch?
checked_static_cast doesn't work with references though... so I would
have to write:
watchpoint &w = *gdb::checked_static_cast<watchpoint *> (&bpt);
Do you think it's possible to make checked_static_cast work for
references? I'll give it a try.
>> diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
>> index a03b57734b9d..c0d73d374cb0 100644
>> --- a/gdb/breakpoint.h
>> +++ b/gdb/breakpoint.h
>
> In patch #7 you added:
>
> #include "gdbsupport/reference-to-pointer-iterator.h"
>
> Is this still needed after this patch? I haven't checked, but it feels
> like maybe it could be removed now.
Yep removed.
Simon
On 5/18/23 14:44, Simon Marchi via Gdb-patches wrote:
>>> @@ -3055,12 +3052,12 @@ breakpoint_program_space_exit (struct program_space *pspace)
>>> void
>>> insert_breakpoints (void)
>>> {
>>> - for (breakpoint *bpt : all_breakpoints ())
>>> - if (is_hardware_watchpoint (bpt))
>>> + for (breakpoint &bpt : all_breakpoints ())
>>> + if (is_hardware_watchpoint (&bpt))
>>> {
>>> - struct watchpoint *w = (struct watchpoint *) bpt;
>>> + watchpoint &w = static_cast<watchpoint &> (bpt);
>>
>> Could possibly use gdb::checked_static_cast here? And in other places
>> throughout this patch?
>
> checked_static_cast doesn't work with references though... so I would
> have to write:
>
> watchpoint &w = *gdb::checked_static_cast<watchpoint *> (&bpt);
>
> Do you think it's possible to make checked_static_cast work for
> references? I'll give it a try.
I sent a patch to make checked_static_cast work with references here:
https://inbox.sourceware.org/gdb-patches/20230518205737.403656-1-simon.marchi@efficios.com/T/#u
I put that patch under this series, and modified this patch (patch 12)
to use checked_static_cast.
Simon
@@ -91,20 +91,20 @@ solib_catchpoint::breakpoint_hit (const struct bp_location *bl,
if (ws.kind () == TARGET_WAITKIND_LOADED)
return 1;
- for (breakpoint *other : all_breakpoints ())
+ for (breakpoint &other : all_breakpoints ())
{
- if (other == bl->owner)
+ if (&other == bl->owner)
continue;
- if (other->type != bp_shlib_event)
+ if (other.type != bp_shlib_event)
continue;
- if (pspace != NULL && other->pspace != pspace)
+ if (pspace != NULL && other.pspace != pspace)
continue;
- for (bp_location &other_bl : other->locations ())
+ for (bp_location &other_bl : other.locations ())
{
- if (other->breakpoint_hit (&other_bl, aspace, bp_addr, ws))
+ if (other.breakpoint_hit (&other_bl, aspace, bp_addr, ws))
return 1;
}
}
@@ -501,8 +501,8 @@ catching_syscall_number_1 (struct breakpoint *b, int syscall_number)
bool
catching_syscall_number (int syscall_number)
{
- for (breakpoint *b : all_breakpoints ())
- if (catching_syscall_number_1 (b, syscall_number))
+ for (breakpoint &b : all_breakpoints ())
+ if (catching_syscall_number_1 (&b, syscall_number))
return true;
return false;
@@ -621,9 +621,7 @@ static intrusive_list<breakpoint> breakpoint_chain;
breakpoint_range
all_breakpoints ()
{
- return breakpoint_range
- (breakpoint_pointer_iterator (breakpoint_chain.begin ()),
- breakpoint_pointer_iterator (breakpoint_chain.end ()));
+ return breakpoint_range (breakpoint_chain.begin (), breakpoint_chain.end ());
}
/* See breakpoint.h. */
@@ -639,9 +637,8 @@ all_breakpoints_safe ()
tracepoint_range
all_tracepoints ()
{
- return tracepoint_range
- (tracepoint_iterator (breakpoint_pointer_iterator (breakpoint_chain.begin ())),
- tracepoint_iterator (breakpoint_pointer_iterator (breakpoint_chain.end ())));
+ return tracepoint_range (tracepoint_iterator (breakpoint_chain.begin ()),
+ tracepoint_iterator (breakpoint_chain.end ()));
}
/* Array is sorted by bp_location_is_less_than - primarily by the ADDRESS. */
@@ -796,8 +793,8 @@ scoped_rbreak_breakpoints::~scoped_rbreak_breakpoints ()
void
clear_breakpoint_hit_counts (void)
{
- for (breakpoint *b : all_breakpoints ())
- b->hit_count = 0;
+ for (breakpoint &b : all_breakpoints ())
+ b.hit_count = 0;
}
@@ -807,9 +804,9 @@ clear_breakpoint_hit_counts (void)
struct breakpoint *
get_breakpoint (int num)
{
- for (breakpoint *b : all_breakpoints ())
- if (b->number == num)
- return b;
+ for (breakpoint &b : all_breakpoints ())
+ if (b.number == num)
+ return &b;
return nullptr;
}
@@ -820,9 +817,9 @@ get_breakpoint (int num)
static bool
has_multiple_locations (int num)
{
- for (breakpoint *b : all_breakpoints ())
- if (b->number == num)
- return b->has_multiple_locations ();
+ for (breakpoint &b : all_breakpoints ())
+ if (b.number == num)
+ return b.has_multiple_locations ();
return false;
}
@@ -1104,14 +1101,14 @@ void
set_breakpoint_condition (int bpnum, const char *exp, int from_tty,
bool force)
{
- for (breakpoint *b : all_breakpoints ())
- if (b->number == bpnum)
+ for (breakpoint &b : all_breakpoints ())
+ if (b.number == bpnum)
{
/* Check if this breakpoint has a "stop" method implemented in an
extension language. This method and conditions entered into GDB
from the CLI are mutually exclusive. */
const struct extension_language_defn *extlang
- = get_breakpoint_cond_ext_lang (b, EXT_LANG_NONE);
+ = get_breakpoint_cond_ext_lang (&b, EXT_LANG_NONE);
if (extlang != NULL)
{
@@ -1119,9 +1116,9 @@ set_breakpoint_condition (int bpnum, const char *exp, int from_tty,
" a %s stop condition defined for this breakpoint."),
ext_lang_capitalized_name (extlang));
}
- set_breakpoint_condition (b, exp, from_tty, force);
+ set_breakpoint_condition (&b, exp, from_tty, force);
- if (is_breakpoint (b))
+ if (is_breakpoint (&b))
update_global_location_list (UGLL_MAY_INSERT);
return;
@@ -1196,11 +1193,11 @@ condition_completer (struct cmd_list_element *cmd,
/* We're completing the breakpoint number. */
len = strlen (text);
- for (breakpoint *b : all_breakpoints ())
+ for (breakpoint &b : all_breakpoints ())
{
char number[50];
- xsnprintf (number, sizeof (number), "%d", b->number);
+ xsnprintf (number, sizeof (number), "%d", b.number);
if (strncmp (number, text, len) == 0)
tracker.add_completion (make_unique_xstrdup (number));
@@ -1417,13 +1414,13 @@ static_tracepoints_here (CORE_ADDR addr)
{
std::vector<breakpoint *> found;
- for (breakpoint *b : all_breakpoints ())
- if (b->type == bp_static_tracepoint
- || b->type == bp_static_marker_tracepoint)
+ for (breakpoint &b : all_breakpoints ())
+ if (b.type == bp_static_tracepoint
+ || b.type == bp_static_marker_tracepoint)
{
- for (bp_location &loc : b->locations ())
+ for (bp_location &loc : b.locations ())
if (loc.address == addr)
- found.push_back (b);
+ found.push_back (&b);
}
return found;
@@ -3030,9 +3027,9 @@ void
breakpoint_program_space_exit (struct program_space *pspace)
{
/* Remove any breakpoint that was set through this program space. */
- for (breakpoint *b : all_breakpoints_safe ())
- if (b->pspace == pspace)
- delete_breakpoint (b);
+ for (breakpoint &b : all_breakpoints_safe ())
+ if (b.pspace == pspace)
+ delete_breakpoint (&b);
/* Breakpoints set through other program spaces could have locations
bound to PSPACE as well. Remove those. */
@@ -3055,12 +3052,12 @@ breakpoint_program_space_exit (struct program_space *pspace)
void
insert_breakpoints (void)
{
- for (breakpoint *bpt : all_breakpoints ())
- if (is_hardware_watchpoint (bpt))
+ for (breakpoint &bpt : all_breakpoints ())
+ if (is_hardware_watchpoint (&bpt))
{
- struct watchpoint *w = (struct watchpoint *) bpt;
+ watchpoint &w = static_cast<watchpoint &> (bpt);
- update_watchpoint (w, false /* don't reparse. */);
+ update_watchpoint (&w, false /* don't reparse. */);
}
/* Updating watchpoints creates new locations, so update the global
@@ -3179,20 +3176,20 @@ insert_breakpoint_locations (void)
/* If we failed to insert all locations of a watchpoint, remove
them, as half-inserted watchpoint is of limited use. */
- for (breakpoint *bpt : all_breakpoints ())
+ for (breakpoint &bpt : all_breakpoints ())
{
bool some_failed = false;
- if (!is_hardware_watchpoint (bpt))
+ if (!is_hardware_watchpoint (&bpt))
continue;
- if (!breakpoint_enabled (bpt))
+ if (!breakpoint_enabled (&bpt))
continue;
- if (bpt->disposition == disp_del_at_next_stop)
+ if (bpt.disposition == disp_del_at_next_stop)
continue;
- for (bp_location &loc : bpt->locations ())
+ for (bp_location &loc : bpt.locations ())
if (!loc.inserted && should_be_inserted (&loc))
{
some_failed = true;
@@ -3201,14 +3198,14 @@ insert_breakpoint_locations (void)
if (some_failed)
{
- for (bp_location &loc : bpt->locations ())
+ for (bp_location &loc : bpt.locations ())
if (loc.inserted)
remove_breakpoint (&loc);
hw_breakpoint_error = 1;
tmp_error_stream.printf ("Could not insert "
"hardware watchpoint %d.\n",
- bpt->number);
+ bpt.number);
error_flag = -1;
}
}
@@ -3249,14 +3246,14 @@ remove_breakpoints (void)
static void
remove_threaded_breakpoints (struct thread_info *tp, int silent)
{
- for (breakpoint *b : all_breakpoints_safe ())
+ for (breakpoint &b : all_breakpoints_safe ())
{
- if (b->thread == tp->global_num && user_breakpoint_p (b))
+ if (b.thread == tp->global_num && user_breakpoint_p (&b))
{
gdb_printf (_("\
Thread-specific breakpoint %d deleted - thread %s no longer in the thread list.\n"),
- b->number, print_thread_id (tp));
- delete_breakpoint (b);
+ b.number, print_thread_id (tp));
+ delete_breakpoint (&b);
}
}
}
@@ -3765,60 +3762,60 @@ update_breakpoints_after_exec (void)
if (bploc->pspace == current_program_space)
gdb_assert (!bploc->inserted);
- for (breakpoint *b : all_breakpoints_safe ())
+ for (breakpoint &b : all_breakpoints_safe ())
{
- if (b->pspace != current_program_space)
+ if (b.pspace != current_program_space)
continue;
/* Solib breakpoints must be explicitly reset after an exec(). */
- if (b->type == bp_shlib_event)
+ if (b.type == bp_shlib_event)
{
- delete_breakpoint (b);
+ delete_breakpoint (&b);
continue;
}
/* JIT breakpoints must be explicitly reset after an exec(). */
- if (b->type == bp_jit_event)
+ if (b.type == bp_jit_event)
{
- delete_breakpoint (b);
+ delete_breakpoint (&b);
continue;
}
/* Thread event breakpoints must be set anew after an exec(),
as must overlay event and longjmp master breakpoints. */
- if (b->type == bp_thread_event || b->type == bp_overlay_event
- || b->type == bp_longjmp_master || b->type == bp_std_terminate_master
- || b->type == bp_exception_master)
+ if (b.type == bp_thread_event || b.type == bp_overlay_event
+ || b.type == bp_longjmp_master || b.type == bp_std_terminate_master
+ || b.type == bp_exception_master)
{
- delete_breakpoint (b);
+ delete_breakpoint (&b);
continue;
}
/* Step-resume breakpoints are meaningless after an exec(). */
- if (b->type == bp_step_resume || b->type == bp_hp_step_resume)
+ if (b.type == bp_step_resume || b.type == bp_hp_step_resume)
{
- delete_breakpoint (b);
+ delete_breakpoint (&b);
continue;
}
/* Just like single-step breakpoints. */
- if (b->type == bp_single_step)
+ if (b.type == bp_single_step)
{
- delete_breakpoint (b);
+ delete_breakpoint (&b);
continue;
}
/* Longjmp and longjmp-resume breakpoints are also meaningless
after an exec. */
- if (b->type == bp_longjmp || b->type == bp_longjmp_resume
- || b->type == bp_longjmp_call_dummy
- || b->type == bp_exception || b->type == bp_exception_resume)
+ if (b.type == bp_longjmp || b.type == bp_longjmp_resume
+ || b.type == bp_longjmp_call_dummy
+ || b.type == bp_exception || b.type == bp_exception_resume)
{
- delete_breakpoint (b);
+ delete_breakpoint (&b);
continue;
}
- if (b->type == bp_catchpoint)
+ if (b.type == bp_catchpoint)
{
/* For now, none of the bp_catchpoint breakpoints need to
do anything at this point. In the future, if some of
@@ -3853,7 +3850,7 @@ update_breakpoints_after_exec (void)
address is probably bogus in the new a.out, unlike e.g., the
solib breakpoints.) */
- if (b->type == bp_finish)
+ if (b.type == bp_finish)
{
continue;
}
@@ -3861,9 +3858,9 @@ update_breakpoints_after_exec (void)
/* Without a symbolic address, we have little hope of the
pre-exec() address meaning the same thing in the post-exec()
a.out. */
- if (breakpoint_location_spec_empty_p (b))
+ if (breakpoint_location_spec_empty_p (&b))
{
- delete_breakpoint (b);
+ delete_breakpoint (&b);
continue;
}
}
@@ -4100,12 +4097,12 @@ breakpoint_init_inferior (enum inf_context context)
mark_breakpoints_out ();
- for (breakpoint *b : all_breakpoints_safe ())
+ for (breakpoint &b : all_breakpoints_safe ())
{
- if (b->has_locations () && b->first_loc ().pspace != pspace)
+ if (b.has_locations () && b.first_loc ().pspace != pspace)
continue;
- switch (b->type)
+ switch (b.type)
{
case bp_call_dummy:
case bp_longjmp_call_dummy:
@@ -4142,7 +4139,7 @@ breakpoint_init_inferior (enum inf_context context)
/* Also remove single-step breakpoints. */
- delete_breakpoint (b);
+ delete_breakpoint (&b);
break;
case bp_watchpoint:
@@ -4150,11 +4147,11 @@ breakpoint_init_inferior (enum inf_context context)
case bp_read_watchpoint:
case bp_access_watchpoint:
{
- struct watchpoint *w = (struct watchpoint *) b;
+ watchpoint &w = static_cast<watchpoint &> (b);
/* Likewise for watchpoints on local expressions. */
- if (w->exp_valid_block != NULL)
- delete_breakpoint (b);
+ if (w.exp_valid_block != NULL)
+ delete_breakpoint (&b);
else
{
/* Get rid of existing locations, which are no longer
@@ -4162,14 +4159,14 @@ breakpoint_init_inferior (enum inf_context context)
update_watchpoint, when the inferior is restarted.
The next update_global_location_list call will
garbage collect them. */
- b->clear_locations ();
+ b.clear_locations ();
if (context == inf_starting)
{
/* Reset val field to force reread of starting value in
insert_breakpoints. */
- w->val.reset (nullptr);
- w->val_valid = false;
+ w.val.reset (nullptr);
+ w.val_valid = false;
}
}
}
@@ -4350,16 +4347,16 @@ int
hardware_watchpoint_inserted_in_range (const address_space *aspace,
CORE_ADDR addr, ULONGEST len)
{
- for (breakpoint *bpt : all_breakpoints ())
+ for (breakpoint &bpt : all_breakpoints ())
{
- if (bpt->type != bp_hardware_watchpoint
- && bpt->type != bp_access_watchpoint)
+ if (bpt.type != bp_hardware_watchpoint
+ && bpt.type != bp_access_watchpoint)
continue;
- if (!breakpoint_enabled (bpt))
+ if (!breakpoint_enabled (&bpt))
continue;
- for (bp_location &loc : bpt->locations ())
+ for (bp_location &loc : bpt.locations ())
if (loc.pspace->aspace == aspace && loc.inserted)
{
CORE_ADDR l, h;
@@ -5009,12 +5006,12 @@ watchpoints_triggered (const target_waitstatus &ws)
{
/* We were not stopped by a watchpoint. Mark all watchpoints
as not triggered. */
- for (breakpoint *b : all_breakpoints ())
- if (is_hardware_watchpoint (b))
+ for (breakpoint &b : all_breakpoints ())
+ if (is_hardware_watchpoint (&b))
{
- struct watchpoint *w = (struct watchpoint *) b;
+ watchpoint &w = static_cast<watchpoint &> (b);
- w->watchpoint_triggered = watch_triggered_no;
+ w.watchpoint_triggered = watch_triggered_no;
}
return 0;
@@ -5024,12 +5021,12 @@ watchpoints_triggered (const target_waitstatus &ws)
{
/* We were stopped by a watchpoint, but we don't know where.
Mark all watchpoints as unknown. */
- for (breakpoint *b : all_breakpoints ())
- if (is_hardware_watchpoint (b))
+ for (breakpoint &b : all_breakpoints ())
+ if (is_hardware_watchpoint (&b))
{
- struct watchpoint *w = (struct watchpoint *) b;
+ watchpoint &w = static_cast<watchpoint &> (b);
- w->watchpoint_triggered = watch_triggered_unknown;
+ w.watchpoint_triggered = watch_triggered_unknown;
}
return 1;
@@ -5039,22 +5036,22 @@ watchpoints_triggered (const target_waitstatus &ws)
affected by this data address as triggered, and all others as not
triggered. */
- for (breakpoint *b : all_breakpoints ())
- if (is_hardware_watchpoint (b))
+ for (breakpoint &b : all_breakpoints ())
+ if (is_hardware_watchpoint (&b))
{
- struct watchpoint *w = (struct watchpoint *) b;
+ watchpoint &w = static_cast<watchpoint &> (b);
- w->watchpoint_triggered = watch_triggered_no;
- for (bp_location &loc : b->locations ())
+ w.watchpoint_triggered = watch_triggered_no;
+ for (bp_location &loc : b.locations ())
{
- if (is_masked_watchpoint (b))
+ if (is_masked_watchpoint (&b))
{
- CORE_ADDR newaddr = addr & w->hw_wp_mask;
- CORE_ADDR start = loc.address & w->hw_wp_mask;
+ CORE_ADDR newaddr = addr & w.hw_wp_mask;
+ CORE_ADDR start = loc.address & w.hw_wp_mask;
if (newaddr == start)
{
- w->watchpoint_triggered = watch_triggered_yes;
+ w.watchpoint_triggered = watch_triggered_yes;
break;
}
}
@@ -5063,7 +5060,7 @@ watchpoints_triggered (const target_waitstatus &ws)
(current_inferior ()->top_target (), addr, loc.address,
loc.length))
{
- w->watchpoint_triggered = watch_triggered_yes;
+ w.watchpoint_triggered = watch_triggered_yes;
break;
}
}
@@ -5363,14 +5360,14 @@ bpstat_check_watchpoint (bpstat *bs)
if (bl->watchpoint_type == hw_read)
{
- for (breakpoint *other_b : all_breakpoints ())
- if (other_b->type == bp_hardware_watchpoint
- || other_b->type == bp_access_watchpoint)
+ for (breakpoint &other_b : all_breakpoints ())
+ if (other_b.type == bp_hardware_watchpoint
+ || other_b.type == bp_access_watchpoint)
{
- struct watchpoint *other_w =
- (struct watchpoint *) other_b;
+ watchpoint &other_w =
+ static_cast<watchpoint &> (other_b);
- if (other_w->watchpoint_triggered
+ if (other_w.watchpoint_triggered
== watch_triggered_yes)
{
other_write_watchpoint = 1;
@@ -5612,19 +5609,19 @@ build_bpstat_chain (const address_space *aspace, CORE_ADDR bp_addr,
{
bpstat *bs_head = nullptr, **bs_link = &bs_head;
- for (breakpoint *b : all_breakpoints ())
+ for (breakpoint &b : all_breakpoints ())
{
- if (!breakpoint_enabled (b))
+ if (!breakpoint_enabled (&b))
continue;
- for (bp_location &bl : b->locations ())
+ for (bp_location &bl : b.locations ())
{
/* For hardware watchpoints, we look only at the first
location. The watchpoint_check function will work on the
entire expression, not the individual locations. For
read watchpoints, the watchpoints_triggered function has
checked all locations already. */
- if (b->type == bp_hardware_watchpoint && &bl != &b->first_loc ())
+ if (b.type == bp_hardware_watchpoint && &bl != &b.first_loc ())
break;
if (!bl.enabled || bl.disabled_by_cond || bl.shlib_disabled)
@@ -5649,9 +5646,9 @@ build_bpstat_chain (const address_space *aspace, CORE_ADDR bp_addr,
watchpoint as triggered so that we will handle the
out-of-scope event. We'll get to the watchpoint next
iteration. */
- if (b->type == bp_watchpoint_scope && b->related_breakpoint != b)
+ if (b.type == bp_watchpoint_scope && b.related_breakpoint != &b)
{
- struct watchpoint *w = (struct watchpoint *) b->related_breakpoint;
+ struct watchpoint *w = (struct watchpoint *) b.related_breakpoint;
w->watchpoint_triggered = watch_triggered_yes;
}
@@ -6044,10 +6041,10 @@ bpstat_run_callbacks (bpstat *bs_head)
bool
bpstat_should_step ()
{
- for (breakpoint *b : all_breakpoints ())
- if (breakpoint_enabled (b)
- && b->type == bp_watchpoint
- && b->has_locations ())
+ for (breakpoint &b : all_breakpoints ())
+ if (breakpoint_enabled (&b)
+ && b.type == bp_watchpoint
+ && b.has_locations ())
return true;
return false;
@@ -6832,31 +6829,31 @@ breakpoint_1 (const char *bp_num_list, bool show_internal,
/* Compute the number of rows in the table, as well as the size
required for address fields. */
nr_printable_breakpoints = 0;
- for (breakpoint *b : all_breakpoints ())
+ for (breakpoint &b : all_breakpoints ())
{
/* If we have a filter, only list the breakpoints it accepts. */
- if (filter && !filter (b))
+ if (filter && !filter (&b))
continue;
/* If we have a BP_NUM_LIST string, it is a list of breakpoints to
accept. Skip the others. */
if (bp_num_list != NULL && *bp_num_list != '\0')
{
- if (show_internal && parse_and_eval_long (bp_num_list) != b->number)
+ if (show_internal && parse_and_eval_long (bp_num_list) != b.number)
continue;
- if (!show_internal && !number_is_in_list (bp_num_list, b->number))
+ if (!show_internal && !number_is_in_list (bp_num_list, b.number))
continue;
}
- if (show_internal || user_breakpoint_p (b))
+ if (show_internal || user_breakpoint_p (&b))
{
int addr_bit, type_len;
- addr_bit = breakpoint_address_bits (b);
+ addr_bit = breakpoint_address_bits (&b);
if (addr_bit > print_address_bits)
print_address_bits = addr_bit;
- type_len = strlen (bptype_string (b->type));
+ type_len = strlen (bptype_string (b.type));
if (type_len > print_type_col_width)
print_type_col_width = type_len;
@@ -6900,11 +6897,11 @@ breakpoint_1 (const char *bp_num_list, bool show_internal,
if (nr_printable_breakpoints > 0)
annotate_breakpoints_table ();
- for (breakpoint *b : all_breakpoints ())
+ for (breakpoint &b : all_breakpoints ())
{
QUIT;
/* If we have a filter, only list the breakpoints it accepts. */
- if (filter && !filter (b))
+ if (filter && !filter (&b))
continue;
/* If we have a BP_NUM_LIST string, it is a list of breakpoints to
@@ -6914,21 +6911,21 @@ breakpoint_1 (const char *bp_num_list, bool show_internal,
{
if (show_internal) /* maintenance info breakpoint */
{
- if (parse_and_eval_long (bp_num_list) != b->number)
+ if (parse_and_eval_long (bp_num_list) != b.number)
continue;
}
else /* all others */
{
- if (!number_is_in_list (bp_num_list, b->number))
+ if (!number_is_in_list (bp_num_list, b.number))
continue;
}
}
/* We only print out user settable breakpoints unless the
show_internal is set. */
- if (show_internal || user_breakpoint_p (b))
+ if (show_internal || user_breakpoint_p (&b))
{
- print_one_breakpoint (b, &last_loc, show_internal);
- for (bp_location &loc : b->locations ())
+ print_one_breakpoint (&b, &last_loc, show_internal);
+ for (bp_location &loc : b.locations ())
if (loc.disabled_by_cond)
has_disabled_by_cond_location = true;
}
@@ -7041,9 +7038,9 @@ describe_other_breakpoints (struct gdbarch *gdbarch,
{
int others = 0;
- for (breakpoint *b : all_breakpoints ())
- others += (user_breakpoint_p (b)
- && breakpoint_has_pc (b, pspace, pc, section));
+ for (breakpoint &b : all_breakpoints ())
+ others += (user_breakpoint_p (&b)
+ && breakpoint_has_pc (&b, pspace, pc, section));
if (others > 0)
{
@@ -7051,23 +7048,24 @@ describe_other_breakpoints (struct gdbarch *gdbarch,
gdb_printf (_("Note: breakpoint "));
else /* if (others == ???) */
gdb_printf (_("Note: breakpoints "));
- for (breakpoint *b : all_breakpoints ())
- if (user_breakpoint_p (b) && breakpoint_has_pc (b, pspace, pc, section))
+ for (breakpoint &b : all_breakpoints ())
+ if (user_breakpoint_p (&b)
+ && breakpoint_has_pc (&b, pspace, pc, section))
{
others--;
- gdb_printf ("%d", b->number);
- if (b->thread == -1 && thread != -1)
+ gdb_printf ("%d", b.number);
+ if (b.thread == -1 && thread != -1)
gdb_printf (" (all threads)");
- else if (b->thread != -1)
+ else if (b.thread != -1)
{
- struct thread_info *thr = find_thread_global_id (b->thread);
+ struct thread_info *thr = find_thread_global_id (b.thread);
gdb_printf (" (thread %s)", print_thread_id (thr));
}
- else if (b->task != -1)
- gdb_printf (" (task %d)", b->task);
+ else if (b.task != -1)
+ gdb_printf (" (task %d)", b.task);
gdb_printf ("%s%s ",
- ((b->enable_state == bp_disabled
- || b->enable_state == bp_call_disabled)
+ ((b.enable_state == bp_disabled
+ || b.enable_state == bp_call_disabled)
? " (disabled)"
: ""),
(others > 1) ? ","
@@ -7510,15 +7508,15 @@ set_longjmp_breakpoint (struct thread_info *tp, struct frame_id frame)
we maintain a list of continually-inserted but always disabled
longjmp "master" breakpoints. Here, we simply create momentary
clones of those and enable them for the requested thread. */
- for (breakpoint *b : all_breakpoints_safe ())
- if (b->pspace == current_program_space
- && (b->type == bp_longjmp_master
- || b->type == bp_exception_master))
+ for (breakpoint &b : all_breakpoints_safe ())
+ if (b.pspace == current_program_space
+ && (b.type == bp_longjmp_master
+ || b.type == bp_exception_master))
{
- enum bptype type = b->type == bp_longjmp_master ? bp_longjmp : bp_exception;
+ bptype type = b.type == bp_longjmp_master ? bp_longjmp : bp_exception;
/* longjmp_breakpoint_ops ensures INITIATING_FRAME is cleared again
after their removal. */
- momentary_breakpoint_from_master (b, type, 1, thread);
+ momentary_breakpoint_from_master (&b, type, 1, thread);
}
tp->initiating_frame = frame;
@@ -7528,22 +7526,22 @@ set_longjmp_breakpoint (struct thread_info *tp, struct frame_id frame)
void
delete_longjmp_breakpoint (int thread)
{
- for (breakpoint *b : all_breakpoints_safe ())
- if (b->type == bp_longjmp || b->type == bp_exception)
+ for (breakpoint &b : all_breakpoints_safe ())
+ if (b.type == bp_longjmp || b.type == bp_exception)
{
- if (b->thread == thread)
- delete_breakpoint (b);
+ if (b.thread == thread)
+ delete_breakpoint (&b);
}
}
void
delete_longjmp_breakpoint_at_next_stop (int thread)
{
- for (breakpoint *b : all_breakpoints_safe ())
- if (b->type == bp_longjmp || b->type == bp_exception)
+ for (breakpoint &b : all_breakpoints_safe ())
+ if (b.type == bp_longjmp || b.type == bp_exception)
{
- if (b->thread == thread)
- b->disposition = disp_del_at_next_stop;
+ if (b.thread == thread)
+ b.disposition = disp_del_at_next_stop;
}
}
@@ -7557,12 +7555,12 @@ set_longjmp_breakpoint_for_call_dummy (void)
{
breakpoint *retval = nullptr;
- for (breakpoint *b : all_breakpoints ())
- if (b->pspace == current_program_space && b->type == bp_longjmp_master)
+ for (breakpoint &b : all_breakpoints ())
+ if (b.pspace == current_program_space && b.type == bp_longjmp_master)
{
int thread = inferior_thread ()->global_num;
breakpoint *new_b
- = momentary_breakpoint_from_master (b, bp_longjmp_call_dummy,
+ = momentary_breakpoint_from_master (&b, bp_longjmp_call_dummy,
1, thread);
/* Link NEW_B into the chain of RETVAL breakpoints. */
@@ -7596,15 +7594,15 @@ check_longjmp_breakpoint_for_call_dummy (struct thread_info *tp)
Save all breakpoints to delete in that set and delete them at the end. */
std::unordered_set<breakpoint *> to_delete;
- for (struct breakpoint *b : all_breakpoints ())
+ for (struct breakpoint &b : all_breakpoints ())
{
- if (b->type == bp_longjmp_call_dummy && b->thread == tp->global_num)
+ if (b.type == bp_longjmp_call_dummy && b.thread == tp->global_num)
{
- struct breakpoint *dummy_b = b->related_breakpoint;
+ struct breakpoint *dummy_b = b.related_breakpoint;
/* Find the bp_call_dummy breakpoint in the list of breakpoints
chained off b->related_breakpoint. */
- while (dummy_b != b && dummy_b->type != bp_call_dummy)
+ while (dummy_b != &b && dummy_b->type != bp_call_dummy)
dummy_b = dummy_b->related_breakpoint;
/* If there was no bp_call_dummy breakpoint then there's nothing
@@ -7653,12 +7651,12 @@ check_longjmp_breakpoint_for_call_dummy (struct thread_info *tp)
dummy_frame_discard (dummy_b->frame_id, tp);
- for (breakpoint *related_breakpoint = b->related_breakpoint;
- related_breakpoint != b;
+ for (breakpoint *related_breakpoint = b.related_breakpoint;
+ related_breakpoint != &b;
related_breakpoint = related_breakpoint->related_breakpoint)
- to_delete.insert (b->related_breakpoint);
+ to_delete.insert (b.related_breakpoint);
- to_delete.insert (b);
+ to_delete.insert (&b);
}
}
@@ -7669,10 +7667,10 @@ check_longjmp_breakpoint_for_call_dummy (struct thread_info *tp)
void
enable_overlay_breakpoints (void)
{
- for (breakpoint *b : all_breakpoints ())
- if (b->type == bp_overlay_event)
+ for (breakpoint &b : all_breakpoints ())
+ if (b.type == bp_overlay_event)
{
- b->enable_state = bp_enabled;
+ b.enable_state = bp_enabled;
update_global_location_list (UGLL_MAY_INSERT);
overlay_events_enabled = 1;
}
@@ -7681,10 +7679,10 @@ enable_overlay_breakpoints (void)
void
disable_overlay_breakpoints (void)
{
- for (breakpoint *b : all_breakpoints ())
- if (b->type == bp_overlay_event)
+ for (breakpoint &b : all_breakpoints ())
+ if (b.type == bp_overlay_event)
{
- b->enable_state = bp_disabled;
+ b.enable_state = bp_disabled;
update_global_location_list (UGLL_DONT_INSERT);
overlay_events_enabled = 0;
}
@@ -7695,11 +7693,11 @@ disable_overlay_breakpoints (void)
void
set_std_terminate_breakpoint (void)
{
- for (breakpoint *b : all_breakpoints_safe ())
- if (b->pspace == current_program_space
- && b->type == bp_std_terminate_master)
+ for (breakpoint &b : all_breakpoints_safe ())
+ if (b.pspace == current_program_space
+ && b.type == bp_std_terminate_master)
{
- momentary_breakpoint_from_master (b, bp_std_terminate, 1,
+ momentary_breakpoint_from_master (&b, bp_std_terminate, 1,
inferior_thread ()->global_num);
}
}
@@ -7708,9 +7706,9 @@ set_std_terminate_breakpoint (void)
void
delete_std_terminate_breakpoint (void)
{
- for (breakpoint *b : all_breakpoints_safe ())
- if (b->type == bp_std_terminate)
- delete_breakpoint (b);
+ for (breakpoint &b : all_breakpoints_safe ())
+ if (b.type == bp_std_terminate)
+ delete_breakpoint (&b);
}
struct breakpoint *
@@ -7748,19 +7746,19 @@ create_jit_event_breakpoint (struct gdbarch *gdbarch, CORE_ADDR address)
void
remove_jit_event_breakpoints (void)
{
- for (breakpoint *b : all_breakpoints_safe ())
- if (b->type == bp_jit_event
- && b->first_loc ().pspace == current_program_space)
- delete_breakpoint (b);
+ for (breakpoint &b : all_breakpoints_safe ())
+ if (b.type == bp_jit_event
+ && b.first_loc ().pspace == current_program_space)
+ delete_breakpoint (&b);
}
void
remove_solib_event_breakpoints (void)
{
- for (breakpoint *b : all_breakpoints_safe ())
- if (b->type == bp_shlib_event
- && b->first_loc ().pspace == current_program_space)
- delete_breakpoint (b);
+ for (breakpoint &b : all_breakpoints_safe ())
+ if (b.type == bp_shlib_event
+ && b.first_loc ().pspace == current_program_space)
+ delete_breakpoint (&b);
}
/* See breakpoint.h. */
@@ -7768,10 +7766,10 @@ remove_solib_event_breakpoints (void)
void
remove_solib_event_breakpoints_at_next_stop (void)
{
- for (breakpoint *b : all_breakpoints_safe ())
- if (b->type == bp_shlib_event
- && b->first_loc ().pspace == current_program_space)
- b->disposition = disp_del_at_next_stop;
+ for (breakpoint &b : all_breakpoints_safe ())
+ if (b.type == bp_shlib_event
+ && b.first_loc ().pspace == current_program_space)
+ b.disposition = disp_del_at_next_stop;
}
/* Helper for create_solib_event_breakpoint /
@@ -7913,14 +7911,14 @@ disable_breakpoints_in_freed_objfile (struct objfile *objfile)
|| (objfile->flags & OBJF_USERLOADED) == 0)
return;
- for (breakpoint *b : all_breakpoints ())
+ for (breakpoint &b : all_breakpoints ())
{
bool bp_modified = false;
- if (!is_breakpoint (b) && !is_tracepoint (b))
+ if (!is_breakpoint (&b) && !is_tracepoint (&b))
continue;
- for (bp_location &loc : b->locations ())
+ for (bp_location &loc : b.locations ())
{
CORE_ADDR loc_addr = loc.address;
@@ -7954,7 +7952,7 @@ disable_breakpoints_in_freed_objfile (struct objfile *objfile)
}
if (bp_modified)
- gdb::observers::breakpoint_modified.notify (b);
+ gdb::observers::breakpoint_modified.notify (&b);
}
}
@@ -8007,13 +8005,13 @@ hw_breakpoint_used_count (void)
{
int i = 0;
- for (breakpoint *b : all_breakpoints ())
- if (b->type == bp_hardware_breakpoint && breakpoint_enabled (b))
- for (bp_location &bl : b->locations ())
+ for (breakpoint &b : all_breakpoints ())
+ if (b.type == bp_hardware_breakpoint && breakpoint_enabled (&b))
+ for (bp_location &bl : b.locations ())
{
/* Special types of hardware breakpoints may use more than
one register. */
- i += b->resources_needed (&bl);
+ i += b.resources_needed (&bl);
}
return i;
@@ -8052,16 +8050,16 @@ hw_watchpoint_used_count_others (struct breakpoint *except,
int i = 0;
*other_type_used = 0;
- for (breakpoint *b : all_breakpoints ())
+ for (breakpoint &b : all_breakpoints ())
{
- if (b == except)
+ if (&b == except)
continue;
- if (!breakpoint_enabled (b))
+ if (!breakpoint_enabled (&b))
continue;
- if (b->type == type)
- i += hw_watchpoint_use_count (b);
- else if (is_hardware_watchpoint (b))
+ if (b.type == type)
+ i += hw_watchpoint_use_count (&b);
+ else if (is_hardware_watchpoint (&b))
*other_type_used = 1;
}
@@ -8071,10 +8069,10 @@ hw_watchpoint_used_count_others (struct breakpoint *except,
void
disable_watchpoints_before_interactive_call_start (void)
{
- for (breakpoint *b : all_breakpoints ())
- if (is_watchpoint (b) && breakpoint_enabled (b))
+ for (breakpoint &b : all_breakpoints ())
+ if (is_watchpoint (&b) && breakpoint_enabled (&b))
{
- b->enable_state = bp_call_disabled;
+ b.enable_state = bp_call_disabled;
update_global_location_list (UGLL_DONT_INSERT);
}
}
@@ -8082,10 +8080,10 @@ disable_watchpoints_before_interactive_call_start (void)
void
enable_watchpoints_after_interactive_call_stop (void)
{
- for (breakpoint *b : all_breakpoints ())
- if (is_watchpoint (b) && b->enable_state == bp_call_disabled)
+ for (breakpoint &b : all_breakpoints ())
+ if (is_watchpoint (&b) && b.enable_state == bp_call_disabled)
{
- b->enable_state = bp_enabled;
+ b.enable_state = bp_enabled;
update_global_location_list (UGLL_MAY_INSERT);
}
}
@@ -8421,9 +8419,9 @@ static void
update_dprintf_commands (const char *args, int from_tty,
struct cmd_list_element *c)
{
- for (breakpoint *b : all_breakpoints ())
- if (b->type == bp_dprintf)
- update_dprintf_command_list (b);
+ for (breakpoint &b : all_breakpoints ())
+ if (b.type == bp_dprintf)
+ update_dprintf_command_list (&b);
}
code_breakpoint::code_breakpoint (struct gdbarch *gdbarch_,
@@ -10824,14 +10822,14 @@ clear_command (const char *arg, int from_tty)
? NULL : symtab_to_fullname (sal.symtab));
/* Find all matching breakpoints and add them to 'found'. */
- for (breakpoint *b : all_breakpoints ())
+ for (breakpoint &b : all_breakpoints ())
{
int match = 0;
/* Are we going to delete b? */
- if (b->type != bp_none && !is_watchpoint (b)
- && user_breakpoint_p (b))
+ if (b.type != bp_none && !is_watchpoint (&b)
+ && user_breakpoint_p (&b))
{
- for (bp_location &loc : b->locations ())
+ for (bp_location &loc : b.locations ())
{
/* If the user specified file:line, don't allow a PC
match. This matches historical gdb behavior. */
@@ -10861,7 +10859,7 @@ clear_command (const char *arg, int from_tty)
}
if (match)
- found.push_back (b);
+ found.push_back (&b);
}
}
@@ -10920,9 +10918,9 @@ breakpoint_auto_delete (bpstat *bs)
&& bs->stop)
delete_breakpoint (bs->breakpoint_at);
- for (breakpoint *b : all_breakpoints_safe ())
- if (b->disposition == disp_del_at_next_stop)
- delete_breakpoint (b);
+ for (breakpoint &b : all_breakpoints_safe ())
+ if (b.disposition == disp_del_at_next_stop)
+ delete_breakpoint (&b);
}
/* A comparison function for bp_location AP and BP being interfaced to
@@ -11013,12 +11011,11 @@ download_tracepoint_locations (void)
scoped_restore_current_pspace_and_thread restore_pspace_thread;
- for (breakpoint *b : all_tracepoints ())
+ for (breakpoint &b : all_tracepoints ())
{
- struct tracepoint *t;
bool bp_location_downloaded = false;
- if ((b->type == bp_fast_tracepoint
+ if ((b.type == bp_fast_tracepoint
? !may_insert_fast_tracepoints
: !may_insert_tracepoints))
continue;
@@ -11034,7 +11031,7 @@ download_tracepoint_locations (void)
if (can_download_tracepoint == TRIBOOL_FALSE)
break;
- for (bp_location &bl : b->locations ())
+ for (bp_location &bl : b.locations ())
{
/* In tracepoint, locations are _never_ duplicated, so
should_be_inserted is equivalent to
@@ -11049,10 +11046,11 @@ download_tracepoint_locations (void)
bl.inserted = 1;
bp_location_downloaded = true;
}
- t = (struct tracepoint *) b;
- t->number_on_target = b->number;
+
+ tracepoint &t = static_cast<tracepoint &> (b);
+ t.number_on_target = b.number;
if (bp_location_downloaded)
- gdb::observers::breakpoint_modified.notify (b);
+ gdb::observers::breakpoint_modified.notify (&b);
}
}
@@ -11159,8 +11157,8 @@ update_global_location_list (enum ugll_insert_mode insert_mode)
std::vector<bp_location *> old_locations = std::move (bp_locations);
bp_locations.clear ();
- for (breakpoint *b : all_breakpoints ())
- for (bp_location &loc : b->locations ())
+ for (breakpoint &b : all_breakpoints ())
+ for (bp_location &loc : b.locations ())
bp_locations.push_back (&loc);
/* See if we need to "upgrade" a software breakpoint to a hardware
@@ -12458,8 +12456,8 @@ delete_command (const char *arg, int from_tty)
/* Delete all breakpoints if no argument. Do not delete
internal breakpoints, these have to be deleted with an
explicit breakpoint number argument. */
- for (breakpoint *b : all_breakpoints ())
- if (user_breakpoint_p (b))
+ for (breakpoint &b : all_breakpoints ())
+ if (user_breakpoint_p (&b))
{
breaks_to_delete = 1;
break;
@@ -12468,9 +12466,9 @@ delete_command (const char *arg, int from_tty)
/* Ask user only if there are some breakpoints to delete. */
if (!from_tty
|| (breaks_to_delete && query (_("Delete all breakpoints? "))))
- for (breakpoint *b : all_breakpoints_safe ())
- if (user_breakpoint_p (b))
- delete_breakpoint (b);
+ for (breakpoint &b : all_breakpoints_safe ())
+ if (user_breakpoint_p (&b))
+ delete_breakpoint (&b);
}
else
map_breakpoint_numbers
@@ -12991,17 +12989,17 @@ breakpoint_re_set (void)
breakpoint 1, we'd insert the locations of breakpoint 2, which
hadn't been re-set yet, and thus may have stale locations. */
- for (breakpoint *b : all_breakpoints_safe ())
+ for (breakpoint &b : all_breakpoints_safe ())
{
try
{
- breakpoint_re_set_one (b);
+ breakpoint_re_set_one (&b);
}
catch (const gdb_exception &ex)
{
exception_fprintf (gdb_stderr, ex,
"Error in re-setting breakpoint %d: ",
- b->number);
+ b.number);
}
}
@@ -13046,10 +13044,10 @@ set_ignore_count (int bptnum, int count, int from_tty)
if (count < 0)
count = 0;
- for (breakpoint *b : all_breakpoints ())
- if (b->number == bptnum)
+ for (breakpoint &b : all_breakpoints ())
+ if (b.number == bptnum)
{
- if (is_tracepoint (b))
+ if (is_tracepoint (&b))
{
if (from_tty && count != 0)
gdb_printf (_("Ignore count ignored for tracepoint %d."),
@@ -13057,7 +13055,7 @@ set_ignore_count (int bptnum, int count, int from_tty)
return;
}
- b->ignore_count = count;
+ b.ignore_count = count;
if (from_tty)
{
if (count == 0)
@@ -13072,7 +13070,7 @@ set_ignore_count (int bptnum, int count, int from_tty)
"crossings of breakpoint %d."),
count, bptnum);
}
- gdb::observers::breakpoint_modified.notify (b);
+ gdb::observers::breakpoint_modified.notify (&b);
return;
}
@@ -13122,11 +13120,11 @@ map_breakpoint_number_range (std::pair<int, int> bp_num_range,
{
bool match = false;
- for (breakpoint *b : all_breakpoints_safe ())
- if (b->number == i)
+ for (breakpoint &b : all_breakpoints_safe ())
+ if (b.number == i)
{
match = true;
- function (b);
+ function (&b);
break;
}
if (!match)
@@ -13441,13 +13439,13 @@ enable_disable_command (const char *args, int from_tty, bool enable)
{
if (args == 0)
{
- for (breakpoint *bpt : all_breakpoints ())
- if (user_breakpoint_p (bpt))
+ for (breakpoint &bpt : all_breakpoints ())
+ if (user_breakpoint_p (&bpt))
{
if (enable)
- enable_breakpoint (bpt);
+ enable_breakpoint (&bpt);
else
- disable_breakpoint (bpt);
+ disable_breakpoint (&bpt);
}
}
else
@@ -13632,21 +13630,21 @@ invalidate_bp_value_on_memory_change (struct inferior *inferior,
CORE_ADDR addr, ssize_t len,
const bfd_byte *data)
{
- for (breakpoint *bp : all_breakpoints ())
- if (bp->enable_state == bp_enabled
- && bp->type == bp_hardware_watchpoint)
+ for (breakpoint &bp : all_breakpoints ())
+ if (bp.enable_state == bp_enabled
+ && bp.type == bp_hardware_watchpoint)
{
- struct watchpoint *wp = (struct watchpoint *) bp;
+ watchpoint &wp = static_cast<watchpoint &> (bp);
- if (wp->val_valid && wp->val != nullptr)
+ if (wp.val_valid && wp.val != nullptr)
{
- for (bp_location &loc : bp->locations ())
+ for (bp_location &loc : bp.locations ())
if (loc.loc_type == bp_loc_hardware_watchpoint
&& loc.address + loc.length > addr
&& addr + len > loc.address)
{
- wp->val = NULL;
- wp->val_valid = false;
+ wp.val = NULL;
+ wp.val_valid = false;
}
}
}
@@ -13734,10 +13732,10 @@ int
single_step_breakpoint_inserted_here_p (const address_space *aspace,
CORE_ADDR pc)
{
- for (breakpoint *bpt : all_breakpoints ())
+ for (breakpoint &bpt : all_breakpoints ())
{
- if (bpt->type == bp_single_step
- && breakpoint_has_location_inserted_here (bpt, aspace, pc))
+ if (bpt.type == bp_single_step
+ && breakpoint_has_location_inserted_here (&bpt, aspace, pc))
return 1;
}
return 0;
@@ -13994,8 +13992,8 @@ delete_trace_command (const char *arg, int from_tty)
Do not delete internal or call-dummy breakpoints, these
have to be deleted with an explicit breakpoint number
argument. */
- for (breakpoint *tp : all_tracepoints ())
- if (is_tracepoint (tp) && user_breakpoint_p (tp))
+ for (breakpoint &tp : all_tracepoints ())
+ if (is_tracepoint (&tp) && user_breakpoint_p (&tp))
{
breaks_to_delete = 1;
break;
@@ -14005,9 +14003,9 @@ delete_trace_command (const char *arg, int from_tty)
if (!from_tty
|| (breaks_to_delete && query (_("Delete all tracepoints? "))))
{
- for (breakpoint *b : all_breakpoints_safe ())
- if (is_tracepoint (b) && user_breakpoint_p (b))
- delete_breakpoint (b);
+ for (breakpoint &b : all_breakpoints_safe ())
+ if (is_tracepoint (&b) && user_breakpoint_p (&b))
+ delete_breakpoint (&b);
}
}
else
@@ -14039,7 +14037,6 @@ trace_pass_set_count (struct tracepoint *tp, int count, int from_tty)
static void
trace_pass_command (const char *args, int from_tty)
{
- struct tracepoint *t1;
ULONGEST count;
if (args == 0 || *args == 0)
@@ -14055,15 +14052,15 @@ trace_pass_command (const char *args, int from_tty)
if (*args)
error (_("Junk at end of arguments."));
- for (breakpoint *b : all_tracepoints ())
+ for (breakpoint &b : all_tracepoints ())
{
- t1 = (struct tracepoint *) b;
- trace_pass_set_count (t1, count, from_tty);
+ tracepoint &t1 = static_cast<tracepoint &> (b);
+ trace_pass_set_count (&t1, count, from_tty);
}
}
else if (*args == '\0')
{
- t1 = get_tracepoint_by_number (&args, NULL);
+ tracepoint *t1 = get_tracepoint_by_number (&args, NULL);
if (t1)
trace_pass_set_count (t1, count, from_tty);
}
@@ -14072,7 +14069,7 @@ trace_pass_command (const char *args, int from_tty)
number_or_range_parser parser (args);
while (!parser.finished ())
{
- t1 = get_tracepoint_by_number (&args, &parser);
+ tracepoint *t1 = get_tracepoint_by_number (&args, &parser);
if (t1)
trace_pass_set_count (t1, count, from_tty);
}
@@ -14082,9 +14079,9 @@ trace_pass_command (const char *args, int from_tty)
struct tracepoint *
get_tracepoint (int num)
{
- for (breakpoint *t : all_tracepoints ())
- if (t->number == num)
- return (struct tracepoint *) t;
+ for (breakpoint &t : all_tracepoints ())
+ if (t.number == num)
+ return static_cast<tracepoint *> (&t);
return NULL;
}
@@ -14096,12 +14093,12 @@ get_tracepoint (int num)
struct tracepoint *
get_tracepoint_by_number_on_target (int num)
{
- for (breakpoint *b : all_tracepoints ())
+ for (breakpoint &b : all_tracepoints ())
{
- struct tracepoint *t = (struct tracepoint *) b;
+ tracepoint &t = static_cast<tracepoint &> (b);
- if (t->number_on_target == num)
- return t;
+ if (t.number_on_target == num)
+ return &t;
}
return NULL;
@@ -14139,9 +14136,9 @@ get_tracepoint_by_number (const char **arg,
return NULL;
}
- for (breakpoint *t : all_tracepoints ())
- if (t->number == tpnum)
- return (struct tracepoint *) t;
+ for (breakpoint &t : all_tracepoints ())
+ if (t.number == tpnum)
+ return static_cast<tracepoint *> (&t);
gdb_printf ("No tracepoint number %d.\n", tpnum);
return NULL;
@@ -14178,19 +14175,19 @@ save_breakpoints (const char *filename, int from_tty,
error (_("Argument required (file name in which to save)"));
/* See if we have anything to save. */
- for (breakpoint *tp : all_breakpoints ())
+ for (breakpoint &tp : all_breakpoints ())
{
/* Skip internal and momentary breakpoints. */
- if (!user_breakpoint_p (tp))
+ if (!user_breakpoint_p (&tp))
continue;
/* If we have a filter, only save the breakpoints it accepts. */
- if (filter && !filter (tp))
+ if (filter && !filter (&tp))
continue;
any = true;
- if (is_tracepoint (tp))
+ if (is_tracepoint (&tp))
{
extra_trace_bits = 1;
@@ -14216,49 +14213,49 @@ save_breakpoints (const char *filename, int from_tty,
if (extra_trace_bits)
save_trace_state_variables (&fp);
- for (breakpoint *tp : all_breakpoints ())
+ for (breakpoint &tp : all_breakpoints ())
{
/* Skip internal and momentary breakpoints. */
- if (!user_breakpoint_p (tp))
+ if (!user_breakpoint_p (&tp))
continue;
/* If we have a filter, only save the breakpoints it accepts. */
- if (filter && !filter (tp))
+ if (filter && !filter (&tp))
continue;
- tp->print_recreate (&fp);
+ tp.print_recreate (&fp);
/* Note, we can't rely on tp->number for anything, as we can't
assume the recreated breakpoint numbers will match. Use $bpnum
instead. */
- if (tp->cond_string)
- fp.printf (" condition $bpnum %s\n", tp->cond_string.get ());
+ if (tp.cond_string)
+ fp.printf (" condition $bpnum %s\n", tp.cond_string.get ());
- if (tp->ignore_count)
- fp.printf (" ignore $bpnum %d\n", tp->ignore_count);
+ if (tp.ignore_count)
+ fp.printf (" ignore $bpnum %d\n", tp.ignore_count);
- if (tp->type != bp_dprintf && tp->commands)
+ if (tp.type != bp_dprintf && tp.commands)
{
fp.puts (" commands\n");
ui_out_redirect_pop redir (current_uiout, &fp);
- print_command_lines (current_uiout, tp->commands.get (), 2);
+ print_command_lines (current_uiout, tp.commands.get (), 2);
fp.puts (" end\n");
}
- if (tp->enable_state == bp_disabled)
+ if (tp.enable_state == bp_disabled)
fp.puts ("disable $bpnum\n");
/* If this is a multi-location breakpoint, check if the locations
should be individually disabled. Watchpoint locations are
special, and not user visible. */
- if (!is_watchpoint (tp) && tp->has_multiple_locations ())
+ if (!is_watchpoint (&tp) && tp.has_multiple_locations ())
{
int n = 1;
- for (bp_location &loc : tp->locations ())
+ for (bp_location &loc : tp.locations ())
{
if (!loc.enabled)
fp.printf ("disable $bpnum.%d\n", n);
@@ -14394,12 +14391,12 @@ int
pc_at_non_inline_function (const address_space *aspace, CORE_ADDR pc,
const target_waitstatus &ws)
{
- for (breakpoint *b : all_breakpoints ())
+ for (breakpoint &b : all_breakpoints ())
{
- if (!is_non_inline_function (b))
+ if (!is_non_inline_function (&b))
continue;
- for (bp_location &bl : b->locations ())
+ for (bp_location &bl : b.locations ())
{
if (!bl.shlib_disabled
&& bpstat_check_location (&bl, aspace, pc, ws))
@@ -1895,11 +1895,9 @@ using breakpoint_list = intrusive_list<breakpoint>;
using breakpoint_iterator = breakpoint_list::iterator;
-using breakpoint_pointer_iterator = reference_to_pointer_iterator<breakpoint_iterator>;
-
/* Breakpoint linked list range. */
-using breakpoint_range = iterator_range<breakpoint_pointer_iterator>;
+using breakpoint_range = iterator_range<breakpoint_iterator>;
/* Return a range to iterate over all breakpoints. */
@@ -1919,14 +1917,14 @@ breakpoint_safe_range all_breakpoints_safe ();
struct tracepoint_filter
{
- bool operator() (breakpoint *b)
- { return is_tracepoint (b); }
+ bool operator() (breakpoint &b)
+ { return is_tracepoint (&b); }
};
/* Breakpoint linked list iterator, filtering to only keep tracepoints. */
using tracepoint_iterator
- = filtered_iterator<breakpoint_pointer_iterator, tracepoint_filter>;
+ = filtered_iterator<breakpoint_iterator, tracepoint_filter>;
/* Breakpoint linked list range, filtering to only keep tracepoints. */
@@ -166,8 +166,8 @@ pop_dummy_frame (struct dummy_frame **dummy_ptr)
restore_infcall_suspend_state (dummy->caller_state);
- for (breakpoint *bp : all_breakpoints_safe ())
- if (pop_dummy_frame_bpt (bp, dummy))
+ for (breakpoint &bp : all_breakpoints_safe ())
+ if (pop_dummy_frame_bpt (&bp, dummy))
break;
/* restore_infcall_control_state frees inf_state,
@@ -569,8 +569,8 @@ gdbscm_breakpoints (void)
{
SCM list = SCM_EOL;
- for (breakpoint *bp : all_breakpoints ())
- bpscm_build_bp_list (bp, &list);
+ for (breakpoint &bp : all_breakpoints ())
+ bpscm_build_bp_list (&bp, &list);
return scm_reverse_x (list, SCM_EOL);
}
@@ -1035,8 +1035,8 @@ gdbpy_breakpoints (PyObject *self, PyObject *args)
/* If build_bp_list returns false, it signals an error condition. In that
case abandon building the list and return nullptr. */
- for (breakpoint *bp : all_breakpoints ())
- if (!build_bp_list (bp, list.get ()))
+ for (breakpoint &bp : all_breakpoints ())
+ if (!build_bp_list (&bp, list.get ()))
return nullptr;
return PyList_AsTuple (list.get ());
@@ -416,9 +416,9 @@ bpfinishpy_handle_stop (struct bpstat *bs, int print_frame)
{
gdbpy_enter enter_py;
- for (breakpoint *bp : all_breakpoints_safe ())
+ for (breakpoint &bp : all_breakpoints_safe ())
bpfinishpy_detect_out_scope_cb
- (bp, bs == NULL ? NULL : bs->breakpoint_at, true);
+ (&bp, bs == NULL ? NULL : bs->breakpoint_at, true);
}
/* Attached to `exit' notifications, triggers all the necessary out of
@@ -429,8 +429,8 @@ bpfinishpy_handle_exit (struct inferior *inf)
{
gdbpy_enter enter_py (target_gdbarch ());
- for (breakpoint *bp : all_breakpoints_safe ())
- bpfinishpy_detect_out_scope_cb (bp, nullptr, true);
+ for (breakpoint &bp : all_breakpoints_safe ())
+ bpfinishpy_detect_out_scope_cb (&bp, nullptr, true);
}
/* Initialize the Python finish breakpoint code. */
@@ -2151,8 +2151,8 @@ svr4_update_solib_event_breakpoint (struct breakpoint *b)
static void
svr4_update_solib_event_breakpoints (void)
{
- for (breakpoint *bp : all_breakpoints_safe ())
- svr4_update_solib_event_breakpoint (bp);
+ for (breakpoint &bp : all_breakpoints_safe ())
+ svr4_update_solib_event_breakpoint (&bp);
}
/* Create and register solib event breakpoints. PROBES is an array
@@ -1520,16 +1520,16 @@ process_tracepoint_on_disconnect (void)
/* Check whether we still have pending tracepoint. If we have, warn the
user that pending tracepoint will no longer work. */
- for (breakpoint *b : all_tracepoints ())
+ for (breakpoint &b : all_tracepoints ())
{
- if (!b->has_locations ())
+ if (!b.has_locations ())
{
has_pending_p = 1;
break;
}
else
{
- for (bp_location &loc1 : b->locations ())
+ for (bp_location &loc1 : b.locations ())
{
if (loc1.shlib_disabled)
{
@@ -1571,18 +1571,18 @@ start_tracing (const char *notes)
if (tracepoint_range.begin () == tracepoint_range.end ())
error (_("No tracepoints defined, not starting trace"));
- for (breakpoint *b : tracepoint_range)
+ for (breakpoint &b : tracepoint_range)
{
- if (b->enable_state == bp_enabled)
+ if (b.enable_state == bp_enabled)
any_enabled = 1;
- if ((b->type == bp_fast_tracepoint
+ if ((b.type == bp_fast_tracepoint
? may_insert_fast_tracepoints
: may_insert_tracepoints))
++num_to_download;
else
warning (_("May not insert %stracepoints, skipping tracepoint %d"),
- (b->type == bp_fast_tracepoint ? "fast " : ""), b->number);
+ (b.type == bp_fast_tracepoint ? "fast " : ""), b.number);
}
if (!any_enabled)
@@ -1602,23 +1602,23 @@ start_tracing (const char *notes)
target_trace_init ();
- for (breakpoint *b : tracepoint_range)
+ for (breakpoint &b : tracepoint_range)
{
- struct tracepoint *t = (struct tracepoint *) b;
+ tracepoint &t = static_cast<tracepoint &> (b);
int bp_location_downloaded = 0;
/* Clear `inserted' flag. */
- for (bp_location &loc : b->locations ())
+ for (bp_location &loc : b.locations ())
loc.inserted = 0;
- if ((b->type == bp_fast_tracepoint
+ if ((b.type == bp_fast_tracepoint
? !may_insert_fast_tracepoints
: !may_insert_tracepoints))
continue;
- t->number_on_target = 0;
+ t.number_on_target = 0;
- for (bp_location &loc : b->locations ())
+ for (bp_location &loc : b.locations ())
{
/* Since tracepoint locations are never duplicated, `inserted'
flag should be zero. */
@@ -1630,14 +1630,14 @@ start_tracing (const char *notes)
bp_location_downloaded = 1;
}
- t->number_on_target = b->number;
+ t.number_on_target = b.number;
- for (bp_location &loc : b->locations ())
+ for (bp_location &loc : b.locations ())
if (loc.probe.prob != NULL)
loc.probe.prob->set_semaphore (loc.probe.objfile, loc.gdbarch);
if (bp_location_downloaded)
- gdb::observers::breakpoint_modified.notify (b);
+ gdb::observers::breakpoint_modified.notify (&b);
}
/* Send down all the trace state variables too. */
@@ -1709,14 +1709,14 @@ stop_tracing (const char *note)
target_trace_stop ();
- for (breakpoint *t : all_tracepoints ())
+ for (breakpoint &t : all_tracepoints ())
{
- if ((t->type == bp_fast_tracepoint
+ if ((t.type == bp_fast_tracepoint
? !may_insert_fast_tracepoints
: !may_insert_tracepoints))
continue;
- for (bp_location &loc : t->locations ())
+ for (bp_location &loc : t.locations ())
{
/* GDB can be totally absent in some disconnected trace scenarios,
but we don't really care if this semaphore goes out of sync.
@@ -1887,8 +1887,8 @@ tstatus_command (const char *args, int from_tty)
(long int) (ts->stop_time % 1000000));
/* Now report any per-tracepoint status available. */
- for (breakpoint *t : all_tracepoints ())
- target_get_tracepoint_status (t, NULL);
+ for (breakpoint &t : all_tracepoints ())
+ target_get_tracepoint_status (&t, NULL);
}
/* Report the trace status to uiout, in a way suitable for MI, and not
@@ -3042,20 +3042,20 @@ cond_string_is_same (char *str1, char *str2)
static struct bp_location *
find_matching_tracepoint_location (struct uploaded_tp *utp)
{
- for (breakpoint *b : all_tracepoints ())
+ for (breakpoint &b : all_tracepoints ())
{
- struct tracepoint *t = (struct tracepoint *) b;
+ tracepoint &t = static_cast<tracepoint &> (b);
- if (b->type == utp->type
- && t->step_count == utp->step
- && t->pass_count == utp->pass
- && cond_string_is_same (t->cond_string.get (),
+ if (b.type == utp->type
+ && t.step_count == utp->step
+ && t.pass_count == utp->pass
+ && cond_string_is_same (t.cond_string.get (),
utp->cond_string.get ())
/* FIXME also test actions. */
)
{
/* Scan the locations for an address match. */
- for (bp_location &loc : b->locations ())
+ for (bp_location &loc : b.locations ())
if (loc.address == utp->addr)
return &loc;
}
@@ -625,24 +625,24 @@ tui_source_window_base::update_breakpoint_info
do with it. Identify enable/disabled breakpoints as well as
those that we already hit. */
tui_bp_flags mode = 0;
- for (breakpoint *bp : all_breakpoints ())
+ for (breakpoint &bp : all_breakpoints ())
{
- if (bp == being_deleted)
+ if (&bp == being_deleted)
continue;
- for (bp_location &loc : bp->locations ())
+ for (bp_location &loc : bp.locations ())
{
if (location_matches_p (&loc, i))
{
- if (bp->enable_state == bp_disabled)
+ if (bp.enable_state == bp_disabled)
mode |= TUI_BP_DISABLED;
else
mode |= TUI_BP_ENABLED;
- if (bp->hit_count)
+ if (bp.hit_count)
mode |= TUI_BP_HIT;
- if (bp->first_loc ().cond)
+ if (bp.first_loc ().cond)
mode |= TUI_BP_CONDITIONAL;
- if (bp->type == bp_hardware_breakpoint)
+ if (bp.type == bp_hardware_breakpoint)
mode |= TUI_BP_HARDWARE;
}
}