[DTrace-devel] [PATCH 1/3] test: skip a test when CTF is built with dwarf2ctf

Kris Van Hees kris.van.hees at oracle.com
Thu Feb 29 18:20:07 UTC 2024


On Wed, Feb 28, 2024 at 10:18:22PM +0000, Nick Alcock via DTrace-devel wrote:
> Bitfields are somewhat broken in dwarf2ctf and unlikely ever to be fixed, so
> skip a test that checks if they work.  This requires detecting, not whether
> DTrace was built with libctf, but whether the CTF was built with the
> toolchain CTF machinery.
> 
> We can reliably detect this by checking the CTF version number: 3
> (CTF_VERSION_2) is libdtrace-ctf 1.0 / dwarf2ctf, while all versions of
> binutils CTF in anything like current use are CTF_VERSION_3.  (Unreleased
> versions of libdtrace-ctf can emit CTF_VERSION_3, but this is not in use to
> build kernels anywhere I know of.)
> 
> Signed-off-by: Nick Alcock <nick.alcock at oracle.com>

Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>

> ---
>  test/unittest/bitfields/tst.bitfield-offset.x | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>  create mode 100755 test/unittest/bitfields/tst.bitfield-offset.x
> 
> diff --git a/test/unittest/bitfields/tst.bitfield-offset.x b/test/unittest/bitfields/tst.bitfield-offset.x
> new file mode 100755
> index 0000000000000..316c54a0d08f9
> --- /dev/null
> +++ b/test/unittest/bitfields/tst.bitfield-offset.x
> @@ -0,0 +1,17 @@
> +#!/bin/sh
> +# Licensed under the Universal Permissive License v 1.0 as shown at
> +# http://oss.oracle.com/licenses/upl.
> +#
> +# This is expected to fail on systems where the CTF was built
> +# with dwarf2ctf.  We can determine this with nothing more than
> +# objdump, because the CTF version number differs.
> +#
> +# Alas objdump cannot read vmlinux.ctfa of this vintage on its
> +# own: we must embed it into an ELF file ourselves.
> +
> +ctfa=$tmpdir/vmlinux.ctfa
> +trap "rm -f $ctfa" EXIT ERR
> +
> +objcopy --add-section=.ctf=/lib/modules/$(uname -r)/kernel/vmlinux.ctfa /bin/true $ctfa
> +objdump --ctf=.ctf --ctf-parent=shared_ctf $ctfa |\
> +    awk '/Version: 3/ { exit 1; } /Version: / { exit 0; }'
> -- 
> 2.43.0.272.gce700b77fd
> 
> 
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel



More information about the DTrace-devel mailing list