Commit 0d97dacc authored by Andrii Nakryiko's avatar Andrii Nakryiko Committed by Daniel Borkmann

bpftool: auto-complete BTF IDs for btf dump

Auto-complete BTF IDs for `btf dump id` sub-command. List of possible BTF
IDs is scavenged from loaded BPF programs that have associated BTFs, as
there is currently no API in libbpf to fetch list of all BTFs in the
system.
Suggested-by: default avatarQuentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
Reviewed-by: default avatarQuentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parent d9a6f413
...@@ -71,6 +71,12 @@ _bpftool_get_prog_tags() ...@@ -71,6 +71,12 @@ _bpftool_get_prog_tags()
command sed -n 's/.*"tag": "\(.*\)",$/\1/p' )" -- "$cur" ) ) command sed -n 's/.*"tag": "\(.*\)",$/\1/p' )" -- "$cur" ) )
} }
_bpftool_get_btf_ids()
{
COMPREPLY+=( $( compgen -W "$( bpftool -jp prog 2>&1 | \
command sed -n 's/.*"btf_id": \(.*\),\?$/\1/p' )" -- "$cur" ) )
}
_bpftool_get_obj_map_names() _bpftool_get_obj_map_names()
{ {
local obj local obj
...@@ -635,6 +641,9 @@ _bpftool() ...@@ -635,6 +641,9 @@ _bpftool()
map) map)
_bpftool_get_map_ids _bpftool_get_map_ids
;; ;;
dump)
_bpftool_get_btf_ids
;;
esac esac
return 0 return 0
;; ;;
......
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