gdb: add all_breakpoints function

Introduce the all_breakpoints function, which returns a range that can
be used to iterate on breakpoints.  Replace all uses of the
ALL_BREAKPOINTS macro with this.

In one instance, I could replace the breakpoint iteration with a call to
get_breakpoint.

gdb/ChangeLog:

	* breakpoint.c (ALL_BREAKPOINTS): Remove, replace all uses with
	all_breakpoints.
	(breakpoint_iterator): New.
	(breakpoint_range): New.
	(all_breakpoints): New.

Change-Id: I229595bddad7c9100b179a9dd56b04b8c206e86c
This commit is contained in:
Simon Marchi 2021-05-27 14:58:36 -04:00
parent bdef572304
commit 43892fdfa1
2 changed files with 78 additions and 119 deletions

View file

@ -1,3 +1,11 @@
2021-05-27 Simon Marchi <simon.marchi@polymtl.ca>
* breakpoint.c (ALL_BREAKPOINTS): Remove, replace all uses with
all_breakpoints.
(breakpoint_iterator): New.
(breakpoint_range): New.
(all_breakpoints): New.
2021-05-27 Hannes Domani <ssbssa@yahoo.de> 2021-05-27 Hannes Domani <ssbssa@yahoo.de>
* python/py-tui.c (tui_py_window::output): Add full_window * python/py-tui.c (tui_py_window::output): Add full_window

View file

@ -486,8 +486,6 @@ bool target_exact_watchpoints = false;
ALL_BREAKPOINTS_SAFE does so even if the statement deletes the ALL_BREAKPOINTS_SAFE does so even if the statement deletes the
current breakpoint. */ current breakpoint. */
#define ALL_BREAKPOINTS(B) for (B = breakpoint_chain; B; B = B->next)
#define ALL_BREAKPOINTS_SAFE(B,TMP) \ #define ALL_BREAKPOINTS_SAFE(B,TMP) \
for (B = breakpoint_chain; \ for (B = breakpoint_chain; \
B ? (TMP=B->next, 1): 0; \ B ? (TMP=B->next, 1): 0; \
@ -526,6 +524,22 @@ bool target_exact_watchpoints = false;
static struct breakpoint *breakpoint_chain; static struct breakpoint *breakpoint_chain;
/* Breakpoint linked list iterator. */
using breakpoint_iterator = next_iterator<breakpoint>;
/* Breakpoint linked list range. */
using breakpoint_range = next_adapter<breakpoint, breakpoint_iterator>;
/* Return a range to iterate over all breakpoints. */
static breakpoint_range
all_breakpoints ()
{
return breakpoint_range (breakpoint_chain);
}
/* Array is sorted by bp_location_is_less_than - primarily by the ADDRESS. */ /* Array is sorted by bp_location_is_less_than - primarily by the ADDRESS. */
static struct bp_location **bp_locations; static struct bp_location **bp_locations;
@ -579,15 +593,11 @@ struct breakpoint *
breakpoint_find_if (int (*func) (struct breakpoint *b, void *d), breakpoint_find_if (int (*func) (struct breakpoint *b, void *d),
void *user_data) void *user_data)
{ {
struct breakpoint *b = NULL; for (breakpoint *b : all_breakpoints ())
if (func (b, user_data) != 0)
return b;
ALL_BREAKPOINTS (b) return nullptr;
{
if (func (b, user_data) != 0)
break;
}
return b;
} }
/* Return whether a breakpoint is an active enabled breakpoint. */ /* Return whether a breakpoint is an active enabled breakpoint. */
@ -632,9 +642,7 @@ scoped_rbreak_breakpoints::~scoped_rbreak_breakpoints ()
void void
clear_breakpoint_hit_counts (void) clear_breakpoint_hit_counts (void)
{ {
struct breakpoint *b; for (breakpoint *b : all_breakpoints ())
ALL_BREAKPOINTS (b)
b->hit_count = 0; b->hit_count = 0;
} }
@ -645,13 +653,11 @@ clear_breakpoint_hit_counts (void)
struct breakpoint * struct breakpoint *
get_breakpoint (int num) get_breakpoint (int num)
{ {
struct breakpoint *b; for (breakpoint *b : all_breakpoints ())
ALL_BREAKPOINTS (b)
if (b->number == num) if (b->number == num)
return b; return b;
return NULL; return nullptr;
} }
@ -979,8 +985,7 @@ void
set_breakpoint_condition (int bpnum, const char *exp, int from_tty, set_breakpoint_condition (int bpnum, const char *exp, int from_tty,
bool force) bool force)
{ {
struct breakpoint *b; for (breakpoint *b : all_breakpoints ())
ALL_BREAKPOINTS (b)
if (b->number == bpnum) if (b->number == bpnum)
{ {
/* Check if this breakpoint has a "stop" method implemented in an /* Check if this breakpoint has a "stop" method implemented in an
@ -1052,7 +1057,6 @@ condition_completer (struct cmd_list_element *cmd,
if (*space == '\0') if (*space == '\0')
{ {
int len; int len;
struct breakpoint *b;
if (text[0] == '$') if (text[0] == '$')
{ {
@ -1073,7 +1077,7 @@ condition_completer (struct cmd_list_element *cmd,
/* We're completing the breakpoint number. */ /* We're completing the breakpoint number. */
len = strlen (text); len = strlen (text);
ALL_BREAKPOINTS (b) for (breakpoint *b : all_breakpoints ())
{ {
char number[50]; char number[50];
@ -1270,11 +1274,10 @@ validate_commands_for_breakpoint (struct breakpoint *b,
std::vector<breakpoint *> std::vector<breakpoint *>
static_tracepoints_here (CORE_ADDR addr) static_tracepoints_here (CORE_ADDR addr)
{ {
struct breakpoint *b;
std::vector<breakpoint *> found; std::vector<breakpoint *> found;
struct bp_location *loc; struct bp_location *loc;
ALL_BREAKPOINTS (b) for (breakpoint *b : all_breakpoints ())
if (b->type == bp_static_tracepoint) if (b->type == bp_static_tracepoint)
{ {
for (loc = b->loc; loc; loc = loc->next) for (loc = b->loc; loc; loc = loc->next)
@ -2929,9 +2932,7 @@ breakpoint_program_space_exit (struct program_space *pspace)
void void
insert_breakpoints (void) insert_breakpoints (void)
{ {
struct breakpoint *bpt; for (breakpoint *bpt : all_breakpoints ())
ALL_BREAKPOINTS (bpt)
if (is_hardware_watchpoint (bpt)) if (is_hardware_watchpoint (bpt))
{ {
struct watchpoint *w = (struct watchpoint *) bpt; struct watchpoint *w = (struct watchpoint *) bpt;
@ -3025,7 +3026,6 @@ update_inserted_breakpoint_locations (void)
static void static void
insert_breakpoint_locations (void) insert_breakpoint_locations (void)
{ {
struct breakpoint *bpt;
struct bp_location *bl, **blp_tmp; struct bp_location *bl, **blp_tmp;
int error_flag = 0; int error_flag = 0;
int val = 0; int val = 0;
@ -3071,7 +3071,7 @@ insert_breakpoint_locations (void)
/* If we failed to insert all locations of a watchpoint, remove /* If we failed to insert all locations of a watchpoint, remove
them, as half-inserted watchpoint is of limited use. */ them, as half-inserted watchpoint is of limited use. */
ALL_BREAKPOINTS (bpt) for (breakpoint *bpt : all_breakpoints ())
{ {
int some_failed = 0; int some_failed = 0;
struct bp_location *loc; struct bp_location *loc;
@ -4280,9 +4280,7 @@ int
hardware_watchpoint_inserted_in_range (const address_space *aspace, hardware_watchpoint_inserted_in_range (const address_space *aspace,
CORE_ADDR addr, ULONGEST len) CORE_ADDR addr, ULONGEST len)
{ {
struct breakpoint *bpt; for (breakpoint *bpt : all_breakpoints ())
ALL_BREAKPOINTS (bpt)
{ {
struct bp_location *loc; struct bp_location *loc;
@ -4861,13 +4859,12 @@ watchpoints_triggered (struct target_waitstatus *ws)
{ {
bool stopped_by_watchpoint = target_stopped_by_watchpoint (); bool stopped_by_watchpoint = target_stopped_by_watchpoint ();
CORE_ADDR addr; CORE_ADDR addr;
struct breakpoint *b;
if (!stopped_by_watchpoint) if (!stopped_by_watchpoint)
{ {
/* We were not stopped by a watchpoint. Mark all watchpoints /* We were not stopped by a watchpoint. Mark all watchpoints
as not triggered. */ as not triggered. */
ALL_BREAKPOINTS (b) for (breakpoint *b : all_breakpoints ())
if (is_hardware_watchpoint (b)) if (is_hardware_watchpoint (b))
{ {
struct watchpoint *w = (struct watchpoint *) b; struct watchpoint *w = (struct watchpoint *) b;
@ -4882,7 +4879,7 @@ watchpoints_triggered (struct target_waitstatus *ws)
{ {
/* We were stopped by a watchpoint, but we don't know where. /* We were stopped by a watchpoint, but we don't know where.
Mark all watchpoints as unknown. */ Mark all watchpoints as unknown. */
ALL_BREAKPOINTS (b) for (breakpoint *b : all_breakpoints ())
if (is_hardware_watchpoint (b)) if (is_hardware_watchpoint (b))
{ {
struct watchpoint *w = (struct watchpoint *) b; struct watchpoint *w = (struct watchpoint *) b;
@ -4897,7 +4894,7 @@ watchpoints_triggered (struct target_waitstatus *ws)
affected by this data address as triggered, and all others as not affected by this data address as triggered, and all others as not
triggered. */ triggered. */
ALL_BREAKPOINTS (b) for (breakpoint *b : all_breakpoints ())
if (is_hardware_watchpoint (b)) if (is_hardware_watchpoint (b))
{ {
struct watchpoint *w = (struct watchpoint *) b; struct watchpoint *w = (struct watchpoint *) b;
@ -5223,9 +5220,7 @@ bpstat_check_watchpoint (bpstat bs)
if (bl->watchpoint_type == hw_read) if (bl->watchpoint_type == hw_read)
{ {
struct breakpoint *other_b; for (breakpoint *other_b : all_breakpoints ())
ALL_BREAKPOINTS (other_b)
if (other_b->type == bp_hardware_watchpoint if (other_b->type == bp_hardware_watchpoint
|| other_b->type == bp_access_watchpoint) || other_b->type == bp_access_watchpoint)
{ {
@ -5441,10 +5436,9 @@ bpstat
build_bpstat_chain (const address_space *aspace, CORE_ADDR bp_addr, build_bpstat_chain (const address_space *aspace, CORE_ADDR bp_addr,
const struct target_waitstatus *ws) const struct target_waitstatus *ws)
{ {
struct breakpoint *b;
bpstat bs_head = NULL, *bs_link = &bs_head; bpstat bs_head = NULL, *bs_link = &bs_head;
ALL_BREAKPOINTS (b) for (breakpoint *b : all_breakpoints ())
{ {
if (!breakpoint_enabled (b)) if (!breakpoint_enabled (b))
continue; continue;
@ -5858,11 +5852,10 @@ bpstat_run_callbacks (bpstat bs_head)
bool bool
bpstat_should_step () bpstat_should_step ()
{ {
struct breakpoint *b; for (breakpoint *b : all_breakpoints ())
ALL_BREAKPOINTS (b)
if (breakpoint_enabled (b) && b->type == bp_watchpoint && b->loc != NULL) if (breakpoint_enabled (b) && b->type == bp_watchpoint && b->loc != NULL)
return true; return true;
return false; return false;
} }
@ -6594,7 +6587,6 @@ static int
breakpoint_1 (const char *bp_num_list, bool show_internal, breakpoint_1 (const char *bp_num_list, bool show_internal,
bool (*filter) (const struct breakpoint *)) bool (*filter) (const struct breakpoint *))
{ {
struct breakpoint *b;
struct bp_location *last_loc = NULL; struct bp_location *last_loc = NULL;
int nr_printable_breakpoints; int nr_printable_breakpoints;
struct value_print_options opts; struct value_print_options opts;
@ -6608,7 +6600,7 @@ breakpoint_1 (const char *bp_num_list, bool show_internal,
/* Compute the number of rows in the table, as well as the size /* Compute the number of rows in the table, as well as the size
required for address fields. */ required for address fields. */
nr_printable_breakpoints = 0; nr_printable_breakpoints = 0;
ALL_BREAKPOINTS (b) for (breakpoint *b : all_breakpoints ())
{ {
/* If we have a filter, only list the breakpoints it accepts. */ /* If we have a filter, only list the breakpoints it accepts. */
if (filter && !filter (b)) if (filter && !filter (b))
@ -6676,7 +6668,7 @@ breakpoint_1 (const char *bp_num_list, bool show_internal,
if (nr_printable_breakpoints > 0) if (nr_printable_breakpoints > 0)
annotate_breakpoints_table (); annotate_breakpoints_table ();
ALL_BREAKPOINTS (b) for (breakpoint *b : all_breakpoints ())
{ {
QUIT; QUIT;
/* If we have a filter, only list the breakpoints it accepts. */ /* If we have a filter, only list the breakpoints it accepts. */
@ -6820,18 +6812,18 @@ describe_other_breakpoints (struct gdbarch *gdbarch,
struct obj_section *section, int thread) struct obj_section *section, int thread)
{ {
int others = 0; int others = 0;
struct breakpoint *b;
ALL_BREAKPOINTS (b) for (breakpoint *b : all_breakpoints ())
others += (user_breakpoint_p (b) others += (user_breakpoint_p (b)
&& breakpoint_has_pc (b, pspace, pc, section)); && breakpoint_has_pc (b, pspace, pc, section));
if (others > 0) if (others > 0)
{ {
if (others == 1) if (others == 1)
printf_filtered (_("Note: breakpoint ")); printf_filtered (_("Note: breakpoint "));
else /* if (others == ???) */ else /* if (others == ???) */
printf_filtered (_("Note: breakpoints ")); printf_filtered (_("Note: breakpoints "));
ALL_BREAKPOINTS (b) for (breakpoint *b : all_breakpoints ())
if (user_breakpoint_p (b) && breakpoint_has_pc (b, pspace, pc, section)) if (user_breakpoint_p (b) && breakpoint_has_pc (b, pspace, pc, section))
{ {
others--; others--;
@ -7422,9 +7414,9 @@ delete_longjmp_breakpoint_at_next_stop (int thread)
struct breakpoint * struct breakpoint *
set_longjmp_breakpoint_for_call_dummy (void) set_longjmp_breakpoint_for_call_dummy (void)
{ {
struct breakpoint *b, *retval = NULL; breakpoint *retval = nullptr;
ALL_BREAKPOINTS (b) for (breakpoint *b : all_breakpoints ())
if (b->pspace == current_program_space && b->type == bp_longjmp_master) if (b->pspace == current_program_space && b->type == bp_longjmp_master)
{ {
struct breakpoint *new_b; struct breakpoint *new_b;
@ -7487,9 +7479,7 @@ check_longjmp_breakpoint_for_call_dummy (struct thread_info *tp)
void void
enable_overlay_breakpoints (void) enable_overlay_breakpoints (void)
{ {
struct breakpoint *b; for (breakpoint *b : all_breakpoints ())
ALL_BREAKPOINTS (b)
if (b->type == bp_overlay_event) if (b->type == bp_overlay_event)
{ {
b->enable_state = bp_enabled; b->enable_state = bp_enabled;
@ -7501,9 +7491,7 @@ enable_overlay_breakpoints (void)
void void
disable_overlay_breakpoints (void) disable_overlay_breakpoints (void)
{ {
struct breakpoint *b; for (breakpoint *b : all_breakpoints ())
ALL_BREAKPOINTS (b)
if (b->type == bp_overlay_event) if (b->type == bp_overlay_event)
{ {
b->enable_state = bp_disabled; b->enable_state = bp_disabled;
@ -7733,8 +7721,6 @@ disable_breakpoints_in_unloaded_shlib (struct so_list *solib)
static void static void
disable_breakpoints_in_freed_objfile (struct objfile *objfile) disable_breakpoints_in_freed_objfile (struct objfile *objfile)
{ {
struct breakpoint *b;
if (objfile == NULL) if (objfile == NULL)
return; return;
@ -7753,7 +7739,7 @@ disable_breakpoints_in_freed_objfile (struct objfile *objfile)
|| (objfile->flags & OBJF_USERLOADED) == 0) || (objfile->flags & OBJF_USERLOADED) == 0)
return; return;
ALL_BREAKPOINTS (b) for (breakpoint *b : all_breakpoints ())
{ {
struct bp_location *loc; struct bp_location *loc;
int bp_modified = 0; int bp_modified = 0;
@ -8085,12 +8071,11 @@ breakpoint_hit_catch_solib (const struct bp_location *bl,
const struct target_waitstatus *ws) const struct target_waitstatus *ws)
{ {
struct solib_catchpoint *self = (struct solib_catchpoint *) bl->owner; struct solib_catchpoint *self = (struct solib_catchpoint *) bl->owner;
struct breakpoint *other;
if (ws->kind == TARGET_WAITKIND_LOADED) if (ws->kind == TARGET_WAITKIND_LOADED)
return 1; return 1;
ALL_BREAKPOINTS (other) for (breakpoint *other : all_breakpoints ())
{ {
struct bp_location *other_bl; struct bp_location *other_bl;
@ -8451,11 +8436,9 @@ static int
hw_breakpoint_used_count (void) hw_breakpoint_used_count (void)
{ {
int i = 0; int i = 0;
struct breakpoint *b;
struct bp_location *bl; struct bp_location *bl;
ALL_BREAKPOINTS (b) for (breakpoint *b : all_breakpoints ())
{
if (b->type == bp_hardware_breakpoint && breakpoint_enabled (b)) if (b->type == bp_hardware_breakpoint && breakpoint_enabled (b))
for (bl = b->loc; bl; bl = bl->next) for (bl = b->loc; bl; bl = bl->next)
{ {
@ -8463,7 +8446,6 @@ hw_breakpoint_used_count (void)
one register. */ one register. */
i += b->ops->resources_needed (bl); i += b->ops->resources_needed (bl);
} }
}
return i; return i;
} }
@ -8500,10 +8482,9 @@ hw_watchpoint_used_count_others (struct breakpoint *except,
enum bptype type, int *other_type_used) enum bptype type, int *other_type_used)
{ {
int i = 0; int i = 0;
struct breakpoint *b;
*other_type_used = 0; *other_type_used = 0;
ALL_BREAKPOINTS (b) for (breakpoint *b : all_breakpoints ())
{ {
if (b == except) if (b == except)
continue; continue;
@ -8522,31 +8503,23 @@ hw_watchpoint_used_count_others (struct breakpoint *except,
void void
disable_watchpoints_before_interactive_call_start (void) disable_watchpoints_before_interactive_call_start (void)
{ {
struct breakpoint *b; for (breakpoint *b : all_breakpoints ())
ALL_BREAKPOINTS (b)
{
if (is_watchpoint (b) && breakpoint_enabled (b)) 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); update_global_location_list (UGLL_DONT_INSERT);
} }
}
} }
void void
enable_watchpoints_after_interactive_call_stop (void) enable_watchpoints_after_interactive_call_stop (void)
{ {
struct breakpoint *b; for (breakpoint *b : all_breakpoints ())
ALL_BREAKPOINTS (b)
{
if (is_watchpoint (b) && b->enable_state == bp_call_disabled) 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); update_global_location_list (UGLL_MAY_INSERT);
} }
}
} }
void void
@ -8896,13 +8869,9 @@ static void
update_dprintf_commands (const char *args, int from_tty, update_dprintf_commands (const char *args, int from_tty,
struct cmd_list_element *c) struct cmd_list_element *c)
{ {
struct breakpoint *b; for (breakpoint *b : all_breakpoints ())
if (b->type == bp_dprintf)
ALL_BREAKPOINTS (b)
{
if (b->type == bp_dprintf)
update_dprintf_command_list (b); update_dprintf_command_list (b);
}
} }
/* Create a breakpoint with SAL as location. Use LOCATION /* Create a breakpoint with SAL as location. Use LOCATION
@ -11496,7 +11465,6 @@ compare_breakpoints (const breakpoint *a, const breakpoint *b)
static void static void
clear_command (const char *arg, int from_tty) clear_command (const char *arg, int from_tty)
{ {
struct breakpoint *b;
int default_match; int default_match;
std::vector<symtab_and_line> decoded_sals; std::vector<symtab_and_line> decoded_sals;
@ -11567,7 +11535,7 @@ clear_command (const char *arg, int from_tty)
? NULL : symtab_to_fullname (sal.symtab)); ? NULL : symtab_to_fullname (sal.symtab));
/* Find all matching breakpoints and add them to 'found'. */ /* Find all matching breakpoints and add them to 'found'. */
ALL_BREAKPOINTS (b) for (breakpoint *b : all_breakpoints ())
{ {
int match = 0; int match = 0;
/* Are we going to delete b? */ /* Are we going to delete b? */
@ -11893,7 +11861,6 @@ force_breakpoint_reinsertion (struct bp_location *bl)
static void static void
update_global_location_list (enum ugll_insert_mode insert_mode) update_global_location_list (enum ugll_insert_mode insert_mode)
{ {
struct breakpoint *b;
struct bp_location **locp, *loc; struct bp_location **locp, *loc;
/* Last breakpoint location address that was marked for update. */ /* Last breakpoint location address that was marked for update. */
CORE_ADDR last_addr = 0; CORE_ADDR last_addr = 0;
@ -11921,13 +11888,13 @@ update_global_location_list (enum ugll_insert_mode insert_mode)
bp_locations = NULL; bp_locations = NULL;
bp_locations_count = 0; bp_locations_count = 0;
ALL_BREAKPOINTS (b) for (breakpoint *b : all_breakpoints ())
for (loc = b->loc; loc; loc = loc->next) for (loc = b->loc; loc; loc = loc->next)
bp_locations_count++; bp_locations_count++;
bp_locations = XNEWVEC (struct bp_location *, bp_locations_count); bp_locations = XNEWVEC (struct bp_location *, bp_locations_count);
locp = bp_locations; locp = bp_locations;
ALL_BREAKPOINTS (b) for (breakpoint *b : all_breakpoints ())
for (loc = b->loc; loc; loc = loc->next) for (loc = b->loc; loc; loc = loc->next)
*locp++ = loc; *locp++ = loc;
@ -12188,7 +12155,7 @@ update_global_location_list (enum ugll_insert_mode insert_mode)
/* ALL_BP_LOCATIONS bp_location has LOC->OWNER always /* ALL_BP_LOCATIONS bp_location has LOC->OWNER always
non-NULL. */ non-NULL. */
struct bp_location **loc_first_p; struct bp_location **loc_first_p;
b = loc->owner; breakpoint *b = loc->owner;
if (!unduplicated_should_be_inserted (loc) if (!unduplicated_should_be_inserted (loc)
|| !bl_address_is_meaningful (loc) || !bl_address_is_meaningful (loc)
@ -13283,8 +13250,6 @@ strace_marker_p (struct breakpoint *b)
void void
delete_breakpoint (struct breakpoint *bpt) delete_breakpoint (struct breakpoint *bpt)
{ {
struct breakpoint *b;
gdb_assert (bpt != NULL); gdb_assert (bpt != NULL);
/* Has this bp already been deleted? This can happen because /* Has this bp already been deleted? This can happen because
@ -13339,7 +13304,7 @@ delete_breakpoint (struct breakpoint *bpt)
if (breakpoint_chain == bpt) if (breakpoint_chain == bpt)
breakpoint_chain = bpt->next; breakpoint_chain = bpt->next;
ALL_BREAKPOINTS (b) for (breakpoint *b : all_breakpoints ())
if (b->next == bpt) if (b->next == bpt)
{ {
b->next = bpt->next; b->next = bpt->next;
@ -13410,7 +13375,7 @@ iterate_over_related_breakpoints (struct breakpoint *b,
static void static void
delete_command (const char *arg, int from_tty) delete_command (const char *arg, int from_tty)
{ {
struct breakpoint *b, *b_tmp; breakpoint *b_tmp;
dont_repeat (); dont_repeat ();
@ -13421,7 +13386,7 @@ delete_command (const char *arg, int from_tty)
/* Delete all breakpoints if no argument. Do not delete /* Delete all breakpoints if no argument. Do not delete
internal breakpoints, these have to be deleted with an internal breakpoints, these have to be deleted with an
explicit breakpoint number argument. */ explicit breakpoint number argument. */
ALL_BREAKPOINTS (b) for (breakpoint *b : all_breakpoints ())
if (user_breakpoint_p (b)) if (user_breakpoint_p (b))
{ {
breaks_to_delete = 1; breaks_to_delete = 1;
@ -13432,6 +13397,8 @@ delete_command (const char *arg, int from_tty)
if (!from_tty if (!from_tty
|| (breaks_to_delete && query (_("Delete all breakpoints? ")))) || (breaks_to_delete && query (_("Delete all breakpoints? "))))
{ {
breakpoint *b;
ALL_BREAKPOINTS_SAFE (b, b_tmp) ALL_BREAKPOINTS_SAFE (b, b_tmp)
if (user_breakpoint_p (b)) if (user_breakpoint_p (b))
delete_breakpoint (b); delete_breakpoint (b);
@ -14084,12 +14051,10 @@ breakpoint_re_set_thread (struct breakpoint *b)
void void
set_ignore_count (int bptnum, int count, int from_tty) set_ignore_count (int bptnum, int count, int from_tty)
{ {
struct breakpoint *b;
if (count < 0) if (count < 0)
count = 0; count = 0;
ALL_BREAKPOINTS (b) for (breakpoint *b : all_breakpoints ())
if (b->number == bptnum) if (b->number == bptnum)
{ {
if (is_tracepoint (b)) if (is_tracepoint (b))
@ -14205,13 +14170,7 @@ map_breakpoint_numbers (const char *args,
static struct bp_location * static struct bp_location *
find_location_by_number (int bp_num, int loc_num) find_location_by_number (int bp_num, int loc_num)
{ {
struct breakpoint *b; breakpoint *b = get_breakpoint (bp_num);
ALL_BREAKPOINTS (b)
if (b->number == bp_num)
{
break;
}
if (!b || b->number != bp_num) if (!b || b->number != bp_num)
error (_("Bad breakpoint number '%d'"), bp_num); error (_("Bad breakpoint number '%d'"), bp_num);
@ -14437,9 +14396,7 @@ enable_disable_command (const char *args, int from_tty, bool enable)
{ {
if (args == 0) if (args == 0)
{ {
struct breakpoint *bpt; for (breakpoint *bpt : all_breakpoints ())
ALL_BREAKPOINTS (bpt)
if (user_breakpoint_p (bpt)) if (user_breakpoint_p (bpt))
{ {
if (enable) if (enable)
@ -14628,9 +14585,7 @@ invalidate_bp_value_on_memory_change (struct inferior *inferior,
CORE_ADDR addr, ssize_t len, CORE_ADDR addr, ssize_t len,
const bfd_byte *data) const bfd_byte *data)
{ {
struct breakpoint *bp; for (breakpoint *bp : all_breakpoints ())
ALL_BREAKPOINTS (bp)
if (bp->enable_state == bp_enabled if (bp->enable_state == bp_enabled
&& bp->type == bp_hardware_watchpoint) && bp->type == bp_hardware_watchpoint)
{ {
@ -14726,9 +14681,7 @@ int
single_step_breakpoint_inserted_here_p (const address_space *aspace, single_step_breakpoint_inserted_here_p (const address_space *aspace,
CORE_ADDR pc) CORE_ADDR pc)
{ {
struct breakpoint *bpt; for (breakpoint *bpt : all_breakpoints ())
ALL_BREAKPOINTS (bpt)
{ {
if (bpt->type == bp_single_step if (bpt->type == bp_single_step
&& breakpoint_has_location_inserted_here (bpt, aspace, pc)) && breakpoint_has_location_inserted_here (bpt, aspace, pc))
@ -15169,7 +15122,6 @@ static void
save_breakpoints (const char *filename, int from_tty, save_breakpoints (const char *filename, int from_tty,
bool (*filter) (const struct breakpoint *)) bool (*filter) (const struct breakpoint *))
{ {
struct breakpoint *tp;
int any = 0; int any = 0;
int extra_trace_bits = 0; int extra_trace_bits = 0;
@ -15177,7 +15129,7 @@ save_breakpoints (const char *filename, int from_tty,
error (_("Argument required (file name in which to save)")); error (_("Argument required (file name in which to save)"));
/* See if we have anything to save. */ /* See if we have anything to save. */
ALL_BREAKPOINTS (tp) for (breakpoint *tp : all_breakpoints ())
{ {
/* Skip internal and momentary breakpoints. */ /* Skip internal and momentary breakpoints. */
if (!user_breakpoint_p (tp)) if (!user_breakpoint_p (tp))
@ -15215,7 +15167,7 @@ save_breakpoints (const char *filename, int from_tty,
if (extra_trace_bits) if (extra_trace_bits)
save_trace_state_variables (&fp); save_trace_state_variables (&fp);
ALL_BREAKPOINTS (tp) for (breakpoint *tp : all_breakpoints ())
{ {
/* Skip internal and momentary breakpoints. */ /* Skip internal and momentary breakpoints. */
if (!user_breakpoint_p (tp)) if (!user_breakpoint_p (tp))
@ -15432,10 +15384,9 @@ int
pc_at_non_inline_function (const address_space *aspace, CORE_ADDR pc, pc_at_non_inline_function (const address_space *aspace, CORE_ADDR pc,
const struct target_waitstatus *ws) const struct target_waitstatus *ws)
{ {
struct breakpoint *b;
struct bp_location *bl; struct bp_location *bl;
ALL_BREAKPOINTS (b) for (breakpoint *b : all_breakpoints ())
{ {
if (!is_non_inline_function (b)) if (!is_non_inline_function (b))
continue; continue;