mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ramkumar Ramachandra <artagnon@gmail.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: David Ahern <dsahern@gmail.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 4/5] perf mem: introduce --list-cmds
Date: Thu,  2 Jan 2014 16:28:49 +0530	[thread overview]
Message-ID: <1388660330-16781-5-git-send-email-artagnon@gmail.com> (raw)
In-Reply-To: <1388660330-16781-1-git-send-email-artagnon@gmail.com>

Cc: David Ahern <dsahern@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 tools/perf/builtin-mem.c      | 15 ++++++++++-----
 tools/perf/perf-completion.sh |  4 ++--
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index 31c00f1..a1db6e7 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -21,11 +21,6 @@ struct perf_mem {
 	DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
 };
 
-static const char * const mem_usage[] = {
-	"perf mem [<options>] {record <command> |report}",
-	NULL
-};
-
 static int __cmd_record(int argc, const char **argv)
 {
 	int rec_argc, i = 0, j;
@@ -191,6 +186,7 @@ static int report_events(int argc, const char **argv, struct perf_mem *mem)
 int cmd_mem(int argc, const char **argv, const char *prefix __maybe_unused)
 {
 	struct stat st;
+	bool list_cmds = false;
 	struct perf_mem mem = {
 		.tool = {
 			.sample		= process_sample_event,
@@ -219,12 +215,21 @@ int cmd_mem(int argc, const char **argv, const char *prefix __maybe_unused)
 		   "separator",
 		   "separator for columns, no spaces will be added"
 		   " between columns '.' is reserved."),
+	OPT_BOOLEAN(0, "list-cmds", &list_cmds,
+		"list commands raw for use by scripts"),
 	OPT_END()
 	};
+	const char *const subcommands[] = { "record", "report", NULL };
+	const char *mem_usage[] = { NULL, NULL };
+	build_usage_string(mem_usage, "mem", subcommands);
 
 	argc = parse_options(argc, argv, mem_options, mem_usage,
 			     PARSE_OPT_STOP_AT_NON_OPTION);
 
+	if (list_cmds) {
+		list_cmds_raw(subcommands);
+		return 0;
+	}
 	if (!argc || !(strncmp(argv[0], "rec", 3) || mem_operation))
 		usage_with_options(mem_usage, mem_options);
 
diff --git a/tools/perf/perf-completion.sh b/tools/perf/perf-completion.sh
index 302de6a..4ecef69 100644
--- a/tools/perf/perf-completion.sh
+++ b/tools/perf/perf-completion.sh
@@ -121,8 +121,8 @@ __perf_main ()
 	elif [[ $prev == "-e" && "${words[1]}" == @(record|stat|top) ]]; then
 		evts=$($cmd list --raw-dump)
 		__perfcomp_colon "$evts" "$cur"
-	# List subcommands for kmem, kvm, lock
-	elif [[ $prev == @(kmem|kvm|lock) ]]; then
+	# List subcommands for kmem, kvm, lock, mem
+	elif [[ $prev == @(kmem|kvm|lock|mem) ]]; then
 		subcmds=$($cmd $prev --list-cmds)
 		__perfcomp_colon "$subcmds" "$cur"
 	# List long option names
-- 
1.8.5.2.227.g53f3478


  parent reply	other threads:[~2014-01-02 10:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-02 10:58 [PATCH 0/5] perf tools: get --list-cmds for subcommands Ramkumar Ramachandra
2014-01-02 10:58 ` [PATCH 1/5] perf kvm: introduce --list-cmds for use by scripts Ramkumar Ramachandra
2014-01-02 10:58 ` [PATCH 2/5] perf kmem: introduce --list-cmds Ramkumar Ramachandra
2014-01-02 10:58 ` [PATCH 3/5] perf lock: " Ramkumar Ramachandra
2014-01-02 10:58 ` Ramkumar Ramachandra [this message]
2014-01-02 10:58 ` [PATCH 5/5] perf sched: " Ramkumar Ramachandra
2014-01-09 10:50 ` [PATCH 0/5] perf tools: get --list-cmds for subcommands Ramkumar Ramachandra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1388660330-16781-5-git-send-email-artagnon@gmail.com \
    --to=artagnon@gmail.com \
    --cc=acme@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®