Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp603686ybz; Wed, 29 Apr 2020 06:13:32 -0700 (PDT) X-Google-Smtp-Source: APiQypIl2FmXKt+DlAmr7ZJi8YxpLUzorpBJGXAtmqwNEuyN9L50kEBmDmBnxmxZ0YXeaIsQU3OS X-Received: by 2002:a17:907:7246:: with SMTP id ds6mr2325533ejc.203.1588166012287; Wed, 29 Apr 2020 06:13:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588166012; cv=none; d=google.com; s=arc-20160816; b=J93QWDhagRH0ZMVvSjrMG4ncMNcBHLOdSqdQVsX0WTSRhaG6+EaUNQ4/T/5guYsWqw RwrfYMjQ2NN0DG36GKv/is1GcG6q70t1P+h/NOAxAVCmCPX7HGSrRwDO3Y8qnbKUB+mP DTUY8WH98HrYdRV3Ts9bqOf+KulWIXJrctjX5+h8lAaSD88KA2xUBmde6W5J2VYRhBwb 4MXWfVAM2yqTjw0/bD29Jz2i1xlTi6e33j5XhsCSTWwHnhhCxmBnlllT7BLFM7y4CjrU LE3FpRaposlYvKZ02S5o9rLDh6/U69XPlK6cYczZ5+XlFMDz6fkBjXuI3PsfJCVZwmca iOMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4m5WCGR9KU4tKRQqu0we7XUSP58BCghJbbmDhfMMJM4=; b=sbW2K0ketwuNRCwfyLoJo/8SrH5avVM/DgYIshCn9I8n4g139HfrHSp7BjmvMhSUV0 0fFUDnuBLMCN3SHQ1lehYQDfGwNhHahX8dhSD8XWGTYDSjwVD3kHOM0CNkpGEtMD2XE1 5RdG5cN1Grtg6Fsji9Poe4oe3X4g+XlQpSFlanyS1sPNrBAV1i0DxpxFu4shMbeEU/jH E2+HOsJ3Bg69u6y7n+nk1TgikM3xOlmN5+sN6ApWXi2oUm7GFiYJPwyMWosa0ugLL33F FuPCl2J1Y1+GMoR547klbw707lp/EkDpt3F71nbSmL2RABFYbIY/DGeIxm8pZVFEYpCE YLKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vnlh5bW4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q8si4032271ejn.176.2020.04.29.06.13.07; Wed, 29 Apr 2020 06:13:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vnlh5bW4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726853AbgD2NL2 (ORCPT + 99 others); Wed, 29 Apr 2020 09:11:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:48146 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727079AbgD2NLZ (ORCPT ); Wed, 29 Apr 2020 09:11:25 -0400 Received: from quaco.ghostprotocols.net (unknown [179.97.37.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 98EB022205; Wed, 29 Apr 2020 13:11:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588165885; bh=G1SX+dlRcXWDH2UFkdgPb6v8XMIP7tvA85oKrVB+z+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vnlh5bW4xt7EnuPBUKQaNEUXbbiMGWjoVUm55wyom3ld9E3S/A5katiYtmtyu+T0A uu+h5MBF9mArksUO75zllSGd7wRYcu6pdl6mONbWB3/kOnLWtnTtEBqw2wHEq6CXGQ Hzi9Hv1iqch6n9mhKQIvle2DEkSnRDCkw/GzH8Nk= From: Arnaldo Carvalho de Melo To: Jiri Olsa , Namhyung Kim Cc: Ingo Molnar , Thomas Gleixner , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Arnaldo Carvalho de Melo , Adrian Hunter , Song Liu Subject: [PATCH 4/8] perf parse-events: Add parse_events_option() variant that creates evlist Date: Wed, 29 Apr 2020 10:11:02 -0300 Message-Id: <20200429131106.27974-5-acme@kernel.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200429131106.27974-1-acme@kernel.org> References: <20200429131106.27974-1-acme@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnaldo Carvalho de Melo For the upcoming --switch-output-event option we want to create the side band event, populate it with the specified events and then, if it is present multiple times, go on adding to it, then, if the BPF tracking is required, use the first event to set its attr.bpf_event to get those PERF_RECORD_BPF_EVENT metadata events too. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Cc: Song Liu Link: http://lore.kernel.org/lkml/20200427211935.25789-6-acme@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/parse-events.c | 23 +++++++++++++++++++++++ tools/perf/util/parse-events.h | 1 + 2 files changed, 24 insertions(+) diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 10107747b361..5795f3a8f71c 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -2190,6 +2190,29 @@ int parse_events_option(const struct option *opt, const char *str, return ret; } +int parse_events_option_new_evlist(const struct option *opt, const char *str, int unset) +{ + struct evlist **evlistp = opt->value; + int ret; + + if (*evlistp == NULL) { + *evlistp = evlist__new(); + + if (*evlistp == NULL) { + fprintf(stderr, "Not enough memory to create evlist\n"); + return -1; + } + } + + ret = parse_events_option(opt, str, unset); + if (ret) { + evlist__delete(*evlistp); + *evlistp = NULL; + } + + return ret; +} + static int foreach_evsel_in_last_glob(struct evlist *evlist, int (*func)(struct evsel *evsel, diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h index 27596cbd0ba0..6ead9661238c 100644 --- a/tools/perf/util/parse-events.h +++ b/tools/perf/util/parse-events.h @@ -31,6 +31,7 @@ bool have_tracepoints(struct list_head *evlist); const char *event_type(int type); int parse_events_option(const struct option *opt, const char *str, int unset); +int parse_events_option_new_evlist(const struct option *opt, const char *str, int unset); int parse_events(struct evlist *evlist, const char *str, struct parse_events_error *error); int parse_events_terms(struct list_head *terms, const char *str); -- 2.21.1