Libbpf userspace function btf_dump__dump_type
Dump BTF type in a compilable C syntax.
Definition
int btf_dump__dump_type(struct btf_dump *d, __u32 id);
Parameters
d
: pointer to astruct btf_dump
objectid
: BTF type ID to dump
Return
0
on success; <0
, otherwise.
Usage
Dump BTF type in a compilable C syntax, including all the necessary dependent types, necessary for compilation. If some of the dependent types were already emitted as part of previous btf_dump__dump_type
invocation for another type, they won't be emitted again. This API allows callers to filter out BTF types according to user-defined criteria and emitted only minimal subset of types, necessary to compile everything. Full struct/union definitions will still be emitted, even if the only usage is through pointer and could be satisfied with just a forward declaration.
Dumping is done in two high-level passes:
- Topologically sort type definitions to satisfy C rules of compilation.
- Emit type definitions in C syntax.
Example
Docs could be improved
This part of the docs is incomplete, contributions are very welcome