Add basic bash completion for the -e option in record, top
and stat subcommands. Only hardware, software and tracepoint
events are supported.
Breakpoints, raw events and events grouping completion
need more thinking.
Signed-off-by: Frederic Weisbecker <fweisbec@xxxxxxxxx>
Cc: David Ahern <dsahern@xxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
Cc: Namhyung Kim <namhyung@xxxxxxxxx>
Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
Cc: Stephane Eranian <eranian@xxxxxxxxxx>
---
tools/perf/bash_completion | 6 +++-
tools/perf/builtin-list.c | 14 ++++---
tools/perf/util/parse-events.c | 70 +++++++++++++++++++++++++---------------
tools/perf/util/parse-events.h | 7 ++--
4 files changed, 61 insertions(+), 36 deletions(-)
diff --git a/tools/perf/bash_completion b/tools/perf/bash_completion
index 3547703..25f4d99 100644
--- a/tools/perf/bash_completion
+++ b/tools/perf/bash_completion
@@ -6,12 +6,16 @@ _perf()
local cur
COMPREPLY=()
- _get_comp_words_by_ref cur
+ _get_comp_words_by_ref cur prev
# List perf subcommands
if [ $COMP_CWORD -eq 1 ]; then
cmds=$(perf --list-cmds)
COMPREPLY=( $( compgen -W '$cmds' -- "$cur" ) )
+ # List possible events for -e option
+ elif [[ $prev == "-e" && "${COMP_WORDS[1]}" == @(record|stat|top) ]]; then
+ cmds=$(perf list --raw-dump)
+ COMPREPLY=( $( compgen -W '$cmds' -- $cur ) )
# Fall down to list regular files
else
_filedir