static void
mark_breakpoint_modified (struct breakpoint *b)
{
- struct bp_location *loc;
-
/* This is only meaningful if the target is
evaluating conditions and if the user has
opted for condition evaluation on the target's
if (!is_breakpoint (b))
return;
- for (loc = b->loc; loc; loc = loc->next)
+ for (bp_location *loc : b->locations ())
loc->condition_changed = condition_modified;
}
else
{
int loc_num = 1;
- for (bp_location *loc = b->loc; loc != nullptr; loc = loc->next)
+ for (bp_location *loc : b->locations ())
{
loc->cond.reset ();
if (loc->disabled_by_cond && loc->enabled)
the error and the condition string will be rejected.
This two-pass approach is taken to avoid setting the
state of locations in case of a reject. */
- for (bp_location *loc = b->loc; loc != nullptr; loc = loc->next)
+ for (bp_location *loc : b->locations ())
{
try
{
/* If we reach here, the condition is valid at some locations. */
int loc_num = 1;
- for (bp_location *loc = b->loc; loc != nullptr;
- loc = loc->next, loc_num++)
- set_breakpoint_location_condition (exp, loc, b->number, loc_num);
+ for (bp_location *loc : b->locations ())
+ {
+ set_breakpoint_location_condition (exp, loc, b->number, loc_num);
+ loc_num++;
+ }
}
/* We know that the new condition parsed successfully. The
static_tracepoints_here (CORE_ADDR addr)
{
std::vector<breakpoint *> found;
- struct bp_location *loc;
for (breakpoint *b : all_breakpoints ())
if (b->type == bp_static_tracepoint)
{
- for (loc = b->loc; loc; loc = loc->next)
+ for (bp_location *loc : b->locations ())
if (loc->address == addr)
found.push_back (b);
}
{
int reg_cnt;
enum bp_loc_type loc_type;
- struct bp_location *bl;
reg_cnt = can_use_hardware_watchpoint (val_chain);
loc_type = (b->type == bp_watchpoint? bp_loc_other
: bp_loc_hardware_watchpoint);
- for (bl = b->loc; bl; bl = bl->next)
+ for (bp_location *bl : b->locations ())
bl->loc_type = loc_type;
}
for (breakpoint *bpt : all_breakpoints ())
{
int some_failed = 0;
- struct bp_location *loc;
if (!is_hardware_watchpoint (bpt))
continue;
if (bpt->disposition == disp_del_at_next_stop)
continue;
- for (loc = bpt->loc; loc; loc = loc->next)
+ for (bp_location *loc : bpt->locations ())
if (!loc->inserted && should_be_inserted (loc))
{
some_failed = 1;
break;
}
+
if (some_failed)
{
- for (loc = bpt->loc; loc; loc = loc->next)
+ for (bp_location *loc : bpt->locations ())
if (loc->inserted)
remove_breakpoint (loc);
{
for (breakpoint *bpt : all_breakpoints ())
{
- struct bp_location *loc;
-
if (bpt->type != bp_hardware_watchpoint
&& bpt->type != bp_access_watchpoint)
continue;
if (!breakpoint_enabled (bpt))
continue;
- for (loc = bpt->loc; loc; loc = loc->next)
+ for (bp_location *loc : bpt->locations ())
if (loc->pspace->aspace == aspace && loc->inserted)
{
CORE_ADDR l, h;
if (is_hardware_watchpoint (b))
{
struct watchpoint *w = (struct watchpoint *) b;
- struct bp_location *loc;
w->watchpoint_triggered = watch_triggered_no;
- for (loc = b->loc; loc; loc = loc->next)
+ for (bp_location *loc : b->locations ())
{
if (is_masked_watchpoint (b))
{
if (!breakpoint_enabled (b))
continue;
- for (bp_location *bl = b->loc; bl != NULL; bl = bl->next)
+ for (bp_location *bl : b->locations ())
{
/* For hardware watchpoints, we look only at the first
location. The watchpoint_check function will work on the
static const char *
bp_condition_evaluator (struct breakpoint *b)
{
- struct bp_location *bl;
char host_evals = 0;
char target_evals = 0;
|| !target_supports_evaluation_of_breakpoint_conditions ())
return condition_evaluation_host;
- for (bl = b->loc; bl; bl = bl->next)
+ for (bp_location *bl : b->locations ())
{
if (bl->cond_bytecode)
target_evals++;
locations_list.emplace (uiout, "locations");
int n = 1;
- for (bp_location *loc = b->loc; loc != NULL; loc = loc->next, ++n)
+ for (bp_location *loc : b->locations ())
{
ui_out_emit_tuple loc_tuple_emitter (uiout, NULL);
print_one_breakpoint_location (b, loc, n, last_loc,
allflag, allflag);
+ n++;
}
}
}
breakpoint_address_bits (struct breakpoint *b)
{
int print_address_bits = 0;
- struct bp_location *loc;
/* Software watchpoints that aren't watching memory don't have an
address to print. */
if (is_no_memory_software_watchpoint (b))
return 0;
- for (loc = b->loc; loc; loc = loc->next)
+ for (bp_location *loc : b->locations ())
{
int addr_bit;
if (show_internal || user_breakpoint_p (b))
{
print_one_breakpoint (b, &last_loc, show_internal);
- for (bp_location *loc = b->loc; loc != NULL; loc = loc->next)
+ for (bp_location *loc : b->locations ())
if (loc->disabled_by_cond)
has_disabled_by_cond_location = true;
}
struct program_space *pspace,
CORE_ADDR pc, struct obj_section *section)
{
- struct bp_location *bl = b->loc;
-
- for (; bl; bl = bl->next)
+ for (bp_location *bl : b->locations ())
{
if (bl->pspace == pspace
&& bl->address == pc
for (breakpoint *b : all_breakpoints ())
{
- struct bp_location *loc;
int bp_modified = 0;
if (!is_breakpoint (b) && !is_tracepoint (b))
continue;
- for (loc = b->loc; loc != NULL; loc = loc->next)
+ for (bp_location *loc : b->locations ())
{
CORE_ADDR loc_addr = loc->address;
for (breakpoint *other : all_breakpoints ())
{
- struct bp_location *other_bl;
-
if (other == bl->owner)
continue;
if (self->pspace != NULL && other->pspace != self->pspace)
continue;
- for (other_bl = other->loc; other_bl != NULL; other_bl = other_bl->next)
+ for (bp_location *other_bl : other->locations ())
{
if (other->ops->breakpoint_hit (other_bl, aspace, bp_addr, ws))
return 1;
hw_breakpoint_used_count (void)
{
int i = 0;
- struct bp_location *bl;
for (breakpoint *b : all_breakpoints ())
if (b->type == bp_hardware_breakpoint && breakpoint_enabled (b))
- for (bl = b->loc; bl; bl = bl->next)
+ for (bp_location *bl : b->locations ())
{
/* Special types of hardware breakpoints may use more than
one register. */
hw_watchpoint_use_count (struct breakpoint *b)
{
int i = 0;
- struct bp_location *bl;
if (!breakpoint_enabled (b))
return 0;
- for (bl = b->loc; bl; bl = bl->next)
+ for (bp_location *bl : b->locations ())
{
/* Special types of hardware watchpoints may use more than
one register. */
/* The order of the locations is now stable. Set the location
condition using the location's number. */
int loc_num = 1;
- for (bp_location *loc = b->loc; loc != nullptr; loc = loc->next)
+ for (bp_location *loc : b->locations ())
{
if (b->cond_string != nullptr)
set_breakpoint_location_condition (b->cond_string, loc, b->number,
/* Are we going to delete b? */
if (b->type != bp_none && !is_watchpoint (b))
{
- struct bp_location *loc = b->loc;
- for (; loc; loc = loc->next)
+ for (bp_location *loc : b->locations ())
{
/* If the user specified file:line, don't allow a PC
match. This matches historical gdb behavior. */
for (breakpoint *b : all_tracepoints ())
{
- struct bp_location *bl;
struct tracepoint *t;
int bp_location_downloaded = 0;
if (can_download_tracepoint == TRIBOOL_FALSE)
break;
- for (bl = b->loc; bl; bl = bl->next)
+ for (bp_location *bl : b->locations ())
{
/* In tracepoint, locations are _never_ duplicated, so
should_be_inserted is equivalent to
static void
update_global_location_list (enum ugll_insert_mode insert_mode)
{
- struct bp_location **locp, *loc;
+ struct bp_location **locp;
/* Last breakpoint location address that was marked for update. */
CORE_ADDR last_addr = 0;
/* Last breakpoint location program space that was marked for update. */
bp_locations_count = 0;
for (breakpoint *b : all_breakpoints ())
- for (loc = b->loc; loc; loc = loc->next)
+ for (bp_location *loc ATTRIBUTE_UNUSED : b->locations ())
bp_locations_count++;
bp_locations = XNEWVEC (struct bp_location *, bp_locations_count);
locp = bp_locations;
for (breakpoint *b : all_breakpoints ())
- for (loc = b->loc; loc; loc = loc->next)
+ for (bp_location *loc : b->locations ())
*locp++ = loc;
/* See if we need to "upgrade" a software breakpoint to a hardware
locp < bp_locations + bp_locations_count;
locp++)
{
- loc = *locp;
+ bp_location *loc = *locp;
if (!loc->inserted && should_be_inserted (loc))
handle_automatic_hardware_breakpoints (loc);
}
wp_loc_first = NULL;
awp_loc_first = NULL;
rwp_loc_first = NULL;
+
+ bp_location *loc;
ALL_BP_LOCATIONS (loc, locp)
{
/* ALL_BP_LOCATIONS bp_location has LOC->OWNER always
xfree (this->extra_string);
}
+/* See breakpoint.h. */
+
+bp_locations_range breakpoint::locations ()
+{
+ return bp_locations_range (this->loc);
+}
+
static struct bp_location *
base_breakpoint_allocate_location (struct breakpoint *self)
{
static int
all_locations_are_pending (struct breakpoint *b, struct program_space *pspace)
{
- struct bp_location *loc;
-
- for (loc = b->loc; loc != NULL; loc = loc->next)
+ for (bp_location *loc : b->locations ())
if ((pspace == NULL
|| loc->pspace == pspace)
&& !loc->shlib_disabled
{
if ((!e->enabled || e->disabled_by_cond) && e->function_name)
{
- struct bp_location *l = b->loc;
if (have_ambiguous_names)
{
- for (; l; l = l->next)
+ for (bp_location *l : b->locations ())
{
/* Ignore software vs hardware location type at
this point, because with "set breakpoint
}
else
{
- for (; l; l = l->next)
+ for (bp_location *l : b->locations ())
if (l->function_name
&& strcmp (e->function_name, l->function_name) == 0)
{
error (_("Bad breakpoint location number '%d'"), loc_num);
int n = 0;
- for (bp_location *loc = b->loc; loc != NULL; loc = loc->next)
+ for (bp_location *loc : b->locations ())
if (++n == loc_num)
return loc;
if (target_supports_enable_disable_tracepoint ()
&& current_trace_status ()->running && is_tracepoint (bpt))
{
- struct bp_location *location;
-
- for (location = bpt->loc; location; location = location->next)
+ for (bp_location *location : bpt->locations ())
target_disable_tracepoint (location);
}
if (target_supports_enable_disable_tracepoint ()
&& current_trace_status ()->running && is_tracepoint (bpt))
{
- struct bp_location *location;
-
- for (location = bpt->loc; location; location = location->next)
+ for (bp_location *location : bpt->locations ())
target_enable_tracepoint (location);
}
if (wp->val_valid && wp->val != nullptr)
{
- struct bp_location *loc;
-
- for (loc = bp->loc; loc != NULL; loc = loc->next)
+ for (bp_location *loc : bp->locations ())
if (loc->loc_type == bp_loc_hardware_watchpoint
&& loc->address + loc->length > addr
&& addr + len > loc->address)
const address_space *aspace,
CORE_ADDR pc)
{
- struct bp_location *loc;
-
- for (loc = bp->loc; loc != NULL; loc = loc->next)
+ for (bp_location *loc : bp->locations ())
if (loc->inserted
&& breakpoint_location_address_match (loc, aspace, pc))
return 1;
special, and not user visible. */
if (!is_watchpoint (tp) && tp->loc && tp->loc->next)
{
- struct bp_location *loc;
int n = 1;
- for (loc = tp->loc; loc != NULL; loc = loc->next, n++)
- if (!loc->enabled)
- fp.printf ("disable $bpnum.%d\n", n);
+ for (bp_location *loc : tp->locations ())
+ {
+ if (!loc->enabled)
+ fp.printf ("disable $bpnum.%d\n", n);
+
+ n++;
+ }
}
}
pc_at_non_inline_function (const address_space *aspace, CORE_ADDR pc,
const struct target_waitstatus *ws)
{
- struct bp_location *bl;
-
for (breakpoint *b : all_breakpoints ())
{
if (!is_non_inline_function (b))
continue;
- for (bl = b->loc; bl != NULL; bl = bl->next)
+ for (bp_location *bl : b->locations ())
{
if (!bl->shlib_disabled
&& bpstat_check_location (bl, aspace, pc, ws))
struct cmd_list_element *c;
const char *tmp_p;
const char *p;
- struct bp_location *loc;
struct tracepoint *t = (struct tracepoint *) b;
/* If EOF is typed, *line is NULL. */
/* else fall thru, treat p as an expression and parse it! */
}
tmp_p = p;
- for (loc = t->loc; loc; loc = loc->next)
+ for (bp_location *loc : t->locations ())
{
p = tmp_p;
expression_up exp = parse_exp_1 (&p, loc->address,
p = skip_spaces (p);
tmp_p = p;
- for (loc = t->loc; loc; loc = loc->next)
+ for (bp_location *loc : t->locations ())
{
p = tmp_p;
}
else
{
- struct bp_location *loc1;
-
- for (loc1 = b->loc; loc1; loc1 = loc1->next)
+ for (bp_location *loc1 : b->locations ())
{
if (loc1->shlib_disabled)
{
for (breakpoint *b : tracepoint_range)
{
struct tracepoint *t = (struct tracepoint *) b;
- struct bp_location *loc;
int bp_location_downloaded = 0;
/* Clear `inserted' flag. */
- for (loc = b->loc; loc; loc = loc->next)
+ for (bp_location *loc : b->locations ())
loc->inserted = 0;
if ((b->type == bp_fast_tracepoint
t->number_on_target = 0;
- for (loc = b->loc; loc; loc = loc->next)
+ for (bp_location *loc : b->locations ())
{
/* Since tracepoint locations are never duplicated, `inserted'
flag should be zero. */
t->number_on_target = b->number;
- for (loc = b->loc; loc; loc = loc->next)
+ for (bp_location *loc : b->locations ())
if (loc->probe.prob != NULL)
loc->probe.prob->set_semaphore (loc->probe.objfile,
loc->gdbarch);
for (breakpoint *t : all_tracepoints ())
{
- struct bp_location *loc;
-
if ((t->type == bp_fast_tracepoint
? !may_insert_fast_tracepoints
: !may_insert_tracepoints))
continue;
- for (loc = t->loc; loc; loc = loc->next)
+ 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.
get_traceframe_location (int *stepping_frame_p)
{
struct tracepoint *t;
- struct bp_location *tloc;
struct regcache *regcache;
if (tracepoint_number == -1)
locations, assume it is a direct hit rather than a while-stepping
frame. (FIXME this is not reliable, should record each frame's
type.) */
- for (tloc = t->loc; tloc; tloc = tloc->next)
+ for (bp_location *tloc : t->locations ())
if (tloc->address == regcache_read_pc (regcache))
{
*stepping_frame_p = 0;