[DTrace-devel] [PATCH 04/10] Include PC in fault reporting

Eugene Loh eugene.loh at oracle.com
Sat Mar 19 22:13:41 UTC 2022


Reviewed-by: Eugene Loh <eugene.loh at oracle.com>
with

On 3/18/22 3:04 PM, Kris Van Hees via DTrace-devel wrote:
> diff --git a/runtest.sh b/runtest.sh
> @@ -482,7 +482,8 @@ postprocess()
>       # TODO: may need adjustment or making optional if scripts emit hex
>       # values which are not continuously variable.
>   
> -    sed '/^==[0-9][0-9]*== /!s,0x[0-9a-f][0-9a-f]*,{ptr},g' < $tmpdir/pp.out > $final
> +    sed -e '/^==[0-9][0-9]*== /!s,0x[0-9a-f][0-9a-f]*,{ptr},g' \
> +	-e 's,at BPF pc [1-9][0-9]*,at BPF pc NNN,' < $tmpdir/pp.out > $final
>   
>       return $retval
>   }
The comment block is just out of view, but maybe the remark about "hex 
strings" should be adjusted.
> diff --git a/test/unittest/error/tst.fault-location.sh b/test/unittest/error/tst.fault-location.sh
> @@ -0,0 +1,31 @@
> +#!/bin/bash
> +dtrace=$1
> +
> +$dtrace $dt_flags -xdisasm=8 -Sn '
> +BEGIN
> +{
> +	a = b = 0;
> +	trace(a / b);
> +	exit(0);
> +}
> +
> +ERROR
> +{
> +	exit(1);
> +}
> +' 2>&1 | \
> +	awk '/mov  %r3, [0-9]+/ { flt = int($10); next; }
> +	     /call dt_probe_error/ { loci[int($1)] = flt; next }
> +	     /divide-by-zero/ && (int($NF) in loci) && loci[int($NF)] == 4 {
> +		$NF = "NNN";
> +		print;
> +	     }'
> +
> +exit $?
The test is good, but for the awk post-processing, how about:

*)  Say why 4 is interesting.  Maybe a comment that points out that 
DTRACEFLT_DIVZERO = 4?

*)  And how about replacing the second two clauses with:
         /call dt_probe_error/ && flt == 4 { loci = int($1) }
         /divide-by-zero/ && int($NF) == loci) {...}
     This stores less stuff and makes clearer what interests us.



More information about the DTrace-devel mailing list