From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754862AbcFPQsX (ORCPT ); Thu, 16 Jun 2016 12:48:23 -0400 Received: from mail.kernel.org ([198.145.29.136]:34420 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753945AbcFPQsT (ORCPT ); Thu, 16 Jun 2016 12:48:19 -0400 Date: Thu, 16 Jun 2016 13:48:15 -0300 From: Arnaldo Carvalho de Melo To: Wang Nan Cc: linux-kernel@vger.kernel.org, pi3orama@163.com, Arnaldo Carvalho de Melo , Alexei Starovoitov , Jiri Olsa Subject: Re: [PATCH 2/2] perf record: Add --dry-run option to check cmdline options Message-ID: <20160616164815.GE13337@kernel.org> References: <1466064161-48553-1-git-send-email-wangnan0@huawei.com> <1466064161-48553-3-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1466064161-48553-3-git-send-email-wangnan0@huawei.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.6.1 (2016-04-27) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Thu, Jun 16, 2016 at 08:02:41AM +0000, Wang Nan escreveu: > With '--dry-run', 'perf record' doesn't do reall recording. Combine with > llvm.dump-obj option, --dry-run can be used to help compile BPF objects for > embedded platform. So these are nice and have value, but can we have a subcommand to do all this with an expressive name, Something like: perf bpfcc foo.c -o foo or shorter: perf bcc foo.c -o foo Just like one would use gcc or some other compiler to generate something for later use? That if called as: perf bcc foo.c Would default to generating a foo.o file. Then, later, one could use this as a event name, i.e. trace --event foo Would, knowing that there is no event named "foo", look at the current directory (and in some other places perhaps) for a file named "foo" that was a bpf object file to use as it would a foo.c, shortcircuiting the bpf compilation code. If this was done instead: trace --event foo.c And foo.c wasn't present, it would fallback to the behaviour described in the previous paragraph: look for a foo.o or foo bpf object file, etc. What do you think? - Arnaldo > Signed-off-by: Wang Nan > Cc: Arnaldo Carvalho de Melo > Cc: Alexei Starovoitov > Cc: Jiri Olsa > --- > tools/perf/Documentation/perf-record.txt | 7 +++++++ > tools/perf/builtin-record.c | 7 +++++++ > 2 files changed, 14 insertions(+) > > diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt > index 8dbee83..5b46b1d 100644 > --- a/tools/perf/Documentation/perf-record.txt > +++ b/tools/perf/Documentation/perf-record.txt > @@ -360,6 +360,13 @@ particular perf.data snapshot should be kept or not. > > Implies --timestamp-filename, --no-buildid and --no-buildid-cache. > > +--dry-run:: > +Parse options then exit. --dry-run can be used to detect errors in cmdline > +options. > + > +'perf record --dry-run -e' can act as a BPF script compiler if llvm.dump-obj > +in config file is set to true. > + > SEE ALSO > -------- > linkperf:perf-stat[1], linkperf:perf-list[1] > diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c > index d4cf1b0..b1304eb 100644 > --- a/tools/perf/builtin-record.c > +++ b/tools/perf/builtin-record.c > @@ -1274,6 +1274,8 @@ static struct record record = { > const char record_callchain_help[] = CALLCHAIN_RECORD_HELP > "\n\t\t\t\tDefault: fp"; > > +static bool dry_run; > + > /* > * XXX Will stay a global variable till we fix builtin-script.c to stop messing > * with it and switch to use the library functions in perf_evlist that came > @@ -1393,6 +1395,8 @@ struct option __record_options[] = { > "append timestamp to output filename"), > OPT_BOOLEAN(0, "switch-output", &record.switch_output, > "Switch output when receive SIGUSR2"), > + OPT_BOOLEAN(0, "dry-run", &dry_run, > + "Parse options then exit"), > OPT_END() > }; > > @@ -1462,6 +1466,9 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused) > if (err) > return err; > > + if (dry_run) > + return 0; > + > err = bpf__setup_stdout(rec->evlist); > if (err) { > bpf__strerror_setup_stdout(rec->evlist, err, errbuf, sizeof(errbuf)); > -- > 1.8.3.4