Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1549606
| From | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 5/7] perf record: Change switch-output option to take optional argument |
| Date | 2017-01-03 09:30 +0100 |
| Message-ID | <sVsDM-3nL-33@gated-at.bofh.it> (permalink) |
| References | <sVsDM-3nL-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-d3qy0tnc4m2dyt8yd6x5phyv@git.kernel.org
---
tools/perf/builtin-record.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index f7e805b30527..b503e5ebc1e7 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -48,6 +48,8 @@
struct switch_output {
bool signal;
+ const char *str;
+ bool set;
};
struct record {
@@ -1356,6 +1358,17 @@ static int record__parse_mmap_pages(const struct option *opt,
return ret;
}
+static int switch_output_setup(struct switch_output *s)
+{
+ 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[] = {
"perf record [<options>] [<command>]",
"perf record [<options>] -- <command> [<options>]",
@@ -1523,8 +1536,9 @@ static struct option __record_options[] = {
"Record build-id of all DSOs regardless of hits"),
OPT_BOOLEAN(0, "timestamp-filename", &record.timestamp_filename,
"append timestamp to output filename"),
- OPT_BOOLEAN(0, "switch-output", &record.switch_output.signal,
- "Switch output when receive SIGUSR2"),
+ OPT_STRING_OPTARG_SET(0, "switch-output", &record.switch_output.str,
+ &record.switch_output.set, "signal",
+ "Switch output when receive SIGUSR2", "signal"),
OPT_BOOLEAN(0, "dry-run", &dry_run,
"Parse options then exit"),
OPT_END()
@@ -1582,6 +1596,12 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)
return -EINVAL;
}
+ if (record.switch_output.set &&
+ switch_output_setup(&rec->switch_output)) {
+ parse_options_usage(record_usage, record_options, "switch-output", 0);
+ return -EINVAL;
+ }
+
if (rec->switch_output.signal)
rec->timestamp_filename = true;
--
2.7.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/7] perf tools: Add switch-output size and time threshold options Jiri Olsa <jolsa@kernel.org> - 2017-01-03 09:30 +0100
[PATCH 1/7] tools lib subcmd: Add OPT_STRING_OPTARG_SET option Jiri Olsa <jolsa@kernel.org> - 2017-01-03 09:30 +0100
[tip:perf/urgent] tools lib subcmd: Add OPT_STRING_OPTARG_SET option tip-bot for Jiri Olsa <tipbot@zytor.com> - 2017-01-05 09:00 +0100
[PATCH 4/7] perf record: Add struct switch_output Jiri Olsa <jolsa@kernel.org> - 2017-01-03 09:30 +0100
[PATCH 5/7] perf record: Change switch-output option to take optional argument Jiri Olsa <jolsa@kernel.org> - 2017-01-03 09:30 +0100
Re: [PATCH 0/7] perf tools: Add switch-output size and time threshold options "Wangnan (F)" <wangnan0@huawei.com> - 2017-01-03 11:00 +0100
Re: [PATCH 0/7] perf tools: Add switch-output size and time threshold options Jiri Olsa <jolsa@redhat.com> - 2017-01-03 11:40 +0100
Re: [PATCH 0/7] perf tools: Add switch-output size and time threshold options Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-01-10 14:40 +0100
Re: [PATCH 0/7] perf tools: Add switch-output size and time threshold options Jiri Olsa <jolsa@redhat.com> - 2017-01-10 19:50 +0100
csiph-web