]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
perf tools: Handle -h and -v options
authorJiri Olsa <jolsa@kernel.org>
Mon, 5 Oct 2015 18:06:09 +0000 (20:06 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 5 Oct 2015 19:36:18 +0000 (16:36 -0300)
Adding handling for '-h' and '-v' options to invoke help and version
command respectively.

Current behaviour is:

   $ perf -v
   Unknown option: -v

    Usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]
   $ perf -h
   Unknown option: -h

    Usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]

New behaviour:

  $ perf -h

   usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]

   The most commonly used perf commands are:
     annotate        Read perf.data (created by perf record) and display annotated code
     archive         Create archive with object files with build-ids found in perf.data file
     bench           General framework for benchmark suites
   ...

  $ perf -v
  perf version 4.3.rc3.gc99e32

Updated man page.

Requested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1444068369-20978-10-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/Documentation/perf.txt
tools/perf/perf.c

index 2b131776363e3a2498ce1b721440c985d22df7fd..864e37597252b3b0449cc1ae0eb5147f79b6e81b 100644 (file)
@@ -27,6 +27,14 @@ OPTIONS
        Setup buildid cache directory. It has higher priority than
        buildid.dir config file option.
 
+-v::
+--version::
+  Display perf version.
+
+-h::
+--help::
+  Run perf help command.
+
 DESCRIPTION
 -----------
 Performance counters for Linux are a new kernel-based subsystem
index 1fded922bcc89e55cb0c40e3fc7d8db671a2bfbf..543713422d14568a8801a08f56a8938f4bc51564 100644 (file)
@@ -161,6 +161,20 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
                if (!strcmp(cmd, "--help") || !strcmp(cmd, "--version"))
                        break;
 
+               /*
+                * Shortcut for '-h' and '-v' options to invoke help
+                * and version command.
+                */
+               if (!strcmp(cmd, "-h")) {
+                       (*argv)[0] = "--help";
+                       break;
+               }
+
+               if (!strcmp(cmd, "-v")) {
+                       (*argv)[0] = "--version";
+                       break;
+               }
+
                /*
                 * Check remaining flags.
                 */