[DTrace-devel] [PATCH v3] ctf: add BTF-to-CTF convertor

Nick Alcock nick.alcock at oracle.com
Wed Nov 8 19:48:44 UTC 2023


On 8 Nov 2023, Kris Van Hees via DTrace-devel outgrape:

> For kernels that do not provide CTF data, kernel type information can be
> obtained at runtime as BTF data.  We pull in that data and generate
> equivalent CTF data from it.
>
> Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
> Reviewed-by: Nick Alcock <nick.alcock at oracle.com>

Still not actually tested here, but...

> +		if (kind == BTF_KIND_STRUCT)
> +			ctfid = ctf_add_struct_sized(ctf, CTF_ADD_ROOT, name,
> +						     type->size);
> +		else
> +			ctfid = ctf_add_union_sized(ctf, CTF_ADD_ROOT, name,
> +						    type->size);

That's exactly the thing to do :)

(Note: if by some mischance the size is too low, ctf_add_member*() will
boost it so that it is always large enough to fit all the members in.
ctf_add_struct() is just the same as ctf_add_struct_sized(..., 0).
So you don't need to worry about that happening.)

-- 
NULL && (void)



More information about the DTrace-devel mailing list