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

Nick Alcock nick.alcock at oracle.com
Fri Nov 10 21:29:33 UTC 2023


On 10 Nov 2023, Alan Maguire via DTrace-devel said:

> On 08/11/2023 17:45, Kris Van Hees via DTrace-devel wrote:
>> 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>
>
> just tested this on an upstream bpf-next kernel, works beautifully:
>
> # /usr/sbin/dtrace -n 'fbt::ip_rcv_core:entry { printf("%s\n",
> stringof(((struct sk_buff *)arg0)->dev)); }'
> dtrace: description 'fbt::ip_rcv_core:entry ' matched 1 probe
> CPU     ID                    FUNCTION:NAME
>   0  80242                ip_rcv_core:entry wlo1
>
>   3  80242                ip_rcv_core:entry cscotun0
>
>
> Great stuff!

Agreed! I was squeeing all the way through.

Note that this does *not* obviate CTF: BTF appears to have no way to
represent the types of static-scope variables that I can see (not
surprising: they were copying Solaris-era CTF and this is a feature I
added later), and even if it did CTF also has a pile of potential
applications in userspace, where BTF is simply inapplicable (more later
once they are less embryonic!).

BTF also can't encode conflicting types -- it seems to deal with it as
well as dwarf2ctf did, which is to say it assumes they can't happen and
if they do it picks the first it sees. This means types can easily
connect to definitions of other types where the two might well not have
been mutually visible in any translation unit at all.

One thing this *does* provide that I might well look at is two-way
cross-checking: we can check if the BTF and CTF encode the same types,
and complain if they do not (and no conflicts are involved etc etc).
At least in theory :) that would probably require splitting the BTF->CTF
thing into a library or exposing its libdtrace implementation in
libdtrace's API or something though. Or just copying the code :)

-- 
NULL && (void)



More information about the DTrace-devel mailing list