| /linux/tools/testing/selftests/bpf/prog_tests/ |
| H A D | linked_list.c | 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_head", 16); in init_btf() 267 nid = btf__add_struct(btf, "bpf_list_node", 24); in init_btf() 270 return btf; in init_btf() 272 btf__free(btf); in init_btf() [all …]
|
| H A D | btf_write.c | 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, 1), in gen_btf() 42 id = btf__add_int(btf, "bad sz int", 7, 0); in gen_btf() 45 id = btf__add_int(btf, "bad enc int", 4, 123); in gen_btf() [all …]
|
| H A D | btf_dump.c | 3 #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 D | btf_field_iter.c | 43 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 D | libbpf_str.c | 23 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 D | libbpf_probes.c | 9 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 D | test_global_funcs.c | 26 static void check_ctx_arg_type(const struct btf *btf, const struct btf_param *p) in check_ctx_arg_type() argument 31 t = btf__type_by_id(btf, p->type); in check_ctx_arg_type() 35 s = btf_type_raw_dump(btf, t->type); in check_ctx_arg_type() 47 struct btf *btf = NULL; in subtest_ctx_arg_rewrite() local 50 struct btf *kern_btf = NULL; in subtest_ctx_arg_rewrite() 87 btf = btf__load_from_kernel_by_id(info.btf_id); in subtest_ctx_arg_rewrite() 88 if (!ASSERT_OK_PTR(btf, "obj_kern_btf")) in subtest_ctx_arg_rewrite() 99 fn_t = btf__type_by_id(btf, rec->type_id); in subtest_ctx_arg_rewrite() 104 proto_t = btf__type_by_id(btf, fn_t->type); in subtest_ctx_arg_rewrite() 108 name = btf__name_by_offset(btf, fn_t->name_off); in subtest_ctx_arg_rewrite() [all …]
|
| H A D | btf_endian.c | 18 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 D | core_autosize.c | 60 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 D | btf_dedup_split.c | 4 #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 D | resolve_btfids.c | 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_elf("btf_data.bpf.o", NULL); in resolve_symbols() 105 if (CHECK(libbpf_get_error(btf), "resolve", in resolve_symbols() 109 nr = btf__type_cnt(btf); in resolve_symbols() 112 if (__resolve_symbol(btf, type_id)) in resolve_symbols() 116 btf__free(btf); in resolve_symbols()
|
| H A D | ctx_rewrite.c | 252 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 313 btf_id = btf__find_by_name(btf, type_str); in find_field_offset() 319 field_offset = find_field_offset_aux(btf, btf_id, field_str, 0); in find_field_offset() 490 static bool match_pattern(struct btf *btf, char *pattern, char *text, char *reg_map[][2]) in match_pattern() argument 561 field_offset = find_field_offset(btf, pattern, matches); in match_pattern() 587 field_offset = find_field_offset(btf, pattern, matches); in match_pattern() [all …]
|
| H A D | test_bpf_ma.c | 16 struct btf *btf; in do_bpf_ma_test() local 24 btf = bpf_object__btf(skel->obj); in do_bpf_ma_test() 25 if (!ASSERT_OK_PTR(btf, "btf")) in do_bpf_ma_test() 30 id = btf__find_by_name_kind(btf, tname, BTF_KIND_STRUCT); in do_bpf_ma_test() 38 id = btf__find_by_name_kind(btf, tname, BTF_KIND_STRUCT); in do_bpf_ma_test()
|
| /linux/tools/lib/bpf/ |
| H A D | btf.h | 10 #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 D | relo_core.h | 10 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 D | btf_relocate.c | 36 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/tools/bpf/bpftool/ |
| H A D | btf.c | 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() [all …]
|
| H A D | xlated_dumper.c | 230 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...] |
| H A D | map.c | 18 #include <bpf/btf.h> 133 unsigned char *value, struct btf *btf) in print_entry_json() argument 145 if (btf) { in print_entry_json() 147 .btf = btf, in print_entry_json() 178 if (btf) { in print_entry_json() 180 .btf = btf, in print_entry_json() 746 struct bpf_map_info *map_info, struct btf *bt in dump_map_elem() argument 793 get_map_kv_btf(const struct bpf_map_info * info,struct btf ** btf) get_map_kv_btf() argument 819 free_map_kv_btf(struct btf * btf) free_map_kv_btf() argument 831 struct btf *btf = NULL; map_dump() local 1038 struct btf *btf; print_key_value() local [all...] |
| /linux/tools/testing/selftests/bpf/ |
| H A D | btf_helpers.h | 9 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 D | btf_helpers.c | 81 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 D | bpf-event.c | 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, finfo->type_id); in synthesize_bpf_prog_name() 149 short_name = btf__name_by_offset(btf, t->name_off); in synthesize_bpf_prog_name() 176 struct btf *btf; member 189 struct btf *btf; in bpf_metadata_read_map_data() local 213 btf = btf__load_from_kernel_by_id(map_info.btf_id); in bpf_metadata_read_map_data() 214 if (!btf) in bpf_metadata_read_map_data() [all …]
|
| /linux/kernel/bpf/preload/iterators/ |
| H A D | iterators.bpf.c | 34 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 D | bpftool-btf.rst | 4 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*] 75 bpftool btf help 82 -B, --base-btf *FILE* [all …]
|
| /linux/kernel/trace/ |
| H A D | trace_btf.c | 13 const struct btf_type *btf_find_func_proto(const char *func_name, struct btf **btf_p) in btf_find_func_proto() 70 const struct btf_member *btf_find_struct_member(struct btf *btf, in btf_find_struct_member() argument 94 if (btf_type_skip_modifiers(btf, member->type, &tid) && in btf_find_struct_member() 101 name = btf_name_by_offset(btf, member->name_off); in btf_find_struct_member() 113 type = btf_type_by_id(btf, tid); in btf_find_struct_member()
|