aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2024-05-12 20:46:10 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2024-05-12 20:46:10 -0300
commita9ae414fef421bdeb13ff7ffe13271e1e4f58993 (patch)
tree7b1d149c9a1ae7f4d44b6e7948e5c82eff27b616
parentd08776019ef6a561e58047b071371e4e8c381d89 (diff)
downloadpahole-next.tar.gz
btf_loader: Initial support for BTF_KIND_DECL_TAGtmp.masternext
For now for just the first one found for a given tag (function, class_member, etc). Pretty print it initially just on functions, with it we can test the kfunc decl tags: $ pfunct --prototypes -F btf vmlinux.btf.decl_tag,decl_tag_kfuncs | grep ^bpf_kfunc | head bpf_kfunc void cubictcp_init(struct sock * sk); bpf_kfunc void cubictcp_cwnd_event(struct sock * sk, enum tcp_ca_event event); bpf_kfunc void cubictcp_cong_avoid(struct sock * sk, u32 ack, u32 acked); bpf_kfunc u32 cubictcp_recalc_ssthresh(struct sock * sk); bpf_kfunc void cubictcp_state(struct sock * sk, u8 new_state); bpf_kfunc void cubictcp_acked(struct sock * sk, const struct ack_sample * sample); bpf_kfunc int bpf_iter_css_new(struct bpf_iter_css * it, struct cgroup_subsys_state * start, unsigned int flags); bpf_kfunc struct cgroup_subsys_state * bpf_iter_css_next(struct bpf_iter_css * it); bpf_kfunc void bpf_iter_css_destroy(struct bpf_iter_css * it); bpf_kfunc s64 bpf_map_sum_elem_count(const struct bpf_map * map); $ pfunct --prototypes -F btf vmlinux.btf.decl_tag,decl_tag_kfuncs | grep ^bpf_kfunc | wc -l 116 $ Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--btf_loader.c31
-rw-r--r--dwarf_loader.c1
-rw-r--r--dwarves.h1
-rw-r--r--dwarves_fprintf.c3
4 files changed, 36 insertions, 0 deletions
diff --git a/btf_loader.c b/btf_loader.c
index 57d6d007..e0d029a1 100644
--- a/btf_loader.c
+++ b/btf_loader.c
@@ -454,6 +454,34 @@ static int create_new_tag(struct cu *cu, int type, const struct btf_type *tp, ui
return 0;
}
+static int process_decl_tag(struct cu *cu, const struct btf_type *tp)
+{
+ struct tag *tag = cu__type(cu, tp->type);
+
+ if (tag == NULL)
+ tag = cu__function(cu, tp->type);
+
+ if (tag == NULL)
+ tag = cu__tag(cu, tp->type);
+
+ if (tag == NULL) {
+ printf("WARNING: BTF_KIND_DECL_TAG for unknown BTF id %d\n", tp->type);
+ return 0;
+ }
+
+ const char *attribute = cu__btf_str(cu, tp->name_off);
+
+ if (tag->attribute != NULL) {
+ char bf[128];
+ printf("WARNING: still unsuported BTF_KIND_DECL_TAG(%s) for %s already with attribute (%s), ignoring\n",
+ attribute, tag__name(tag, cu, bf, sizeof(bf), NULL), tag->attribute);
+ } else {
+ tag->attribute = attribute;
+ }
+
+ return 0;
+}
+
static int btf__load_types(struct btf *btf, struct cu *cu)
{
uint32_t type_index;
@@ -522,6 +550,9 @@ static int btf__load_types(struct btf *btf, struct cu *cu)
case BTF_KIND_FLOAT:
err = create_new_float_type(cu, type_ptr, type_index);
break;
+ case BTF_KIND_DECL_TAG:
+ err = process_decl_tag(cu, type_ptr);
+ break;
default:
fprintf(stderr, "BTF: idx: %d, Unknown kind %d\n", type_index, type);
fflush(stderr);
diff --git a/dwarf_loader.c b/dwarf_loader.c
index b15cf543..f59477b4 100644
--- a/dwarf_loader.c
+++ b/dwarf_loader.c
@@ -498,6 +498,7 @@ static void tag__init(struct tag *tag, struct cu *cu, Dwarf_Die *die)
dtag->abstract_origin = attr_type(die, DW_AT_abstract_origin);
tag->recursivity_level = 0;
+ tag->attribute = NULL;
if (cu->extra_dbg_info) {
pthread_mutex_lock(&libdw__lock);
diff --git a/dwarves.h b/dwarves.h
index 7d566b60..f5ae79ff 100644
--- a/dwarves.h
+++ b/dwarves.h
@@ -493,6 +493,7 @@ struct tag {
bool top_level;
bool has_btf_type_tag;
uint16_t recursivity_level;
+ const char *attribute;
void *priv;
};
diff --git a/dwarves_fprintf.c b/dwarves_fprintf.c
index f3bf96f5..54d2fc23 100644
--- a/dwarves_fprintf.c
+++ b/dwarves_fprintf.c
@@ -1406,6 +1406,9 @@ static size_t function__fprintf(const struct tag *tag, const struct cu *cu,
size_t printed = 0;
bool inlined = !conf->strip_inline && function__declared_inline(func);
+ if (tag->attribute)
+ printed += fprintf(fp, "%s ", tag->attribute);
+
if (func->virtuality == DW_VIRTUALITY_virtual ||
func->virtuality == DW_VIRTUALITY_pure_virtual)
printed += fprintf(fp, "virtual ");