[DTrace-devel] [PATCH v4 5/5] selftests/usdt: add test covering different forms of stapsdt note args
Kris Van Hees
kris.van.hees at oracle.com
Tue Jul 1 16:42:02 UTC 2025
This test does not pass on Debian, or any other system that compiles with
PIE enbaled by default as far as I can see because it fails to resolve the
function name (even though it is in the symbol table since that is not
stripped). So there must be something wrong with the logic of the
implementing patch to get the function name from the address information.
On Mon, Jun 23, 2025 at 11:13:10AM +0100, Alan Maguire wrote:
> Add a test exercising various arg types supported by stapsdt notes;
> register values, register + offset and constants. The test generates
> a binary with probes represented as follows on x86_64:
>
> Displaying notes found in: .note.stapsdt
> Owner Data size Description
> stapsdt 0x00000048 NT_STAPSDT (SystemTap probe descriptors)
> Provider: test_prov
> Name: args
> Location: 0x0000000000400557, Base: 0x00000000004005f8, Semaphore: 0x0000000000000000
> Arguments: -4 at -4(%rbp) 8@%rax 8@%rdx -4@$18
>
> Verify we get expected data for the probe arguments.
>
> Signed-off-by: Alan Maguire <alan.maguire at oracle.com>
> ---
> test/unittest/usdt/tst.stapsdt-notes-args.r | 2 +
> test/unittest/usdt/tst.stapsdt-notes-args.sh | 50 ++++++++++++++++++++
> 2 files changed, 52 insertions(+)
> create mode 100644 test/unittest/usdt/tst.stapsdt-notes-args.r
> create mode 100755 test/unittest/usdt/tst.stapsdt-notes-args.sh
>
> diff --git a/test/unittest/usdt/tst.stapsdt-notes-args.r b/test/unittest/usdt/tst.stapsdt-notes-args.r
> new file mode 100644
> index 00000000..42bca19f
> --- /dev/null
> +++ b/test/unittest/usdt/tst.stapsdt-notes-args.r
> @@ -0,0 +1,2 @@
> +test:main:args:2:./test:val:18
> +
> diff --git a/test/unittest/usdt/tst.stapsdt-notes-args.sh b/test/unittest/usdt/tst.stapsdt-notes-args.sh
> new file mode 100755
> index 00000000..82097808
> --- /dev/null
> +++ b/test/unittest/usdt/tst.stapsdt-notes-args.sh
> @@ -0,0 +1,50 @@
> +#!/bin/bash
> +#
> +# Oracle Linux DTrace.
> +# Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
> +# Licensed under the Universal Permissive License v 1.0 as shown at
> +# http://oss.oracle.com/licenses/upl.
> +
> +# This test covers stapsdt probes fired by the STAP_PROBEn macros,
> +# testing various argument forms (constant, register, deref etc).
> +
> +if [ $# != 1 ]; then
> + echo expected one argument: '<'dtrace-path'>'
> + exit 2
> +fi
> +
> +dtrace=$1
> +CC=/usr/bin/gcc
> +CFLAGS="-I${PWD}/test/unittest/usdt"
> +
> +DIRNAME="$tmpdir/usdt-notes.$$.$RANDOM"
> +mkdir -p $DIRNAME
> +cd $DIRNAME
> +
> +cat > test.c <<EOF
> +#include <sdt_notes.h>
> +
> +int
> +main(int argc, char **argv)
> +{
> + STAP_PROBE4(test_prov, args, argc, argv[0], argv[1] + 4, 18);
> +}
> +EOF
> +
> +${CC} ${CFLAGS} -o test test.c
> +if [ $? -ne 0 ]; then
> + echo "failed to compile test.c" >& 2
> + exit 1
> +fi
> +
> +$dtrace -c './test arg1val' -qs /dev/stdin <<EOF
> +test_prov\$target:::args
> +{
> + printf("%s:%s:%s:%li:%s:%s:%li\n", probemod, probefunc, probename,
> + arg0, copyinstr(arg1), copyinstr(arg2), arg3);
> +}
> +
> +EOF
> +status=$?
> +
> +exit $status
> --
> 2.43.5
>
More information about the DTrace-devel
mailing list