gdb: add all_tracepoints function
Same idea as the previous patches, but to replace the ALL_TRACEPOINTS macro. Define a new filtered_iterator that only keeps the breakpoints for which is_tracepoint returns true (just like the macro did). I would have like to make it so tracepoint_range yields some `tracepoint *` instead of some `breakpoint *`, that would help simplify the callers, who wouldn't have to do the cast themselves. But I didn't find an obvious way to do it. It can always be added later. It turns out there is already an all_tracepoints function, which returns a vector containing all the breakpoints that are tracepoint. Remove it, most users will just work seamlessly with the new function. The exception is start_tracing, which iterated multiple times on the vector. Adapt this one so it iterates multiple times on the returned range. Since the existing users of all_tracepoints are outside of breakpoint.c, this requires defining all_tracepoints and a few supporting types in breakpoint.h. So, move breakpoint_iterator from breakpoint.c to breakpoint.h. gdb/ChangeLog: * breakpoint.h (all_tracepoints): Remove. (breakpoint_iterator): Move here. (struct tracepoint_filter): New. (tracepoint_iterator): New. (tracepoint_range): New. (all_tracepoints): New. * breakpoint.c (ALL_TRACEPOINTS): Remove, replace all users with all_tracepoints. (breakpoint_iterator): Move to header. (all_tracepoints): New. * tracepoint.c (start_tracing): Adjust. Change-Id: I76b1bba4215dbec7a03846c568368aeef7f1e05a
This commit is contained in:
parent
1428b37afb
commit
f6d17b2b1c
4 changed files with 58 additions and 48 deletions
|
@ -1603,13 +1603,13 @@ start_tracing (const char *notes)
|
|||
int any_enabled = 0, num_to_download = 0;
|
||||
int ret;
|
||||
|
||||
std::vector<breakpoint *> tp_vec = all_tracepoints ();
|
||||
auto tracepoint_range = all_tracepoints ();
|
||||
|
||||
/* No point in tracing without any tracepoints... */
|
||||
if (tp_vec.empty ())
|
||||
if (tracepoint_range.begin () == tracepoint_range.end ())
|
||||
error (_("No tracepoints defined, not starting trace"));
|
||||
|
||||
for (breakpoint *b : tp_vec)
|
||||
for (breakpoint *b : tracepoint_range)
|
||||
{
|
||||
if (b->enable_state == bp_enabled)
|
||||
any_enabled = 1;
|
||||
|
@ -1640,7 +1640,7 @@ start_tracing (const char *notes)
|
|||
|
||||
target_trace_init ();
|
||||
|
||||
for (breakpoint *b : tp_vec)
|
||||
for (breakpoint *b : tracepoint_range)
|
||||
{
|
||||
struct tracepoint *t = (struct tracepoint *) b;
|
||||
struct bp_location *loc;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue