From patchwork Wed Oct 9 19:39:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Biesinger X-Patchwork-Id: 34889 Received: (qmail 51105 invoked by alias); 9 Oct 2019 19:39:46 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 51097 invoked by uid 89); 9 Oct 2019 19:39:46 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=HContent-Transfer-Encoding:8bit X-HELO: mail-io1-f66.google.com Received: from mail-io1-f66.google.com (HELO mail-io1-f66.google.com) (209.85.166.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 09 Oct 2019 19:39:45 +0000 Received: by mail-io1-f66.google.com with SMTP id w12so7716846iol.11 for ; Wed, 09 Oct 2019 12:39:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=KY6fPji/v0EPTxKiLsm43HV8VxwUA7x8IcGSDDGe+2A=; b=BW1BFNb1VskhDwJ/f8vGgSnwV1BIgGEk1NtdYKodnWL6Shpt3p9EYqLxMNnfyCznww 1xRA0Bi8syJLZFwGjFCb6YlxZvPg/Z3/lNJB9pZZKqSnc894M6E7wE0rbR1Pv6sOxZql 80WdHTHgXrYQSbK9sX6zAGOiPLS6f3Gdks8CM= Return-Path: Received: from cbiesinger.roam.corp.google.com (ip-174-152-19-98.chcgil.spcsdns.net. [174.152.19.98]) by smtp.googlemail.com with ESMTPSA id i26sm1718657iol.84.2019.10.09.12.39.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2019 12:39:42 -0700 (PDT) From: cbiesinger@chromium.org To: gdb-patches@sourceware.org Cc: Christian Biesinger Subject: [PATCH v2 1/2] Change iterate_over_breakpoints to take a function_view Date: Wed, 9 Oct 2019 14:39:37 -0500 Message-Id: <20191009193938.147076-1-cbiesinger@chromium.org> MIME-Version: 1.0 From: Christian Biesinger 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 * 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 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 #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, void *); /* Nonzero if the specified PC cannot be a location where functions have been inlined. */