[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190525053809.1207929-1-andriin@fb.com>
Date: Fri, 24 May 2019 22:38:09 -0700
From: Andrii Nakryiko <andriin@...com>
To: <andrii.nakryiko@...il.com>, <kernel-team@...com>,
<netdev@...r.kernel.org>, <bpf@...r.kernel.org>, <ast@...com>,
<daniel@...earbox.net>, <quentin.monnet@...ronome.com>
CC: Andrii Nakryiko <andriin@...com>
Subject: [PATCH bpf-next] 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: Quentin Monnet <quentin.monnet@...ronome.com>
Signed-off-by: Andrii Nakryiko <andriin@...com>
---
tools/bpf/bpftool/bash-completion/bpftool | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/tools/bpf/bpftool/bash-completion/bpftool b/tools/bpf/bpftool/bash-completion/bpftool
index 75c01eafd3a1..9fbc33e93689 100644
--- a/tools/bpf/bpftool/bash-completion/bpftool
+++ b/tools/bpf/bpftool/bash-completion/bpftool
@@ -71,6 +71,13 @@ _bpftool_get_prog_tags()
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' | \
+ command sort -nu )" -- "$cur" ) )
+}
+
_bpftool_get_obj_map_names()
{
local obj
@@ -635,6 +642,9 @@ _bpftool()
map)
_bpftool_get_map_ids
;;
+ dump)
+ _bpftool_get_btf_ids
+ ;;
esac
return 0
;;
--
2.17.1
Powered by blists - more mailing lists