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)
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;
}
}

View File

@ -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;

File diff suppressed because it is too large Load Diff

View File

@ -33,7 +33,6 @@
#include "gdbsupport/next-iterator.h"
#include "gdbsupport/iterator-range.h"
#include "gdbsupport/refcounted-object.h"
#include "gdbsupport/reference-to-pointer-iterator.h"
#include "gdbsupport/safe-iterator.h"
#include "cli/cli-script.h"
#include "target/waitstatus.h"
@ -1897,11 +1896,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. */
@ -1921,14 +1918,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. */

View File

@ -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,

View File

@ -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);
}

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
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 ());

View File

@ -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. */

View File

@ -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

View File

@ -1522,16 +1522,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)
{
@ -1573,18 +1573,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)
@ -1604,23 +1604,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 = gdb::checked_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. */
@ -1632,14 +1632,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. */
@ -1711,14 +1711,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.
@ -1889,8 +1889,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
@ -3044,20 +3044,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 = gdb::checked_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;
}

View File

@ -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;
}
}