/tools/testing/selftests/bpf/prog_tests/ |
D | linked_list.c | 237 static struct btf *init_btf(void) in init_btf() 240 struct btf *btf; in init_btf() local 242 btf = btf__new_empty(); in init_btf() 243 if (!ASSERT_OK_PTR(btf, "btf__new_empty")) in init_btf() 245 id = btf__add_int(btf, "int", 4, BTF_INT_SIGNED); in init_btf() 248 lid = btf__add_struct(btf, "bpf_spin_lock", 4); in init_btf() 251 hid = btf__add_struct(btf, "bpf_list_head", 16); in init_btf() 254 nid = btf__add_struct(btf, "bpf_list_node", 24); in init_btf() 257 return btf; in init_btf() 259 btf__free(btf); in init_btf() [all …]
|
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 …]
|
D | btf_dump.c | 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() 60 btf = NULL; in test_btf_dump_case() 70 btf__set_pointer_size(btf, 8); in test_btf_dump_case() 72 CHECK(btf__pointer_size(btf) != 8, "ptr_sz", "exp %d, got %zu\n", in test_btf_dump_case() [all …]
|
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 …]
|
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() 42 btf__free(btf); in test_libbpf_probe_prog_types() 47 struct btf *btf; in test_libbpf_probe_map_types() local 52 btf = btf__parse("/sys/kernel/btf/vmlinux", NULL); in test_libbpf_probe_map_types() 53 if (!ASSERT_OK_PTR(btf, "btf_parse")) in test_libbpf_probe_map_types() [all …]
|
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 …]
|
D | btf_dedup_split.c | 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, "a", ID(3), 0, 0); /* struct anon a; */ in btf_add_dup_struct_in_cu() 341 btf__add_field(btf, "b", ID(4), 0, 0); /* struct anon b; */ in btf_add_dup_struct_in_cu() 344 btf__add_struct(btf, "(anon)", 8); /* [3] struct anon { */ in btf_add_dup_struct_in_cu() [all …]
|
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 …]
|
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()
|
D | test_bpf_ma.c | 15 struct btf *btf; in test_test_bpf_ma() local 22 btf = bpf_object__btf(skel->obj); in test_test_bpf_ma() 23 if (!ASSERT_OK_PTR(btf, "btf")) in test_test_bpf_ma() 31 id = btf__find_by_name_kind(btf, name, BTF_KIND_STRUCT); in test_test_bpf_ma()
|
D | ctx_rewrite.c | 249 static int find_field_offset_aux(struct btf *btf, int btf_id, char *field_name, int off) in find_field_offset_aux() argument 251 const struct btf_type *type = btf__type_by_id(btf, btf_id); in find_field_offset_aux() 270 const char *mname = btf__name_by_offset(btf, m->name_off); in find_field_offset_aux() 273 int msize = find_field_offset_aux(btf, m->type, field_name, in find_field_offset_aux() 288 static int find_field_offset(struct btf *btf, char *pattern, regmatch_t *matches) in find_field_offset() argument 310 btf_id = btf__find_by_name(btf, type_str); in find_field_offset() 316 field_offset = find_field_offset_aux(btf, btf_id, field_str, 0); in find_field_offset() 487 static bool match_pattern(struct btf *btf, char *pattern, char *text, char *reg_map[][2]) in match_pattern() argument 558 field_offset = find_field_offset(btf, pattern, matches); in match_pattern() 584 field_offset = find_field_offset(btf, pattern, matches); in match_pattern() [all …]
|
/tools/lib/bpf/ |
D | btf.h | 23 struct btf; 38 LIBBPF_API void btf__free(struct btf *btf); 54 LIBBPF_API struct btf *btf__new(const void *data, __u32 size); 76 LIBBPF_API struct btf *btf__new_split(const void *data, __u32 size, struct btf *base_btf); 90 LIBBPF_API struct btf *btf__new_empty(void); 108 LIBBPF_API struct btf *btf__new_empty_split(struct btf *base_btf); 110 LIBBPF_API struct btf *btf__parse(const char *path, struct btf_ext **btf_ext); 111 LIBBPF_API struct btf *btf__parse_split(const char *path, struct btf *base_btf); 112 LIBBPF_API struct btf *btf__parse_elf(const char *path, struct btf_ext **btf_ext); 113 LIBBPF_API struct btf *btf__parse_elf_split(const char *path, struct btf *base_btf); [all …]
|
D | btf.c | 31 struct btf { struct 97 struct btf *base_btf; argument 192 static void *btf_add_type_offs_mem(struct btf *btf, size_t add_cnt) in btf_add_type_offs_mem() argument 194 return libbpf_add_mem((void **)&btf->type_offs, &btf->type_offs_cap, sizeof(__u32), in btf_add_type_offs_mem() 195 btf->nr_types, BTF_MAX_NR_TYPES, add_cnt); in btf_add_type_offs_mem() 198 static int btf_add_type_idx_entry(struct btf *btf, __u32 type_off) in btf_add_type_idx_entry() argument 202 p = btf_add_type_offs_mem(btf, 1); in btf_add_type_idx_entry() 220 static int btf_parse_hdr(struct btf *btf) in btf_parse_hdr() argument 222 struct btf_header *hdr = btf->hdr; in btf_parse_hdr() 225 if (btf->raw_size < sizeof(struct btf_header)) { in btf_parse_hdr() [all …]
|
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,
|
D | relo_core.c | 22 skip_mods_and_typedefs(const struct btf *btf, u32 id, u32 *res_id) in skip_mods_and_typedefs() argument 24 return btf_type_skip_modifiers(btf, id, res_id); in skip_mods_and_typedefs() 27 static const char *btf__name_by_offset(const struct btf *btf, u32 offset) in btf__name_by_offset() argument 29 return btf_name_by_offset(btf, offset); in btf__name_by_offset() 32 static s64 btf__resolve_size(const struct btf *btf, u32 type_id) in btf__resolve_size() argument 37 t = btf_type_by_id(btf, type_id); in btf__resolve_size() 38 t = btf_resolve_size(btf, t, &size); in btf__resolve_size() 71 static bool is_flex_arr(const struct btf *btf, in is_flex_arr() argument 82 t = btf_type_by_id(btf, acc->type_id); in is_flex_arr() 146 int __bpf_core_types_are_compat(const struct btf *local_btf, __u32 local_id, in __bpf_core_types_are_compat() [all …]
|
D | libbpf_legacy.h | 125 struct btf; 128 LIBBPF_API struct btf *libbpf_find_kernel_btf(void); 133 LIBBPF_API const void *btf__get_raw_data(const struct btf *btf, __u32 *size);
|
/tools/testing/selftests/bpf/ |
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);
|
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 …]
|
/tools/bpf/bpftool/ |
D | btf_dumper.c | 27 static int btf_dump_func(const struct btf *btf, char *func_sig, 40 struct btf *prog_btf = NULL; in dump_prog_id_as_func_ptr() 47 func_sig_len = btf_dump_func(d->btf, prog_str, func_proto, NULL, 0, in dump_prog_id_as_func_ptr() 118 ptr_type_id = btf__resolve_type(d->btf, t->type); in btf_dumper_ptr() 121 ptr_type = btf__type_by_id(d->btf, ptr_type_id); in btf_dumper_ptr() 140 actual_type_id = btf__resolve_type(d->btf, type_id); in btf_dumper_modifier() 175 btf__name_by_offset(d->btf, in btf_dumper_enum() 201 btf__name_by_offset(d->btf, in btf_dumper_enum64() 211 static bool is_str_array(const struct btf *btf, const struct btf_array *arr, in is_str_array() argument 220 elem_type = btf__type_by_id(btf, arr->type); in is_str_array() [all …]
|
D | gen.c | 125 struct btf *btf, in codegen_datasec_def() argument 130 const char *sec_name = btf__name_by_offset(btf, sec->name_off); in codegen_datasec_def() 144 const struct btf_type *var = btf__type_by_id(btf, sec_var->type); in codegen_datasec_def() 145 const char *var_name = btf__name_by_offset(btf, var->name_off); in codegen_datasec_def() 164 align = btf__align_of(btf, var->type); in codegen_datasec_def() 212 static const struct btf_type *find_type_for_map(struct btf *btf, const char *map_ident) in find_type_for_map() argument 214 int n = btf__type_cnt(btf), i; in find_type_for_map() 218 const struct btf_type *t = btf__type_by_id(btf, i); in find_type_for_map() 224 name = btf__str_by_offset(btf, t->name_off); in find_type_for_map() 247 struct btf *btf = bpf_object__btf(obj); in codegen_datasecs() local [all …]
|
D | main.h | 85 extern struct btf *base_btf; 112 struct btf; 179 const struct btf *btf, 188 const struct btf *btf, in disasm_print_insn() argument 210 const struct btf *btf; member 225 void btf_dumper_type_only(const struct btf *btf, __u32 func_type_id, 228 void btf_dump_linfo_plain(const struct btf *btf, 231 void btf_dump_linfo_json(const struct btf *btf, 233 void btf_dump_linfo_dotlabel(const struct btf *btf,
|
D | btf.c | 90 static const char *btf_str(const struct btf *btf, __u32 off) in btf_str() argument 94 return btf__name_by_offset(btf, off) ? : "(invalid)"; in btf_str() 102 static int dump_btf_type(const struct btf *btf, __u32 id, in dump_btf_type() argument 112 jsonw_string_field(w, "name", btf_str(btf, t->name_off)); in dump_btf_type() 115 btf_str(btf, t->name_off)); in dump_btf_type() 176 const char *name = btf_str(btf, m->name_off); in dump_btf_type() 225 const char *name = btf_str(btf, v->name_off); in dump_btf_type() 263 const char *name = btf_str(btf, v->name_off); in dump_btf_type() 322 const char *name = btf_str(btf, p->name_off); in dump_btf_type() 376 if (v->type < btf__type_cnt(btf)) { in dump_btf_type() [all …]
|
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 && record) { in dump_xlated_plain() 330 btf_dumper_type_only(btf, record->type_id, in dump_xlated_plain() 344 btf_dump_linfo_plain(btf, linfo, "; ", in dump_xlated_plain() 383 struct btf *btf = dd->btf; in dump_xlated_for_graph() local 397 if (btf && record) { in dump_xlated_for_graph() [all …]
|
/tools/bpf/bpftool/Documentation/ |
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*] 28 | **bpftool** **btf help** 37 **bpftool btf { show | list }** [**id** *BTF_ID*] 48 **bpftool btf dump** *BTF_SRC* 73 **bpftool btf help** 80 -B, --base-btf *FILE* [all …]
|
/tools/perf/util/ |
D | bpf-event.c | 97 struct btf *btf) in perf_env__fetch_btf() argument 103 data = btf__raw_data(btf, &data_size); in perf_env__fetch_btf() 123 struct btf *btf, in synthesize_bpf_prog_name() argument 137 if (btf) { in synthesize_bpf_prog_name() 139 t = btf__type_by_id(btf, finfo->type_id); in synthesize_bpf_prog_name() 140 short_name = btf__name_by_offset(btf, t->name_off); in synthesize_bpf_prog_name() 176 struct btf *btf = NULL; in perf_event__synthesize_one_bpf_prog() local 231 btf = btf__load_from_kernel_by_id(info->btf_id); in perf_event__synthesize_one_bpf_prog() 232 if (libbpf_get_error(btf)) { in perf_event__synthesize_one_bpf_prog() 237 perf_env__fetch_btf(env, info->btf_id, btf); in perf_event__synthesize_one_bpf_prog() [all …]
|