public inbox for dtrace@lists.linux.dev
 help / color / mirror / Atom feed
From: Eugene Loh <eugene.loh@oracle.com>
To: Kris Van Hees <kris.van.hees@oracle.com>,
	dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: Re: [PATCH 2/3] test: make tst.dash.sh work for position-independent code
Date: Mon, 9 Feb 2026 18:52:38 -0500	[thread overview]
Message-ID: <52a0dd3c-d946-ffa0-dd79-44aeeca99d16@oracle.com> (raw)
In-Reply-To: <DS0PR10MB75221E0927D3E1E80DCE5EDCC265A@DS0PR10MB7522.namprd10.prod.outlook.com>

Reviewed-by: Eugene Loh <eugene.loh@oracle.com>
though if you wanted to get rid of the two commented out lines ("Write 
the expected output to the compare file.") that would also be fine by me.

On 2/9/26 15:43, Kris Van Hees wrote:
> When code is compiled as position-independent code, the logic for
> comparing the reported PC at probe firing needs to adjust for the
> fact that the reported addresses are absolute whereas the addresses
> obtained from the executable are relative to the mapping base
>
> Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
> ---
>   test/unittest/pid/tst.dash.sh | 20 ++++++++++++++++----
>   1 file changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/test/unittest/pid/tst.dash.sh b/test/unittest/pid/tst.dash.sh
> index 0289b609..d793e081 100755
> --- a/test/unittest/pid/tst.dash.sh
> +++ b/test/unittest/pid/tst.dash.sh
> @@ -1,7 +1,7 @@
>   #!/bin/bash
>   #
>   # Oracle Linux DTrace.
> -# Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
> +# Copyright (c) 2025, 2026, 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.
>   #
> @@ -16,6 +16,8 @@ cd $DIRNAME
>   # Make trigger program.
>   
>   cat << EOF > main.c
> +#include <stdio.h>
> +
>   int foo0(int i) {
>       int j, k;
>   
> @@ -46,6 +48,10 @@ int foo2(int i) {
>   int main(int c, char **v) {
>       int i = 0;
>   
> +    printf("foo0 %p\n"
> +	   "foo1 %p\n"
> +	   "foo2 %p\n"
> +	   "main %p\n", &foo0, &foo1, &foo2, &main);
>       i = foo0(i) ^ i;
>       i = foo1(i) ^ i;
>       i = foo2(i) ^ i;
> @@ -85,8 +91,8 @@ for func in foo0 foo1 foo2 main; do
>   	  }'`
>   
>   	# Write the expected output to the compare file.
> -	echo got $ABS $func:$REL >> dtrace.exp
> -	echo got $ABS "-":$ABS   >> dtrace.exp
> +#	echo got $ABS $func:$REL >> dtrace.exp
> +#	echo got $ABS "-":$ABS   >> dtrace.exp
>   
>   	# Write the actual dtrace output to the output file.
>   	# Specify the pid probe with both relative and absolute
> @@ -95,12 +101,18 @@ for func in foo0 foo1 foo2 main; do
>   		$dtrace -c ./a.out -o dtrace.out -qn '
>   		    pid$target:a.out:'$probe'
>   		    { printf("got %x %s:%s", uregs[R_PC], probefunc,
> -							  probename); }'
> +							  probename); }' > addrs
>   		if [ $? -ne 0 ]; then
>   			echo ERROR: dtrace
>   			cat dtrace.out
>   			exit 1
>   		fi
> +
> +		awk -vfn="$func" -vrel="$REL" -vprobe="$probe" \
> +		    '$1 == fn {
> +			addr = strtonum($2) + int(rel);
> +			printf "got %x %s\n", addr, probe;
> +		     }' addrs >> dtrace.exp
>   	done
>   done
>   

      reply	other threads:[~2026-02-09 23:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-09 20:43 [PATCH 2/3] test: make tst.dash.sh work for position-independent code Kris Van Hees
2026-02-09 23:52 ` Eugene Loh [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52a0dd3c-d946-ffa0-dd79-44aeeca99d16@oracle.com \
    --to=eugene.loh@oracle.com \
    --cc=dtrace-devel@oss.oracle.com \
    --cc=dtrace@lists.linux.dev \
    --cc=kris.van.hees@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox