Commit 0aab2136 authored by Wang Nan's avatar Wang Nan Committed by Arnaldo Carvalho de Melo

perf record: Add --dry-run option to check cmdline options

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.
Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1466064161-48553-3-git-send-email-wangnan0@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent f0784649
...@@ -360,6 +360,13 @@ particular perf.data snapshot should be kept or not. ...@@ -360,6 +360,13 @@ particular perf.data snapshot should be kept or not.
Implies --timestamp-filename, --no-buildid and --no-buildid-cache. 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 SEE ALSO
-------- --------
linkperf:perf-stat[1], linkperf:perf-list[1] linkperf:perf-stat[1], linkperf:perf-list[1]
...@@ -1274,6 +1274,8 @@ static struct record record = { ...@@ -1274,6 +1274,8 @@ static struct record record = {
const char record_callchain_help[] = CALLCHAIN_RECORD_HELP const char record_callchain_help[] = CALLCHAIN_RECORD_HELP
"\n\t\t\t\tDefault: fp"; "\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 * 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 * with it and switch to use the library functions in perf_evlist that came
...@@ -1393,6 +1395,8 @@ struct option __record_options[] = { ...@@ -1393,6 +1395,8 @@ struct option __record_options[] = {
"append timestamp to output filename"), "append timestamp to output filename"),
OPT_BOOLEAN(0, "switch-output", &record.switch_output, OPT_BOOLEAN(0, "switch-output", &record.switch_output,
"Switch output when receive SIGUSR2"), "Switch output when receive SIGUSR2"),
OPT_BOOLEAN(0, "dry-run", &dry_run,
"Parse options then exit"),
OPT_END() OPT_END()
}; };
...@@ -1462,6 +1466,9 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused) ...@@ -1462,6 +1466,9 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)
if (err) if (err)
return err; return err;
if (dry_run)
return 0;
err = bpf__setup_stdout(rec->evlist); err = bpf__setup_stdout(rec->evlist);
if (err) { if (err) {
bpf__strerror_setup_stdout(rec->evlist, err, errbuf, sizeof(errbuf)); bpf__strerror_setup_stdout(rec->evlist, err, errbuf, sizeof(errbuf));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment