From: cbiesinger@chromium.org
To: gdb-patches@sourceware.org
Cc: Christian Biesinger <cbiesinger@google.com>
Subject: [PATCH v2 1/2] Change iterate_over_breakpoints to take a function_view
Date: Wed, 09 Oct 2019 19:39:00 -0000 [thread overview]
Message-ID: <20191009193938.147076-1-cbiesinger@chromium.org> (raw)
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
next reply other threads:[~2019-10-09 19:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-09 19:39 cbiesinger [this message]
2019-10-09 19:39 ` [PATCH v2 2/2] Make tui-winsource not use breakpoint_chain cbiesinger
2019-10-09 21:02 ` [PATCH v2 1/2] Change iterate_over_breakpoints to take a function_view Tom Tromey
2019-10-10 0:13 ` Christian Biesinger via gdb-patches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191009193938.147076-1-cbiesinger@chromium.org \
--to=cbiesinger@chromium.org \
--cc=cbiesinger@google.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox