[DTrace-devel] [PATCH v2] Fix execution with -Z

eugene.loh at oracle.com eugene.loh at oracle.com
Fri Jun 18 00:55:12 PDT 2021


From: Eugene Loh <eugene.loh at oracle.com>

This fix addresses the case where a probe definition does not match any
probes.  Another challenging problem is where the matching probes do
not exist yet.  Ultimately, a solution for that greater problem will
also be needed.

With such -Z support, a number of XFAIL tests now can pass.  A few,
however, were relying on architecture-specific probes (e.g., for x64)
and/or certain background activity.  For test completion, add
triggering activities explicitly and, on ARM64, appropriate
architecture-specific probes.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
---
 libdtrace/dt_program.c                             | 14 +++++++++++++-
 test/unittest/dtrace-util/tst.CoalesceTrace.d      |  5 +++--
 .../unittest/dtrace-util/tst.ZeroFunctionProbes.sh |  3 +--
 test/unittest/dtrace-util/tst.ZeroNameProbes.sh    |  3 +--
 .../unittest/dtrace-util/tst.ZeroProviderProbes.sh |  4 +---
 test/unittest/fbtprovider/tst.functionentry.d      |  6 ++++--
 .../unittest/fbtprovider/tst.functionreturnvalue.d |  5 +++--
 test/unittest/fbtprovider/tst.ioctlargs.d          |  6 ++++--
 test/unittest/fbtprovider/tst.offset.d             |  6 ++++--
 test/unittest/fbtprovider/tst.offsetzero.d         |  6 ++++--
 test/unittest/fbtprovider/tst.return.d             |  5 +++--
 test/unittest/fbtprovider/tst.tls.d                |  8 +++++++-
 test/unittest/fbtprovider/tst.tls2.d               |  6 +++++-
 13 files changed, 53 insertions(+), 24 deletions(-)

diff --git a/libdtrace/dt_program.c b/libdtrace/dt_program.c
index 5399ae05..c114fda7 100644
--- a/libdtrace/dt_program.c
+++ b/libdtrace/dt_program.c
@@ -163,10 +163,22 @@ dt_prog_stmt(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, dtrace_stmtdesc_t *sdp,
 {
 	pi_state_t		st;
 	dtrace_probedesc_t	*pdp = &sdp->dtsd_ecbdesc->dted_probe;
+	int			rc;
 
 	st.cnt = cnt;
 	st.idp = sdp->dtsd_clause;
-	return dt_probe_iter(dtp, pdp, (dt_probe_f *)dt_stmt_probe, NULL, &st);
+	rc = dt_probe_iter(dtp, pdp, (dt_probe_f *)dt_stmt_probe, NULL, &st);
+
+	/*
+	 * At this point, dtp->dt_cflags has no information about
+	 * DTRACE_C_ZDEFS.  Do not worry about it.  If the probe
+	 * definition matches no probes and DTRACE_C_ZDEFS had not
+	 * been set, the problem would have been reported earlier,
+	 * in dt_setcontext().
+	 */
+	if (rc && dtrace_errno(dtp) == EDT_NOPROBE)
+		return 0;
+	return rc;
 }
 
 int
diff --git a/test/unittest/dtrace-util/tst.CoalesceTrace.d b/test/unittest/dtrace-util/tst.CoalesceTrace.d
index 4a675be9..ffc0e948 100644
--- a/test/unittest/dtrace-util/tst.CoalesceTrace.d
+++ b/test/unittest/dtrace-util/tst.CoalesceTrace.d
@@ -1,10 +1,9 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021, 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.
  */
-/* @@xfail: dtv2 */
 
 /*
  *
@@ -22,6 +21,7 @@
 
 /* @@runtest-opts: -FZ */
 /* @@timeout: 70 */
+/* @@trigger: readwholedir */
 
 BEGIN
 {
@@ -36,6 +36,7 @@ syscall::read:
 }
 
 fbt:vmlinux:SyS_read:,
+fbt:vmlinux:__arm64_sys_read:,
 fbt:vmlinux:__x64_sys_read:
 {
 	printf("fbt: %d\n", j++);
diff --git a/test/unittest/dtrace-util/tst.ZeroFunctionProbes.sh b/test/unittest/dtrace-util/tst.ZeroFunctionProbes.sh
index 94198bd2..3e2221a0 100755
--- a/test/unittest/dtrace-util/tst.ZeroFunctionProbes.sh
+++ b/test/unittest/dtrace-util/tst.ZeroFunctionProbes.sh
@@ -1,11 +1,10 @@
 #!/bin/bash
 #
 # Oracle Linux DTrace.
-# Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2021, 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.
 #
-# @@xfail: dtv2
 
 ##
 #
diff --git a/test/unittest/dtrace-util/tst.ZeroNameProbes.sh b/test/unittest/dtrace-util/tst.ZeroNameProbes.sh
index 814443de..731b2adf 100755
--- a/test/unittest/dtrace-util/tst.ZeroNameProbes.sh
+++ b/test/unittest/dtrace-util/tst.ZeroNameProbes.sh
@@ -1,11 +1,10 @@
 #!/bin/bash
 #
 # Oracle Linux DTrace.
-# Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2021, 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.
 #
-# @@xfail: dtv2
 
 ##
 #
diff --git a/test/unittest/dtrace-util/tst.ZeroProviderProbes.sh b/test/unittest/dtrace-util/tst.ZeroProviderProbes.sh
index 85dab241..63d1ab8b 100755
--- a/test/unittest/dtrace-util/tst.ZeroProviderProbes.sh
+++ b/test/unittest/dtrace-util/tst.ZeroProviderProbes.sh
@@ -1,11 +1,9 @@
 #!/bin/bash
 #
 # Oracle Linux DTrace.
-# Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2021, 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.
-#
-# @@xfail: dtv2
 
 ##
 #
diff --git a/test/unittest/fbtprovider/tst.functionentry.d b/test/unittest/fbtprovider/tst.functionentry.d
index 187f22c4..20837637 100644
--- a/test/unittest/fbtprovider/tst.functionentry.d
+++ b/test/unittest/fbtprovider/tst.functionentry.d
@@ -1,6 +1,6 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021, 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.
  */
@@ -11,19 +11,21 @@
  * SECTION: FBT Provider/Probe arguments
  */
 
-/* @@xfail: dtv2 */
 /* @@runtest-opts: -Z */
+/* @@trigger: pid-tst-args1 */
 
 #pragma D option quiet
 #pragma D option statusrate=10ms
 
 fbt::SyS_ioctl:entry,
+fbt::__arm64_sys_ioctl:entry,
 fbt::__x64_sys_ioctl:entry
 {
 	printf("Entering the ioctl function\n");
 }
 
 fbt::SyS_ioctl:return,
+fbt::__arm64_sys_ioctl:return,
 fbt::__x64_sys_ioctl:return
 {
 	printf("Returning from ioctl function\n");
diff --git a/test/unittest/fbtprovider/tst.functionreturnvalue.d b/test/unittest/fbtprovider/tst.functionreturnvalue.d
index 7c9e474c..19c09e3d 100644
--- a/test/unittest/fbtprovider/tst.functionreturnvalue.d
+++ b/test/unittest/fbtprovider/tst.functionreturnvalue.d
@@ -1,6 +1,6 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021, 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.
  */
@@ -11,13 +11,14 @@
  * SECTION: FBT Provider/Probe arguments
  */
 
-/* @@xfail: dtv2 */
 /* @@runtest-opts: -Z */
+/* @@trigger: pid-tst-args1 */
 
 #pragma D option quiet
 #pragma D option statusrate=10ms
 
 fbt::SyS_ioctl:return,
+fbt::__arm64_sys_ioctl:return,
 fbt::__x64_sys_ioctl:return
 {
 	printf("The function return value is stored in %u\n", arg1);
diff --git a/test/unittest/fbtprovider/tst.ioctlargs.d b/test/unittest/fbtprovider/tst.ioctlargs.d
index 2fb13860..5850b07b 100644
--- a/test/unittest/fbtprovider/tst.ioctlargs.d
+++ b/test/unittest/fbtprovider/tst.ioctlargs.d
@@ -1,6 +1,6 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021, 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.
  */
@@ -11,13 +11,14 @@
  * SECTION: FBT Provider/Probe arguments
  */
 
-/* @@xfail: dtv2 */
 /* @@runtest-opts: -Z */
+/* @@trigger: pid-tst-args1 */
 
 #pragma D option quiet
 #pragma D option statusrate=10ms
 
 fbt::SyS_ioctl:entry,
+fbt::__arm64_sys_ioctl:entry,
 fbt::__x64_sys_ioctl:entry
 {
 	printf("Entering the ioctl function\n");
@@ -25,6 +26,7 @@ fbt::__x64_sys_ioctl:entry
 }
 
 fbt::SyS_ioctl:return,
+fbt::__arm64_sys_ioctl:return,
 fbt::__x64_sys_ioctl:return
 {
 	printf("Returning from ioctl function\n");
diff --git a/test/unittest/fbtprovider/tst.offset.d b/test/unittest/fbtprovider/tst.offset.d
index cdd163f2..4656281c 100644
--- a/test/unittest/fbtprovider/tst.offset.d
+++ b/test/unittest/fbtprovider/tst.offset.d
@@ -1,6 +1,6 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021, 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.
  */
@@ -11,8 +11,8 @@
  * SECTION: FBT Provider/Probe arguments
  */
 
-/* @@xfail: dtv2 */
 /* @@runtest-opts: -Z */
+/* @@trigger: pid-tst-args1 */
 
 #pragma D option quiet
 #pragma D option statusrate=10ms
@@ -23,12 +23,14 @@ BEGIN
 }
 
 fbt::SyS_ioctl:entry,
+fbt::__arm64_sys_ioctl:entry,
 fbt::__x64_sys_ioctl:entry
 {
 	printf("Entering the function\n");
 }
 
 fbt::SyS_ioctl:return,
+fbt::__arm64_sys_ioctl:return,
 fbt::__x64_sys_ioctl:return
 {
 	printf("The offset = %u\n", arg0);
diff --git a/test/unittest/fbtprovider/tst.offsetzero.d b/test/unittest/fbtprovider/tst.offsetzero.d
index feae2e37..8485f2f1 100644
--- a/test/unittest/fbtprovider/tst.offsetzero.d
+++ b/test/unittest/fbtprovider/tst.offsetzero.d
@@ -1,6 +1,6 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021, 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.
  */
@@ -11,13 +11,14 @@
  * SECTION: FBT Provider/Probe arguments
  */
 
-/* @@xfail: dtv2 */
 /* @@runtest-opts: -Z */
+/* @@trigger: pid-tst-args1 */
 
 #pragma D option quiet
 #pragma D option statusrate=10ms
 
 fbt::SyS_ioctl:entry,
+fbt::__arm64_sys_ioctl:entry,
 fbt::__x64_sys_ioctl:entry
 {
 	printf("Entering the ioctl function\n");
@@ -26,6 +27,7 @@ fbt::__x64_sys_ioctl:entry
 }
 
 fbt::SyS_ioctl:return,
+fbt::__arm64_sys_ioctl:return,
 fbt::__x64_sys_ioctl:return
 {
 	printf("Returning from ioctl function\n");
diff --git a/test/unittest/fbtprovider/tst.return.d b/test/unittest/fbtprovider/tst.return.d
index e62d67d4..d966b05c 100644
--- a/test/unittest/fbtprovider/tst.return.d
+++ b/test/unittest/fbtprovider/tst.return.d
@@ -1,6 +1,6 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021, 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.
  */
@@ -11,13 +11,14 @@
  * SECTION: FBT Provider/Probe arguments
  */
 
-/* @@xfail: dtv2 */
 /* @@runtest-opts: -Z */
+/* @@trigger: pid-tst-args1 */
 
 #pragma D option quiet
 #pragma D option statusrate=10ms
 
 fbt::SyS_ioctl:return,
+fbt::__arm64_sys_ioctl:return,
 fbt::__x64_sys_ioctl:return
 {
 	exit(0);
diff --git a/test/unittest/fbtprovider/tst.tls.d b/test/unittest/fbtprovider/tst.tls.d
index 5875ef47..dd57f0c6 100644
--- a/test/unittest/fbtprovider/tst.tls.d
+++ b/test/unittest/fbtprovider/tst.tls.d
@@ -1,6 +1,6 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021, 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.
  */
@@ -13,6 +13,7 @@
 
 /* @@xfail: dtv2 */
 /* @@runtest-opts: -Z */
+/* @@trigger: pid-tst-args1 */
 
 #pragma D option quiet
 #pragma D option statusrate=10ms
@@ -26,6 +27,7 @@ BEGIN
 }
 
 fbt::SyS_ioctl:entry,
+fbt::__arm64_sys_ioctl:entry,
 fbt::__x64_sys_ioctl:entry
 /me == pid/
 {
@@ -34,6 +36,7 @@ fbt::__x64_sys_ioctl:entry
 }
 
 fbt::SyS_ioctl:return,
+fbt::__arm64_sys_ioctl:return,
 fbt::__x64_sys_ioctl:return
 /me == pid && num_entry > 0/
 {
@@ -41,6 +44,7 @@ fbt::__x64_sys_ioctl:return
 }
 
 fbt::SyS_ioctl:return,
+fbt::__arm64_sys_ioctl:return,
 fbt::__x64_sys_ioctl:return
 /me == pid && num_entry > 0 && self->token != pid/
 {
@@ -49,6 +53,8 @@ fbt::__x64_sys_ioctl:return
 
 fbt::SyS_ioctl:entry,
 fbt::SyS_ioctl:return,
+fbt::__arm64_sys_ioctl:entry,
+fbt::__arm64_sys_ioctl:return,
 fbt::__x64_sys_ioctl:entry,
 fbt::__x64_sys_ioctl:return
 /num_entry >= 10 && num_return >= 10/
diff --git a/test/unittest/fbtprovider/tst.tls2.d b/test/unittest/fbtprovider/tst.tls2.d
index 455bcc60..e8c44eab 100644
--- a/test/unittest/fbtprovider/tst.tls2.d
+++ b/test/unittest/fbtprovider/tst.tls2.d
@@ -1,6 +1,6 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021, 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.
  */
@@ -13,6 +13,7 @@
 
 /* @@xfail: dtv2 */
 /* @@runtest-opts: -Z */
+/* @@trigger: pid-tst-args1 */
 
 #pragma D option quiet
 #pragma D option statusrate=10ms
@@ -33,18 +34,21 @@ syscall::ioctl:entry
 }
 
 fbt::SyS_ioctl:entry,
+fbt::__arm64_sys_ioctl:entry,
 fbt::__x64_sys_ioctl:entry
 /me == pid && num_entry > 0/
 {
 }
 
 fbt::SyS_ioctl:return,
+fbt::__arm64_sys_ioctl:return,
 fbt::__x64_sys_ioctl:return
 /me == pid && num_entry > 0/
 {
 }
 
 fbt::SyS_ioctl:return,
+fbt::__arm64_sys_ioctl:return,
 fbt::__x64_sys_ioctl:return
 /me == pid && num_entry > 0 && self->token != pid/
 {
-- 
2.18.4




More information about the DTrace-devel mailing list