Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Yunlong Song and committed by
Arnaldo Carvalho de Melo
6fdd9cb7 33ec0caf

+10 -6
+4 -3
tools/perf/builtin-trace.c
··· 2609 2609 2610 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 2613 "perf trace [<options>] [<command>]", 2614 2614 "perf trace [<options>] -- <command> [<options>]", 2615 2615 "perf trace record [<options>] [<command>]", ··· 2684 2684 OPT_BOOLEAN(0, "syscalls", &trace.trace_syscalls, "Trace syscalls"), 2685 2685 OPT_END() 2686 2686 }; 2687 + const char * const trace_subcommands[] = { "record", NULL }; 2687 2688 int err; 2688 2689 char bf[BUFSIZ]; 2689 2690 ··· 2700 2699 goto out; 2701 2700 } 2702 2701 2703 - argc = parse_options(argc, argv, trace_options, trace_usage, 2704 - PARSE_OPT_STOP_AT_NON_OPTION); 2702 + argc = parse_options_subcommand(argc, argv, trace_options, trace_subcommands, 2703 + trace_usage, PARSE_OPT_STOP_AT_NON_OPTION); 2705 2704 2706 2705 if (trace.trace_pgfaults) { 2707 2706 trace.opts.sample_address = true;
+6 -3
tools/perf/perf-completion.sh
··· 120 120 ((i--)) 121 121 done 122 122 } 123 + 123 124 __perf_main () 124 125 { 125 126 local cmd ··· 138 137 cmds=$($cmd --list-cmds) 139 138 fi 140 139 __perfcomp "$cmds" "$cur" 141 - # List possible events for -e and --event option 142 - elif [[ $prev == @("-e"|"--event") && $prev_skip_opts == @(record|stat|top) ]]; then 140 + # List possible events for -e option 141 + elif [[ $prev == @("-e"|"--event") && 142 + $prev_skip_opts == @(record|stat|top) ]]; then 143 143 evts=$($cmd list --raw-dump) 144 144 __perfcomp_colon "$evts" "$cur" 145 145 else 146 146 # List subcommands for perf commands 147 - if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched|data|help|script|test|timechart) ]]; then 147 + if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched| 148 + |data|help|script|test|timechart|trace) ]]; then 148 149 subcmds=$($cmd $prev_skip_opts --list-cmds) 149 150 __perfcomp_colon "$subcmds" "$cur" 150 151 fi