ALL_BREAKPOINTS_SAFE does so even if the statement deletes the
current breakpoint. */
-#define ALL_BREAKPOINTS(B) for (B = breakpoint_chain; B; B = B->next)
-
#define ALL_BREAKPOINTS_SAFE(B,TMP) \
for (B = breakpoint_chain; \
B ? (TMP=B->next, 1): 0; \
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. */
static struct bp_location **bp_locations;
breakpoint_find_if (int (*func) (struct breakpoint *b, void *d),
void *user_data)
{
- struct breakpoint *b = NULL;
-
- ALL_BREAKPOINTS (b)
- {
- if (func (b, user_data) != 0)
- break;
- }
+ for (breakpoint *b : all_breakpoints ())
+ if (func (b, user_data) != 0)
+ return b;
- return b;
+ return nullptr;
}
/* Return whether a breakpoint is an active enabled breakpoint. */
void
clear_breakpoint_hit_counts (void)
{
- struct breakpoint *b;
-
- ALL_BREAKPOINTS (b)
+ for (breakpoint *b : all_breakpoints ())
b->hit_count = 0;
}
struct breakpoint *
get_breakpoint (int num)
{
- struct breakpoint *b;
-
- ALL_BREAKPOINTS (b)
+ for (breakpoint *b : all_breakpoints ())
if (b->number == num)
return b;
- return NULL;
+ return nullptr;
}
\f
set_breakpoint_condition (int bpnum, const char *exp, int from_tty,
bool force)
{
- struct breakpoint *b;
- ALL_BREAKPOINTS (b)
+ for (breakpoint *b : all_breakpoints ())
if (b->number == bpnum)
{
/* Check if this breakpoint has a "stop" method implemented in an
if (*space == '\0')
{
int len;
- struct breakpoint *b;
if (text[0] == '$')
{
/* We're completing the breakpoint number. */
len = strlen (text);
- ALL_BREAKPOINTS (b)
+ for (breakpoint *b : all_breakpoints ())
{
char number[50];
std::vector<breakpoint *>
static_tracepoints_here (CORE_ADDR addr)
{
- struct breakpoint *b;
std::vector<breakpoint *> found;
struct bp_location *loc;
- ALL_BREAKPOINTS (b)
+ for (breakpoint *b : all_breakpoints ())
if (b->type == bp_static_tracepoint)
{
for (loc = b->loc; loc; loc = loc->next)
void
insert_breakpoints (void)
{
- struct breakpoint *bpt;
-
- ALL_BREAKPOINTS (bpt)
+ for (breakpoint *bpt : all_breakpoints ())
if (is_hardware_watchpoint (bpt))
{
struct watchpoint *w = (struct watchpoint *) bpt;
static void
insert_breakpoint_locations (void)
{
- struct breakpoint *bpt;
struct bp_location *bl, **blp_tmp;
int error_flag = 0;
int val = 0;
/* If we failed to insert all locations of a watchpoint, remove
them, as half-inserted watchpoint is of limited use. */
- ALL_BREAKPOINTS (bpt)
+ for (breakpoint *bpt : all_breakpoints ())
{
int some_failed = 0;
struct bp_location *loc;
hardware_watchpoint_inserted_in_range (const address_space *aspace,
CORE_ADDR addr, ULONGEST len)
{
- struct breakpoint *bpt;
-
- ALL_BREAKPOINTS (bpt)
+ for (breakpoint *bpt : all_breakpoints ())
{
struct bp_location *loc;
{
bool stopped_by_watchpoint = target_stopped_by_watchpoint ();
CORE_ADDR addr;
- struct breakpoint *b;
if (!stopped_by_watchpoint)
{
/* We were not stopped by a watchpoint. Mark all watchpoints
as not triggered. */
- ALL_BREAKPOINTS (b)
+ for (breakpoint *b : all_breakpoints ())
if (is_hardware_watchpoint (b))
{
struct watchpoint *w = (struct watchpoint *) b;
{
/* We were stopped by a watchpoint, but we don't know where.
Mark all watchpoints as unknown. */
- ALL_BREAKPOINTS (b)
+ for (breakpoint *b : all_breakpoints ())
if (is_hardware_watchpoint (b))
{
struct watchpoint *w = (struct watchpoint *) b;
affected by this data address as triggered, and all others as not
triggered. */
- ALL_BREAKPOINTS (b)
+ for (breakpoint *b : all_breakpoints ())
if (is_hardware_watchpoint (b))
{
struct watchpoint *w = (struct watchpoint *) b;
if (bl->watchpoint_type == hw_read)
{
- struct breakpoint *other_b;
-
- ALL_BREAKPOINTS (other_b)
+ for (breakpoint *other_b : all_breakpoints ())
if (other_b->type == bp_hardware_watchpoint
|| other_b->type == bp_access_watchpoint)
{
build_bpstat_chain (const address_space *aspace, CORE_ADDR bp_addr,
const struct target_waitstatus *ws)
{
- struct breakpoint *b;
bpstat bs_head = NULL, *bs_link = &bs_head;
- ALL_BREAKPOINTS (b)
+ for (breakpoint *b : all_breakpoints ())
{
if (!breakpoint_enabled (b))
continue;
bool
bpstat_should_step ()
{
- struct breakpoint *b;
-
- ALL_BREAKPOINTS (b)
+ for (breakpoint *b : all_breakpoints ())
if (breakpoint_enabled (b) && b->type == bp_watchpoint && b->loc != NULL)
return true;
+
return false;
}
breakpoint_1 (const char *bp_num_list, bool show_internal,
bool (*filter) (const struct breakpoint *))
{
- struct breakpoint *b;
struct bp_location *last_loc = NULL;
int nr_printable_breakpoints;
struct value_print_options opts;
/* Compute the number of rows in the table, as well as the size
required for address fields. */
nr_printable_breakpoints = 0;
- ALL_BREAKPOINTS (b)
+ for (breakpoint *b : all_breakpoints ())
{
/* If we have a filter, only list the breakpoints it accepts. */
if (filter && !filter (b))
if (nr_printable_breakpoints > 0)
annotate_breakpoints_table ();
- ALL_BREAKPOINTS (b)
+ for (breakpoint *b : all_breakpoints ())
{
QUIT;
/* If we have a filter, only list the breakpoints it accepts. */
struct obj_section *section, int thread)
{
int others = 0;
- struct breakpoint *b;
- ALL_BREAKPOINTS (b)
+ for (breakpoint *b : all_breakpoints ())
others += (user_breakpoint_p (b)
&& breakpoint_has_pc (b, pspace, pc, section));
+
if (others > 0)
{
if (others == 1)
printf_filtered (_("Note: breakpoint "));
else /* if (others == ???) */
printf_filtered (_("Note: breakpoints "));
- ALL_BREAKPOINTS (b)
+ for (breakpoint *b : all_breakpoints ())
if (user_breakpoint_p (b) && breakpoint_has_pc (b, pspace, pc, section))
{
others--;
struct breakpoint *
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)
{
struct breakpoint *new_b;
void
enable_overlay_breakpoints (void)
{
- struct breakpoint *b;
-
- ALL_BREAKPOINTS (b)
+ for (breakpoint *b : all_breakpoints ())
if (b->type == bp_overlay_event)
{
b->enable_state = bp_enabled;
void
disable_overlay_breakpoints (void)
{
- struct breakpoint *b;
-
- ALL_BREAKPOINTS (b)
+ for (breakpoint *b : all_breakpoints ())
if (b->type == bp_overlay_event)
{
b->enable_state = bp_disabled;
static void
disable_breakpoints_in_freed_objfile (struct objfile *objfile)
{
- struct breakpoint *b;
-
if (objfile == NULL)
return;
|| (objfile->flags & OBJF_USERLOADED) == 0)
return;
- ALL_BREAKPOINTS (b)
+ for (breakpoint *b : all_breakpoints ())
{
struct bp_location *loc;
int bp_modified = 0;
const struct target_waitstatus *ws)
{
struct solib_catchpoint *self = (struct solib_catchpoint *) bl->owner;
- struct breakpoint *other;
if (ws->kind == TARGET_WAITKIND_LOADED)
return 1;
- ALL_BREAKPOINTS (other)
+ for (breakpoint *other : all_breakpoints ())
{
struct bp_location *other_bl;
hw_breakpoint_used_count (void)
{
int i = 0;
- struct breakpoint *b;
struct bp_location *bl;
- ALL_BREAKPOINTS (b)
- {
+ for (breakpoint *b : all_breakpoints ())
if (b->type == bp_hardware_breakpoint && breakpoint_enabled (b))
for (bl = b->loc; bl; bl = bl->next)
{
one register. */
i += b->ops->resources_needed (bl);
}
- }
return i;
}
enum bptype type, int *other_type_used)
{
int i = 0;
- struct breakpoint *b;
*other_type_used = 0;
- ALL_BREAKPOINTS (b)
+ for (breakpoint *b : all_breakpoints ())
{
if (b == except)
continue;
void
disable_watchpoints_before_interactive_call_start (void)
{
- struct breakpoint *b;
-
- ALL_BREAKPOINTS (b)
- {
+ for (breakpoint *b : all_breakpoints ())
if (is_watchpoint (b) && breakpoint_enabled (b))
{
b->enable_state = bp_call_disabled;
update_global_location_list (UGLL_DONT_INSERT);
}
- }
}
void
enable_watchpoints_after_interactive_call_stop (void)
{
- struct breakpoint *b;
-
- ALL_BREAKPOINTS (b)
- {
+ for (breakpoint *b : all_breakpoints ())
if (is_watchpoint (b) && b->enable_state == bp_call_disabled)
{
b->enable_state = bp_enabled;
update_global_location_list (UGLL_MAY_INSERT);
}
- }
}
void
update_dprintf_commands (const char *args, int from_tty,
struct cmd_list_element *c)
{
- struct breakpoint *b;
-
- ALL_BREAKPOINTS (b)
- {
- if (b->type == bp_dprintf)
+ for (breakpoint *b : all_breakpoints ())
+ if (b->type == bp_dprintf)
update_dprintf_command_list (b);
- }
}
/* Create a breakpoint with SAL as location. Use LOCATION
static void
clear_command (const char *arg, int from_tty)
{
- struct breakpoint *b;
int default_match;
std::vector<symtab_and_line> decoded_sals;
? NULL : symtab_to_fullname (sal.symtab));
/* Find all matching breakpoints and add them to 'found'. */
- ALL_BREAKPOINTS (b)
+ for (breakpoint *b : all_breakpoints ())
{
int match = 0;
/* Are we going to delete b? */
static void
update_global_location_list (enum ugll_insert_mode insert_mode)
{
- struct breakpoint *b;
struct bp_location **locp, *loc;
/* Last breakpoint location address that was marked for update. */
CORE_ADDR last_addr = 0;
bp_locations = NULL;
bp_locations_count = 0;
- ALL_BREAKPOINTS (b)
+ for (breakpoint *b : all_breakpoints ())
for (loc = b->loc; loc; loc = loc->next)
bp_locations_count++;
bp_locations = XNEWVEC (struct bp_location *, bp_locations_count);
locp = bp_locations;
- ALL_BREAKPOINTS (b)
+ for (breakpoint *b : all_breakpoints ())
for (loc = b->loc; loc; loc = loc->next)
*locp++ = loc;
/* ALL_BP_LOCATIONS bp_location has LOC->OWNER always
non-NULL. */
struct bp_location **loc_first_p;
- b = loc->owner;
+ breakpoint *b = loc->owner;
if (!unduplicated_should_be_inserted (loc)
|| !bl_address_is_meaningful (loc)
void
delete_breakpoint (struct breakpoint *bpt)
{
- struct breakpoint *b;
-
gdb_assert (bpt != NULL);
/* Has this bp already been deleted? This can happen because
if (breakpoint_chain == bpt)
breakpoint_chain = bpt->next;
- ALL_BREAKPOINTS (b)
+ for (breakpoint *b : all_breakpoints ())
if (b->next == bpt)
{
b->next = bpt->next;
static void
delete_command (const char *arg, int from_tty)
{
- struct breakpoint *b, *b_tmp;
+ breakpoint *b_tmp;
dont_repeat ();
/* Delete all breakpoints if no argument. Do not delete
internal breakpoints, these have to be deleted with an
explicit breakpoint number argument. */
- ALL_BREAKPOINTS (b)
+ for (breakpoint *b : all_breakpoints ())
if (user_breakpoint_p (b))
{
breaks_to_delete = 1;
if (!from_tty
|| (breaks_to_delete && query (_("Delete all breakpoints? "))))
{
+ breakpoint *b;
+
ALL_BREAKPOINTS_SAFE (b, b_tmp)
if (user_breakpoint_p (b))
delete_breakpoint (b);
void
set_ignore_count (int bptnum, int count, int from_tty)
{
- struct breakpoint *b;
-
if (count < 0)
count = 0;
- ALL_BREAKPOINTS (b)
+ for (breakpoint *b : all_breakpoints ())
if (b->number == bptnum)
{
if (is_tracepoint (b))
static struct bp_location *
find_location_by_number (int bp_num, int loc_num)
{
- struct breakpoint *b;
-
- ALL_BREAKPOINTS (b)
- if (b->number == bp_num)
- {
- break;
- }
+ breakpoint *b = get_breakpoint (bp_num);
if (!b || b->number != bp_num)
error (_("Bad breakpoint number '%d'"), bp_num);
{
if (args == 0)
{
- struct breakpoint *bpt;
-
- ALL_BREAKPOINTS (bpt)
+ for (breakpoint *bpt : all_breakpoints ())
if (user_breakpoint_p (bpt))
{
if (enable)
CORE_ADDR addr, ssize_t len,
const bfd_byte *data)
{
- struct breakpoint *bp;
-
- ALL_BREAKPOINTS (bp)
+ for (breakpoint *bp : all_breakpoints ())
if (bp->enable_state == bp_enabled
&& bp->type == bp_hardware_watchpoint)
{
single_step_breakpoint_inserted_here_p (const address_space *aspace,
CORE_ADDR pc)
{
- struct breakpoint *bpt;
-
- ALL_BREAKPOINTS (bpt)
+ for (breakpoint *bpt : all_breakpoints ())
{
if (bpt->type == bp_single_step
&& breakpoint_has_location_inserted_here (bpt, aspace, pc))
save_breakpoints (const char *filename, int from_tty,
bool (*filter) (const struct breakpoint *))
{
- struct breakpoint *tp;
int any = 0;
int extra_trace_bits = 0;
error (_("Argument required (file name in which to save)"));
/* See if we have anything to save. */
- ALL_BREAKPOINTS (tp)
+ for (breakpoint *tp : all_breakpoints ())
{
/* Skip internal and momentary breakpoints. */
if (!user_breakpoint_p (tp))
if (extra_trace_bits)
save_trace_state_variables (&fp);
- ALL_BREAKPOINTS (tp)
+ for (breakpoint *tp : all_breakpoints ())
{
/* Skip internal and momentary breakpoints. */
if (!user_breakpoint_p (tp))
pc_at_non_inline_function (const address_space *aspace, CORE_ADDR pc,
const struct target_waitstatus *ws)
{
- struct breakpoint *b;
struct bp_location *bl;
- ALL_BREAKPOINTS (b)
+ for (breakpoint *b : all_breakpoints ())
{
if (!is_non_inline_function (b))
continue;