Message ID | 20200303195555.1309028-4-songliubraving@fb.com |
---|---|
State | Changes Requested |
Delegated to: | BPF Maintainers |
Headers | show |
Series | bpftool: introduce prog profile | expand |
2020-03-03 11:55 UTC-0800 ~ Song Liu <songliubraving@fb.com> > Add bash completion for "bpftool prog profile" command. > > Signed-off-by: Song Liu <songliubraving@fb.com> > --- > tools/bpf/bpftool/bash-completion/bpftool | 45 ++++++++++++++++++++++- > 1 file changed, 44 insertions(+), 1 deletion(-) > > diff --git a/tools/bpf/bpftool/bash-completion/bpftool b/tools/bpf/bpftool/bash-completion/bpftool > index f2838a658339..e54f36c0c973 100644 > --- a/tools/bpf/bpftool/bash-completion/bpftool > +++ b/tools/bpf/bpftool/bash-completion/bpftool > @@ -337,6 +337,7 @@ _bpftool() > > local PROG_TYPE='id pinned tag name' > local MAP_TYPE='id pinned name' > + local METRIC_TYPE='cycles instructions l1d_loads llc_misses' > case $command in > show|list) > [[ $prev != "$command" ]] && return 0 > @@ -498,6 +499,48 @@ _bpftool() > tracelog) > 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_map_names s/map/prog/ > + ;; > + 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 > + ;; You have a mix of tabs and spaces for indent on this chunk, could you please fix it? Other than this and the map|prog thing above, completion looks good to me, thanks a lot! > run) > if [[ ${#words[@]} -lt 5 ]]; then > _filedir > @@ -525,7 +568,7 @@ _bpftool() > *) > [[ $prev == $object ]] && \ > COMPREPLY=( $( compgen -W 'dump help pin attach detach \ > - load loadall show list tracelog run' -- "$cur" ) ) > + load loadall show list tracelog run profile' -- "$cur" ) ) > ;; > esac > ;; >
diff --git a/tools/bpf/bpftool/bash-completion/bpftool b/tools/bpf/bpftool/bash-completion/bpftool index f2838a658339..e54f36c0c973 100644 --- a/tools/bpf/bpftool/bash-completion/bpftool +++ b/tools/bpf/bpftool/bash-completion/bpftool @@ -337,6 +337,7 @@ _bpftool() local PROG_TYPE='id pinned tag name' local MAP_TYPE='id pinned name' + local METRIC_TYPE='cycles instructions l1d_loads llc_misses' case $command in show|list) [[ $prev != "$command" ]] && return 0 @@ -498,6 +499,48 @@ _bpftool() tracelog) 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_map_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) if [[ ${#words[@]} -lt 5 ]]; then _filedir @@ -525,7 +568,7 @@ _bpftool() *) [[ $prev == $object ]] && \ COMPREPLY=( $( compgen -W 'dump help pin attach detach \ - load loadall show list tracelog run' -- "$cur" ) ) + load loadall show list tracelog run profile' -- "$cur" ) ) ;; esac ;;
Add bash completion for "bpftool prog profile" command. Signed-off-by: Song Liu <songliubraving@fb.com> --- tools/bpf/bpftool/bash-completion/bpftool | 45 ++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-)