Home
last modified time | relevance | path

Searched refs:btf (Results 1 – 25 of 123) sorted by relevance

12345

/linux/tools/testing/selftests/bpf/prog_tests/
H A Dlinked_list.c2 #include <bpf/btf.h>
4 #include <linux/btf.h>
250 static struct btf *init_btf(void) in init_btf()
253 struct btf *btf; in init_btf() local
255 btf = btf__new_empty(); in init_btf()
256 if (!ASSERT_OK_PTR(btf, "btf__new_empty")) in init_btf()
258 id = btf__add_int(btf, "int", 4, BTF_INT_SIGNED); in init_btf()
261 lid = btf__add_struct(btf, "bpf_spin_lock", 4); in init_btf()
264 hid = btf__add_struct(btf, "bpf_list_hea in init_btf()
279 struct btf *btf; list_and_rb_node_same_struct() local
331 struct btf *btf = NULL; test_btf() local
[all...]
H A Dbtf_write.c4 #include <bpf/btf.h>
7 static void gen_btf(struct btf *btf) in gen_btf() argument
17 str_off = btf__find_str(btf, "int"); in gen_btf()
20 str_off = btf__add_str(btf, "int"); in gen_btf()
23 str_off = btf__find_str(btf, "int"); in gen_btf()
27 id = btf__add_int(btf, "int", 4, BTF_INT_SIGNED); in gen_btf()
30 t = btf__type_by_id(btf, 1); in gen_btf()
33 ASSERT_STREQ(btf__str_by_offset(btf, t->name_off), "int", "int_name"); in gen_btf()
38 ASSERT_STREQ(btf_type_raw_dump(btf, in gen_btf()
357 struct btf *btf; test_btf_add() local
[all...]
H A Dbtf_dump.c3 #include <bpf/btf.h>
26 static int btf_dump_all_types(const struct btf *btf, void *ctx) in btf_dump_all_types() argument
28 size_t type_cnt = btf__type_cnt(btf); in btf_dump_all_types()
32 d = btf_dump__new(btf, btf_dump_printf, ctx, NULL); in btf_dump_all_types()
51 struct btf *btf = NULL; in test_btf_dump_case() local
57 btf = btf__parse_elf(test_file, NULL); in test_btf_dump_case()
58 if (!ASSERT_OK_PTR(btf, "btf_parse_elf")) { in test_btf_dump_case()
59 err = -PTR_ERR(btf); in test_btf_dump_case()
130 struct btf *btf; global() member
184 struct btf *btf; test_btf_dump_incremental() local
285 struct btf *btf; test_btf_dump_type_tags() local
339 btf_dump_data(struct btf * btf,struct btf_dump * d,char * name,char * prefix,__u64 flags,void * ptr,size_t ptr_sz,char * str,const char * expected_val) btf_dump_data() argument
420 test_btf_dump_int_data(struct btf * btf,struct btf_dump * d,char * str) test_btf_dump_int_data() argument
478 test_btf_dump_float_data(struct btf * btf,struct btf_dump * d,char * str) test_btf_dump_float_data() argument
523 test_btf_dump_char_data(struct btf * btf,struct btf_dump * d,char * str) test_btf_dump_char_data() argument
545 test_btf_dump_typedef_data(struct btf * btf,struct btf_dump * d,char * str) test_btf_dump_typedef_data() argument
600 test_btf_dump_enum_data(struct btf * btf,struct btf_dump * d,char * str) test_btf_dump_enum_data() argument
636 test_btf_dump_struct_data(struct btf * btf,struct btf_dump * d,char * str) test_btf_dump_struct_data() argument
871 test_btf_dump_var_data(struct btf * btf,struct btf_dump * d,char * str) test_btf_dump_var_data() argument
883 struct btf *btf; global() member
998 test_btf_datasec(struct btf * btf,struct btf_dump * d,char * str,const char * name,const char * expected_val,void * data,size_t data_sz) test_btf_datasec() argument
1026 struct btf *btf; test_btf_dump_datasec_data() local
1049 struct btf *btf; test_btf_dump() local
[all...]
H A Dbtf_field_iter.c43 struct btf *btf = NULL; in test_btf_field_iter() local
46 btf = btf__new_empty(); in test_btf_field_iter()
47 if (!ASSERT_OK_PTR(btf, "empty_btf")) in test_btf_field_iter()
50 btf__add_int(btf, "int", 4, BTF_INT_SIGNED); /* [1] int */ in test_btf_field_iter()
51 btf__add_int(btf, "int64", 8, BTF_INT_SIGNED); /* [2] int64 */ in test_btf_field_iter()
52 btf__add_ptr(btf, 1); /* [3] int * */ in test_btf_field_iter()
53 btf__add_array(btf, 1, 2, 3); /* [4] int64[3] */ in test_btf_field_iter()
54 btf__add_struct(btf, "s1", 12); /* [5] struct s1 { */ in test_btf_field_iter()
55 btf__add_field(btf, "f1", 3, 0, 0); /* int *f1; */ in test_btf_field_iter()
56 btf__add_field(btf, "f2", 1, 0, 0); /* int f2; */ in test_btf_field_iter()
[all …]
H A Dlibbpf_str.c23 struct btf *btf; in test_libbpf_bpf_attach_type_str() local
28 btf = btf__parse("/sys/kernel/btf/vmlinux", NULL); in test_libbpf_bpf_attach_type_str()
29 if (!ASSERT_OK_PTR(btf, "btf_parse")) in test_libbpf_bpf_attach_type_str()
33 id = btf__find_by_name_kind(btf, "bpf_attach_type", BTF_KIND_ENUM); in test_libbpf_bpf_attach_type_str()
36 t = btf__type_by_id(btf, id); in test_libbpf_bpf_attach_type_str()
48 attach_type_name = btf__str_by_offset(btf, e->name_off); in test_libbpf_bpf_attach_type_str()
59 btf__free(btf); in test_libbpf_bpf_attach_type_str()
68 struct btf *btf; in test_libbpf_bpf_link_type_str() local
73 btf = btf__parse("/sys/kernel/btf/vmlinux", NULL); in test_libbpf_bpf_link_type_str()
74 if (!ASSERT_OK_PTR(btf, "btf_parse")) in test_libbpf_bpf_link_type_str()
[all …]
H A Dlibbpf_probes.c9 struct btf *btf; in test_libbpf_probe_prog_types() local
14 btf = btf__parse("/sys/kernel/btf/vmlinux", NULL); in test_libbpf_probe_prog_types()
15 if (!ASSERT_OK_PTR(btf, "btf_parse")) in test_libbpf_probe_prog_types()
19 id = btf__find_by_name_kind(btf, "bpf_prog_type", BTF_KIND_ENUM); in test_libbpf_probe_prog_types()
22 t = btf__type_by_id(btf, id); in test_libbpf_probe_prog_types()
27 const char *prog_type_name = btf__str_by_offset(btf, e->name_off); in test_libbpf_probe_prog_types()
44 btf__free(btf); in test_libbpf_probe_prog_types()
49 struct btf *btf; in test_libbpf_probe_map_types() local
54 btf = btf__parse("/sys/kernel/btf/vmlinux", NULL); in test_libbpf_probe_map_types()
55 if (!ASSERT_OK_PTR(btf, "btf_parse")) in test_libbpf_probe_map_types()
[all …]
H A Dtest_global_funcs.c27 static void check_ctx_arg_type(const struct btf *btf, const struct btf_param *p) in check_ctx_arg_type()
32 t = btf__type_by_id(btf, p->type); in check_ctx_arg_type()
36 s = btf_type_raw_dump(btf, t->type); in check_ctx_arg_type()
48 struct btf *btf = NULL; in subtest_ctx_arg_rewrite()
51 struct btf *kern_btf = NULL; in subtest_ctx_arg_rewrite()
88 btf = btf__load_from_kernel_by_id(info.btf_id); in subtest_ctx_arg_rewrite()
89 if (!ASSERT_OK_PTR(btf, "obj_kern_btf")) in subtest_ctx_arg_rewrite()
100 fn_t = btf__type_by_id(btf, re in subtest_ctx_arg_rewrite()
26 check_ctx_arg_type(const struct btf * btf,const struct btf_param * p) check_ctx_arg_type() argument
47 struct btf *btf = NULL; subtest_ctx_arg_rewrite() local
[all...]
H A Dbtf_endian.c18 struct btf *btf = NULL, *swap_btf = NULL; in test_btf_endian() local
26 btf = btf__parse_elf("btf_dump_test_case_syntax.bpf.o", NULL); in test_btf_endian()
27 if (!ASSERT_OK_PTR(btf, "parse_native_btf")) in test_btf_endian()
30 ASSERT_EQ(btf__endianness(btf), endian, "endian"); in test_btf_endian()
31 btf__set_endianness(btf, swap_endian); in test_btf_endian()
32 ASSERT_EQ(btf__endianness(btf), swap_endian, "endian"); in test_btf_endian()
35 raw_data = btf__raw_data(btf, &raw_sz); in test_btf_endian()
45 ASSERT_EQ(btf__type_cnt(swap_btf), btf__type_cnt(btf), "nr_types"); in test_btf_endian()
71 var_id = btf__add_var(btf, "some_var", BTF_VAR_GLOBAL_ALLOCATED, 1); in test_btf_endian()
77 btf__set_endianness(btf, swap_endian); in test_btf_endian()
[all …]
H A Dcore_autosize.c60 struct btf *btf = NULL; in test_core_autosize() local
66 btf = btf__new_empty(); in test_core_autosize()
67 if (!ASSERT_OK_PTR(btf, "empty_btf")) in test_core_autosize()
85 btf__set_pointer_size(btf, 4); in test_core_autosize()
87 char_id = btf__add_int(btf, "unsigned char", 1, 0); in test_core_autosize()
89 short_id = btf__add_int(btf, "unsigned short", 2, 0); in test_core_autosize()
92 int_id = btf__add_int(btf, "long unsigned int", 4, 0); in test_core_autosize()
94 long_long_id = btf__add_int(btf, "unsigned long long", 8, 0); in test_core_autosize()
96 void_ptr_id = btf__add_ptr(btf, 0); in test_core_autosize()
99 id = btf__add_struct(btf, "test_struct", 20 /* bytes */); in test_core_autosize()
[all …]
H A Dbtf_dedup_split.c4 #include <bpf/btf.h>
9 struct btf *btf1, *btf2; in test_split_simple()
127 struct btf *btf1, *btf2; in test_split_fwd_resolve()
225 struct btf *btf1, *btf2; in test_split_struct_duped()
332 static void btf_add_dup_struct_in_cu(struct btf *btf, int start_id) in btf_add_dup_struct_in_cu() argument
335 btf__set_pointer_size(btf, 8); /* enforce 64-bit arch */ in btf_add_dup_struct_in_cu()
337 btf__add_int(btf, "int", 4, BTF_INT_SIGNED); /* [1] int */ in btf_add_dup_struct_in_cu()
339 btf__add_struct(btf, "s", 8); /* [2] struct s { */ in btf_add_dup_struct_in_cu()
340 btf__add_field(btf, " in btf_add_dup_struct_in_cu()
[all...]
H A Dresolve_btfids.c5 #include <bpf/btf.h>
7 #include <linux/btf.h>
66 __resolve_symbol(struct btf *btf, int type_id) in BTF_ID()
72 type = btf__type_by_id(btf, type_id); in BTF_ID()
85 str = btf__name_by_offset(btf, type->name_off); in BTF_ID()
100 struct btf *btf; in resolve_symbols() local
104 btf = btf__parse_raw("resolve_btfids.test.o.BTF"); in resolve_symbols()
105 if (CHECK(libbpf_get_error(btf), "resolv in resolve_symbols()
[all...]
H A Dctx_rewrite.c252 static int find_field_offset_aux(struct btf *btf, int btf_id, char *field_name, int off) in find_field_offset_aux() argument
254 const struct btf_type *type = btf__type_by_id(btf, btf_id); in find_field_offset_aux()
273 const char *mname = btf__name_by_offset(btf, m->name_off); in find_field_offset_aux()
276 int msize = find_field_offset_aux(btf, m->type, field_name, in find_field_offset_aux()
291 static int find_field_offset(struct btf *btf, char *pattern, regmatch_t *matches) in find_field_offset() argument
315 btf_id = btf__find_by_name(btf, type_str); in find_field_offset()
321 field_offset = find_field_offset_aux(btf, btf_id, field_str, 0); in find_field_offset()
492 static bool match_pattern(struct btf *btf, char *pattern, char *text, char *reg_map[][2]) in match_pattern() argument
563 field_offset = find_field_offset(btf, pattern, matches); in match_pattern()
589 field_offset = find_field_offset(btf, pattern, matches); in match_pattern()
[all …]
/linux/tools/lib/bpf/
H A Dbtf.h10 #include <linux/btf.h>
24 struct btf;
37 * @param btf BTF object to free
39 LIBBPF_API void btf__free(struct btf *btf);
55 LIBBPF_API struct btf *btf__new(const void *data, __u32 size);
77 LIBBPF_API struct btf *btf__new_split(const void *data, __u32 size, struct btf *base_btf);
91 LIBBPF_API struct btf *btf__new_empty(void);
110 LIBBPF_API struct btf *btf__new_empty_spli
[all...]
H A Drelo_core.h10 const struct btf *btf; member
30 const struct btf *btf; member
71 int __bpf_core_types_are_compat(const struct btf *local_btf, __u32 local_id,
72 const struct btf *targ_btf, __u32 targ_id, int level);
73 int bpf_core_types_are_compat(const struct btf *local_btf, __u32 local_id,
74 const struct btf *targ_btf, __u32 targ_id);
75 int __bpf_core_types_match(const struct btf *local_btf, __u32 local_id, const struct btf *targ_btf,
77 int bpf_core_types_match(const struct btf *local_btf, __u32 local_id, const struct btf *targ_btf,
84 const struct btf *local_btf,
93 int bpf_core_parse_spec(const char *prog_name, const struct btf *btf,
H A Dlibbpf_internal.h44 #include "btf.h"
244 struct btf;
247 struct btf_type *btf_type_by_id(const struct btf *btf, __u32 type_id);
249 const struct btf_type *skip_mods_and_typedefs(const struct btf *btf, __u32 id, __u32 *res_id);
250 const struct btf_header *btf_header(const struct btf *btf);
251 void btf_set_base_btf(struct btf *btf, cons
[all...]
H A Dbtf_relocate.c36 struct btf;
39 struct btf *btf; member
40 const struct btf *base_btf;
41 const struct btf *dist_base_btf;
68 struct btf_type *t = btf_type_by_id(r->btf, i); in btf_relocate_rewrite_type_id()
134 struct btf_type *t = btf_type_by_id(r->btf, i); in btf_mark_embedded_composite_type_ids()
150 t = btf_type_by_id(r->btf, next_id); in btf_mark_embedded_composite_type_ids()
414 struct btf_type *t = btf_type_by_id(r->btf, i); in btf_relocate_rewrite_strs()
432 btf__str_by_offset(r->btf, off), *str_off); in btf_relocate_rewrite_strs()
444 int btf_relocate(struct btf *btf, const struct btf *base_btf, __u32 **id_map) in btf_relocate() argument
[all …]
/linux/kernel/bpf/
H A Dbtf.c254 struct btf { struct
276 struct btf *base_btf; argument
317 struct btf *btf; member
423 const struct btf *btf; member
462 void (*show)(const struct btf *btf, const struct btf_type *t,
500 static int btf_start_id(const struct btf *btf) in btf_start_id() argument
502 return btf->start_id + (btf->base_btf ? 0 : 1); in btf_start_id()
538 bool btf_is_vmlinux(const struct btf *btf) in btf_is_vmlinux() argument
540 return btf->kernel_btf && !btf->base_btf; in btf_is_vmlinux()
543 u32 btf_nr_types(const struct btf *btf) in btf_nr_types() argument
[all …]
/linux/tools/bpf/bpftool/
H A Dbtf.c15 #include <linux/btf.h>
20 #include <bpf/btf.h>
108 static const char *btf_str(const struct btf *btf, __u32 off) in btf_str()
112 return btf__name_by_offset(btf, off) ? : "(invalid)"; in btf_str()
120 static int dump_btf_type(const struct btf *btf, __u32 id, in dump_btf_type()
130 jsonw_string_field(w, "name", btf_str(btf, t->name_off)); in dump_btf_type()
133 btf_str(btf, t->name_off)); in dump_btf_type()
194 const char *name = btf_str(btf, in dump_btf_type()
107 btf_str(const struct btf * btf,__u32 off) btf_str() argument
119 dump_btf_type(const struct btf * btf,__u32 id,const struct btf_type * t) dump_btf_type() argument
435 dump_btf_raw(const struct btf * btf,__u32 * root_type_ids,int root_type_cnt) dump_btf_raw() argument
504 struct btf *btf = ctx; cmp_kfuncs() local
512 dump_btf_kfuncs(struct btf_dump * d,const struct btf * btf) dump_btf_kfuncs() argument
589 btf_type_rank(const struct btf * btf,__u32 index,bool has_name) btf_type_rank() argument
629 btf_type_sort_name(const struct btf * btf,__u32 index,bool from_ref) btf_type_sort_name() argument
666 btf_name_hasher(__u64 hash,const struct btf * btf,__u32 name_off) btf_name_hasher() argument
674 btf_type_disambig_hash(const struct btf * btf,__u32 id,bool include_members) btf_type_disambig_hash() argument
745 sort_btf_c(const struct btf * btf) sort_btf_c() argument
771 dump_btf_c(const struct btf * btf,__u32 * root_type_ids,int root_type_cnt,bool sort_dump) dump_btf_c() argument
884 struct btf *btf = NULL, *base = NULL; do_dump() local
[all...]
H A Dxlated_dumper.c230 struct btf *btf = dd->btf; in dump_xlated_json() local
247 if (btf && record) { in dump_xlated_json()
249 btf_dumper_type_only(btf, record->type_id, in dump_xlated_json()
265 btf_dump_linfo_json(btf, linfo, linum); in dump_xlated_json()
315 struct btf *btf = dd->btf; in dump_xlated_plain() local
328 if (btf in dump_xlated_plain()
383 struct btf *btf = dd->btf; dump_xlated_for_graph() local
[all...]
/linux/tools/bpf/resolve_btfids/
H A Dmain.c127 struct btf *btf; member
128 struct btf *base_btf;
165 struct btf *btf; member
583 struct btf *base_btf = NULL, *btf = NULL; in load_btf() local
596 btf = btf__parse_split(obj->btf_path ?: obj->path, base_btf); in load_btf()
597 err = libbpf_get_error(btf); in load_btf()
605 obj->btf = btf; in load_btf()
611 btf__free(btf); in load_btf()
613 obj->btf = NULL; in load_btf()
623 struct btf *btf = obj->btf; in symbols_resolve() local
[all …]
/linux/tools/testing/selftests/bpf/
H A Dbtf_helpers.h9 int fprintf_btf_type_raw(FILE *out, const struct btf *btf, __u32 id);
10 const char *btf_type_raw_dump(const struct btf *btf, int type_id);
11 int btf_validate_raw(struct btf *btf, int nr_types, const char *exp_types[]);
13 #define VALIDATE_RAW_BTF(btf, raw_types...) \ argument
14 btf_validate_raw(btf, \
18 const char *btf_type_c_dump(const struct btf *btf);
H A Dbtf_helpers.c81 static const char *btf_str(const struct btf *btf, __u32 off) in btf_str() argument
85 return btf__str_by_offset(btf, off) ?: "(invalid)"; in btf_str()
88 int fprintf_btf_type_raw(FILE *out, const struct btf *btf, __u32 id) in fprintf_btf_type_raw() argument
94 t = btf__type_by_id(btf, id); in fprintf_btf_type_raw()
101 fprintf(out, "[%u] %s '%s'", id, btf_kind_str(kind), btf_str(btf, t->name_off)); in fprintf_btf_type_raw()
135 btf_str(btf, m->name_off), m->type, bit_off); in fprintf_btf_type_raw()
150 btf_str(btf, v->name_off), v->val); in fprintf_btf_type_raw()
164 btf_str(btf, v->name_off), in fprintf_btf_type_raw()
181 btf_str(btf, p->name_off), p->type); in fprintf_btf_type_raw()
216 const char *btf_type_raw_dump(const struct btf *btf, int type_id) in btf_type_raw_dump() argument
[all …]
/linux/tools/perf/util/
H A Dbpf-event.c9 #include <bpf/btf.h>
12 #include <linux/btf.h>
92 * Do not free bpf_prog_info and btf of the program here, in machine__process_bpf()
106 struct btf *btf) in perf_env__fetch_btf() argument
112 data = btf__raw_data(btf, &data_size); in perf_env__fetch_btf()
132 struct btf *btf, in synthesize_bpf_prog_name() argument
146 if (btf) { in synthesize_bpf_prog_name()
148 t = btf__type_by_id(btf, finf in synthesize_bpf_prog_name()
176 struct btf *btf; global() member
189 struct btf *btf; bpf_metadata_read_map_data() local
279 format_btf_variable(struct btf * btf,char * buf,size_t buf_size,const struct btf_type * t,const void * btf_data) format_btf_variable() argument
542 struct btf *btf = NULL; perf_event__synthesize_one_bpf_prog() local
838 struct btf *btf = NULL; perf_env__add_bpf_info() local
953 struct btf *btf = NULL; __bpf_event__print_bpf_prog_info() local
[all...]
/linux/kernel/bpf/preload/iterators/
H A Diterators.bpf.c34 struct btf { struct
46 struct btf *btf; argument
59 static const char *get_name(struct btf *btf, long btf_id, const char *fallback) in get_name() argument
65 if (!btf) in get_name()
67 str = btf->strings; in get_name()
68 types = btf->types; in get_name()
71 if (name_off >= btf->hdr.str_len) in get_name()
114 get_name(aux->btf, aux->func_info[0].type_id, aux->name), in dump_bpf_prog()
/linux/tools/bpf/bpftool/Documentation/
H A Dbpftool-btf.rst4 bpftool-btf
17 **bpftool** [*OPTIONS*] **btf** *COMMAND*
19 *OPTIONS* := { |COMMON_OPTIONS| | { **-B** | **--base-btf** } }
26 | **bpftool** **btf** { **show** | **list** } [**id** *BTF_ID*]
27 | **bpftool** **btf dump** *BTF_SRC* [**format** *FORMAT*] [**root_id** *ROOT_ID*]
28 | **bpftool** **btf help**
37 bpftool btf { show | list } [id *BTF_ID*]
46 bpftool btf dump *BTF_SRC* [format *FORMAT*] [root_id *ROOT_ID*]
62 ``/sys/kernel/btf/``) is expected. Multiple **file** arguments may be
78 bpftool btf hel
[all...]

12345