Cc: David Ahern <dsah...@gmail.com>
Cc: Arnaldo Carvalho de Melo <a...@redhat.com>
Signed-off-by: Ramkumar Ramachandra <artag...@gmail.com>
---
 tools/perf/builtin-lock.c     | 14 ++++++++++----
 tools/perf/perf-completion.sh |  4 ++--
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index c852c7a..bc7b853 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -938,6 +938,7 @@ static int __cmd_record(int argc, const char **argv)
 
 int cmd_lock(int argc, const char **argv, const char *prefix __maybe_unused)
 {
+       bool list_cmds = false;
        const struct option info_options[] = {
        OPT_BOOLEAN('t', "threads", &info_threads,
                    "dump thread list in perf.data"),
@@ -949,6 +950,7 @@ int cmd_lock(int argc, const char **argv, const char 
*prefix __maybe_unused)
        OPT_STRING('i', "input", &input_name, "file", "input file name"),
        OPT_INCR('v', "verbose", &verbose, "be more verbose (show symbol 
address, etc)"),
        OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, "dump raw trace in 
ASCII"),
+       OPT_BOOLEAN(0, "list-cmds", &list_cmds, "list commands raw for use by 
scripts"),
        OPT_END()
        };
        const struct option report_options[] = {
@@ -961,10 +963,6 @@ int cmd_lock(int argc, const char **argv, const char 
*prefix __maybe_unused)
                "perf lock info [<options>]",
                NULL
        };
-       const char * const lock_usage[] = {
-               "perf lock [<options>] {record|report|script|info}",
-               NULL
-       };
        const char * const report_usage[] = {
                "perf lock report [<options>]",
                NULL
@@ -972,12 +970,20 @@ int cmd_lock(int argc, const char **argv, const char 
*prefix __maybe_unused)
        unsigned int i;
        int rc = 0;
 
+       const char *const subcommands[] = { "record", "report", "script", 
"info", NULL };
+       const char *lock_usage[] = { NULL, NULL };
+       build_usage_string(lock_usage, "lock", subcommands);
+
        symbol__init();
        for (i = 0; i < LOCKHASH_SIZE; i++)
                INIT_LIST_HEAD(lockhash_table + i);
 
        argc = parse_options(argc, argv, lock_options, lock_usage,
                             PARSE_OPT_STOP_AT_NON_OPTION);
+       if (list_cmds) {
+               list_cmds_raw(subcommands);
+               return 0;
+       }
        if (!argc)
                usage_with_options(lock_usage, lock_options);
 
diff --git a/tools/perf/perf-completion.sh b/tools/perf/perf-completion.sh
index 81a932a..302de6a 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
-       elif [[ $prev == @(kmem|kvm) ]]; then
+       # List subcommands for kmem, kvm, lock
+       elif [[ $prev == @(kmem|kvm|lock) ]]; then
                subcmds=$($cmd $prev --list-cmds)
                __perfcomp_colon "$subcmds" "$cur"
        # List long option names
-- 
1.8.5.2.227.g53f3478

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to