Lines Matching refs:btf
100 static const char *btf_str(const struct btf *btf, __u32 off) in btf_str() argument
104 return btf__name_by_offset(btf, off) ? : "(invalid)"; in btf_str()
112 static int dump_btf_type(const struct btf *btf, __u32 id, in dump_btf_type() argument
122 jsonw_string_field(w, "name", btf_str(btf, t->name_off)); in dump_btf_type()
125 btf_str(btf, t->name_off)); in dump_btf_type()
186 const char *name = btf_str(btf, m->name_off); in dump_btf_type()
235 const char *name = btf_str(btf, v->name_off); in dump_btf_type()
273 const char *name = btf_str(btf, v->name_off); in dump_btf_type()
332 const char *name = btf_str(btf, p->name_off); in dump_btf_type()
386 if (v->type < btf__type_cnt(btf)) { in dump_btf_type()
387 vt = btf__type_by_id(btf, v->type); in dump_btf_type()
390 btf_str(btf, vt->name_off)); in dump_btf_type()
428 static int dump_btf_raw(const struct btf *btf, in dump_btf_raw() argument
442 t = btf__type_by_id(btf, root_type_ids[i]); in dump_btf_raw()
443 dump_btf_type(btf, root_type_ids[i], t); in dump_btf_raw()
446 const struct btf *base; in dump_btf_raw()
447 int cnt = btf__type_cnt(btf); in dump_btf_raw()
450 base = btf__base_btf(btf); in dump_btf_raw()
455 t = btf__type_by_id(btf, i); in dump_btf_raw()
456 dump_btf_type(btf, i, t); in dump_btf_raw()
467 static int dump_btf_kfuncs(struct btf_dump *d, const struct btf *btf) in dump_btf_kfuncs() argument
470 int cnt = btf__type_cnt(btf); in dump_btf_kfuncs()
477 const struct btf_type *t = btf__type_by_id(btf, i); in dump_btf_kfuncs()
487 name = btf__name_by_offset(btf, t->name_off); in dump_btf_kfuncs()
491 t = btf__type_by_id(btf, t->type); in dump_btf_kfuncs()
497 opts.field_name = btf__name_by_offset(btf, t->name_off); in dump_btf_kfuncs()
516 static int btf_type_rank(const struct btf *btf, __u32 index, bool has_name) in btf_type_rank() argument
518 const struct btf_type *t = btf__type_by_id(btf, index); in btf_type_rank()
539 return btf_type_rank(btf, btf_array(t)->type, has_name); in btf_type_rank()
549 return btf_type_rank(btf, t->type, has_name); in btf_type_rank()
556 static const char *btf_type_sort_name(const struct btf *btf, __u32 index, bool from_ref) in btf_type_sort_name() argument
558 const struct btf_type *t = btf__type_by_id(btf, index); in btf_type_sort_name()
570 return btf__name_by_offset(btf, name_off); in btf_type_sort_name()
573 return btf_type_sort_name(btf, btf_array(t)->type, true); in btf_type_sort_name()
581 return btf_type_sort_name(btf, t->type, true); in btf_type_sort_name()
583 return btf__name_by_offset(btf, t->name_off); in btf_type_sort_name()
593 static __u64 btf_name_hasher(__u64 hash, const struct btf *btf, __u32 name_off) in btf_name_hasher() argument
598 return hasher(hash, str_hash(btf__name_by_offset(btf, name_off))); in btf_name_hasher()
601 static __u64 btf_type_disambig_hash(const struct btf *btf, __u32 id, bool include_members) in btf_type_disambig_hash() argument
603 const struct btf_type *t = btf__type_by_id(btf, id); in btf_type_disambig_hash()
607 hash = btf_name_hasher(hash, btf, t->name_off); in btf_type_disambig_hash()
617 hash = btf_name_hasher(hash, btf, name_off); in btf_type_disambig_hash()
627 hash = btf_name_hasher(hash, btf, m->name_off); in btf_type_disambig_hash()
629 hash = hasher(hash, btf_type_disambig_hash(btf, m->type, false)); in btf_type_disambig_hash()
639 hash = hasher(hash, btf_type_disambig_hash(btf, t->type, include_members)); in btf_type_disambig_hash()
645 hash = hasher(hash, btf_type_disambig_hash(btf, arr->type, include_members)); in btf_type_disambig_hash()
672 static struct sort_datum *sort_btf_c(const struct btf *btf) in sort_btf_c() argument
677 n = btf__type_cnt(btf); in sort_btf_c()
684 const struct btf_type *t = btf__type_by_id(btf, i); in sort_btf_c()
687 d->type_rank = btf_type_rank(btf, i, false); in sort_btf_c()
688 d->sort_name = btf_type_sort_name(btf, i, false); in sort_btf_c()
689 d->own_name = btf__name_by_offset(btf, t->name_off); in sort_btf_c()
690 d->disambig_hash = btf_type_disambig_hash(btf, i, true); in sort_btf_c()
698 static int dump_btf_c(const struct btf *btf, in dump_btf_c() argument
705 d = btf_dump__new(btf, btf_dump_printf, NULL, NULL); in dump_btf_c()
729 int cnt = btf__type_cnt(btf); in dump_btf_c()
732 datums = sort_btf_c(btf); in dump_btf_c()
741 err = dump_btf_kfuncs(d, btf); in dump_btf_c()
760 static struct btf *get_vmlinux_btf_from_sysfs(void) in get_vmlinux_btf_from_sysfs()
762 struct btf *base; in get_vmlinux_btf_from_sysfs()
804 struct btf *btf = NULL, *base = NULL; in do_dump() local
884 btf = btf__parse_split(*argv, base ?: base_btf); in do_dump()
885 if (!btf) { in do_dump()
927 if (!btf) { in do_dump()
934 btf = btf__load_from_kernel_by_id_split(btf_id, base_btf); in do_dump()
935 if (!btf) { in do_dump()
948 err = dump_btf_c(btf, root_type_ids, root_type_cnt, sort_dump_c); in do_dump()
950 err = dump_btf_raw(btf, root_type_ids, root_type_cnt); in do_dump()
955 btf__free(btf); in do_dump()