perf record: Change switch-output option to take optional argument
Next patches will add --switch-output option arguments, changing the option to allow that and adding its default value to 'signal'. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Acked-by: Wang Nan <wangnan0@huawei.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: David Ahern <dsahern@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1483955520-29063-4-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
1b43b70484
commit
cb4e1ebb6a
|
@ -48,6 +48,8 @@
|
||||||
|
|
||||||
struct switch_output {
|
struct switch_output {
|
||||||
bool signal;
|
bool signal;
|
||||||
|
const char *str;
|
||||||
|
bool set;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct record {
|
struct record {
|
||||||
|
@ -1356,6 +1358,22 @@ out_free:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int switch_output_setup(struct record *rec)
|
||||||
|
{
|
||||||
|
struct switch_output *s = &rec->switch_output;
|
||||||
|
|
||||||
|
if (!s->set)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!strcmp(s->str, "signal")) {
|
||||||
|
s->signal = true;
|
||||||
|
pr_debug("switch-output with SIGUSR2 signal\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
static const char * const __record_usage[] = {
|
static const char * const __record_usage[] = {
|
||||||
"perf record [<options>] [<command>]",
|
"perf record [<options>] [<command>]",
|
||||||
"perf record [<options>] -- <command> [<options>]",
|
"perf record [<options>] -- <command> [<options>]",
|
||||||
|
@ -1523,8 +1541,9 @@ static struct option __record_options[] = {
|
||||||
"Record build-id of all DSOs regardless of hits"),
|
"Record build-id of all DSOs regardless of hits"),
|
||||||
OPT_BOOLEAN(0, "timestamp-filename", &record.timestamp_filename,
|
OPT_BOOLEAN(0, "timestamp-filename", &record.timestamp_filename,
|
||||||
"append timestamp to output filename"),
|
"append timestamp to output filename"),
|
||||||
OPT_BOOLEAN(0, "switch-output", &record.switch_output.signal,
|
OPT_STRING_OPTARG_SET(0, "switch-output", &record.switch_output.str,
|
||||||
"Switch output when receive SIGUSR2"),
|
&record.switch_output.set, "signal",
|
||||||
|
"Switch output when receive SIGUSR2", "signal"),
|
||||||
OPT_BOOLEAN(0, "dry-run", &dry_run,
|
OPT_BOOLEAN(0, "dry-run", &dry_run,
|
||||||
"Parse options then exit"),
|
"Parse options then exit"),
|
||||||
OPT_END()
|
OPT_END()
|
||||||
|
@ -1582,6 +1601,11 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (switch_output_setup(rec)) {
|
||||||
|
parse_options_usage(record_usage, record_options, "switch-output", 0);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
if (rec->switch_output.signal)
|
if (rec->switch_output.signal)
|
||||||
rec->timestamp_filename = true;
|
rec->timestamp_filename = true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue