[DTrace-devel] [PATCH v3] dtrace provider: add a predicate against the current tgid
Eugene Loh
eugene.loh at oracle.com
Thu Feb 29 20:57:30 UTC 2024
On 2/29/24 15:16, Eugene Loh wrote:
> On 2/29/24 14:47, Nick Alcock wrote:
>
>> On 29 Feb 2024, Kris Van Hees verbalised:
>>
>>> On Thu, Feb 29, 2024 at 05:42:30PM +0000, Nick Alcock via
>>> DTrace-devel wrote:
>>>> Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
>>> Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>
>> This commit induces a failure of
>> test/unittest/dtrace-util/tst.DisOption.sh, but this test is testing an
>> undocumented option, is carrying out transformations with awk etc on it,
>> that are uncommented and entirely opaque to me (it seems to be splitting
>> things up then diffing the original against the split-up pieces and
>> expecting it to work?), and honestly I think Eugene can probably fix it
>> in seconds. I don't have any idea what it's trying to verify. A comment
>> or two might be a good idea.
>
> I'll add some comments.
>
> Anyhow, it's trying to confirm that the option values dump the
> appropriate phases. So it runs a few times for different phases and
> checks for consistency.
>
> One question: will the disasm output be the same from run to run?
> BOOTTM will change, so the test filters that out.
>
> With this patch, the tgid value in the predicate also changes. So
> that should also be filtered.
>
> Proposed fix coming up next.
I'm attaching a diff you can add to this patch.
-------------- next part --------------
diff --git a/test/unittest/dtrace-util/tst.DisOption.sh b/test/unittest/dtrace-util/tst.DisOption.sh
index 1ad3f35f..c1d627e8 100755
--- a/test/unittest/dtrace-util/tst.DisOption.sh
+++ b/test/unittest/dtrace-util/tst.DisOption.sh
@@ -1,13 +1,37 @@
#!/bin/bash
#
# Oracle Linux DTrace.
-# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2022, 2024, 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.
#
# ASSERTION: That the dtrace -xdisasm option can control the listings.
+# We create simple D scripts (as well as their expected output).
+#
+# We run with different settings of -xdisasm:
+#
+# # default
+# -xdisasm=1 # listing mode 0
+# -xdisasm=2 # listing mode 1
+# -xdisasm=4 # listing mode 2
+# -xdisasm=8 # listing mode 3
+# -xdisasm=15 # all
+#
+# We sanity check stdout and stderr.
+#
+# We check that the default is equivalent to -xdisasm=1.
+#
+# We split the -xdisasm=15 output into different pieces, and check
+# that the pieces correspond to the -xdisasm=1, 2, 4, and 8 output.
+#
+# One problem is that, since the checks are between different invocations
+# of dtrace, some of the output may change -- specifically:
+# * the BOOTTM value
+# * the tgid value that the predicate checks
+# So, we filter those run-dependent items out.
+
dtrace=$1
DIRNAME="$tmpdir/DisOption.$$.$RANDOM"
@@ -36,13 +60,14 @@ EOF
# run dtrace for various xdisasm settings
function run_dtrace() {
- $dtrace $dt_flags $2 -Sq -s D1.d -s D2.d > $1.out 2> $1.tmp
+ $dtrace $dt_flags $2 -Sq -s D1.d -s D2.d > $1.out 2> $1.err
if [ $? -ne 0 ]; then
echo DTrace failed $2
cat $1.out $1.err
exit 1
fi
- # Avoid differenced due to different BOOTTM values.
+
+ # Avoid differences due to different BOOTTM values.
awk '/: 18 [0-9] 0 / && /lddw/ {
sub(/0x[0-9a-f]+/, 0x0);
sub(/[0-9a-f]{8}/, "00000000");
@@ -58,7 +83,17 @@ function run_dtrace() {
print;
next;
}
- { print; }' $1.tmp > $1.err
+ { print; }' $1.err > $1.tmp
+ mv $1.tmp $1.err
+
+ # Avoid differences due to different tgid values in predicates.
+ # If we see bpf_get_current_pid_tgid, omit the 3rd line if it's
+ # "jne %r0, ..." since the check value will change from run to run.
+ awk '/call bpf_get_current_pid_tgid/ { ncount = 0 }
+ { ncount++ }
+ ncount == 3 && /^[ :0-9a-f]* jne *%r0, / { next }
+ { print; }' $1.err > $1.tmp
+ mv $1.tmp $1.err
}
run_dtrace def # default
@@ -68,7 +103,7 @@ run_dtrace 2 -xdisasm=4 # listing mode 2
run_dtrace 3 -xdisasm=8 # listing mode 3
run_dtrace all -xdisasm=15 # all
-# check individual D stdout and stderr files
+# sanity check individual D stdout and stderr files
for x in def 0 1 2 3 all; do
if [ `cat $x.err | wc -l` -lt 10 ]; then
More information about the DTrace-devel
mailing list