From 8d2a2a1d885d36e978c4619a3db8791f9768dd6a Mon Sep 17 00:00:00 2001 From: Ramkumar Ramachandra Date: Fri, 14 Mar 2014 23:17:52 -0400 Subject: [PATCH] perf mem: Introduce --list-cmds for use by scripts Signed-off-by: Ramkumar Ramachandra Acked-by: David Ahern Cc: David Ahern Cc: Jiri Olsa Link: http://lkml.kernel.org/r/1394853474-31019-3-git-send-email-artagnon@gmail.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Jiri Olsa --- tools/perf/builtin-mem.c | 15 ++++++++------- tools/perf/perf-completion.sh | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c index 2e3ade69a58e..4a1a6c94a5eb 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 [] {record |report}", - NULL -}; - static int __cmd_record(int argc, const char **argv) { int rec_argc, i = 0, j; @@ -220,9 +215,15 @@ int cmd_mem(int argc, const char **argv, const char *prefix __maybe_unused) " between columns '.' is reserved."), OPT_END() }; + const char *const mem_subcommands[] = { "record", "report", NULL }; + const char *mem_usage[] = { + NULL, + NULL + }; + - argc = parse_options(argc, argv, mem_options, mem_usage, - PARSE_OPT_STOP_AT_NON_OPTION); + argc = parse_options_subcommand(argc, argv, mem_options, mem_subcommands, + mem_usage, PARSE_OPT_STOP_AT_NON_OPTION); 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 0ef59dd4c78d..f44c04b1015d 100644 --- a/tools/perf/perf-completion.sh +++ b/tools/perf/perf-completion.sh @@ -122,7 +122,7 @@ __perf_main () evts=$($cmd list --raw-dump) __perfcomp_colon "$evts" "$cur" # List subcommands for perf commands - elif [[ $prev == @(kvm|kmem) ]]; then + elif [[ $prev == @(kvm|kmem|mem) ]]; then subcmds=$($cmd $prev --list-cmds) __perfcomp_colon "$subcmds" "$cur" # List long option names -- 2.34.1