diff options
Diffstat (limited to 'tools/perf/perf.c')
| -rw-r--r-- | tools/perf/perf.c | 75 |
1 files changed, 45 insertions, 30 deletions
diff --git a/tools/perf/perf.c b/tools/perf/perf.c index 2b2e225a4d4c..fc2f770e3027 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include "util/run-command.h" | 14 | #include "util/run-command.h" |
| 15 | #include "util/parse-events.h" | 15 | #include "util/parse-events.h" |
| 16 | #include "util/debugfs.h" | 16 | #include "util/debugfs.h" |
| 17 | #include <pthread.h> | ||
| 17 | 18 | ||
| 18 | const char perf_usage_string[] = | 19 | const char perf_usage_string[] = |
| 19 | "perf [--version] [--help] COMMAND [ARGS]"; | 20 | "perf [--version] [--help] COMMAND [ARGS]"; |
| @@ -24,6 +25,42 @@ const char perf_more_info_string[] = | |||
| 24 | int use_browser = -1; | 25 | int use_browser = -1; |
| 25 | static int use_pager = -1; | 26 | static int use_pager = -1; |
| 26 | 27 | ||
| 28 | struct cmd_struct { | ||
| 29 | const char *cmd; | ||
| 30 | int (*fn)(int, const char **, const char *); | ||
| 31 | int option; | ||
| 32 | }; | ||
| 33 | |||
| 34 | static struct cmd_struct commands[] = { | ||
| 35 | { "buildid-cache", cmd_buildid_cache, 0 }, | ||
| 36 | { "buildid-list", cmd_buildid_list, 0 }, | ||
| 37 | { "diff", cmd_diff, 0 }, | ||
| 38 | { "evlist", cmd_evlist, 0 }, | ||
| 39 | { "help", cmd_help, 0 }, | ||
| 40 | { "list", cmd_list, 0 }, | ||
| 41 | { "record", cmd_record, 0 }, | ||
| 42 | { "report", cmd_report, 0 }, | ||
| 43 | { "bench", cmd_bench, 0 }, | ||
| 44 | { "stat", cmd_stat, 0 }, | ||
| 45 | { "timechart", cmd_timechart, 0 }, | ||
| 46 | { "top", cmd_top, 0 }, | ||
| 47 | { "annotate", cmd_annotate, 0 }, | ||
| 48 | { "version", cmd_version, 0 }, | ||
| 49 | { "script", cmd_script, 0 }, | ||
| 50 | { "sched", cmd_sched, 0 }, | ||
| 51 | #ifndef NO_LIBELF_SUPPORT | ||
| 52 | { "probe", cmd_probe, 0 }, | ||
| 53 | #endif | ||
| 54 | { "kmem", cmd_kmem, 0 }, | ||
| 55 | { "lock", cmd_lock, 0 }, | ||
| 56 | { "kvm", cmd_kvm, 0 }, | ||
| 57 | { "test", cmd_test, 0 }, | ||
| 58 | #ifndef NO_LIBAUDIT_SUPPORT | ||
| 59 | { "trace", cmd_trace, 0 }, | ||
| 60 | #endif | ||
| 61 | { "inject", cmd_inject, 0 }, | ||
| 62 | }; | ||
| 63 | |||
| 27 | struct pager_config { | 64 | struct pager_config { |
| 28 | const char *cmd; | 65 | const char *cmd; |
| 29 | int val; | 66 | int val; |
| @@ -160,6 +197,14 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) | |||
| 160 | fprintf(stderr, "dir: %s\n", debugfs_mountpoint); | 197 | fprintf(stderr, "dir: %s\n", debugfs_mountpoint); |
| 161 | if (envchanged) | 198 | if (envchanged) |
| 162 | *envchanged = 1; | 199 | *envchanged = 1; |
| 200 | } else if (!strcmp(cmd, "--list-cmds")) { | ||
| 201 | unsigned int i; | ||
| 202 | |||
| 203 | for (i = 0; i < ARRAY_SIZE(commands); i++) { | ||
| 204 | struct cmd_struct *p = commands+i; | ||
| 205 | printf("%s ", p->cmd); | ||
| 206 | } | ||
| 207 | exit(0); | ||
| 163 | } else { | 208 | } else { |
| 164 | fprintf(stderr, "Unknown option: %s\n", cmd); | 209 | fprintf(stderr, "Unknown option: %s\n", cmd); |
| 165 | usage(perf_usage_string); | 210 | usage(perf_usage_string); |
| @@ -245,12 +290,6 @@ const char perf_version_string[] = PERF_VERSION; | |||
| 245 | */ | 290 | */ |
| 246 | #define NEED_WORK_TREE (1<<2) | 291 | #define NEED_WORK_TREE (1<<2) |
| 247 | 292 | ||
| 248 | struct cmd_struct { | ||
| 249 | const char *cmd; | ||
| 250 | int (*fn)(int, const char **, const char *); | ||
| 251 | int option; | ||
| 252 | }; | ||
| 253 | |||
| 254 | static int run_builtin(struct cmd_struct *p, int argc, const char **argv) | 293 | static int run_builtin(struct cmd_struct *p, int argc, const char **argv) |
| 255 | { | 294 | { |
| 256 | int status; | 295 | int status; |
| @@ -296,30 +335,6 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv) | |||
| 296 | static void handle_internal_command(int argc, const char **argv) | 335 | static void handle_internal_command(int argc, const char **argv) |
| 297 | { | 336 | { |
| 298 | const char *cmd = argv[0]; | 337 | const char *cmd = argv[0]; |
| 299 | static struct cmd_struct commands[] = { | ||
| 300 | { "buildid-cache", cmd_buildid_cache, 0 }, | ||
| 301 | { "buildid-list", cmd_buildid_list, 0 }, | ||
| 302 | { "diff", cmd_diff, 0 }, | ||
| 303 | { "evlist", cmd_evlist, 0 }, | ||
| 304 | { "help", cmd_help, 0 }, | ||
| 305 | { "list", cmd_list, 0 }, | ||
| 306 | { "record", cmd_record, 0 }, | ||
| 307 | { "report", cmd_report, 0 }, | ||
| 308 | { "bench", cmd_bench, 0 }, | ||
| 309 | { "stat", cmd_stat, 0 }, | ||
| 310 | { "timechart", cmd_timechart, 0 }, | ||
| 311 | { "top", cmd_top, 0 }, | ||
| 312 | { "annotate", cmd_annotate, 0 }, | ||
| 313 | { "version", cmd_version, 0 }, | ||
| 314 | { "script", cmd_script, 0 }, | ||
| 315 | { "sched", cmd_sched, 0 }, | ||
| 316 | { "probe", cmd_probe, 0 }, | ||
| 317 | { "kmem", cmd_kmem, 0 }, | ||
| 318 | { "lock", cmd_lock, 0 }, | ||
| 319 | { "kvm", cmd_kvm, 0 }, | ||
| 320 | { "test", cmd_test, 0 }, | ||
| 321 | { "inject", cmd_inject, 0 }, | ||
| 322 | }; | ||
| 323 | unsigned int i; | 338 | unsigned int i; |
| 324 | static const char ext[] = STRIP_EXTENSION; | 339 | static const char ext[] = STRIP_EXTENSION; |
| 325 | 340 | ||
