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

Nick Alcock nick.alcock at oracle.com
Wed Feb 28 22:18:22 UTC 2024


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>
---
 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




More information about the DTrace-devel mailing list