This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH v2 1/2] Change iterate_over_breakpoints to take a function_view
- From: cbiesinger at chromium dot org
- To: gdb-patches at sourceware dot org
- Cc: Christian Biesinger <cbiesinger at google dot com>
- Date: Wed, 9 Oct 2019 14:39:37 -0500
- Subject: [PATCH v2 1/2] Change iterate_over_breakpoints to take a function_view
From: Christian Biesinger <cbiesinger@google.com>
This allows callers to pass in capturing lambdas. I have not changed the
signature to remove the void* argument or to change the return type to
bool; that can be done in a future cleanup.
gdb/ChangeLog:
2019-10-09 Christian Biesinger <cbiesinger@google.com>
* breakpoint.c (iterate_over_breakpoints): Change function pointer to
a gdb::function_view.
* breakpoint.h (iterate_over_breakpoints): Likewise.
---
gdb/breakpoint.c | 6 +++---
gdb/breakpoint.h | 5 +++--
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 0a705163386..698411d707f 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -15132,14 +15132,14 @@ save_command (const char *arg, int from_tty)
}
struct breakpoint *
-iterate_over_breakpoints (int (*callback) (struct breakpoint *, void *),
- void *data)
+iterate_over_breakpoints
+ (gdb::function_view<int (breakpoint *, void *)> callback, void *data)
{
struct breakpoint *b, *b_tmp;
ALL_BREAKPOINTS_SAFE (b, b_tmp)
{
- if ((*callback) (b, data))
+ if (callback (b, data))
return b;
}
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 9791032c5e8..ea1a2bb5f76 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -29,6 +29,7 @@
#include "location.h"
#include <vector>
#include "gdbsupport/array-view.h"
+#include "gdbsupport/function-view.h"
#include "cli/cli-script.h"
struct block;
@@ -1664,8 +1665,8 @@ public:
returned. This can be useful for implementing a search for a
breakpoint with arbitrary attributes, or for applying an operation
to every breakpoint. */
-extern struct breakpoint *iterate_over_breakpoints (int (*) (struct breakpoint *,
- void *), void *);
+extern struct breakpoint *iterate_over_breakpoints
+ (gdb::function_view<int (breakpoint *, void *)>, void *);
/* Nonzero if the specified PC cannot be a location where functions
have been inlined. */
--
2.23.0.581.g78d2f28ef7-goog