All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next] bpftool: print function linkage in BTF dump
@ 2020-01-24  5:43 Andrii Nakryiko
  2020-01-24  7:01 ` Martin Lau
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Andrii Nakryiko @ 2020-01-24  5:43 UTC (permalink / raw)
  To: bpf, netdev, ast, daniel; +Cc: andrii.nakryiko, kernel-team, Andrii Nakryiko

Add printing out BTF_KIND_FUNC's linkage.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
---
 tools/bpf/bpftool/btf.c | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c
index 4ba90d81b6a1..b3745ed711ba 100644
--- a/tools/bpf/bpftool/btf.c
+++ b/tools/bpf/bpftool/btf.c
@@ -77,6 +77,20 @@ static const char *btf_var_linkage_str(__u32 linkage)
 	}
 }
 
+static const char *btf_func_linkage_str(const struct btf_type *t)
+{
+	switch (btf_vlen(t)) {
+	case BTF_FUNC_STATIC:
+		return "static";
+	case BTF_FUNC_GLOBAL:
+		return "global";
+	case BTF_FUNC_EXTERN:
+		return "extern";
+	default:
+		return "(unknown)";
+	}
+}
+
 static const char *btf_str(const struct btf *btf, __u32 off)
 {
 	if (!off)
@@ -231,12 +245,17 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
 			printf(" fwd_kind=%s", fwd_kind);
 		break;
 	}
-	case BTF_KIND_FUNC:
-		if (json_output)
+	case BTF_KIND_FUNC: {
+		const char *linkage = btf_func_linkage_str(t);
+
+		if (json_output) {
 			jsonw_uint_field(w, "type_id", t->type);
-		else
-			printf(" type_id=%u", t->type);
+			jsonw_string_field(w, "linkage", linkage);
+		} else {
+			printf(" type_id=%u linkage=%s", t->type, linkage);
+		}
 		break;
+	}
 	case BTF_KIND_FUNC_PROTO: {
 		const struct btf_param *p = (const void *)(t + 1);
 		__u16 vlen = BTF_INFO_VLEN(t->info);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf-next] bpftool: print function linkage in BTF dump
  2020-01-24  5:43 [PATCH bpf-next] bpftool: print function linkage in BTF dump Andrii Nakryiko
@ 2020-01-24  7:01 ` Martin Lau
  2020-01-24  9:53 ` Toke Høiland-Jørgensen
  2020-01-24 10:12 ` Daniel Borkmann
  2 siblings, 0 replies; 4+ messages in thread
From: Martin Lau @ 2020-01-24  7:01 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: bpf, netdev, Alexei Starovoitov, daniel, andrii.nakryiko, Kernel Team

On Thu, Jan 23, 2020 at 09:43:17PM -0800, Andrii Nakryiko wrote:
> Add printing out BTF_KIND_FUNC's linkage.
Acked-by: Martin KaFai Lau <kafai@fb.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf-next] bpftool: print function linkage in BTF dump
  2020-01-24  5:43 [PATCH bpf-next] bpftool: print function linkage in BTF dump Andrii Nakryiko
  2020-01-24  7:01 ` Martin Lau
@ 2020-01-24  9:53 ` Toke Høiland-Jørgensen
  2020-01-24 10:12 ` Daniel Borkmann
  2 siblings, 0 replies; 4+ messages in thread
From: Toke Høiland-Jørgensen @ 2020-01-24  9:53 UTC (permalink / raw)
  To: Andrii Nakryiko, bpf, netdev, ast, daniel
  Cc: andrii.nakryiko, kernel-team, Andrii Nakryiko

Andrii Nakryiko <andriin@fb.com> writes:

> Add printing out BTF_KIND_FUNC's linkage.
>
> Signed-off-by: Andrii Nakryiko <andriin@fb.com>

Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf-next] bpftool: print function linkage in BTF dump
  2020-01-24  5:43 [PATCH bpf-next] bpftool: print function linkage in BTF dump Andrii Nakryiko
  2020-01-24  7:01 ` Martin Lau
  2020-01-24  9:53 ` Toke Høiland-Jørgensen
@ 2020-01-24 10:12 ` Daniel Borkmann
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Borkmann @ 2020-01-24 10:12 UTC (permalink / raw)
  To: Andrii Nakryiko, bpf, netdev, ast; +Cc: andrii.nakryiko, kernel-team

On 1/24/20 6:43 AM, Andrii Nakryiko wrote:
> Add printing out BTF_KIND_FUNC's linkage.
> 
> Signed-off-by: Andrii Nakryiko <andriin@fb.com>

Applied, thanks!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-01-24 10:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-24  5:43 [PATCH bpf-next] bpftool: print function linkage in BTF dump Andrii Nakryiko
2020-01-24  7:01 ` Martin Lau
2020-01-24  9:53 ` Toke Høiland-Jørgensen
2020-01-24 10:12 ` Daniel Borkmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.