Răsfoiți Sursa

tools: bpftool: add bash completion for CFG dump

Add bash completion for the "visual" keyword used for dumping the CFG of
eBPF programs with bpftool. Make sure we only complete with this keyword
when we dump "xlated" (and not "jited") instructions.

Acked-by: Jiong Wang <jiong.wang@netronome.com>
Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Quentin Monnet 7 ani în urmă
părinte
comite
d96fc832bc
1 a modificat fișierele cu 9 adăugiri și 4 ștergeri
  1. 9 4
      tools/bpf/bpftool/bash-completion/bpftool

+ 9 - 4
tools/bpf/bpftool/bash-completion/bpftool

@@ -147,7 +147,7 @@ _bpftool()
 
 
     # Deal with simplest keywords
     # Deal with simplest keywords
     case $prev in
     case $prev in
-        help|key|opcodes)
+        help|key|opcodes|visual)
             return 0
             return 0
             ;;
             ;;
         tag)
         tag)
@@ -223,11 +223,16 @@ _bpftool()
                             return 0
                             return 0
                             ;;
                             ;;
                     *)
                     *)
-                            _bpftool_once_attr 'file'
+                        _bpftool_once_attr 'file'
+                        if _bpftool_search_list 'xlated'; then
+                            COMPREPLY+=( $( compgen -W 'opcodes visual' -- \
+                                "$cur" ) )
+                        else
                             COMPREPLY+=( $( compgen -W 'opcodes' -- \
                             COMPREPLY+=( $( compgen -W 'opcodes' -- \
                                 "$cur" ) )
                                 "$cur" ) )
-                            return 0
-                            ;;
+                        fi
+                        return 0
+                        ;;
                     esac
                     esac
                     ;;
                     ;;
                 pin)
                 pin)