Commit 397692ea authored by Song Liu's avatar Song Liu Committed by Daniel Borkmann

bpftool: Bash completion for "bpftool prog profile"

Add bash completion for "bpftool prog profile" command.
Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Reviewed-by: default avatarQuentin Monnet <quentin@isovalent.com>
Link: https://lore.kernel.org/bpf/20200309173218.2739965-4-songliubraving@fb.com
parent 319c7c1f
...@@ -337,6 +337,7 @@ _bpftool() ...@@ -337,6 +337,7 @@ _bpftool()
local PROG_TYPE='id pinned tag name' local PROG_TYPE='id pinned tag name'
local MAP_TYPE='id pinned name' local MAP_TYPE='id pinned name'
local METRIC_TYPE='cycles instructions l1d_loads llc_misses'
case $command in case $command in
show|list) show|list)
[[ $prev != "$command" ]] && return 0 [[ $prev != "$command" ]] && return 0
...@@ -498,6 +499,48 @@ _bpftool() ...@@ -498,6 +499,48 @@ _bpftool()
tracelog) tracelog)
return 0 return 0
;; ;;
profile)
case $cword in
3)
COMPREPLY=( $( compgen -W "$PROG_TYPE" -- "$cur" ) )
return 0
;;
4)
case $prev in
id)
_bpftool_get_prog_ids
;;
name)
_bpftool_get_prog_names
;;
pinned)
_filedir
;;
esac
return 0
;;
5)
COMPREPLY=( $( compgen -W "$METRIC_TYPE duration" -- "$cur" ) )
return 0
;;
6)
case $prev in
duration)
return 0
;;
*)
COMPREPLY=( $( compgen -W "$METRIC_TYPE" -- "$cur" ) )
return 0
;;
esac
return 0
;;
*)
COMPREPLY=( $( compgen -W "$METRIC_TYPE" -- "$cur" ) )
return 0
;;
esac
;;
run) run)
if [[ ${#words[@]} -lt 5 ]]; then if [[ ${#words[@]} -lt 5 ]]; then
_filedir _filedir
...@@ -525,7 +568,7 @@ _bpftool() ...@@ -525,7 +568,7 @@ _bpftool()
*) *)
[[ $prev == $object ]] && \ [[ $prev == $object ]] && \
COMPREPLY=( $( compgen -W 'dump help pin attach detach \ COMPREPLY=( $( compgen -W 'dump help pin attach detach \
load loadall show list tracelog run' -- "$cur" ) ) load loadall show list tracelog run profile' -- "$cur" ) )
;; ;;
esac esac
;; ;;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment