Lines Matching refs:btf

107 static const char *btf_str(const struct btf *btf, __u32 off)  in btf_str()  argument
111 return btf__name_by_offset(btf, off) ? : "(invalid)"; in btf_str()
119 static int dump_btf_type(const struct btf *btf, __u32 id, in dump_btf_type() argument
129 jsonw_string_field(w, "name", btf_str(btf, t->name_off)); in dump_btf_type()
132 btf_str(btf, t->name_off)); in dump_btf_type()
193 const char *name = btf_str(btf, m->name_off); in dump_btf_type()
242 const char *name = btf_str(btf, v->name_off); in dump_btf_type()
280 const char *name = btf_str(btf, v->name_off); in dump_btf_type()
339 const char *name = btf_str(btf, p->name_off); in dump_btf_type()
393 if (v->type < btf__type_cnt(btf)) { in dump_btf_type()
394 vt = btf__type_by_id(btf, v->type); in dump_btf_type()
397 btf_str(btf, vt->name_off)); in dump_btf_type()
435 static int dump_btf_raw(const struct btf *btf, in dump_btf_raw() argument
449 t = btf__type_by_id(btf, root_type_ids[i]); in dump_btf_raw()
450 dump_btf_type(btf, root_type_ids[i], t); in dump_btf_raw()
453 const struct btf *base; in dump_btf_raw()
454 int cnt = btf__type_cnt(btf); in dump_btf_raw()
457 base = btf__base_btf(btf); in dump_btf_raw()
462 t = btf__type_by_id(btf, i); in dump_btf_raw()
463 dump_btf_type(btf, i, t); in dump_btf_raw()
504 struct btf *btf = ctx; in cmp_kfuncs() local
508 return strcmp(btf__str_by_offset(btf, a->name_off), in cmp_kfuncs()
509 btf__str_by_offset(btf, b->name_off)); in cmp_kfuncs()
512 static int dump_btf_kfuncs(struct btf_dump *d, const struct btf *btf) in dump_btf_kfuncs() argument
515 __u32 cnt = btf__type_cnt(btf), i, j; in dump_btf_kfuncs()
524 const struct btf_type *t = btf__type_by_id(btf, i); in dump_btf_kfuncs()
534 ft = btf__type_by_id(btf, t->type); in dump_btf_kfuncs()
538 name = btf__name_by_offset(btf, t->name_off); in dump_btf_kfuncs()
553 qsort_r(kfuncs.elems, kfuncs.cnt, sizeof(*kfuncs.elems), cmp_kfuncs, (void *)btf); in dump_btf_kfuncs()
567 opts.field_name = btf__name_by_offset(btf, t->name_off); in dump_btf_kfuncs()
589 static int btf_type_rank(const struct btf *btf, __u32 index, bool has_name) in btf_type_rank() argument
591 const struct btf_type *t = btf__type_by_id(btf, index); in btf_type_rank()
612 return btf_type_rank(btf, btf_array(t)->type, has_name); in btf_type_rank()
622 return btf_type_rank(btf, t->type, has_name); in btf_type_rank()
629 static const char *btf_type_sort_name(const struct btf *btf, __u32 index, bool from_ref) in btf_type_sort_name() argument
631 const struct btf_type *t = btf__type_by_id(btf, index); in btf_type_sort_name()
643 return btf__name_by_offset(btf, name_off); in btf_type_sort_name()
646 return btf_type_sort_name(btf, btf_array(t)->type, true); in btf_type_sort_name()
654 return btf_type_sort_name(btf, t->type, true); in btf_type_sort_name()
656 return btf__name_by_offset(btf, t->name_off); in btf_type_sort_name()
666 static __u64 btf_name_hasher(__u64 hash, const struct btf *btf, __u32 name_off) in btf_name_hasher() argument
671 return hasher(hash, str_hash(btf__name_by_offset(btf, name_off))); in btf_name_hasher()
674 static __u64 btf_type_disambig_hash(const struct btf *btf, __u32 id, bool include_members) in btf_type_disambig_hash() argument
676 const struct btf_type *t = btf__type_by_id(btf, id); in btf_type_disambig_hash()
680 hash = btf_name_hasher(hash, btf, t->name_off); in btf_type_disambig_hash()
690 hash = btf_name_hasher(hash, btf, name_off); in btf_type_disambig_hash()
700 hash = btf_name_hasher(hash, btf, m->name_off); in btf_type_disambig_hash()
702 hash = hasher(hash, btf_type_disambig_hash(btf, m->type, false)); in btf_type_disambig_hash()
712 hash = hasher(hash, btf_type_disambig_hash(btf, t->type, include_members)); in btf_type_disambig_hash()
718 hash = hasher(hash, btf_type_disambig_hash(btf, arr->type, include_members)); in btf_type_disambig_hash()
745 static struct sort_datum *sort_btf_c(const struct btf *btf) in sort_btf_c() argument
750 n = btf__type_cnt(btf); in sort_btf_c()
757 const struct btf_type *t = btf__type_by_id(btf, i); in sort_btf_c()
760 d->type_rank = btf_type_rank(btf, i, false); in sort_btf_c()
761 d->sort_name = btf_type_sort_name(btf, i, false); in sort_btf_c()
762 d->own_name = btf__name_by_offset(btf, t->name_off); in sort_btf_c()
763 d->disambig_hash = btf_type_disambig_hash(btf, i, true); in sort_btf_c()
771 static int dump_btf_c(const struct btf *btf, in dump_btf_c() argument
778 d = btf_dump__new(btf, btf_dump_printf, NULL, NULL); in dump_btf_c()
809 int cnt = btf__type_cnt(btf); in dump_btf_c()
812 datums = sort_btf_c(btf); in dump_btf_c()
821 err = dump_btf_kfuncs(d, btf); in dump_btf_c()
840 static struct btf *get_vmlinux_btf_from_sysfs(void) in get_vmlinux_btf_from_sysfs()
842 struct btf *base; in get_vmlinux_btf_from_sysfs()
884 struct btf *btf = NULL, *base = NULL; in do_dump() local
967 btf = btf__parse_split(*argv, base ?: base_btf); in do_dump()
968 if (!btf) { in do_dump()
1042 if (!btf) { in do_dump()
1049 btf = btf__load_from_kernel_by_id_split(btf_id, base_btf); in do_dump()
1050 if (!btf) { in do_dump()
1061 if (root_type_ids[i] >= btf__type_cnt(btf)) { in do_dump()
1074 err = dump_btf_c(btf, root_type_ids, root_type_cnt, sort_dump_c); in do_dump()
1076 err = dump_btf_raw(btf, root_type_ids, root_type_cnt); in do_dump()
1081 btf__free(btf); in do_dump()