On Tue, Aug 04, 2020 at 11:24:07AM -0700, Andrii Nakryiko wrote:
> +
> +SEC("raw_tracepoint/sys_enter")
> +int test_core_type_id(void *ctx)
> +{
> +     struct core_reloc_type_id_output *out = (void *)&data.out;
> +
> +     out->local_anon_struct = bpf_core_type_id_local(struct { int 
> marker_field; });
> +     out->local_anon_union = bpf_core_type_id_local(union { int 
> marker_field; });
> +     out->local_anon_enum = bpf_core_type_id_local(enum { MARKER_ENUM_VAL = 
> 123 });
> +     out->local_anon_func_proto_ptr = bpf_core_type_id_local(_Bool(*)(int));
> +     out->local_anon_void_ptr = bpf_core_type_id_local(void *);
> +     out->local_anon_arr = bpf_core_type_id_local(_Bool[47]);
> +
> +     out->local_struct = bpf_core_type_id_local(struct a_struct);
> +     out->local_union = bpf_core_type_id_local(union a_union);
> +     out->local_enum = bpf_core_type_id_local(enum an_enum);
> +     out->local_int = bpf_core_type_id_local(int);
> +     out->local_struct_typedef = 
> bpf_core_type_id_local(named_struct_typedef);
> +     out->local_func_proto_typedef = 
> bpf_core_type_id_local(func_proto_typedef);
> +     out->local_arr_typedef = bpf_core_type_id_local(arr_typedef);
> +
> +     out->targ_struct = bpf_core_type_id_kernel(struct a_struct);
> +     out->targ_union = bpf_core_type_id_kernel(union a_union);
> +     out->targ_enum = bpf_core_type_id_kernel(enum an_enum);
> +     out->targ_int = bpf_core_type_id_kernel(int);
> +     out->targ_struct_typedef = 
> bpf_core_type_id_kernel(named_struct_typedef);
> +     out->targ_func_proto_typedef = 
> bpf_core_type_id_kernel(func_proto_typedef);
> +     out->targ_arr_typedef = bpf_core_type_id_kernel(arr_typedef);

bpf_core_type_id_kernel() returns btf_id of the type in vmlinux BTF or zero,
so what is the point of above tests? All targ_* will be zero.
Should the test find a type that actually exists in the kernel?
What am I missing?

Reply via email to