From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758089AbdAKU0F (ORCPT ); Wed, 11 Jan 2017 15:26:05 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:48270 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934272AbdAKUWu (ORCPT ); Wed, 11 Jan 2017 15:22:50 -0500 From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, Jiri Olsa , David Ahern , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo Subject: [PATCH 09/13] perf record: Change switch-output option to take optional argument Date: Wed, 11 Jan 2017 17:22:07 -0300 Message-Id: <20170111202211.32137-10-acme@kernel.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170111202211.32137-1-acme@kernel.org> References: <20170111202211.32137-1-acme@kernel.org> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiri Olsa 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 Acked-by: Wang Nan Tested-by: Arnaldo Carvalho de Melo Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1483955520-29063-4-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-record.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index f7e805b30527..2bf811acaf8d 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,22 @@ static int record__parse_mmap_pages(const struct option *opt, 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[] = { "perf record [] []", "perf record [] -- []", @@ -1523,8 +1541,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 +1601,11 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused) return -EINVAL; } + if (switch_output_setup(rec)) { + parse_options_usage(record_usage, record_options, "switch-output", 0); + return -EINVAL; + } + if (rec->switch_output.signal) rec->timestamp_filename = true; -- 2.9.3