diff options
author | Yunlong Song <yunlong.song@huawei.com> | 2015-03-18 09:35:57 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-03-19 12:53:26 -0400 |
commit | 6fdd9cb700dcd84193a259bbf8f6c918c243da15 (patch) | |
tree | a55e4f7d5cf65263c716a2f08e1124e76e3529cc /tools | |
parent | 33ec0caf6a3bce1289a915845866828e19c04afb (diff) |
perf tools: Add the bash completion for listing subsubcommands of perf trace
The bash completion does not support listing subsubcommands for 'perf
trace <TAB>', so fix it.
Example:
Before this patch:
$ perf trace <TAB>
$
As shown above, the subsubcommands of perf trace does not come out.
After this patch:
$ perf trace <TAB>
record
As shown above, the subsubcommands of perf trace can come out now.
Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1426685758-25488-13-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-trace.c | 7 | ||||
-rw-r--r-- | tools/perf/perf-completion.sh | 9 |
2 files changed, 10 insertions, 6 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 6969ba98ff2f..0b3b4e4984b9 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -2609,7 +2609,7 @@ static void evlist__set_evsel_handler(struct perf_evlist *evlist, void *handler) | |||
2609 | 2609 | ||
2610 | int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused) | 2610 | int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused) |
2611 | { | 2611 | { |
2612 | const char * const trace_usage[] = { | 2612 | const char *trace_usage[] = { |
2613 | "perf trace [<options>] [<command>]", | 2613 | "perf trace [<options>] [<command>]", |
2614 | "perf trace [<options>] -- <command> [<options>]", | 2614 | "perf trace [<options>] -- <command> [<options>]", |
2615 | "perf trace record [<options>] [<command>]", | 2615 | "perf trace record [<options>] [<command>]", |
@@ -2684,6 +2684,7 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused) | |||
2684 | OPT_BOOLEAN(0, "syscalls", &trace.trace_syscalls, "Trace syscalls"), | 2684 | OPT_BOOLEAN(0, "syscalls", &trace.trace_syscalls, "Trace syscalls"), |
2685 | OPT_END() | 2685 | OPT_END() |
2686 | }; | 2686 | }; |
2687 | const char * const trace_subcommands[] = { "record", NULL }; | ||
2687 | int err; | 2688 | int err; |
2688 | char bf[BUFSIZ]; | 2689 | char bf[BUFSIZ]; |
2689 | 2690 | ||
@@ -2699,8 +2700,8 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused) | |||
2699 | goto out; | 2700 | goto out; |
2700 | } | 2701 | } |
2701 | 2702 | ||
2702 | argc = parse_options(argc, argv, trace_options, trace_usage, | 2703 | argc = parse_options_subcommand(argc, argv, trace_options, trace_subcommands, |
2703 | PARSE_OPT_STOP_AT_NON_OPTION); | 2704 | trace_usage, PARSE_OPT_STOP_AT_NON_OPTION); |
2704 | 2705 | ||
2705 | if (trace.trace_pgfaults) { | 2706 | if (trace.trace_pgfaults) { |
2706 | trace.opts.sample_address = true; | 2707 | trace.opts.sample_address = true; |
diff --git a/tools/perf/perf-completion.sh b/tools/perf/perf-completion.sh index a33d2ef53ae4..bdd40350870a 100644 --- a/tools/perf/perf-completion.sh +++ b/tools/perf/perf-completion.sh | |||
@@ -120,6 +120,7 @@ __perf_prev_skip_opts () | |||
120 | ((i--)) | 120 | ((i--)) |
121 | done | 121 | done |
122 | } | 122 | } |
123 | |||
123 | __perf_main () | 124 | __perf_main () |
124 | { | 125 | { |
125 | local cmd | 126 | local cmd |
@@ -137,13 +138,15 @@ __perf_main () | |||
137 | cmds=$($cmd --list-cmds) | 138 | cmds=$($cmd --list-cmds) |
138 | fi | 139 | fi |
139 | __perfcomp "$cmds" "$cur" | 140 | __perfcomp "$cmds" "$cur" |
140 | # List possible events for -e and --event option | 141 | # List possible events for -e option |
141 | elif [[ $prev == @("-e"|"--event") && $prev_skip_opts == @(record|stat|top) ]]; then | 142 | elif [[ $prev == @("-e"|"--event") && |
143 | $prev_skip_opts == @(record|stat|top) ]]; then | ||
142 | evts=$($cmd list --raw-dump) | 144 | evts=$($cmd list --raw-dump) |
143 | __perfcomp_colon "$evts" "$cur" | 145 | __perfcomp_colon "$evts" "$cur" |
144 | else | 146 | else |
145 | # List subcommands for perf commands | 147 | # List subcommands for perf commands |
146 | if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched|data|help|script|test|timechart) ]]; then | 148 | if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched| |
149 | |data|help|script|test|timechart|trace) ]]; then | ||
147 | subcmds=$($cmd $prev_skip_opts --list-cmds) | 150 | subcmds=$($cmd $prev_skip_opts --list-cmds) |
148 | __perfcomp_colon "$subcmds" "$cur" | 151 | __perfcomp_colon "$subcmds" "$cur" |
149 | fi | 152 | fi |