gdb: remove breakpoint_pointer_iterator

Remove the breakpoint_pointer_iterator layer.  Adjust all users of
all_breakpoints and all_tracepoints to use references instead of
pointers.

Change-Id: I376826f812117cee1e6b199c384a10376973af5d
Reviewed-By: Andrew Burgess <aburgess@redhat.com>
This commit is contained in:
Simon Marchi 2023-05-09 10:08:51 -04:00
parent 410f4d7a76
commit a1decfc1df
11 changed files with 360 additions and 366 deletions

View file

@ -91,20 +91,20 @@ solib_catchpoint::breakpoint_hit (const struct bp_location *bl,
if (ws.kind () == TARGET_WAITKIND_LOADED) if (ws.kind () == TARGET_WAITKIND_LOADED)
return 1; return 1;
for (breakpoint *other : all_breakpoints ()) for (breakpoint &other : all_breakpoints ())
{ {
if (other == bl->owner) if (&other == bl->owner)
continue; continue;
if (other->type != bp_shlib_event) if (other.type != bp_shlib_event)
continue; continue;
if (pspace != NULL && other->pspace != pspace) if (pspace != NULL && other.pspace != pspace)
continue; 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; return 1;
} }
} }

View file

@ -501,8 +501,8 @@ catching_syscall_number_1 (struct breakpoint *b, int syscall_number)
bool bool
catching_syscall_number (int syscall_number) catching_syscall_number (int syscall_number)
{ {
for (breakpoint *b : all_breakpoints ()) for (breakpoint &b : all_breakpoints ())
if (catching_syscall_number_1 (b, syscall_number)) if (catching_syscall_number_1 (&b, syscall_number))
return true; return true;
return false; return false;

File diff suppressed because it is too large Load diff

View file

@ -33,7 +33,6 @@
#include "gdbsupport/next-iterator.h" #include "gdbsupport/next-iterator.h"
#include "gdbsupport/iterator-range.h" #include "gdbsupport/iterator-range.h"
#include "gdbsupport/refcounted-object.h" #include "gdbsupport/refcounted-object.h"
#include "gdbsupport/reference-to-pointer-iterator.h"
#include "gdbsupport/safe-iterator.h" #include "gdbsupport/safe-iterator.h"
#include "cli/cli-script.h" #include "cli/cli-script.h"
#include "target/waitstatus.h" #include "target/waitstatus.h"
@ -1897,11 +1896,9 @@ using breakpoint_list = intrusive_list<breakpoint>;
using breakpoint_iterator = breakpoint_list::iterator; using breakpoint_iterator = breakpoint_list::iterator;
using breakpoint_pointer_iterator = reference_to_pointer_iterator<breakpoint_iterator>;
/* Breakpoint linked list range. */ /* 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. */ /* Return a range to iterate over all breakpoints. */
@ -1921,14 +1918,14 @@ breakpoint_safe_range all_breakpoints_safe ();
struct tracepoint_filter struct tracepoint_filter
{ {
bool operator() (breakpoint *b) bool operator() (breakpoint &b)
{ return is_tracepoint (b); } { return is_tracepoint (&b); }
}; };
/* Breakpoint linked list iterator, filtering to only keep tracepoints. */ /* Breakpoint linked list iterator, filtering to only keep tracepoints. */
using tracepoint_iterator 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. */ /* Breakpoint linked list range, filtering to only keep tracepoints. */

View file

@ -166,8 +166,8 @@ pop_dummy_frame (struct dummy_frame **dummy_ptr)
restore_infcall_suspend_state (dummy->caller_state); restore_infcall_suspend_state (dummy->caller_state);
for (breakpoint *bp : all_breakpoints_safe ()) for (breakpoint &bp : all_breakpoints_safe ())
if (pop_dummy_frame_bpt (bp, dummy)) if (pop_dummy_frame_bpt (&bp, dummy))
break; break;
/* restore_infcall_control_state frees inf_state, /* restore_infcall_control_state frees inf_state,

View file

@ -569,8 +569,8 @@ gdbscm_breakpoints (void)
{ {
SCM list = SCM_EOL; SCM list = SCM_EOL;
for (breakpoint *bp : all_breakpoints ()) for (breakpoint &bp : all_breakpoints ())
bpscm_build_bp_list (bp, &list); bpscm_build_bp_list (&bp, &list);
return scm_reverse_x (list, SCM_EOL); return scm_reverse_x (list, SCM_EOL);
} }

View file

@ -1035,8 +1035,8 @@ gdbpy_breakpoints (PyObject *self, PyObject *args)
/* If build_bp_list returns false, it signals an error condition. In that /* If build_bp_list returns false, it signals an error condition. In that
case abandon building the list and return nullptr. */ case abandon building the list and return nullptr. */
for (breakpoint *bp : all_breakpoints ()) for (breakpoint &bp : all_breakpoints ())
if (!build_bp_list (bp, list.get ())) if (!build_bp_list (&bp, list.get ()))
return nullptr; return nullptr;
return PyList_AsTuple (list.get ()); return PyList_AsTuple (list.get ());

View file

@ -416,9 +416,9 @@ bpfinishpy_handle_stop (struct bpstat *bs, int print_frame)
{ {
gdbpy_enter enter_py; gdbpy_enter enter_py;
for (breakpoint *bp : all_breakpoints_safe ()) for (breakpoint &bp : all_breakpoints_safe ())
bpfinishpy_detect_out_scope_cb 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 /* 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 ()); gdbpy_enter enter_py (target_gdbarch ());
for (breakpoint *bp : all_breakpoints_safe ()) for (breakpoint &bp : all_breakpoints_safe ())
bpfinishpy_detect_out_scope_cb (bp, nullptr, true); bpfinishpy_detect_out_scope_cb (&bp, nullptr, true);
} }
/* Initialize the Python finish breakpoint code. */ /* Initialize the Python finish breakpoint code. */

View file

@ -2151,8 +2151,8 @@ svr4_update_solib_event_breakpoint (struct breakpoint *b)
static void static void
svr4_update_solib_event_breakpoints (void) svr4_update_solib_event_breakpoints (void)
{ {
for (breakpoint *bp : all_breakpoints_safe ()) for (breakpoint &bp : all_breakpoints_safe ())
svr4_update_solib_event_breakpoint (bp); svr4_update_solib_event_breakpoint (&bp);
} }
/* Create and register solib event breakpoints. PROBES is an array /* Create and register solib event breakpoints. PROBES is an array

View file

@ -1522,16 +1522,16 @@ process_tracepoint_on_disconnect (void)
/* Check whether we still have pending tracepoint. If we have, warn the /* Check whether we still have pending tracepoint. If we have, warn the
user that pending tracepoint will no longer work. */ 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; has_pending_p = 1;
break; break;
} }
else else
{ {
for (bp_location &loc1 : b->locations ()) for (bp_location &loc1 : b.locations ())
{ {
if (loc1.shlib_disabled) if (loc1.shlib_disabled)
{ {
@ -1573,18 +1573,18 @@ start_tracing (const char *notes)
if (tracepoint_range.begin () == tracepoint_range.end ()) if (tracepoint_range.begin () == tracepoint_range.end ())
error (_("No tracepoints defined, not starting trace")); 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; any_enabled = 1;
if ((b->type == bp_fast_tracepoint if ((b.type == bp_fast_tracepoint
? may_insert_fast_tracepoints ? may_insert_fast_tracepoints
: may_insert_tracepoints)) : may_insert_tracepoints))
++num_to_download; ++num_to_download;
else else
warning (_("May not insert %stracepoints, skipping tracepoint %d"), 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) if (!any_enabled)
@ -1604,23 +1604,23 @@ start_tracing (const char *notes)
target_trace_init (); target_trace_init ();
for (breakpoint *b : tracepoint_range) for (breakpoint &b : tracepoint_range)
{ {
struct tracepoint *t = (struct tracepoint *) b; tracepoint &t = gdb::checked_static_cast<tracepoint &> (b);
int bp_location_downloaded = 0; int bp_location_downloaded = 0;
/* Clear `inserted' flag. */ /* Clear `inserted' flag. */
for (bp_location &loc : b->locations ()) for (bp_location &loc : b.locations ())
loc.inserted = 0; loc.inserted = 0;
if ((b->type == bp_fast_tracepoint if ((b.type == bp_fast_tracepoint
? !may_insert_fast_tracepoints ? !may_insert_fast_tracepoints
: !may_insert_tracepoints)) : !may_insert_tracepoints))
continue; 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' /* Since tracepoint locations are never duplicated, `inserted'
flag should be zero. */ flag should be zero. */
@ -1632,14 +1632,14 @@ start_tracing (const char *notes)
bp_location_downloaded = 1; 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) if (loc.probe.prob != NULL)
loc.probe.prob->set_semaphore (loc.probe.objfile, loc.gdbarch); loc.probe.prob->set_semaphore (loc.probe.objfile, loc.gdbarch);
if (bp_location_downloaded) if (bp_location_downloaded)
gdb::observers::breakpoint_modified.notify (b); gdb::observers::breakpoint_modified.notify (&b);
} }
/* Send down all the trace state variables too. */ /* Send down all the trace state variables too. */
@ -1711,14 +1711,14 @@ stop_tracing (const char *note)
target_trace_stop (); 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_fast_tracepoints
: !may_insert_tracepoints)) : !may_insert_tracepoints))
continue; continue;
for (bp_location &loc : t->locations ()) for (bp_location &loc : t.locations ())
{ {
/* GDB can be totally absent in some disconnected trace scenarios, /* GDB can be totally absent in some disconnected trace scenarios,
but we don't really care if this semaphore goes out of sync. but we don't really care if this semaphore goes out of sync.
@ -1889,8 +1889,8 @@ tstatus_command (const char *args, int from_tty)
(long int) (ts->stop_time % 1000000)); (long int) (ts->stop_time % 1000000));
/* Now report any per-tracepoint status available. */ /* Now report any per-tracepoint status available. */
for (breakpoint *t : all_tracepoints ()) for (breakpoint &t : all_tracepoints ())
target_get_tracepoint_status (t, NULL); target_get_tracepoint_status (&t, NULL);
} }
/* Report the trace status to uiout, in a way suitable for MI, and not /* Report the trace status to uiout, in a way suitable for MI, and not
@ -3044,20 +3044,20 @@ cond_string_is_same (char *str1, char *str2)
static struct bp_location * static struct bp_location *
find_matching_tracepoint_location (struct uploaded_tp *utp) 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 = gdb::checked_static_cast<tracepoint &> (b);
if (b->type == utp->type if (b.type == utp->type
&& t->step_count == utp->step && t.step_count == utp->step
&& t->pass_count == utp->pass && t.pass_count == utp->pass
&& cond_string_is_same (t->cond_string.get (), && cond_string_is_same (t.cond_string.get (),
utp->cond_string.get ()) utp->cond_string.get ())
/* FIXME also test actions. */ /* FIXME also test actions. */
) )
{ {
/* Scan the locations for an address match. */ /* Scan the locations for an address match. */
for (bp_location &loc : b->locations ()) for (bp_location &loc : b.locations ())
if (loc.address == utp->addr) if (loc.address == utp->addr)
return &loc; return &loc;
} }

View file

@ -625,24 +625,24 @@ tui_source_window_base::update_breakpoint_info
do with it. Identify enable/disabled breakpoints as well as do with it. Identify enable/disabled breakpoints as well as
those that we already hit. */ those that we already hit. */
tui_bp_flags mode = 0; tui_bp_flags mode = 0;
for (breakpoint *bp : all_breakpoints ()) for (breakpoint &bp : all_breakpoints ())
{ {
if (bp == being_deleted) if (&bp == being_deleted)
continue; continue;
for (bp_location &loc : bp->locations ()) for (bp_location &loc : bp.locations ())
{ {
if (location_matches_p (&loc, i)) if (location_matches_p (&loc, i))
{ {
if (bp->enable_state == bp_disabled) if (bp.enable_state == bp_disabled)
mode |= TUI_BP_DISABLED; mode |= TUI_BP_DISABLED;
else else
mode |= TUI_BP_ENABLED; mode |= TUI_BP_ENABLED;
if (bp->hit_count) if (bp.hit_count)
mode |= TUI_BP_HIT; mode |= TUI_BP_HIT;
if (bp->first_loc ().cond) if (bp.first_loc ().cond)
mode |= TUI_BP_CONDITIONAL; mode |= TUI_BP_CONDITIONAL;
if (bp->type == bp_hardware_breakpoint) if (bp.type == bp_hardware_breakpoint)
mode |= TUI_BP_HARDWARE; mode |= TUI_BP_HARDWARE;
} }
} }