/* Chains of all breakpoints defined. */
-static struct breakpoint *breakpoint_chain;
+static intrusive_list<breakpoint> breakpoint_chain;
/* See breakpoint.h. */
breakpoint_range
all_breakpoints ()
{
- return breakpoint_range (breakpoint_chain);
+ return breakpoint_range
+ (breakpoint_pointer_iterator (breakpoint_chain.begin ()),
+ breakpoint_pointer_iterator (breakpoint_chain.end ()));
}
/* See breakpoint.h. */
tracepoint_range
all_tracepoints ()
{
- return tracepoint_range (breakpoint_chain);
+ return tracepoint_range
+ (tracepoint_iterator (breakpoint_pointer_iterator (breakpoint_chain.begin ())),
+ tracepoint_iterator (breakpoint_pointer_iterator (breakpoint_chain.end ())));
}
/* Array is sorted by bp_location_is_less_than - primarily by the ADDRESS. */
static breakpoint *
add_to_breakpoint_chain (std::unique_ptr<breakpoint> &&b)
{
- struct breakpoint *b1;
- struct breakpoint *result = b.get ();
-
/* Add this breakpoint to the end of the chain so that a list of
breakpoints will come out in order of increasing numbers. */
- b1 = breakpoint_chain;
- if (b1 == 0)
- breakpoint_chain = b.release ();
- else
- {
- while (b1->next)
- b1 = b1->next;
- b1->next = b.release ();
- }
+ breakpoint_chain.push_back (*b.release ());
- return result;
+ return &breakpoint_chain.back ();
}
/* Initialize loc->function_name. */
if (bpt->number)
gdb::observers::breakpoint_deleted.notify (bpt);
- if (breakpoint_chain == bpt)
- breakpoint_chain = bpt->next;
-
- for (breakpoint *b : all_breakpoints ())
- if (b->next == bpt)
- {
- b->next = bpt->next;
- break;
- }
+ breakpoint_chain.erase (breakpoint_chain.iterator_to (*bpt));
/* Be sure no bpstat's are pointing at the breakpoint after it's
been freed. */
gdb::observers::memory_changed.attach (invalidate_bp_value_on_memory_change,
"breakpoint");
- breakpoint_chain = 0;
/* Don't bother to call set_breakpoint_count. $bpnum isn't useful
before a breakpoint is set. */
breakpoint_count = 0;
/* Abstract base class representing all kinds of breakpoints. */
-struct breakpoint
+struct breakpoint : public intrusive_list_node<breakpoint>
{
breakpoint (struct gdbarch *gdbarch_, enum bptype bptype,
bool temp = true, const char *cond_string = nullptr);
/* Nothing to do. */
}
- breakpoint *next = NULL;
/* Type of breakpoint. */
bptype type = bp_none;
/* Zero means disabled; remember the info but don't break here. */
/* Breakpoint linked list iterator. */
-using breakpoint_iterator = next_iterator<breakpoint>;
+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_iterator>;
+using breakpoint_range = iterator_range<breakpoint_pointer_iterator>;
/* Return a range to iterate over all breakpoints. */
/* Breakpoint linked list iterator, filtering to only keep tracepoints. */
using tracepoint_iterator
- = filtered_iterator<breakpoint_iterator, tracepoint_filter>;
+ = filtered_iterator<breakpoint_pointer_iterator, tracepoint_filter>;
/* Breakpoint linked list range, filtering to only keep tracepoints. */