summaryrefslogtreecommitdiff
path: root/tools/bpf/bpftool/bash-completion
diff options
context:
space:
mode:
authorQuentin Monnet <quentin@isovalent.com>2023-04-05 16:21:18 +0300
committerAlexei Starovoitov <ast@kernel.org>2023-04-06 07:27:27 +0300
commit9b79f02722bbf24f060b2ab79513ad6e22c8e2f0 (patch)
treee998630eabdb43b4da2b0c5968d2e1c421053b61 /tools/bpf/bpftool/bash-completion
parent05a06be722896e51f65dbbb6a3610f85a8353d6b (diff)
downloadlinux-9b79f02722bbf24f060b2ab79513ad6e22c8e2f0.tar.xz
bpftool: Support "opcodes", "linum", "visual" simultaneously
When dumping a program, the keywords "opcodes" (for printing the raw opcodes), "linum" (for displaying the filename, line number, column number along with the source code), and "visual" (for generating the control flow graph for translated programs) are mutually exclusive. But there's no reason why they should be. Let's make it possible to pass several of them at once. The "file FILE" option, which makes bpftool output a binary image to a file, remains incompatible with the others. Signed-off-by: Quentin Monnet <quentin@isovalent.com> Link: https://lore.kernel.org/r/20230405132120.59886-6-quentin@isovalent.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/bpf/bpftool/bash-completion')
-rw-r--r--tools/bpf/bpftool/bash-completion/bpftool17
1 files changed, 10 insertions, 7 deletions
diff --git a/tools/bpf/bpftool/bash-completion/bpftool b/tools/bpf/bpftool/bash-completion/bpftool
index a3cb07172789..69c64dc18b1d 100644
--- a/tools/bpf/bpftool/bash-completion/bpftool
+++ b/tools/bpf/bpftool/bash-completion/bpftool
@@ -271,7 +271,7 @@ _bpftool()
# Deal with simplest keywords
case $prev in
- help|hex|opcodes|visual|linum)
+ help|hex)
return 0
;;
tag)
@@ -369,13 +369,16 @@ _bpftool()
return 0
;;
*)
- _bpftool_once_attr 'file'
+ # "file" is not compatible with other keywords here
+ if _bpftool_search_list 'file'; then
+ return 0
+ fi
+ if ! _bpftool_search_list 'linum opcodes visual'; then
+ _bpftool_once_attr 'file'
+ fi
+ _bpftool_once_attr 'linum opcodes'
if _bpftool_search_list 'xlated' && [[ "$json" == 0 ]]; then
- COMPREPLY+=( $( compgen -W 'opcodes visual linum' -- \
- "$cur" ) )
- else
- COMPREPLY+=( $( compgen -W 'opcodes linum' -- \
- "$cur" ) )
+ _bpftool_once_attr 'visual'
fi
return 0
;;