Skip to contentSkip to conversation

test: Handle dtrace:::ERROR arg3 specially

PATCH In review [email protected] 3 participants 54 messages Aug 29, 2024 – Oct 17, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/22 test: Handle dtrace:::ERROR arg3 specially

From: Eugene Loh <[email protected]>

The ERROR probe's arg3 reports the culprit PC, whose value can vary with minor implementation changes. On the one hand, we do not want tests to be overly sensitive to this value. On the other hand, we do at least want to check the value is reasonable.

Therefore:

*) Change tests that dump ERROR's args to omit arg3.

*) Add a new test that checks that ERROR's arg3 is reasonable.

---
 test/unittest/error/tst.DTRACEFLT_UNKNOWN.d   |  6 +-
 test/unittest/error/tst.DTRACEFLT_UNKNOWN.r   |  2 +-
 .../regression/tst.DTRACEFLT_BADADDR.d_path.d |  8 +-
 .../regression/tst.DTRACEFLT_BADADDR.d_path.r |  2 +-
 test/unittest/variables/bvar/tst.arg3-ERROR.d | 92 +++++++++++++++++++
 5 files changed, 101 insertions(+), 9 deletions(-)
 create mode 100644 test/unittest/variables/bvar/tst.arg3-ERROR.d
test/unittest/error/tst.DTRACEFLT_UNKNOWN.d +3 -3
index 001903ff..bfc77bf5 100644
@@ -1,6 +1,6 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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.
  */
@@ -19,8 +19,8 @@
 
 ERROR
 {
-	printf("The arguments are %u %u %u %u %u\n",
-		arg1, arg2, arg3, arg4, arg5);
+	printf("The arguments are %u %u PC %u %u\n",
+		arg1, arg2, arg4, arg5);
 	printf("The value of arg4 = %u\n", DTRACEFLT_UNKNOWN);
 	exit(0);
 }
test/unittest/error/tst.DTRACEFLT_UNKNOWN.r +1 -1
index b11f6c99..3e7caac4 100644
@@ -1,4 +1,4 @@
-The arguments are 2 2 4 1 64
+The arguments are 2 2 PC 1 64
 The value of arg4 = 0
 
 -- @@stderr --
test/unittest/regression/tst.DTRACEFLT_BADADDR.d_path.d +4 -4
index c23f9503..ec519f4f 100644
@@ -1,10 +1,10 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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.
  */
-/* @@xfail: dtv2 */
+/* @@xfail: dtv2 d_path */
 
 /*
  * ASSERTION:
@@ -18,8 +18,7 @@
 
 ERROR
 {
-	printf("The arguments are %u %u %u %u %u\n",
-		arg1, arg2, arg3, arg4, arg5);
+	printf("The arguments are %u %u PC %u %u\n", arg1, arg2, arg4, arg5);
 	printf("The value of arg4 should be %u\n", DTRACEFLT_BADADDR);
 	printf("The value of arg5 should be %u\n", 0x18);
 	exit(0);
@@ -29,4 +28,5 @@ BEGIN
 {
 	d = d_path((struct path *)0x18);
 	trace(d);
+	exit(1);
 }
test/unittest/regression/tst.DTRACEFLT_BADADDR.d_path.r +1 -1
index 8c601a43..be1f6d5b 100644
@@ -1,4 +1,4 @@
-The arguments are 2 1 28 1 24
+The arguments are 2 1 PC 1 24
 The value of arg4 should be 1
 The value of arg5 should be 24
 
test/unittest/variables/bvar/tst.arg3-ERROR.d new file +92 -0

92 lines not on this page · raw message

Signature · 1 line
2.43.5
#1 lore raw

PATCH 2/22 test: Clean up tests still expecting obsolete "at DIF offset NN"

From: Eugene Loh <[email protected]>

Also, the numbering of EPIDs has changed.

---
 test/demo/dtrace/error.d                                | 1 -
 test/demo/dtrace/error.r                                | 2 +-
 test/unittest/assocs/tst.invalidref.r                   | 4 ++--
 test/unittest/drops/drp.DTRACEDROP_DBLERROR.r           | 2 +-
 test/unittest/error/tst.DTRACEFLT_UNKNOWN.d             | 1 -
 test/unittest/error/tst.DTRACEFLT_UNKNOWN.r             | 4 ++--
 test/unittest/error/tst.DTRACEFLT_UNKNOWN.sparc64.r     | 5 -----
 test/unittest/pointers/err.BadAlign.d                   | 1 -
 test/unittest/pointers/err.BadAlign.r                   | 2 +-
 test/unittest/pointers/err.InvalidAddress2.d            | 1 -
 test/unittest/pointers/err.InvalidAddress2.r            | 2 +-
 test/unittest/pointers/err.InvalidAddress3.r            | 2 +-
 test/unittest/pointers/err.InvalidAddress4.d            | 1 -
 test/unittest/pointers/err.InvalidAddress4.r            | 2 +-
 test/unittest/regression/tst.DTRACEFLT_BADADDR.d_path.r | 4 ++--
 15 files changed, 12 insertions(+), 22 deletions(-)
 delete mode 100644 test/unittest/error/tst.DTRACEFLT_UNKNOWN.sparc64.r
test/demo/dtrace/error.d +0 -1
index 5700dd33..d55fb090 100644
@@ -5,7 +5,6 @@
  * http://oss.oracle.com/licenses/upl.
  */
 
-/* @@xfail: dtv2 */
 /* @@trigger: none */
 
 BEGIN
test/demo/dtrace/error.r +1 -1
index d894776b..d3904f47 100644
@@ -3,4 +3,4 @@
 
 -- @@stderr --
 dtrace: script 'test/demo/dtrace/error.d' matched 2 probes
-dtrace: error on enabled probe ID 1 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at DIF offset 16 at BPF pc NNN
+dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/assocs/tst.invalidref.r +2 -2
index b050e436..20f131b4 100644
@@ -1,4 +1,4 @@
 
 -- @@stderr --
-dtrace: error on enabled probe ID (ID: profile:::tick-1s): invalid address ({ptr}) in action #2 at DIF offset 64 at BPF pc NNN
-dtrace: error on enabled probe ID (ID: profile:::tick-1s): invalid address ({ptr}) in action #2 at DIF offset 64 at BPF pc NNN
+dtrace: error on enabled probe ID (ID: profile:::tick-1s): invalid address ({ptr}) in action #2 at BPF pc NNN
+dtrace: error on enabled probe ID (ID: profile:::tick-1s): invalid address ({ptr}) in action #2 at BPF pc NNN
test/unittest/drops/drp.DTRACEDROP_DBLERROR.r +1 -1
index 14654676..9fa54dd9 100644
@@ -4,4 +4,4 @@
 -- @@stderr --
 dtrace: script 'test/unittest/drops/drp.DTRACEDROP_DBLERROR.d' matched 3 probes
 dtrace: [DTRACEDROP_DBLERROR] 1 error in ERROR probe enabling
-dtrace: error on enabled probe ID 1 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at DIF offset 16 at BPF pc NNN
+dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/error/tst.DTRACEFLT_UNKNOWN.d +0 -1
index bfc77bf5..c74762ae 100644
@@ -4,7 +4,6 @@
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
 
 /*
  * ASSERTION:
test/unittest/error/tst.DTRACEFLT_UNKNOWN.r +2 -2
index 3e7caac4..1e4fdd64 100644
@@ -1,5 +1,5 @@
-The arguments are 2 2 PC 1 64
+The arguments are 3 1 PC 1 64
 The value of arg4 = 0
 
 -- @@stderr --
-dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #2 at DIF offset 4 at BPF pc NNN
+dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/error/tst.DTRACEFLT_UNKNOWN.sparc64.r deleted +0 -5
deleted file mode 100644
index 3944c138..00000000
@@ -1,5 +0,0 @@
-The arguments are 2 2 4 1 0
-The value of arg4 = 0
-
--- @@stderr --
-dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #2 at DIF offset 4
test/unittest/pointers/err.BadAlign.d +0 -1
index cd4138ae..e859dd75 100644
@@ -4,7 +4,6 @@
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
 
 /*
  * ASSERTION: This test reproduces the alignment error.
test/unittest/pointers/err.BadAlign.r +1 -1
index 4328aac4..187543b6 100644
@@ -1,3 +1,3 @@
 
 -- @@stderr --
-dtrace: error on enabled probe ID 1 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #2 at DIF offset 4
+dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/pointers/err.InvalidAddress2.d +0 -1
index 682ad650..b22f08fb 100644
@@ -4,7 +4,6 @@
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
 
 /*
  * ASSERTION: D pointers do not allow invalid pointer accesses.
test/unittest/pointers/err.InvalidAddress2.r +1 -1
index d866eae1..187543b6 100644
@@ -1,3 +1,3 @@
 
 -- @@stderr --
-dtrace: error on enabled probe ID 1 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #4 at DIF offset 8
+dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/pointers/err.InvalidAddress3.r +1 -1
index 069ee1de..187543b6 100644
@@ -1,3 +1,3 @@
 
 -- @@stderr --
-dtrace: error on enabled probe ID 1 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #2 at DIF offset 8
+dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/pointers/err.InvalidAddress4.d +0 -1
index 1e2b4f62..586cddf9 100644
@@ -4,7 +4,6 @@
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
 
 /*
  * ASSERTION: Demonstrating valid memory access.
test/unittest/pointers/err.InvalidAddress4.r +1 -1
index d866eae1..187543b6 100644
@@ -1,3 +1,3 @@
 
 -- @@stderr --
-dtrace: error on enabled probe ID 1 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #4 at DIF offset 8
+dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
test/unittest/regression/tst.DTRACEFLT_BADADDR.d_path.r +2 -2
index be1f6d5b..b5435eef 100644
@@ -1,6 +1,6 @@
-The arguments are 2 1 PC 1 24
+The arguments are 3 1 PC 1 24
 The value of arg4 should be 1
 The value of arg5 should be 24
 
 -- @@stderr --
-dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at DIF offset 28 at BPF pc NNN
+dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
Signature · 1 line
2.43.5
#2 lore raw

PATCH 3/22 Action clear() should clear only one aggregation

In reply to [email protected]

From: Eugene Loh <[email protected]>

In dt_clear(), we:

*) extract an aggregation ID (dtrace_aggid_t)

*) increment the gen counter for this aggregation ID

*) clear the consumer copy of the aggregation, using:

      /* Also clear our own copy of the data, in case it gets printed. */
      dtrace_aggregate_walk(dtp, dt_aggregate_clear_one, dtp);

However, this clears all the aggregations. While the next snapshot of the aggregations will refresh our copies of the aggregations -- after all, dtrace_aggregate_snap() itself starts with a call to dtrace_aggregate_clear() -- if we print aggregations before the next snapshot, we would display an erroneously cleared aggregation.

Therefore, change dt_clear() to clear only those aggregations that correspond to the specified aggregation ID.

In order that only a specific aggregation ID can be cleared, we modify the last argument to dt_aggregate_clear_one() to be not simply the dtp, but a pointer to a struct that has both the dtp and the aggregation ID. The previous "clear all" behavior can be specified with an aggregation ID of DTRACE_AGGVARIDNONE.

Though trunc() appears not to be similarly afflicted, add a test for it too.

Orabug: 36900180

---
 libdtrace/dt_aggregate.c           | 16 ++++++++++++---
 libdtrace/dt_aggregate.h           |  5 +++++
 libdtrace/dt_consume.c             |  4 +++-
 test/unittest/aggs/tst.clear-one.d | 33 ++++++++++++++++++++++++++++++
 test/unittest/aggs/tst.clear-one.r | 13 ++++++++++++
 test/unittest/aggs/tst.trunc-one.d | 33 ++++++++++++++++++++++++++++++
 test/unittest/aggs/tst.trunc-one.r | 10 +++++++++
 7 files changed, 110 insertions(+), 4 deletions(-)
 create mode 100644 test/unittest/aggs/tst.clear-one.d
 create mode 100644 test/unittest/aggs/tst.clear-one.r
 create mode 100644 test/unittest/aggs/tst.trunc-one.d
 create mode 100644 test/unittest/aggs/tst.trunc-one.r
libdtrace/dt_aggregate.c +13 -3
index 329b8ffa..8825739c 100644
@@ -504,7 +504,9 @@ dt_aggregate_clear_one_percpu(const dtrace_aggdata_t *agd,
 int
 dt_aggregate_clear_one(const dtrace_aggdata_t *agd, void *arg)
 {
-	dtrace_hdl_t		*dtp = arg;
+	dt_clear_arg_t		*dca = arg;
+	dtrace_hdl_t		*dtp = dca->dtp;
+	dtrace_aggid_t		aid = dca->aid;
 	dtrace_aggdesc_t	*agg = agd->dtada_desc;
 	dtrace_recdesc_t	*rec = &agg->dtagd_drecs[DT_AGGDATA_RECORD];
 	int64_t			*vals = (int64_t *)
@@ -512,6 +514,9 @@ dt_aggregate_clear_one(const dtrace_aggdata_t *agd, void *arg)
 	uint64_t		agen;
 	int			max_cpus = dtp->dt_conf.max_cpuid + 1;
 
+	if (aid != DTRACE_AGGVARIDNONE && aid != agg->dtagd_varid)
+		return DTRACE_AGGWALK_NEXT;
+
 	/*
 	 * We can pass the entire key because we know that the first uint32_t
 	 * in the key is the aggregation ID we need.
@@ -609,7 +614,9 @@ dt_aggregate_snap_one(dtrace_hdl_t *dtp, int aggid, int cpu, const char *key,
 		 */
 		hgen = *(int64_t *)agd->dtada_data;
 		if (dgen > hgen) {
-			dt_aggregate_clear_one(agd, dtp);
+			dt_clear_arg_t arg = { dtp, DTRACE_AGGVARIDNONE };
+
+			dt_aggregate_clear_one(agd, &arg);
 			hgen = *(int64_t *)agd->dtada_data;
 		}
 
@@ -1859,10 +1866,13 @@ dtrace_aggregate_print(dtrace_hdl_t *dtp, FILE *fp,
 	return 0;
 }
 
+/* FIXME: dtrace_aggregate_clear() is called from only one site.  Should we inline it? */
 void
 dtrace_aggregate_clear(dtrace_hdl_t *dtp)
 {
-	dtrace_aggregate_walk(dtp, dt_aggregate_clear_one, dtp);
+	dt_clear_arg_t arg = { dtp, DTRACE_AGGVARIDNONE };
+
+	dtrace_aggregate_walk(dtp, dt_aggregate_clear_one, &arg);
 }
 
 void
libdtrace/dt_aggregate.h +5 -0
index 4f8d09bf..0dc126e9 100644
@@ -12,6 +12,11 @@
 extern "C" {
 #endif
 
+typedef struct dt_clear_arg {
+	dtrace_hdl_t	*dtp;
+	dtrace_aggid_t	aid;
+} dt_clear_arg_t;
+
 typedef struct dt_aggregate dt_aggregate_t;
 
 #define DT_AGGDATA_COUNTER	0
libdtrace/dt_consume.c +3 -1
index 0e30ddbd..f2d5cb74 100644
@@ -1552,6 +1552,7 @@ dt_clear(dtrace_hdl_t *dtp, caddr_t base, dtrace_recdesc_t *rec)
 	dtrace_aggid_t	aid;
 	uint64_t	gen;
 	caddr_t		addr;
+	dt_clear_arg_t	arg = { dtp, 0 };
 
 	/* We have just one record: the aggregation ID. */
 	addr = base + rec->dtrd_offset;
@@ -1568,7 +1569,8 @@ dt_clear(dtrace_hdl_t *dtp, caddr_t base, dtrace_recdesc_t *rec)
 		return -1;
 
 	/* Also clear our own copy of the data, in case it gets printed. */
-	dtrace_aggregate_walk(dtp, dt_aggregate_clear_one, dtp);
+	arg.aid = aid;
+	dtrace_aggregate_walk(dtp, dt_aggregate_clear_one, &arg);
 
 	return 0;
 }
test/unittest/aggs/tst.clear-one.d new file +33 -0
new file mode 100644
index 00000000..f96c2db0
@@ -0,0 +1,33 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 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: Clearing one aggregation clears only that one.
+ *
+ * SECTION: Aggregations/Clearing aggregations
+ */
+/* @@nosort */
+
+#pragma D option quiet
+
+BEGIN
+{
+	@a[1] = sum(100);
+	@a[2] = sum( 20);
+	@a[3] = sum(  3);
+	@b[4] = sum(400);
+	@b[5] = sum( 50);
+	@b[6] = sum(  6);
+	@c[7] = sum(700);
+	@c[8] = sum( 80);
+	@c[9] = sum(  9);
+	clear(@b);
+	printa(@a);
+	printa(@b);
+	printa(@c);
+	exit(0);
+}
test/unittest/aggs/tst.clear-one.r new file +13 -0
new file mode 100644
index 00000000..101d173f
@@ -0,0 +1,13 @@
+
+        3                3
+        2               20
+        1              100
+
+        4                0
+        5                0
+        6                0
+
+        9                9
+        8               80
+        7              700
+
test/unittest/aggs/tst.trunc-one.d new file +33 -0
new file mode 100644
index 00000000..0556bb34
@@ -0,0 +1,33 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 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: Truncating one aggregation truncates only that one.
+ *
+ * SECTION: Aggregations/Clearing aggregations
+ */
+/* @@nosort */
+
+#pragma D option quiet
+
+BEGIN
+{
+	@a[1] = sum(100);
+	@a[2] = sum( 20);
+	@a[3] = sum(  3);
+	@b[4] = sum(400);
+	@b[5] = sum( 50);
+	@b[6] = sum(  6);
+	@c[7] = sum(700);
+	@c[8] = sum( 80);
+	@c[9] = sum(  9);
+	trunc(@b);
+	printa(@a);
+	printa(@b);
+	printa(@c);
+	exit(0);
+}
test/unittest/aggs/tst.trunc-one.r new file +10 -0
new file mode 100644
index 00000000..a611026d
@@ -0,0 +1,10 @@
+
+        3                3
+        2               20
+        1              100
+
+
+        9                9
+        8               80
+        7              700
+
Signature · 1 line
2.43.5
Reviewed-by on v1 3/22
#3 lore raw

Re: [PATCH 03/22] Action clear() should clear only one aggregation

Quoted 28 lines · On Thu, Aug 29, 2024 at 01:22:00AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

In dt_clear(), we:

*) extract an aggregation ID (dtrace_aggid_t)

*) increment the gen counter for this aggregation ID

*) clear the consumer copy of the aggregation, using:

      /* Also clear our own copy of the data, in case it gets printed. */
      dtrace_aggregate_walk(dtp, dt_aggregate_clear_one, dtp);

However, this clears all the aggregations. While the next snapshot of the aggregations will refresh our copies of the aggregations -- after all, dtrace_aggregate_snap() itself starts with a call to dtrace_aggregate_clear() -- if we print aggregations before the next snapshot, we would display an erroneously cleared aggregation.

Therefore, change dt_clear() to clear only those aggregations that correspond to the specified aggregation ID.

In order that only a specific aggregation ID can be cleared, we modify the last argument to dt_aggregate_clear_one() to be not simply the dtp, but a pointer to a struct that has both the dtp and the aggregation ID. The previous "clear all" behavior can be specified with an aggregation ID of DTRACE_AGGVARIDNONE.

Quoted 5 lines

Though trunc() appears not to be similarly afflicted, add a test for it too.

Orabug: 36900180

... though with minor comments/changes as listed below.

Quoted 51 lines
---
 libdtrace/dt_aggregate.c           | 16 ++++++++++++---
 libdtrace/dt_aggregate.h           |  5 +++++
 libdtrace/dt_consume.c             |  4 +++-
 test/unittest/aggs/tst.clear-one.d | 33 ++++++++++++++++++++++++++++++
 test/unittest/aggs/tst.clear-one.r | 13 ++++++++++++
 test/unittest/aggs/tst.trunc-one.d | 33 ++++++++++++++++++++++++++++++
 test/unittest/aggs/tst.trunc-one.r | 10 +++++++++
 7 files changed, 110 insertions(+), 4 deletions(-)
 create mode 100644 test/unittest/aggs/tst.clear-one.d
 create mode 100644 test/unittest/aggs/tst.clear-one.r
 create mode 100644 test/unittest/aggs/tst.trunc-one.d
 create mode 100644 test/unittest/aggs/tst.trunc-one.r
libdtrace/dt_aggregate.c +9 -2
index 329b8ffa..8825739c 100644
@@ -504,7 +504,9 @@ dt_aggregate_clear_one_percpu(const dtrace_aggdata_t *agd,
 int
 dt_aggregate_clear_one(const dtrace_aggdata_t *agd, void *arg)
 {
-	dtrace_hdl_t		*dtp = arg;
+	dt_clear_arg_t		*dca = arg;
+	dtrace_hdl_t		*dtp = dca->dtp;
+	dtrace_aggid_t		aid = dca->aid;
 	dtrace_aggdesc_t	*agg = agd->dtada_desc;
 	dtrace_recdesc_t	*rec = &agg->dtagd_drecs[DT_AGGDATA_RECORD];
 	int64_t			*vals = (int64_t *)
@@ -512,6 +514,9 @@ dt_aggregate_clear_one(const dtrace_aggdata_t *agd, void *arg)
 	uint64_t		agen;
 	int			max_cpus = dtp->dt_conf.max_cpuid + 1;
 
+	if (aid != DTRACE_AGGVARIDNONE && aid != agg->dtagd_varid)
+		return DTRACE_AGGWALK_NEXT;
+
 	/*
 	 * We can pass the entire key because we know that the first uint32_t
 	 * in the key is the aggregation ID we need.
@@ -609,7 +614,9 @@ dt_aggregate_snap_one(dtrace_hdl_t *dtp, int aggid, int cpu, const char *key,
 		 */
 		hgen = *(int64_t *)agd->dtada_data;
 		if (dgen > hgen) {
-			dt_aggregate_clear_one(agd, dtp);
+			dt_clear_arg_t arg = { dtp, DTRACE_AGGVARIDNONE };
+
+			dt_aggregate_clear_one(agd, &arg);
 			hgen = *(int64_t *)agd->dtada_data;
 		}
 

libdtrace/dt_aggregate.c dtrace_aggregate_print(dtrace_hdl_t *dtp, FILE *fp, · line 1869

Quoted 4 lines
libdtrace/dt_aggregate.c +1 -0
@@ -1859,10 +1866,13 @@ dtrace_aggregate_print(dtrace_hdl_t *dtp, FILE *fp,
 	return 0;
 }
 
+/* FIXME: dtrace_aggregate_clear() is called from only one site.  Should we inline it? */

Removing the FIXME. Yes, it needs to remain as-is because it is part of the libdtrace API.

Quoted 31 lines
libdtrace/dt_aggregate.c +3 -1
 void
 dtrace_aggregate_clear(dtrace_hdl_t *dtp)
 {
-	dtrace_aggregate_walk(dtp, dt_aggregate_clear_one, dtp);
+	dt_clear_arg_t arg = { dtp, DTRACE_AGGVARIDNONE };
+
+	dtrace_aggregate_walk(dtp, dt_aggregate_clear_one, &arg);
 }
 
 void
libdtrace/dt_aggregate.h +5 -0
index 4f8d09bf..0dc126e9 100644
@@ -12,6 +12,11 @@
 extern "C" {
 #endif
 
+typedef struct dt_clear_arg {
+	dtrace_hdl_t	*dtp;
+	dtrace_aggid_t	aid;
+} dt_clear_arg_t;
+
 typedef struct dt_aggregate dt_aggregate_t;
 
 #define DT_AGGDATA_COUNTER	0
libdtrace/dt_consume.c +0 -0
index 0e30ddbd..f2d5cb74 100644

libdtrace/dt_consume.c dt_clear(dtrace_hdl_t *dtp, caddr_t base, dtrace_recdesc_t *rec) · line 1555

Quoted 4 lines
libdtrace/dt_consume.c +1 -0
@@ -1552,6 +1552,7 @@ dt_clear(dtrace_hdl_t *dtp, caddr_t base, dtrace_recdesc_t *rec)
 	dtrace_aggid_t	aid;
 	uint64_t	gen;
 	caddr_t		addr;
+	dt_clear_arg_t	arg = { dtp, 0 };

0 -> DTRACE_AGGVARIDNONE

Quoted 129 lines
libdtrace/dt_consume.c +2 -1
 	/* We have just one record: the aggregation ID. */
 	addr = base + rec->dtrd_offset;
@@ -1568,7 +1569,8 @@ dt_clear(dtrace_hdl_t *dtp, caddr_t base, dtrace_recdesc_t *rec)
 		return -1;
 
 	/* Also clear our own copy of the data, in case it gets printed. */
-	dtrace_aggregate_walk(dtp, dt_aggregate_clear_one, dtp);
+	arg.aid = aid;
+	dtrace_aggregate_walk(dtp, dt_aggregate_clear_one, &arg);
 
 	return 0;
 }
test/unittest/aggs/tst.clear-one.d new file +33 -0
new file mode 100644
index 00000000..f96c2db0
@@ -0,0 +1,33 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 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: Clearing one aggregation clears only that one.
+ *
+ * SECTION: Aggregations/Clearing aggregations
+ */
+/* @@nosort */
+
+#pragma D option quiet
+
+BEGIN
+{
+	@a[1] = sum(100);
+	@a[2] = sum( 20);
+	@a[3] = sum(  3);
+	@b[4] = sum(400);
+	@b[5] = sum( 50);
+	@b[6] = sum(  6);
+	@c[7] = sum(700);
+	@c[8] = sum( 80);
+	@c[9] = sum(  9);
+	clear(@b);
+	printa(@a);
+	printa(@b);
+	printa(@c);
+	exit(0);
+}
test/unittest/aggs/tst.clear-one.r new file +13 -0
new file mode 100644
index 00000000..101d173f
@@ -0,0 +1,13 @@
+
+        3                3
+        2               20
+        1              100
+
+        4                0
+        5                0
+        6                0
+
+        9                9
+        8               80
+        7              700
+
test/unittest/aggs/tst.trunc-one.d new file +33 -0
new file mode 100644
index 00000000..0556bb34
@@ -0,0 +1,33 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 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: Truncating one aggregation truncates only that one.
+ *
+ * SECTION: Aggregations/Clearing aggregations
+ */
+/* @@nosort */
+
+#pragma D option quiet
+
+BEGIN
+{
+	@a[1] = sum(100);
+	@a[2] = sum( 20);
+	@a[3] = sum(  3);
+	@b[4] = sum(400);
+	@b[5] = sum( 50);
+	@b[6] = sum(  6);
+	@c[7] = sum(700);
+	@c[8] = sum( 80);
+	@c[9] = sum(  9);
+	trunc(@b);
+	printa(@a);
+	printa(@b);
+	printa(@c);
+	exit(0);
+}
test/unittest/aggs/tst.trunc-one.r new file +10 -0
new file mode 100644
index 00000000..a611026d
@@ -0,0 +1,10 @@
+
+        3                3
+        2               20
+        1              100
+
+
+        9                9
+        8               80
+        7              700
+
Signature · 1 line
2.43.5
#4 lore raw

PATCH 4/22 Remove unused "next" arg from dt_flowindent()

In reply to [email protected]

From: Eugene Loh <[email protected]>

---
 libdtrace/dt_consume.c | 24 +++---------------------
 1 file changed, 3 insertions(+), 21 deletions(-)
libdtrace/dt_consume.c +3 -21
index f2d5cb74..6aa9812e 100644
@@ -433,11 +433,9 @@ static dt_htab_ops_t dt_spec_buf_htab_ops = {
 };
 
 static int
-dt_flowindent(dtrace_hdl_t *dtp, dtrace_probedata_t *data, dtrace_epid_t last,
-	      dtrace_epid_t next)
+dt_flowindent(dtrace_hdl_t *dtp, dtrace_probedata_t *data, dtrace_epid_t last)
 {
-	dtrace_probedesc_t	*pd = data->dtpda_pdesc, *npd;
-	dtrace_datadesc_t	*ndd;
+	dtrace_probedesc_t	*pd = data->dtpda_pdesc;
 	dtrace_flowkind_t	flow = DTRACEFLOW_NONE;
 	const char		*p = pd->prv;
 	const char		*n = pd->prb;
@@ -448,7 +446,6 @@ dt_flowindent(dtrace_hdl_t *dtp, dtrace_probedata_t *data, dtrace_epid_t last,
 	static const char	*ent = "entry", *ret = "return";
 	static int		entlen = 0, retlen = 0;
 	dtrace_epid_t		id = data->dtpda_epid;
-	int			rval;
 
 	if (entlen == 0) {
 		assert(retlen == 0);
@@ -486,21 +483,6 @@ dt_flowindent(dtrace_hdl_t *dtp, dtrace_probedata_t *data, dtrace_epid_t last,
 			flow = DTRACEFLOW_NONE;
 	}
 
-	/*
-	 * If we're going to unindent this, it's more difficult to see if
-	 * we don't actually want to unindent it -- we need to look at the
-	 * _next_ EPID.
-	 */
-	if (flow == DTRACEFLOW_RETURN && next != DTRACE_EPIDNONE &&
-	    next != id) {
-		rval = dt_epid_lookup(dtp, next, &ndd, &npd);
-		if (rval != 0)
-			return rval;
-
-		if (npd->id == pd->id)
-			flow = DTRACEFLOW_NONE;
-	}
-
 	if (flow == DTRACEFLOW_ENTRY || flow == DTRACEFLOW_RETURN)
 		data->dtpda_prefix = str;
 	else
@@ -2327,7 +2309,7 @@ dt_consume_one_probe(dtrace_hdl_t *dtp, FILE *fp, char *data, uint32_t size,
 
 	if (data_recording) {
 		if (flow)
-			dt_flowindent(dtp, pdat, *last, DTRACE_EPIDNONE);
+			dt_flowindent(dtp, pdat, *last);
 
 		rval = (*efunc)(pdat, arg);
 
Signature · 1 line
2.43.5
Reviewed-by on v1 4/22
#5 lore raw

Re: [PATCH 04/22] Remove unused "next" arg from dt_flowindent()

Quoted 3 lines · On Thu, Aug 29, 2024 at 01:22:01AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

Quoted 64 lines
---
 libdtrace/dt_consume.c | 24 +++---------------------
 1 file changed, 3 insertions(+), 21 deletions(-)
libdtrace/dt_consume.c +3 -21
index f2d5cb74..6aa9812e 100644
@@ -433,11 +433,9 @@ static dt_htab_ops_t dt_spec_buf_htab_ops = {
 };
 
 static int
-dt_flowindent(dtrace_hdl_t *dtp, dtrace_probedata_t *data, dtrace_epid_t last,
-	      dtrace_epid_t next)
+dt_flowindent(dtrace_hdl_t *dtp, dtrace_probedata_t *data, dtrace_epid_t last)
 {
-	dtrace_probedesc_t	*pd = data->dtpda_pdesc, *npd;
-	dtrace_datadesc_t	*ndd;
+	dtrace_probedesc_t	*pd = data->dtpda_pdesc;
 	dtrace_flowkind_t	flow = DTRACEFLOW_NONE;
 	const char		*p = pd->prv;
 	const char		*n = pd->prb;
@@ -448,7 +446,6 @@ dt_flowindent(dtrace_hdl_t *dtp, dtrace_probedata_t *data, dtrace_epid_t last,
 	static const char	*ent = "entry", *ret = "return";
 	static int		entlen = 0, retlen = 0;
 	dtrace_epid_t		id = data->dtpda_epid;
-	int			rval;
 
 	if (entlen == 0) {
 		assert(retlen == 0);
@@ -486,21 +483,6 @@ dt_flowindent(dtrace_hdl_t *dtp, dtrace_probedata_t *data, dtrace_epid_t last,
 			flow = DTRACEFLOW_NONE;
 	}
 
-	/*
-	 * If we're going to unindent this, it's more difficult to see if
-	 * we don't actually want to unindent it -- we need to look at the
-	 * _next_ EPID.
-	 */
-	if (flow == DTRACEFLOW_RETURN && next != DTRACE_EPIDNONE &&
-	    next != id) {
-		rval = dt_epid_lookup(dtp, next, &ndd, &npd);
-		if (rval != 0)
-			return rval;
-
-		if (npd->id == pd->id)
-			flow = DTRACEFLOW_NONE;
-	}
-
 	if (flow == DTRACEFLOW_ENTRY || flow == DTRACEFLOW_RETURN)
 		data->dtpda_prefix = str;
 	else
@@ -2327,7 +2309,7 @@ dt_consume_one_probe(dtrace_hdl_t *dtp, FILE *fp, char *data, uint32_t size,
 
 	if (data_recording) {
 		if (flow)
-			dt_flowindent(dtp, pdat, *last, DTRACE_EPIDNONE);
+			dt_flowindent(dtp, pdat, *last);
 
 		rval = (*efunc)(pdat, arg);
 
Signature · 1 line
2.43.5
#6 lore raw

PATCH 5/22 Set the ERROR PRID in BPF code

In reply to [email protected]

From: Eugene Loh <[email protected]>

We use the fact that the ERROR PRID is always 3.

---
 bpf/probe_error.c                         |  3 +++
 test/unittest/builtinvar/tst.id_ERROR.d   | 32 +++++++++++++++++++++++
 test/unittest/builtinvar/tst.id_ERROR.r   |  3 +++
 test/unittest/builtinvar/tst.id_ERROR.r.p |  4 +++
 4 files changed, 42 insertions(+)
 create mode 100644 test/unittest/builtinvar/tst.id_ERROR.d
 create mode 100644 test/unittest/builtinvar/tst.id_ERROR.r
 create mode 100755 test/unittest/builtinvar/tst.id_ERROR.r.p
bpf/probe_error.c +3 -0
index c8ddcdfa..ee1a1793 100644
@@ -26,6 +26,7 @@ noinline void dt_probe_error(const dt_dctx_t *dctx, uint64_t pc, uint64_t fault,
 			     uint64_t illval)
 {
 	dt_mstate_t	*mst = dctx->mst;
+	int		oldprid = mst->prid;
 
 	mst->argv[0] = 0;
 	mst->argv[1] = mst->epid;
@@ -34,7 +35,9 @@ noinline void dt_probe_error(const dt_dctx_t *dctx, uint64_t pc, uint64_t fault,
 	mst->argv[4] = fault;
 	mst->argv[5] = illval;
 
+	mst->prid = 3;
 	dt_error(dctx);
+	mst->prid = oldprid;
 
 	mst->fault = fault;
 }
test/unittest/builtinvar/tst.id_ERROR.d new file +32 -0
new file mode 100644
index 00000000..59021c60
@@ -0,0 +1,32 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 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:
+ * The id in the ERROR probe is 3.
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+tick-1s
+{
+	/* trigger the ERROR probe */
+	trace(*((int*)0));
+}
+
+tick-2s
+{
+	exit(1);
+}
+
+ERROR
+{
+	printf("id of the ERROR probe = %d\n", id);
+	exit(0);
+}
test/unittest/builtinvar/tst.id_ERROR.r new file +3 -0
new file mode 100644
index 00000000..95974abe
@@ -0,0 +1,3 @@
+id of the ERROR probe = 3
+
+-- @@stderr --
test/unittest/builtinvar/tst.id_ERROR.r.p new file +4 -0
new file mode 100755
index 00000000..884b43f4
@@ -0,0 +1,4 @@
+#!/usr/bin/gawk -f
+
+# Drop the line with run-dependent PRID for profile probe.
+!/error on enabled probe ID/ { print }
Signature · 1 line
2.43.5
#7 lore raw

Re: [PATCH 05/22] Set the ERROR PRID in BPF code

Quoted 3 lines · On Thu, Aug 29, 2024 at 01:22:02AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

We use the fact that the ERROR PRID is always 3.

Where do we use it? We certainly should never override the probe id that is assigned by dtrace when providers provide probes. Will it always be 3? Almost certainly, yes. But the right way to do this is to actually make the ERROR PRID available as a symbol that can be resolved at program load time, so that the dt_probe_error function can get to its value.

Anyway, the need to restore the mst->prid value in this patch also highlights that there is a much bigger problem... A fault in one clause contaminates the first 6 arguments of the probe, and since a fault only interrupts the execution of the current clause, following clauses will no longer see the correct values of the first 6 arguments but rather the ones that dt_probe_error() stored in mst->argv[0 .. 5]. That is a bug for sure!

Here is a test that demonstrates this issue:

#pragma D option quiet

syscall::write*:entry

{
	self->arg0 = arg0;
	self->arg1 = arg1;
	self->arg2 = arg2;
	self->arg3 = arg3;
	self->arg4 = arg4;
	self->arg5 = arg5;

	printf("%d / %d / %d / %d / %d / %d\n",
	       arg0, arg1, arg2, arg3, arg4, arg5);
}

syscall::write*:entry

{
	trace(*(int *)0);
}

syscall::write*:entry,

ERROR {
	printf("%d / %d / %d / %d / %d / %d\n",
	       arg0, arg1, arg2, arg3, arg4, arg5);
}

syscall::write*:entry

{
	exit(self->arg0 != arg0 || self->arg1 != arg1 || self->arg2 != arg2 ||
	     self->arg3 != arg3 || self->arg4 != arg4 || self->arg5 != arg5
		? 1 : 0);
}

So, we need the ERROR prid value exposed as an external symbol so that it can be used in dt_probe_error(), and a patch that fixes the contamination of the arg values.

Quoted 93 lines
---
 bpf/probe_error.c                         |  3 +++
 test/unittest/builtinvar/tst.id_ERROR.d   | 32 +++++++++++++++++++++++
 test/unittest/builtinvar/tst.id_ERROR.r   |  3 +++
 test/unittest/builtinvar/tst.id_ERROR.r.p |  4 +++
 4 files changed, 42 insertions(+)
 create mode 100644 test/unittest/builtinvar/tst.id_ERROR.d
 create mode 100644 test/unittest/builtinvar/tst.id_ERROR.r
 create mode 100755 test/unittest/builtinvar/tst.id_ERROR.r.p
bpf/probe_error.c +3 -0
index c8ddcdfa..ee1a1793 100644
@@ -26,6 +26,7 @@ noinline void dt_probe_error(const dt_dctx_t *dctx, uint64_t pc, uint64_t fault,
 			     uint64_t illval)
 {
 	dt_mstate_t	*mst = dctx->mst;
+	int		oldprid = mst->prid;
 
 	mst->argv[0] = 0;
 	mst->argv[1] = mst->epid;
@@ -34,7 +35,9 @@ noinline void dt_probe_error(const dt_dctx_t *dctx, uint64_t pc, uint64_t fault,
 	mst->argv[4] = fault;
 	mst->argv[5] = illval;
 
+	mst->prid = 3;
 	dt_error(dctx);
+	mst->prid = oldprid;
 
 	mst->fault = fault;
 }
test/unittest/builtinvar/tst.id_ERROR.d new file +32 -0
new file mode 100644
index 00000000..59021c60
@@ -0,0 +1,32 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 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:
+ * The id in the ERROR probe is 3.
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+tick-1s
+{
+	/* trigger the ERROR probe */
+	trace(*((int*)0));
+}
+
+tick-2s
+{
+	exit(1);
+}
+
+ERROR
+{
+	printf("id of the ERROR probe = %d\n", id);
+	exit(0);
+}
test/unittest/builtinvar/tst.id_ERROR.r new file +3 -0
new file mode 100644
index 00000000..95974abe
@@ -0,0 +1,3 @@
+id of the ERROR probe = 3
+
+-- @@stderr --
test/unittest/builtinvar/tst.id_ERROR.r.p new file +4 -0
new file mode 100755
index 00000000..884b43f4
@@ -0,0 +1,4 @@
+#!/usr/bin/gawk -f
+
+# Drop the line with run-dependent PRID for profile probe.
+!/error on enabled probe ID/ { print }
Signature · 1 line
2.43.5
author
#8 lore raw

Re: [PATCH 05/22] Set the ERROR PRID in BPF code

Quoted 9 lines · Kris Van Hees
Quoted 3 lines · On Thu, Aug 29, 2024 at 01:22:02AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

We use the fact that the ERROR PRID is always 3.

Where do we use it? We certainly should never override the probe id that is assigned by dtrace when providers provide probes. Will it always be 3? Almost certainly, yes. But the right way to do this is to actually make the ERROR PRID available as a symbol that can be resolved at program load time, so that the dt_probe_error function can get to its value.

I'm confused?  I thought I did this and you suggested simply hardwiring the value 3. https://oss.oracle.com/pipermail/dtrace-devel/2024-July/004989.html

Quoted 6 lines

Anyway, the need to restore the mst->prid value in this patch also highlights that there is a much bigger problem... A fault in one clause contaminates the first 6 arguments of the probe, and since a fault only interrupts the execution of the current clause, following clauses will no longer see the correct values of the first 6 arguments but rather the ones that dt_probe_error() stored in mst->argv[0 .. 5]. That is a bug for sure!

Good point, but... a separate issue/patch?

Quoted 132 lines

Here is a test that demonstrates this issue:

#pragma D option quiet

syscall::write*:entry

{
	self->arg0 = arg0;
	self->arg1 = arg1;
	self->arg2 = arg2;
	self->arg3 = arg3;
	self->arg4 = arg4;
	self->arg5 = arg5;

	printf("%d / %d / %d / %d / %d / %d\n",
	       arg0, arg1, arg2, arg3, arg4, arg5);
}

syscall::write*:entry

{
	trace(*(int *)0);
}

syscall::write*:entry,

ERROR {
	printf("%d / %d / %d / %d / %d / %d\n",
	       arg0, arg1, arg2, arg3, arg4, arg5);
}

syscall::write*:entry

{
	exit(self->arg0 != arg0 || self->arg1 != arg1 || self->arg2 != arg2 ||
	     self->arg3 != arg3 || self->arg4 != arg4 || self->arg5 != arg5
		? 1 : 0);
}

So, we need the ERROR prid value exposed as an external symbol so that it can be used in dt_probe_error(), and a patch that fixes the contamination of the arg values.

Quoted 93 lines
---
  bpf/probe_error.c                         |  3 +++
  test/unittest/builtinvar/tst.id_ERROR.d   | 32 +++++++++++++++++++++++
  test/unittest/builtinvar/tst.id_ERROR.r   |  3 +++
  test/unittest/builtinvar/tst.id_ERROR.r.p |  4 +++
  4 files changed, 42 insertions(+)

create mode 100644 test/unittest/builtinvar/tst.id_ERROR.d create mode 100644 test/unittest/builtinvar/tst.id_ERROR.r create mode 100755 test/unittest/builtinvar/tst.id_ERROR.r.p

bpf/probe_error.c +3 -0
index c8ddcdfa..ee1a1793 100644
@@ -26,6 +26,7 @@ noinline void dt_probe_error(const dt_dctx_t *dctx, uint64_t pc, uint64_t fault,
  			     uint64_t illval)
  {
  	dt_mstate_t	*mst = dctx->mst;
+	int		oldprid = mst->prid;
 
  	mst->argv[0] = 0;
  	mst->argv[1] = mst->epid;
@@ -34,7 +35,9 @@ noinline void dt_probe_error(const dt_dctx_t *dctx, uint64_t pc, uint64_t fault,
  	mst->argv[4] = fault;
  	mst->argv[5] = illval;
 
+	mst->prid = 3;
  	dt_error(dctx);
+	mst->prid = oldprid;
 
  	mst->fault = fault;
  }
test/unittest/builtinvar/tst.id_ERROR.d new file +32 -0
new file mode 100644
index 00000000..59021c60
@@ -0,0 +1,32 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 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:
+ * The id in the ERROR probe is 3.
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+tick-1s
+{
+	/* trigger the ERROR probe */
+	trace(*((int*)0));
+}
+
+tick-2s
+{
+	exit(1);
+}
+
+ERROR
+{
+	printf("id of the ERROR probe = %d\n", id);
+	exit(0);
+}
test/unittest/builtinvar/tst.id_ERROR.r new file +3 -0
new file mode 100644
index 00000000..95974abe
@@ -0,0 +1,3 @@
+id of the ERROR probe = 3
+
+-- @@stderr --
test/unittest/builtinvar/tst.id_ERROR.r.p new file +4 -0
new file mode 100755
index 00000000..884b43f4
@@ -0,0 +1,4 @@
+#!/usr/bin/gawk -f
+
+# Drop the line with run-dependent PRID for profile probe.
+!/error on enabled probe ID/ { print }
Signature · 1 line
2.43.5
#9 lore raw

Re: [PATCH 05/22] Set the ERROR PRID in BPF code

Quoted 6 lines · Eugene Loh
Quoted 4 lines · Kris Van Hees
Quoted 3 lines · On Thu, Aug 29, 2024 at 01:22:02AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

We use the fact that the ERROR PRID is always 3.

Quoted 8 lines
Quoted 5 lines

Where do we use it? We certainly should never override the probe id that is assigned by dtrace when providers provide probes. Will it always be 3? Almost certainly, yes. But the right way to do this is to actually make the ERROR PRID available as a symbol that can be resolved at program load time, so that the dt_probe_error function can get to its value.

I'm confused?  I thought I did this and you suggested simply hardwiring the value 3. https://oss.oracle.com/pipermail/dtrace-devel/2024-July/004989.html

True, though I didn't mean to just hardwire the value 3. At a minimum, I think it ought to be a define to set the value of the BEGIN, END, and ERROR probe, so that a symbolic name can be used in code. And that probably would mean that it is best to add a check in the dtrace provider to ensure that those are indeed the probe ids assigned to BEGIN/END/ERROR (and if not, something is very wrong).

Quoted 8 lines
Quoted 6 lines

Anyway, the need to restore the mst->prid value in this patch also highlights that there is a much bigger problem... A fault in one clause contaminates the first 6 arguments of the probe, and since a fault only interrupts the execution of the current clause, following clauses will no longer see the correct values of the first 6 arguments but rather the ones that dt_probe_error() stored in mst->argv[0 .. 5]. That is a bug for sure!

Good point, but... a separate issue/patch?

Yes, already written :)

Quoted 129 lines
Quoted 129 lines

Here is a test that demonstrates this issue:

#pragma D option quiet

syscall::write*:entry

{
	self->arg0 = arg0;
	self->arg1 = arg1;
	self->arg2 = arg2;
	self->arg3 = arg3;
	self->arg4 = arg4;
	self->arg5 = arg5;

	printf("%d / %d / %d / %d / %d / %d\n",
	       arg0, arg1, arg2, arg3, arg4, arg5);
}

syscall::write*:entry

{
	trace(*(int *)0);
}

syscall::write*:entry,

ERROR {
	printf("%d / %d / %d / %d / %d / %d\n",
	       arg0, arg1, arg2, arg3, arg4, arg5);
}

syscall::write*:entry

{
	exit(self->arg0 != arg0 || self->arg1 != arg1 || self->arg2 != arg2 ||
	     self->arg3 != arg3 || self->arg4 != arg4 || self->arg5 != arg5
		? 1 : 0);
}

So, we need the ERROR prid value exposed as an external symbol so that it can be used in dt_probe_error(), and a patch that fixes the contamination of the arg values.

Quoted 90 lines
---
  bpf/probe_error.c                         |  3 +++
  test/unittest/builtinvar/tst.id_ERROR.d   | 32 +++++++++++++++++++++++
  test/unittest/builtinvar/tst.id_ERROR.r   |  3 +++
  test/unittest/builtinvar/tst.id_ERROR.r.p |  4 +++
  4 files changed, 42 insertions(+)

create mode 100644 test/unittest/builtinvar/tst.id_ERROR.d create mode 100644 test/unittest/builtinvar/tst.id_ERROR.r create mode 100755 test/unittest/builtinvar/tst.id_ERROR.r.p

bpf/probe_error.c +3 -0
index c8ddcdfa..ee1a1793 100644
@@ -26,6 +26,7 @@ noinline void dt_probe_error(const dt_dctx_t *dctx, uint64_t pc, uint64_t fault,
  			     uint64_t illval)
  {
  	dt_mstate_t	*mst = dctx->mst;
+	int		oldprid = mst->prid;
  	mst->argv[0] = 0;
  	mst->argv[1] = mst->epid;
@@ -34,7 +35,9 @@ noinline void dt_probe_error(const dt_dctx_t *dctx, uint64_t pc, uint64_t fault,
  	mst->argv[4] = fault;
  	mst->argv[5] = illval;
+	mst->prid = 3;
  	dt_error(dctx);
+	mst->prid = oldprid;
  	mst->fault = fault;
  }
test/unittest/builtinvar/tst.id_ERROR.d new file +32 -0
new file mode 100644
index 00000000..59021c60
@@ -0,0 +1,32 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 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:
+ * The id in the ERROR probe is 3.
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+tick-1s
+{
+	/* trigger the ERROR probe */
+	trace(*((int*)0));
+}
+
+tick-2s
+{
+	exit(1);
+}
+
+ERROR
+{
+	printf("id of the ERROR probe = %d\n", id);
+	exit(0);
+}
test/unittest/builtinvar/tst.id_ERROR.r new file +3 -0
new file mode 100644
index 00000000..95974abe
@@ -0,0 +1,3 @@
+id of the ERROR probe = 3
+
+-- @@stderr --
test/unittest/builtinvar/tst.id_ERROR.r.p new file +4 -0
new file mode 100755
index 00000000..884b43f4
@@ -0,0 +1,4 @@
+#!/usr/bin/gawk -f
+
+# Drop the line with run-dependent PRID for profile probe.
+!/error on enabled probe ID/ { print }
Signature · 1 line
2.43.5
#10 lore raw

Re: [PATCH 05/22] Set the ERROR PRID in BPF code

In addition, I think that the test should compare the id reported by the ERROR probe against the id given in dtrace -ln dtrace:::ERROR output. Yes, it will be 3 (and I think putting the following three defines in dt_dctx.h would be helpful with that), but by doing the comparison against the dtrace -l output avoids having to encode a constant value in the expected output (and we cannot easily access the defines from the test).

/* Static probe IDs for the dtrace provider. */
#define DTRACE_BEGIN_ID 1
#define DTRACE_END_ID 2
#define DTRACE_ERROR_ID 3

Quoted 163 lines · Kris Van Hees
Quoted 6 lines · Eugene Loh
Quoted 4 lines · Kris Van Hees
Quoted 3 lines · On Thu, Aug 29, 2024 at 01:22:02AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

We use the fact that the ERROR PRID is always 3.

Quoted 8 lines
Quoted 5 lines

Where do we use it? We certainly should never override the probe id that is assigned by dtrace when providers provide probes. Will it always be 3? Almost certainly, yes. But the right way to do this is to actually make the ERROR PRID available as a symbol that can be resolved at program load time, so that the dt_probe_error function can get to its value.

I'm confused?  I thought I did this and you suggested simply hardwiring the value 3. https://oss.oracle.com/pipermail/dtrace-devel/2024-July/004989.html

True, though I didn't mean to just hardwire the value 3. At a minimum, I think it ought to be a define to set the value of the BEGIN, END, and ERROR probe, so that a symbolic name can be used in code. And that probably would mean that it is best to add a check in the dtrace provider to ensure that those are indeed the probe ids assigned to BEGIN/END/ERROR (and if not, something is very wrong).

Quoted 8 lines
Quoted 6 lines

Anyway, the need to restore the mst->prid value in this patch also highlights that there is a much bigger problem... A fault in one clause contaminates the first 6 arguments of the probe, and since a fault only interrupts the execution of the current clause, following clauses will no longer see the correct values of the first 6 arguments but rather the ones that dt_probe_error() stored in mst->argv[0 .. 5]. That is a bug for sure!

Good point, but... a separate issue/patch?

Yes, already written :)

Quoted 129 lines
Quoted 129 lines

Here is a test that demonstrates this issue:

#pragma D option quiet

syscall::write*:entry

{
	self->arg0 = arg0;
	self->arg1 = arg1;
	self->arg2 = arg2;
	self->arg3 = arg3;
	self->arg4 = arg4;
	self->arg5 = arg5;

	printf("%d / %d / %d / %d / %d / %d\n",
	       arg0, arg1, arg2, arg3, arg4, arg5);
}

syscall::write*:entry

{
	trace(*(int *)0);
}

syscall::write*:entry,

ERROR {
	printf("%d / %d / %d / %d / %d / %d\n",
	       arg0, arg1, arg2, arg3, arg4, arg5);
}

syscall::write*:entry

{
	exit(self->arg0 != arg0 || self->arg1 != arg1 || self->arg2 != arg2 ||
	     self->arg3 != arg3 || self->arg4 != arg4 || self->arg5 != arg5
		? 1 : 0);
}

So, we need the ERROR prid value exposed as an external symbol so that it can be used in dt_probe_error(), and a patch that fixes the contamination of the arg values.

Quoted 90 lines
---
  bpf/probe_error.c                         |  3 +++
  test/unittest/builtinvar/tst.id_ERROR.d   | 32 +++++++++++++++++++++++
  test/unittest/builtinvar/tst.id_ERROR.r   |  3 +++
  test/unittest/builtinvar/tst.id_ERROR.r.p |  4 +++
  4 files changed, 42 insertions(+)

create mode 100644 test/unittest/builtinvar/tst.id_ERROR.d create mode 100644 test/unittest/builtinvar/tst.id_ERROR.r create mode 100755 test/unittest/builtinvar/tst.id_ERROR.r.p

bpf/probe_error.c +3 -0
index c8ddcdfa..ee1a1793 100644
@@ -26,6 +26,7 @@ noinline void dt_probe_error(const dt_dctx_t *dctx, uint64_t pc, uint64_t fault,
  			     uint64_t illval)
  {
  	dt_mstate_t	*mst = dctx->mst;
+	int		oldprid = mst->prid;
  	mst->argv[0] = 0;
  	mst->argv[1] = mst->epid;
@@ -34,7 +35,9 @@ noinline void dt_probe_error(const dt_dctx_t *dctx, uint64_t pc, uint64_t fault,
  	mst->argv[4] = fault;
  	mst->argv[5] = illval;
+	mst->prid = 3;
  	dt_error(dctx);
+	mst->prid = oldprid;
  	mst->fault = fault;
  }
test/unittest/builtinvar/tst.id_ERROR.d new file +32 -0
new file mode 100644
index 00000000..59021c60
@@ -0,0 +1,32 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 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:
+ * The id in the ERROR probe is 3.
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+tick-1s
+{
+	/* trigger the ERROR probe */
+	trace(*((int*)0));
+}
+
+tick-2s
+{
+	exit(1);
+}
+
+ERROR
+{
+	printf("id of the ERROR probe = %d\n", id);
+	exit(0);
+}
test/unittest/builtinvar/tst.id_ERROR.r new file +3 -0
new file mode 100644
index 00000000..95974abe
@@ -0,0 +1,3 @@
+id of the ERROR probe = 3
+
+-- @@stderr --
test/unittest/builtinvar/tst.id_ERROR.r.p new file +4 -0
new file mode 100755
index 00000000..884b43f4
@@ -0,0 +1,4 @@
+#!/usr/bin/gawk -f
+
+# Drop the line with run-dependent PRID for profile probe.
+!/error on enabled probe ID/ { print }
Signature · 1 line
2.43.5
author
#11 lore raw

Re: [PATCH 05/22] Set the ERROR PRID in BPF code

Okay.  I posted a v2.  I also posted a v5 of "Deprecate EPID" since it experiences a minor side effect.

Quoted 172 lines · Kris Van Hees

In addition, I think that the test should compare the id reported by the ERROR probe against the id given in dtrace -ln dtrace:::ERROR output. Yes, it will be 3 (and I think putting the following three defines in dt_dctx.h would be helpful with that), but by doing the comparison against the dtrace -l output avoids having to encode a constant value in the expected output (and we cannot easily access the defines from the test).

/* Static probe IDs for the dtrace provider. */
#define DTRACE_BEGIN_ID 1
#define DTRACE_END_ID 2
#define DTRACE_ERROR_ID 3

Quoted 159 lines · Kris Van Hees
Quoted 5 lines · Eugene Loh
Quoted 3 lines · Kris Van Hees
Quoted 2 lines · On Thu, Aug 29, 2024 at 01:22:02AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

We use the fact that the ERROR PRID is always 3.

Where do we use it? We certainly should never override the probe id that is assigned by dtrace when providers provide probes. Will it always be 3? Almost certainly, yes. But the right way to do this is to actually make the ERROR PRID available as a symbol that can be resolved at program load time, so that the dt_probe_error function can get to its value.

I'm confused?  I thought I did this and you suggested simply hardwiring the value 3. https://oss.oracle.com/pipermail/dtrace-devel/2024-July/004989.html

True, though I didn't mean to just hardwire the value 3. At a minimum, I think it ought to be a define to set the value of the BEGIN, END, and ERROR probe, so that a symbolic name can be used in code. And that probably would mean that it is best to add a check in the dtrace provider to ensure that those are indeed the probe ids assigned to BEGIN/END/ERROR (and if not, something is very wrong).

Quoted 7 lines
Quoted 6 lines

Anyway, the need to restore the mst->prid value in this patch also highlights that there is a much bigger problem... A fault in one clause contaminates the first 6 arguments of the probe, and since a fault only interrupts the execution of the current clause, following clauses will no longer see the correct values of the first 6 arguments but rather the ones that dt_probe_error() stored in mst->argv[0 .. 5]. That is a bug for sure!

Good point, but... a separate issue/patch?

Yes, already written :)

Quoted 129 lines
Quoted 129 lines

Here is a test that demonstrates this issue:

#pragma D option quiet

syscall::write*:entry

{
	self->arg0 = arg0;
	self->arg1 = arg1;
	self->arg2 = arg2;
	self->arg3 = arg3;
	self->arg4 = arg4;
	self->arg5 = arg5;

	printf("%d / %d / %d / %d / %d / %d\n",
	       arg0, arg1, arg2, arg3, arg4, arg5);
}

syscall::write*:entry

{
	trace(*(int *)0);
}

syscall::write*:entry,

ERROR {
	printf("%d / %d / %d / %d / %d / %d\n",
	       arg0, arg1, arg2, arg3, arg4, arg5);
}

syscall::write*:entry

{
	exit(self->arg0 != arg0 || self->arg1 != arg1 || self->arg2 != arg2 ||
	     self->arg3 != arg3 || self->arg4 != arg4 || self->arg5 != arg5
		? 1 : 0);
}

So, we need the ERROR prid value exposed as an external symbol so that it can be used in dt_probe_error(), and a patch that fixes the contamination of the arg values.

Quoted 90 lines
---
   bpf/probe_error.c                         |  3 +++
   test/unittest/builtinvar/tst.id_ERROR.d   | 32 +++++++++++++++++++++++
   test/unittest/builtinvar/tst.id_ERROR.r   |  3 +++
   test/unittest/builtinvar/tst.id_ERROR.r.p |  4 +++
   4 files changed, 42 insertions(+)

create mode 100644 test/unittest/builtinvar/tst.id_ERROR.d create mode 100644 test/unittest/builtinvar/tst.id_ERROR.r create mode 100755 test/unittest/builtinvar/tst.id_ERROR.r.p

bpf/probe_error.c +3 -0
index c8ddcdfa..ee1a1793 100644
@@ -26,6 +26,7 @@ noinline void dt_probe_error(const dt_dctx_t *dctx, uint64_t pc, uint64_t fault,
   			     uint64_t illval)
   {
   	dt_mstate_t	*mst = dctx->mst;
+	int		oldprid = mst->prid;
   	mst->argv[0] = 0;
   	mst->argv[1] = mst->epid;
@@ -34,7 +35,9 @@ noinline void dt_probe_error(const dt_dctx_t *dctx, uint64_t pc, uint64_t fault,
   	mst->argv[4] = fault;
   	mst->argv[5] = illval;
+	mst->prid = 3;
   	dt_error(dctx);
+	mst->prid = oldprid;
   	mst->fault = fault;
   }
test/unittest/builtinvar/tst.id_ERROR.d new file +32 -0
new file mode 100644
index 00000000..59021c60
@@ -0,0 +1,32 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 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:
+ * The id in the ERROR probe is 3.
+ *
+ * SECTION: Variables/Built-in Variables
+ */
+
+#pragma D option quiet
+
+tick-1s
+{
+	/* trigger the ERROR probe */
+	trace(*((int*)0));
+}
+
+tick-2s
+{
+	exit(1);
+}
+
+ERROR
+{
+	printf("id of the ERROR probe = %d\n", id);
+	exit(0);
+}
test/unittest/builtinvar/tst.id_ERROR.r new file +3 -0
new file mode 100644
index 00000000..95974abe
@@ -0,0 +1,3 @@
+id of the ERROR probe = 3
+
+-- @@stderr --
test/unittest/builtinvar/tst.id_ERROR.r.p new file +4 -0
new file mode 100755
index 00000000..884b43f4
@@ -0,0 +1,4 @@
+#!/usr/bin/gawk -f
+
+# Drop the line with run-dependent PRID for profile probe.
+!/error on enabled probe ID/ { print }
Signature · 1 line
2.43.5
#12 lore raw

PATCH 6/22 Fix provider lookup to use prv not prb

In reply to [email protected]

From: Eugene Loh <[email protected]>

---
 libdtrace/dt_prov_uprobe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libdtrace/dt_prov_uprobe.c +1 -1
index 09a9ae58..cbde6a48 100644
@@ -247,7 +247,7 @@ static int provide_probe(dtrace_hdl_t *dtp, const pid_probespec_t *psp,
 	pd.prb = prb;
 
 	/* Get (or create) the provider for the PID of the probe. */
-	pvp = dt_provider_lookup(dtp, pd.prb);
+	pvp = dt_provider_lookup(dtp, pd.prv);
 	if (pvp == NULL) {
 		pvp = dt_provider_create(dtp, pd.prv, pvops, &pattr, NULL);
 		if (pvp == NULL)
Signature · 1 line
2.43.5
Reviewed-by on v1 6/22
#13 lore raw

Re: [PATCH 06/22] Fix provider lookup to use prv not prb

Quoted 3 lines · On Thu, Aug 29, 2024 at 01:22:03AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

Quoted 20 lines
---
 libdtrace/dt_prov_uprobe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libdtrace/dt_prov_uprobe.c +1 -1
index 09a9ae58..cbde6a48 100644
@@ -247,7 +247,7 @@ static int provide_probe(dtrace_hdl_t *dtp, const pid_probespec_t *psp,
 	pd.prb = prb;
 
 	/* Get (or create) the provider for the PID of the probe. */
-	pvp = dt_provider_lookup(dtp, pd.prb);
+	pvp = dt_provider_lookup(dtp, pd.prv);
 	if (pvp == NULL) {
 		pvp = dt_provider_create(dtp, pd.prv, pvops, &pattr, NULL);
 		if (pvp == NULL)
Signature · 1 line
2.43.5
#14 lore raw

PATCH 7/22 Supply a default probe_info()

In reply to [email protected]

From: Eugene Loh <[email protected]>

---
 libdtrace/dt_probe.c        |  4 +++-
 libdtrace/dt_prov_cpc.c     | 11 -----------
 libdtrace/dt_prov_dtrace.c  | 10 ----------
 libdtrace/dt_prov_fbt.c     | 10 ----------
 libdtrace/dt_prov_profile.c | 11 -----------
 5 files changed, 3 insertions(+), 43 deletions(-)
libdtrace/dt_probe.c +3 -1
index 0b53121a..ab90d2ed 100644
@@ -892,8 +892,10 @@ dt_probe_args_info(dtrace_hdl_t *dtp, dt_probe_t *prp)
 	/* Only retrieve probe argument information once per probe. */
 	if (prp->argc != -1)
 		return 0;
-	if (!prp->prov->impl->probe_info)
+	if (!prp->prov->impl->probe_info) {
+		prp->argc = 0;
 		return 0;
+	}
 	rc = prp->prov->impl->probe_info(dtp, prp, &argc, &argv);
 	if (rc == -1)
 		return rc;
libdtrace/dt_prov_cpc.c +0 -11
index 08689b35..8f33cf58 100644
@@ -451,16 +451,6 @@ static int attach(dtrace_hdl_t *dtp, const dt_probe_t *prp, int bpf_fd)
 	return nattach > 0 ? 0 : -1;
 }
 
-static int probe_info(dtrace_hdl_t *dtp, const dt_probe_t *prp,
-		      int *argcp, dt_argdesc_t **argvp)
-{
-	/* cpc-provider probe arguments are not typed */
-	*argcp = 0;
-	*argvp = NULL;
-
-	return 0;
-}
-
 static void detach(dtrace_hdl_t *dtp, const dt_probe_t *prp)
 {
 	cpc_probe_t	*datap = prp->prv_data;
@@ -504,7 +494,6 @@ dt_provimpl_t	dt_cpc = {
 	.load_prog	= &dt_bpf_prog_load,
 	.trampoline	= &trampoline,
 	.attach		= &attach,
-	.probe_info	= &probe_info,
 	.detach		= &detach,
 	.probe_destroy	= &probe_destroy,
 	.destroy	= &destroy,
libdtrace/dt_prov_dtrace.c +0 -10
index bf87cb05..a9deccee 100644
@@ -273,15 +273,6 @@ static int attach(dtrace_hdl_t *dtp, const dt_probe_t *prp, int bpf_fd)
 	return dt_tp_probe_attach(dtp, prp, bpf_fd);
 }
 
-static int probe_info(dtrace_hdl_t *dtp, const dt_probe_t *prp,
-		      int *argcp, dt_argdesc_t **argvp)
-{
-	*argcp = 0;			/* no arguments */
-	*argvp = NULL;
-
-	return 0;
-}
-
 /*
  * Try to clean up system resources that may have been allocated for this
  * probe.
@@ -317,7 +308,6 @@ dt_provimpl_t	dt_dtrace = {
 	.trampoline	= &trampoline,
 	.load_prog	= &dt_bpf_prog_load,
 	.attach		= &attach,
-	.probe_info	= &probe_info,
 	.detach		= &detach,
 	.probe_destroy	= &dt_tp_probe_destroy,
 };
libdtrace/dt_prov_fbt.c +0 -10
index 62c568ce..21f63ddf 100644
@@ -411,15 +411,6 @@ static int kprobe_attach(dtrace_hdl_t *dtp, const dt_probe_t *prp, int bpf_fd)
 	return dt_tp_probe_attach(dtp, prp, bpf_fd);
 }
 
-static int kprobe_probe_info(dtrace_hdl_t *dtp, const dt_probe_t *prp,
-			     int *argcp, dt_argdesc_t **argvp)
-{
-	*argcp = 0;			/* no arguments by default */
-	*argvp = NULL;
-
-	return 0;
-}
-
 /*
  * Try to clean up system resources that may have been allocated for this
  * probe.
@@ -469,7 +460,6 @@ dt_provimpl_t	dt_fbt_kprobe = {
 	.load_prog	= &dt_bpf_prog_load,
 	.trampoline	= &kprobe_trampoline,
 	.attach		= &kprobe_attach,
-	.probe_info	= &kprobe_probe_info,
 	.detach		= &kprobe_detach,
 	.probe_destroy	= &dt_tp_probe_destroy,
 };
libdtrace/dt_prov_profile.c +0 -11
index bc224348..e1369ca9 100644
@@ -299,16 +299,6 @@ static int attach(dtrace_hdl_t *dtp, const dt_probe_t *prp, int bpf_fd)
 	return nattach > 0 ? 0 : -1;
 }
 
-static int probe_info(dtrace_hdl_t *dtp, const dt_probe_t *prp,
-		      int *argcp, dt_argdesc_t **argvp)
-{
-	/* profile-provider probe arguments are not typed */
-	*argcp = 0;
-	*argvp = NULL;
-
-	return 0;
-}
-
 static void detach(dtrace_hdl_t *dtp, const dt_probe_t *prp)
 {
 	profile_probe_t	*pp = prp->prv_data;
@@ -337,7 +327,6 @@ dt_provimpl_t	dt_profile = {
 	.load_prog	= &dt_bpf_prog_load,
 	.trampoline	= &trampoline,
 	.attach		= &attach,
-	.probe_info	= &probe_info,
 	.detach		= &detach,
 	.probe_destroy	= &probe_destroy,
 };
Signature · 1 line
2.43.5
#15 lore raw

Re: [PATCH 07/22] Supply a default probe_info()

Is this still needed after the fix we put in for dealing with argc == -1, i.e. commit 0e3231a268 "ident: fix unsigned vs signed comparison" ?

Quoted 144 lines · On Thu, Aug 29, 2024 at 01:22:04AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

---
 libdtrace/dt_probe.c        |  4 +++-
 libdtrace/dt_prov_cpc.c     | 11 -----------
 libdtrace/dt_prov_dtrace.c  | 10 ----------
 libdtrace/dt_prov_fbt.c     | 10 ----------
 libdtrace/dt_prov_profile.c | 11 -----------
 5 files changed, 3 insertions(+), 43 deletions(-)
libdtrace/dt_probe.c +3 -1
index 0b53121a..ab90d2ed 100644
@@ -892,8 +892,10 @@ dt_probe_args_info(dtrace_hdl_t *dtp, dt_probe_t *prp)
 	/* Only retrieve probe argument information once per probe. */
 	if (prp->argc != -1)
 		return 0;
-	if (!prp->prov->impl->probe_info)
+	if (!prp->prov->impl->probe_info) {
+		prp->argc = 0;
 		return 0;
+	}
 	rc = prp->prov->impl->probe_info(dtp, prp, &argc, &argv);
 	if (rc == -1)
 		return rc;
libdtrace/dt_prov_cpc.c +0 -11
index 08689b35..8f33cf58 100644
@@ -451,16 +451,6 @@ static int attach(dtrace_hdl_t *dtp, const dt_probe_t *prp, int bpf_fd)
 	return nattach > 0 ? 0 : -1;
 }
 
-static int probe_info(dtrace_hdl_t *dtp, const dt_probe_t *prp,
-		      int *argcp, dt_argdesc_t **argvp)
-{
-	/* cpc-provider probe arguments are not typed */
-	*argcp = 0;
-	*argvp = NULL;
-
-	return 0;
-}
-
 static void detach(dtrace_hdl_t *dtp, const dt_probe_t *prp)
 {
 	cpc_probe_t	*datap = prp->prv_data;
@@ -504,7 +494,6 @@ dt_provimpl_t	dt_cpc = {
 	.load_prog	= &dt_bpf_prog_load,
 	.trampoline	= &trampoline,
 	.attach		= &attach,
-	.probe_info	= &probe_info,
 	.detach		= &detach,
 	.probe_destroy	= &probe_destroy,
 	.destroy	= &destroy,
libdtrace/dt_prov_dtrace.c +0 -10
index bf87cb05..a9deccee 100644
@@ -273,15 +273,6 @@ static int attach(dtrace_hdl_t *dtp, const dt_probe_t *prp, int bpf_fd)
 	return dt_tp_probe_attach(dtp, prp, bpf_fd);
 }
 
-static int probe_info(dtrace_hdl_t *dtp, const dt_probe_t *prp,
-		      int *argcp, dt_argdesc_t **argvp)
-{
-	*argcp = 0;			/* no arguments */
-	*argvp = NULL;
-
-	return 0;
-}
-
 /*
  * Try to clean up system resources that may have been allocated for this
  * probe.
@@ -317,7 +308,6 @@ dt_provimpl_t	dt_dtrace = {
 	.trampoline	= &trampoline,
 	.load_prog	= &dt_bpf_prog_load,
 	.attach		= &attach,
-	.probe_info	= &probe_info,
 	.detach		= &detach,
 	.probe_destroy	= &dt_tp_probe_destroy,
 };
libdtrace/dt_prov_fbt.c +0 -10
index 62c568ce..21f63ddf 100644
@@ -411,15 +411,6 @@ static int kprobe_attach(dtrace_hdl_t *dtp, const dt_probe_t *prp, int bpf_fd)
 	return dt_tp_probe_attach(dtp, prp, bpf_fd);
 }
 
-static int kprobe_probe_info(dtrace_hdl_t *dtp, const dt_probe_t *prp,
-			     int *argcp, dt_argdesc_t **argvp)
-{
-	*argcp = 0;			/* no arguments by default */
-	*argvp = NULL;
-
-	return 0;
-}
-
 /*
  * Try to clean up system resources that may have been allocated for this
  * probe.
@@ -469,7 +460,6 @@ dt_provimpl_t	dt_fbt_kprobe = {
 	.load_prog	= &dt_bpf_prog_load,
 	.trampoline	= &kprobe_trampoline,
 	.attach		= &kprobe_attach,
-	.probe_info	= &kprobe_probe_info,
 	.detach		= &kprobe_detach,
 	.probe_destroy	= &dt_tp_probe_destroy,
 };
libdtrace/dt_prov_profile.c +0 -11
index bc224348..e1369ca9 100644
@@ -299,16 +299,6 @@ static int attach(dtrace_hdl_t *dtp, const dt_probe_t *prp, int bpf_fd)
 	return nattach > 0 ? 0 : -1;
 }
 
-static int probe_info(dtrace_hdl_t *dtp, const dt_probe_t *prp,
-		      int *argcp, dt_argdesc_t **argvp)
-{
-	/* profile-provider probe arguments are not typed */
-	*argcp = 0;
-	*argvp = NULL;
-
-	return 0;
-}
-
 static void detach(dtrace_hdl_t *dtp, const dt_probe_t *prp)
 {
 	profile_probe_t	*pp = prp->prv_data;
@@ -337,7 +327,6 @@ dt_provimpl_t	dt_profile = {
 	.load_prog	= &dt_bpf_prog_load,
 	.trampoline	= &trampoline,
 	.attach		= &attach,
-	.probe_info	= &probe_info,
 	.detach		= &detach,
 	.probe_destroy	= &probe_destroy,
 };
Signature · 1 line
2.43.5
#16 lore raw

Re: [PATCH 07/22] Supply a default probe_info()

Quoted 2 lines · Kris Van Hees

Is this still needed after the fix we put in for dealing with argc == -1, i.e. commit 0e3231a268 "ident: fix unsigned vs signed comparison" ?

Ah no, you posted one that is based on the ident fix.

Comments below...

Quoted 12 lines · On Thu, Aug 29, 2024 at 01:22:04AM -0400, [email protected] wrote:
Quoted 11 lines

From: Eugene Loh <[email protected]>

---
 libdtrace/dt_probe.c        |  4 +++-
 libdtrace/dt_prov_cpc.c     | 11 -----------
 libdtrace/dt_prov_dtrace.c  | 10 ----------
 libdtrace/dt_prov_fbt.c     | 10 ----------
 libdtrace/dt_prov_profile.c | 11 -----------
 5 files changed, 3 insertions(+), 43 deletions(-)
Quoted 16 lines
Quoted 6 lines
libdtrace/dt_probe.c +0 -0
index 0b53121a..ab90d2ed 100644
@@ -892,8 +892,10 @@ dt_probe_args_info(dtrace_hdl_t *dtp, dt_probe_t *prp)
 	/* Only retrieve probe argument information once per probe. */

libdtrace/dt_probe.c dt_probe_args_info(dtrace_hdl_t *dtp, dt_probe_t *prp) · line 901

Quoted 10 lines
libdtrace/dt_probe.c +3 -1
 	if (prp->argc != -1)
 		return 0;
-	if (!prp->prov->impl->probe_info)
+	if (!prp->prov->impl->probe_info) {
+		prp->argc = 0;
 		return 0;
+	}
 	rc = prp->prov->impl->probe_info(dtp, prp, &argc, &argv);
 	if (rc == -1)
 		return rc;

I think that it might be cleaner to do:

	if (prp->prov->impl->probe_info &&
	    prp->prov->impl->probe_info(dtp, prp, &argc, &argv) == -1)
		return -1;

because the code that follows will look at argc (initialized as 0) and argv (initialized as NULL), so if there is no probe_info hook, those initial values will result in prp->argc being set to 0.

Quoted 117 lines
Quoted 117 lines
libdtrace/dt_prov_cpc.c +0 -11
index 08689b35..8f33cf58 100644
@@ -451,16 +451,6 @@ static int attach(dtrace_hdl_t *dtp, const dt_probe_t *prp, int bpf_fd)
 	return nattach > 0 ? 0 : -1;
 }
 
-static int probe_info(dtrace_hdl_t *dtp, const dt_probe_t *prp,
-		      int *argcp, dt_argdesc_t **argvp)
-{
-	/* cpc-provider probe arguments are not typed */
-	*argcp = 0;
-	*argvp = NULL;
-
-	return 0;
-}
-
 static void detach(dtrace_hdl_t *dtp, const dt_probe_t *prp)
 {
 	cpc_probe_t	*datap = prp->prv_data;
@@ -504,7 +494,6 @@ dt_provimpl_t	dt_cpc = {
 	.load_prog	= &dt_bpf_prog_load,
 	.trampoline	= &trampoline,
 	.attach		= &attach,
-	.probe_info	= &probe_info,
 	.detach		= &detach,
 	.probe_destroy	= &probe_destroy,
 	.destroy	= &destroy,
libdtrace/dt_prov_dtrace.c +0 -10
index bf87cb05..a9deccee 100644
@@ -273,15 +273,6 @@ static int attach(dtrace_hdl_t *dtp, const dt_probe_t *prp, int bpf_fd)
 	return dt_tp_probe_attach(dtp, prp, bpf_fd);
 }
 
-static int probe_info(dtrace_hdl_t *dtp, const dt_probe_t *prp,
-		      int *argcp, dt_argdesc_t **argvp)
-{
-	*argcp = 0;			/* no arguments */
-	*argvp = NULL;
-
-	return 0;
-}
-
 /*
  * Try to clean up system resources that may have been allocated for this
  * probe.
@@ -317,7 +308,6 @@ dt_provimpl_t	dt_dtrace = {
 	.trampoline	= &trampoline,
 	.load_prog	= &dt_bpf_prog_load,
 	.attach		= &attach,
-	.probe_info	= &probe_info,
 	.detach		= &detach,
 	.probe_destroy	= &dt_tp_probe_destroy,
 };
libdtrace/dt_prov_fbt.c +0 -10
index 62c568ce..21f63ddf 100644
@@ -411,15 +411,6 @@ static int kprobe_attach(dtrace_hdl_t *dtp, const dt_probe_t *prp, int bpf_fd)
 	return dt_tp_probe_attach(dtp, prp, bpf_fd);
 }
 
-static int kprobe_probe_info(dtrace_hdl_t *dtp, const dt_probe_t *prp,
-			     int *argcp, dt_argdesc_t **argvp)
-{
-	*argcp = 0;			/* no arguments by default */
-	*argvp = NULL;
-
-	return 0;
-}
-
 /*
  * Try to clean up system resources that may have been allocated for this
  * probe.
@@ -469,7 +460,6 @@ dt_provimpl_t	dt_fbt_kprobe = {
 	.load_prog	= &dt_bpf_prog_load,
 	.trampoline	= &kprobe_trampoline,
 	.attach		= &kprobe_attach,
-	.probe_info	= &kprobe_probe_info,
 	.detach		= &kprobe_detach,
 	.probe_destroy	= &dt_tp_probe_destroy,
 };
libdtrace/dt_prov_profile.c +0 -11
index bc224348..e1369ca9 100644
@@ -299,16 +299,6 @@ static int attach(dtrace_hdl_t *dtp, const dt_probe_t *prp, int bpf_fd)
 	return nattach > 0 ? 0 : -1;
 }
 
-static int probe_info(dtrace_hdl_t *dtp, const dt_probe_t *prp,
-		      int *argcp, dt_argdesc_t **argvp)
-{
-	/* profile-provider probe arguments are not typed */
-	*argcp = 0;
-	*argvp = NULL;
-
-	return 0;
-}
-
 static void detach(dtrace_hdl_t *dtp, const dt_probe_t *prp)
 {
 	profile_probe_t	*pp = prp->prv_data;
@@ -337,7 +327,6 @@ dt_provimpl_t	dt_profile = {
 	.load_prog	= &dt_bpf_prog_load,
 	.trampoline	= &trampoline,
 	.attach		= &attach,
-	.probe_info	= &probe_info,
 	.detach		= &detach,
 	.probe_destroy	= &probe_destroy,
 };
Signature · 1 line
2.43.5
#17 lore raw

PATCH 8/22 dtprobed: Fix comment typo

In reply to [email protected]

From: Eugene Loh <[email protected]>

---
 dtprobed/dof_stash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
dtprobed/dof_stash.c +1 -1
index 625572d5..0e639076 100644
@@ -64,7 +64,7 @@
  *
  * /run/dtrace/probes/: Per-probe info, written by dtprobed, read by DTrace.
  *
- *    .../$pid/$prv$pid/$mod/$fun/$prb: Hardlink from $prv$pid:$mod:$fun:$prb
+ *    .../$pid/$prv$pid/$mod/$fun/$prb: Hardlink from $prv:$mod:$fun:$prb
  *    above; parsed representation of one probe in a given process. Removed by
  *    dtprobed when the process dies, or if all mappings containing the probe
  *    are unmmapped.  Used by DTrace for tracing by PID.
Signature · 1 line
2.43.5
Reviewed-by on v1 8/22
#18 lore raw

Re: [PATCH 08/22] dtprobed: Fix comment typo

Quoted 3 lines · On Thu, Aug 29, 2024 at 01:22:05AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

Quoted 20 lines
---
 dtprobed/dof_stash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
dtprobed/dof_stash.c +1 -1
index 625572d5..0e639076 100644
@@ -64,7 +64,7 @@
  *
  * /run/dtrace/probes/: Per-probe info, written by dtprobed, read by DTrace.
  *
- *    .../$pid/$prv$pid/$mod/$fun/$prb: Hardlink from $prv$pid:$mod:$fun:$prb
+ *    .../$pid/$prv$pid/$mod/$fun/$prb: Hardlink from $prv:$mod:$fun:$prb
  *    above; parsed representation of one probe in a given process. Removed by
  *    dtprobed when the process dies, or if all mappings containing the probe
  *    are unmmapped.  Used by DTrace for tracing by PID.
Signature · 1 line
2.43.5
#19 lore raw

PATCH 9/22 Clean up dtsd_* members

In reply to [email protected]

From: Eugene Loh <[email protected]>

---
 libdtrace/dtrace.h | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
libdtrace/dtrace.h +1 -4
index 8f40a581..09a87977 100644
@@ -146,10 +146,7 @@ extern void *dtrace_geterr_dof(dtrace_hdl_t *dtp);
 typedef struct dtrace_stmtdesc {
 	dtrace_ecbdesc_t *dtsd_ecbdesc;		/* ECB description */
 	struct dt_ident *dtsd_clause;		/* clause identifier */
-	void *dtsd_aggdata;			/* aggregation data */
-	void *dtsd_fmtdata;			/* type-specific output data */
-	void (*dtsd_callback)();		/* callback function for EPID */
-	void *dtsd_data;			/* callback data pointer */
+	void *dtsd_fmtdata;			/* type-specific output data */    /* FIXME: dead code */
 	dtrace_attribute_t dtsd_descattr;	/* probedesc attributes */
 	dtrace_attribute_t dtsd_stmtattr;	/* statement attributes */
 	int dtsd_clauseflags;			/* clause flags */
Signature · 1 line
2.43.5
Reviewed-by on v1 9/22
#20 lore raw

Re: [PATCH 09/22] Clean up dtsd_* members

Quoted 3 lines · On Thu, Aug 29, 2024 at 01:22:06AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

Quoted 23 lines
---
 libdtrace/dtrace.h | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
libdtrace/dtrace.h +1 -4
index 8f40a581..09a87977 100644
@@ -146,10 +146,7 @@ extern void *dtrace_geterr_dof(dtrace_hdl_t *dtp);
 typedef struct dtrace_stmtdesc {
 	dtrace_ecbdesc_t *dtsd_ecbdesc;		/* ECB description */
 	struct dt_ident *dtsd_clause;		/* clause identifier */
-	void *dtsd_aggdata;			/* aggregation data */
-	void *dtsd_fmtdata;			/* type-specific output data */
-	void (*dtsd_callback)();		/* callback function for EPID */
-	void *dtsd_data;			/* callback data pointer */
+	void *dtsd_fmtdata;			/* type-specific output data */    /* FIXME: dead code */
 	dtrace_attribute_t dtsd_descattr;	/* probedesc attributes */
 	dtrace_attribute_t dtsd_stmtattr;	/* statement attributes */
 	int dtsd_clauseflags;			/* clause flags */
Signature · 1 line
2.43.5
#21 lore raw

PATCH 10/22 Simplify dtrace_stmt_create() attr init

In reply to [email protected]

From: Eugene Loh <[email protected]>

Even though dtrace_stmt_create() initializes dtsd_descattr and dtsd_stmtattr, there is no point to doing so. Its only caller is dt_stmt_create(), which itself sets these members.

---
 libdtrace/dt_program.c | 2 --
 1 file changed, 2 deletions(-)
libdtrace/dt_program.c +0 -2
index a4b052fc..bdb434e0 100644
@@ -240,8 +240,6 @@ dtrace_stmt_create(dtrace_hdl_t *dtp, dtrace_ecbdesc_t *edp)
 
 	dt_ecbdesc_hold(edp);
 	sdp->dtsd_ecbdesc = edp;
-	sdp->dtsd_descattr = _dtrace_defattr;
-	sdp->dtsd_stmtattr = _dtrace_defattr;
 
 	return sdp;
 }
Signature · 1 line
2.43.5
#22 lore raw

Re: [PATCH 10/22] Simplify dtrace_stmt_create() attr init

Quoted 5 lines · On Thu, Aug 29, 2024 at 01:22:07AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

Even though dtrace_stmt_create() initializes dtsd_descattr and dtsd_stmtattr, there is no point to doing so. Its only caller is dt_stmt_create(), which itself sets these members.

No, it is the other way around... It should be done in dtrace_stmt_create() and thus it is no longer needed in dt_stmt_create(). As dtrace_stmt_create() is a libdtrace API function, it can be called from other code, and since it is the function that actual creates the statement and initializes some of its members, it is the logical place to retain setting the attr fields.

So, instead remove the assignments from dt_stmt_create().

Quoted 22 lines
---
 libdtrace/dt_program.c | 2 --
 1 file changed, 2 deletions(-)
libdtrace/dt_program.c +0 -2
index a4b052fc..bdb434e0 100644
@@ -240,8 +240,6 @@ dtrace_stmt_create(dtrace_hdl_t *dtp, dtrace_ecbdesc_t *edp)
 
 	dt_ecbdesc_hold(edp);
 	sdp->dtsd_ecbdesc = edp;
-	sdp->dtsd_descattr = _dtrace_defattr;
-	sdp->dtsd_stmtattr = _dtrace_defattr;
 
 	return sdp;
 }
Signature · 1 line
2.43.5
#23 lore raw

Re: [DTrace-devel] [PATCH 10/22] Simplify dtrace_stmt_create() attr init

I adjusted the patch, and changed the commit message to be:

Simplify dt_stmt_create() attr init

Even though dt_stmt_create() initializes dtsd_descattr and dtsd_stmtattr, there is no point to doing so. It calls dtrace_stmt_create(), which also sets these members.

and added my R-b.

Quoted 42 lines · Kris Van Hees via DTrace-devel
Quoted 5 lines · On Thu, Aug 29, 2024 at 01:22:07AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

Even though dtrace_stmt_create() initializes dtsd_descattr and dtsd_stmtattr, there is no point to doing so. Its only caller is dt_stmt_create(), which itself sets these members.

No, it is the other way around... It should be done in dtrace_stmt_create() and thus it is no longer needed in dt_stmt_create(). As dtrace_stmt_create() is a libdtrace API function, it can be called from other code, and since it is the function that actual creates the statement and initializes some of its members, it is the logical place to retain setting the attr fields.

So, instead remove the assignments from dt_stmt_create().

Quoted 22 lines
---
 libdtrace/dt_program.c | 2 --
 1 file changed, 2 deletions(-)
libdtrace/dt_program.c +0 -2
index a4b052fc..bdb434e0 100644
@@ -240,8 +240,6 @@ dtrace_stmt_create(dtrace_hdl_t *dtp, dtrace_ecbdesc_t *edp)
 
 	dt_ecbdesc_hold(edp);
 	sdp->dtsd_ecbdesc = edp;
-	sdp->dtsd_descattr = _dtrace_defattr;
-	sdp->dtsd_stmtattr = _dtrace_defattr;
 
 	return sdp;
 }
Signature · 1 line
2.43.5

_______________________________________________
DTrace-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/dtrace-devel

author
#24 lore raw

Re: [DTrace-devel] [PATCH 10/22] Simplify dtrace_stmt_create() attr init

Quoted 9 lines · Kris Van Hees

I adjusted the patch, and changed the commit message to be:

Simplify dt_stmt_create() attr init

Even though dt_stmt_create() initializes dtsd_descattr and dtsd_stmtattr, there is no point to doing so. It calls dtrace_stmt_create(), which also sets these members.

and added my R-b.

That doesn't seem to work.  In dtrace_stmt_create(), we have:
        sdp->dtsd_descattr = _dtrace_defattr; sdp->dtsd_stmtattr = _dtrace_defattr;

In dt_stmt_create(), we have:
        dtrace_stmtdesc_t *sdp = dtrace_stmt_create(dtp, edp);
        sdp->dtsd_descattr = descattr;
        sdp->dtsd_stmtattr = stmtattr;
which means that whatever dtrace_stmt_create() does, we overwrite it with the attributes passed in by dt_stmt_create()'s caller.  So, what dtrace_stmt_create() does is irrelevant and what dt_stmt_create()'s caller asks for matters.  So removing the assignments from dtrace_stmt_create() makes sense (except for the API issue) and removing the assignments from dt_stmt_create() is wrong.

Specifically, removing the attr assignments in dt_stmt_create() causes test/unittest/dtrace-util/tst.VerboseStabilityReport.d to fail.

Either we should go with the original version of the patch or, more likely, to preserve the API, the patch should be withdrawn.

Quoted 40 lines · Kris Van Hees via DTrace-devel
Quoted 39 lines · On Thu, Aug 29, 2024 at 01:22:07AM -0400, [email protected] wrote:
Quoted 5 lines

From: Eugene Loh <[email protected]>

Even though dtrace_stmt_create() initializes dtsd_descattr and dtsd_stmtattr, there is no point to doing so. Its only caller is dt_stmt_create(), which itself sets these members.

No, it is the other way around... It should be done in dtrace_stmt_create() and thus it is no longer needed in dt_stmt_create(). As dtrace_stmt_create() is a libdtrace API function, it can be called from other code, and since it is the function that actual creates the statement and initializes some of its members, it is the logical place to retain setting the attr fields.

So, instead remove the assignments from dt_stmt_create().

Quoted 21 lines
---
  libdtrace/dt_program.c | 2 --
  1 file changed, 2 deletions(-)
libdtrace/dt_program.c +0 -2
index a4b052fc..bdb434e0 100644
@@ -240,8 +240,6 @@ dtrace_stmt_create(dtrace_hdl_t *dtp, dtrace_ecbdesc_t *edp)
 
  	dt_ecbdesc_hold(edp);
  	sdp->dtsd_ecbdesc = edp;
-	sdp->dtsd_descattr = _dtrace_defattr;
-	sdp->dtsd_stmtattr = _dtrace_defattr;
 
  	return sdp;
  }
Signature · 1 line
2.43.5

_______________________________________________
DTrace-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/dtrace-devel

#25 lore raw

Re: [DTrace-devel] [PATCH 10/22] Simplify dtrace_stmt_create() attr init

Ah yes, good point. I should have realized that. Yes, then we should just drop the patch (for now). Thanks for catching my mistake.

I'll have to do a revert since I already pushed to dev.... My bad - thanks for pointing it out.

________________________________________
From: Eugene Loh <[email protected]>
Sent: Thursday, September 19, 2024 1:38 PM
To: [email protected]; [email protected]
Subject: Re: [DTrace-devel] [PATCH 10/22] Simplify dtrace_stmt_create() attr init

Quoted 9 lines · Kris Van Hees

I adjusted the patch, and changed the commit message to be:

Simplify dt_stmt_create() attr init

Even though dt_stmt_create() initializes dtsd_descattr and dtsd_stmtattr, there is no point to doing so. It calls dtrace_stmt_create(), which also sets these members.

and added my R-b.

That doesn't seem to work. In dtrace_stmt_create(), we have:

         sdp->dtsd_descattr = _dtrace_defattr;
         sdp->dtsd_stmtattr = _dtrace_defattr;

In dt_stmt_create(), we have:

         dtrace_stmtdesc_t *sdp = dtrace_stmt_create(dtp, edp);
         sdp->dtsd_descattr = descattr;
         sdp->dtsd_stmtattr = stmtattr;

which means that whatever dtrace_stmt_create() does, we overwrite it with the attributes passed in by dt_stmt_create()'s caller. So, what dtrace_stmt_create() does is irrelevant and what dt_stmt_create()'s caller asks for matters. So removing the assignments from dtrace_stmt_create() makes sense (except for the API issue) and removing the assignments from dt_stmt_create() is wrong.

Specifically, removing the attr assignments in dt_stmt_create() causes test/unittest/dtrace-util/tst.VerboseStabilityReport.d to fail.

Either we should go with the original version of the patch or, more likely, to preserve the API, the patch should be withdrawn.

Quoted 40 lines · Kris Van Hees via DTrace-devel
Quoted 39 lines · On Thu, Aug 29, 2024 at 01:22:07AM -0400, [email protected] wrote:
Quoted 5 lines

From: Eugene Loh <[email protected]>

Even though dtrace_stmt_create() initializes dtsd_descattr and dtsd_stmtattr, there is no point to doing so. Its only caller is dt_stmt_create(), which itself sets these members.

No, it is the other way around... It should be done in dtrace_stmt_create() and thus it is no longer needed in dt_stmt_create(). As dtrace_stmt_create() is a libdtrace API function, it can be called from other code, and since it is the function that actual creates the statement and initializes some of its members, it is the logical place to retain setting the attr fields.

So, instead remove the assignments from dt_stmt_create().

Quoted 19 lines
---
  libdtrace/dt_program.c | 2 --
  1 file changed, 2 deletions(-)
libdtrace/dt_program.c +0 -3
index a4b052fc..bdb434e0 100644
@@ -240,8 +240,6 @@ dtrace_stmt_create(dtrace_hdl_t *dtp, dtrace_ecbdesc_t *edp)
 
    dt_ecbdesc_hold(edp);
    sdp->dtsd_ecbdesc = edp;
-   sdp->dtsd_descattr = _dtrace_defattr;
-   sdp->dtsd_stmtattr = _dtrace_defattr;
 
    return sdp;
  }
--
Quoted 2 lines

2.43.5

_______________________________________________
DTrace-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/dtrace-devel

#26 lore raw

PATCH 11/22 DTPPT_POST_OFFSETS is unused

In reply to [email protected]

From: Eugene Loh <[email protected]>

---
 include/dtrace/pid.h | 1 -
 1 file changed, 1 deletion(-)
include/dtrace/pid.h +0 -1
index 1fd594b6..0129674a 100644
@@ -22,7 +22,6 @@ typedef enum pid_probetype {
 	DTPPT_ENTRY,
 	DTPPT_RETURN,
 	DTPPT_OFFSETS,
-	DTPPT_POST_OFFSETS,
 	DTPPT_IS_ENABLED
 } pid_probetype_t;
 
Signature · 1 line
2.43.5
Reviewed-by on v1 11/22
#27 lore raw

Re: [PATCH 11/22] DTPPT_POST_OFFSETS is unused

Quoted 3 lines · On Thu, Aug 29, 2024 at 01:22:08AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

Quoted 19 lines
---
 include/dtrace/pid.h | 1 -
 1 file changed, 1 deletion(-)
include/dtrace/pid.h +0 -1
index 1fd594b6..0129674a 100644
@@ -22,7 +22,6 @@ typedef enum pid_probetype {
 	DTPPT_ENTRY,
 	DTPPT_RETURN,
 	DTPPT_OFFSETS,
-	DTPPT_POST_OFFSETS,
 	DTPPT_IS_ENABLED
 } pid_probetype_t;
 
Signature · 1 line
2.43.5
#28 lore raw

PATCH 12/22 Remove apparently redundant assignment

In reply to [email protected]

From: Eugene Loh <[email protected]>

---
 libdtrace/dt_aggregate.c | 1 -
 1 file changed, 1 deletion(-)
libdtrace/dt_aggregate.c +0 -1
index 8825739c..d87d49e8 100644
@@ -621,7 +621,6 @@ dt_aggregate_snap_one(dtrace_hdl_t *dtp, int aggid, int cpu, const char *key,
 		}
 
 		/* Skip if data gen is older than hash gen.  */
-		hgen = *(int64_t *)agd->dtada_data;
 		if (dgen < hgen)
 			return 0;
 
Signature · 1 line
2.43.5
Reviewed-by on v1 12/22
#29 lore raw

Re: [PATCH 12/22] Remove apparently redundant assignment

Quoted 3 lines · On Thu, Aug 29, 2024 at 01:22:09AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

Quoted 19 lines
---
 libdtrace/dt_aggregate.c | 1 -
 1 file changed, 1 deletion(-)
libdtrace/dt_aggregate.c +0 -1
index 8825739c..d87d49e8 100644
@@ -621,7 +621,6 @@ dt_aggregate_snap_one(dtrace_hdl_t *dtp, int aggid, int cpu, const char *key,
 		}
 
 		/* Skip if data gen is older than hash gen.  */
-		hgen = *(int64_t *)agd->dtada_data;
 		if (dgen < hgen)
 			return 0;
 
Signature · 1 line
2.43.5
#30 lore raw

PATCH 13/22 Eliminate unused args to dt_spec_buf_add_data()

In reply to [email protected]

From: Eugene Loh <[email protected]>

---
 libdtrace/dt_consume.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
libdtrace/dt_consume.c +2 -5
index 6aa9812e..51eb6c80 100644
@@ -2060,9 +2060,7 @@ oom:
 
 static dt_spec_buf_data_t *
 dt_spec_buf_add_data(dtrace_hdl_t *dtp, dt_spec_buf_t *dtsb,
-		     dtrace_epid_t epid, unsigned int cpu,
-		     dtrace_datadesc_t *datadesc, char *data,
-		     uint32_t size)
+		     unsigned int cpu, char *data, uint32_t size)
 {
 	dt_spec_buf_data_t *dsbd;
 
@@ -2265,8 +2263,7 @@ dt_consume_one_probe(dtrace_hdl_t *dtp, FILE *fp, char *data, uint32_t size,
 			}
 		}
 
-		if (dt_spec_buf_add_data(dtp, dtsb, epid, pdat->dtpda_cpu, epd,
-					 data, size) == NULL)
+		if (dt_spec_buf_add_data(dtp, dtsb, pdat->dtpda_cpu, data, size) == NULL)
 			dtp->dt_specdrops++;
 
 		return DTRACE_WORKSTATUS_OKAY;
Signature · 1 line
2.43.5
Reviewed-by on v1 13/22
#31 lore raw

Re: [PATCH 13/22] Eliminate unused args to dt_spec_buf_add_data()

Quoted 3 lines · On Thu, Aug 29, 2024 at 01:22:10AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

Quoted 32 lines
---
 libdtrace/dt_consume.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
libdtrace/dt_consume.c +2 -5
index 6aa9812e..51eb6c80 100644
@@ -2060,9 +2060,7 @@ oom:
 
 static dt_spec_buf_data_t *
 dt_spec_buf_add_data(dtrace_hdl_t *dtp, dt_spec_buf_t *dtsb,
-		     dtrace_epid_t epid, unsigned int cpu,
-		     dtrace_datadesc_t *datadesc, char *data,
-		     uint32_t size)
+		     unsigned int cpu, char *data, uint32_t size)
 {
 	dt_spec_buf_data_t *dsbd;
 
@@ -2265,8 +2263,7 @@ dt_consume_one_probe(dtrace_hdl_t *dtp, FILE *fp, char *data, uint32_t size,
 			}
 		}
 
-		if (dt_spec_buf_add_data(dtp, dtsb, epid, pdat->dtpda_cpu, epd,
-					 data, size) == NULL)
+		if (dt_spec_buf_add_data(dtp, dtsb, pdat->dtpda_cpu, data, size) == NULL)
 			dtp->dt_specdrops++;
 
 		return DTRACE_WORKSTATUS_OKAY;
Signature · 1 line
2.43.5
#32 lore raw

PATCH 14/22 Both dted_uarg and dofe_uarg are unused

In reply to [email protected]

From: Eugene Loh <[email protected]>

I confirmed in a run of the test suite that they are unused.

But I do not understand how any of the dof_ecbdesc_t fields are
used: dofe_probes, dofe_actions, or dofe_pad.

---
 include/dtrace/dof.h      | 1 -
 include/dtrace/enabling.h | 1 -
 libdtrace/dt_dof.c        | 1 -
 3 files changed, 3 deletions(-)
include/dtrace/dof.h +0 -1
index f5655fe2..f9b66e10 100644
@@ -94,7 +94,6 @@ typedef struct dof_ecbdesc {
 	dof_secidx_t dofe_probes;	/* link to DOF_SECT_PROBEDESC */
 	dof_secidx_t dofe_actions;	/* link to DOF_SECT_ACTDESC */
 	uint32_t dofe_pad;		/* reserved for future use */
-	uint64_t dofe_uarg;		/* user-supplied library argument */
 } dof_ecbdesc_t;
 
 typedef struct dof_probedesc {
include/dtrace/enabling.h +0 -1
index f1ec444c..55f67c03 100644
@@ -53,7 +53,6 @@ typedef struct dtrace_actdesc {
 
 typedef struct dtrace_ecbdesc {
 	dtrace_probedesc_t dted_probe;		/* probe description */
-	uint64_t dted_uarg;			/* library argument */
 	int dted_refcnt;			/* reference count */
 } dtrace_ecbdesc_t;
 
libdtrace/dt_dof.c +0 -1
index be29f045..c89ad830 100644
@@ -738,7 +738,6 @@ dtrace_dof_create(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t flags)
 		dofe.dofe_probes = probesec;
 		dofe.dofe_actions = actsec;
 		dofe.dofe_pad = 0;
-		dofe.dofe_uarg = edp->dted_uarg;
 
 		dof_add_lsect(ddo, &dofe, DOF_SECT_ECBDESC,
 		    sizeof(uint64_t), 0, 0, sizeof(dof_ecbdesc_t));
Signature · 1 line
2.43.5
Reviewed-by on v1 14/22
#33 lore raw

Re: [PATCH 14/22] Both dted_uarg and dofe_uarg are unused

Quoted 8 lines · On Thu, Aug 29, 2024 at 01:22:11AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

I confirmed in a run of the test suite that they are unused.

But I do not understand how any of the dof_ecbdesc_t fields are
used: dofe_probes, dofe_actions, or dofe_pad.

Quoted 45 lines
---
 include/dtrace/dof.h      | 1 -
 include/dtrace/enabling.h | 1 -
 libdtrace/dt_dof.c        | 1 -
 3 files changed, 3 deletions(-)
include/dtrace/dof.h +0 -1
index f5655fe2..f9b66e10 100644
@@ -94,7 +94,6 @@ typedef struct dof_ecbdesc {
 	dof_secidx_t dofe_probes;	/* link to DOF_SECT_PROBEDESC */
 	dof_secidx_t dofe_actions;	/* link to DOF_SECT_ACTDESC */
 	uint32_t dofe_pad;		/* reserved for future use */
-	uint64_t dofe_uarg;		/* user-supplied library argument */
 } dof_ecbdesc_t;
 
 typedef struct dof_probedesc {
include/dtrace/enabling.h +0 -1
index f1ec444c..55f67c03 100644
@@ -53,7 +53,6 @@ typedef struct dtrace_actdesc {
 
 typedef struct dtrace_ecbdesc {
 	dtrace_probedesc_t dted_probe;		/* probe description */
-	uint64_t dted_uarg;			/* library argument */
 	int dted_refcnt;			/* reference count */
 } dtrace_ecbdesc_t;
 
libdtrace/dt_dof.c +0 -1
index be29f045..c89ad830 100644
@@ -738,7 +738,6 @@ dtrace_dof_create(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t flags)
 		dofe.dofe_probes = probesec;
 		dofe.dofe_actions = actsec;
 		dofe.dofe_pad = 0;
-		dofe.dofe_uarg = edp->dted_uarg;
 
 		dof_add_lsect(ddo, &dofe, DOF_SECT_ECBDESC,
 		    sizeof(uint64_t), 0, 0, sizeof(dof_ecbdesc_t));
Signature · 1 line
2.43.5
#34 lore raw

PATCH 15/22 test: Clean up the specsize tests

In reply to [email protected]

From: Eugene Loh <[email protected]>

The tests had actions like

    printf("%lld: Lots of data\n", x);
    printf("%lld: Has to be crammed into this buffer\n", x);
    printf("%lld: Until it overflows\n", x);
    printf("%lld: And causes flops\n", x);

suggesting that these strings were crowding the buffer, but these strings are not passed from producer to consumer at all.

The tests also only tested one clause per speculation. It would be nice also to test multiple clauses per speculation.

There is much replicated code from one of the tests to the other, a shortcoming that is amplified if we want to test more specsize values, which is the case when we test multiple clauses per speculation.

Therefore, replace the multiple tests with a single test that checks multiple clauses per speculation and more values of specsize.

---
 .../speculation/tst.SpecSizeVariations.r      | 68 +++++++++++++++++
 .../speculation/tst.SpecSizeVariations.sh     | 74 +++++++++++++++++++
 .../speculation/tst.SpecSizeVariations4.d     | 66 -----------------
 .../speculation/tst.SpecSizeVariations4.r     |  5 --
 .../speculation/tst.SpecSizeVariations5.d     | 61 ---------------
 .../speculation/tst.SpecSizeVariations5.r     |  7 --
 6 files changed, 142 insertions(+), 139 deletions(-)
 create mode 100644 test/unittest/speculation/tst.SpecSizeVariations.r
 create mode 100755 test/unittest/speculation/tst.SpecSizeVariations.sh
 delete mode 100644 test/unittest/speculation/tst.SpecSizeVariations4.d
 delete mode 100644 test/unittest/speculation/tst.SpecSizeVariations4.r
 delete mode 100644 test/unittest/speculation/tst.SpecSizeVariations5.d
 delete mode 100644 test/unittest/speculation/tst.SpecSizeVariations5.r
test/unittest/speculation/tst.SpecSizeVariations.r new file +68 -0
new file mode 100644
index 00000000..51f0596c
@@ -0,0 +1,68 @@
+Speculative buffer ID: 1
+counts: 0 1
+
+Speculative buffer ID: 1
+123456700
+123456701
+123456702
+123456703
+123456704
+123456705
+123456706
+counts: 1 1
+
+Speculative buffer ID: 1
+123456700
+123456701
+123456702
+123456703
+123456704
+123456705
+123456706
+counts: 1 1
+
+Speculative buffer ID: 1
+123456700
+123456701
+123456702
+123456703
+123456704
+123456705
+123456706
+counts: 2 1
+
+Speculative buffer ID: 1
+123456700
+123456701
+123456702
+123456703
+123456704
+123456705
+123456706
+counts: 2 1
+
+Speculative buffer ID: 1
+123456700
+123456701
+123456702
+123456703
+123456704
+123456705
+123456706
+123456800
+123456801
+123456802
+123456803
+123456804
+123456805
+123456806
+123456807
+123456808
+counts: 2 1
+
+-- @@stderr --
+dtrace: 2 speculative drops
+dtrace: 1 speculative drop
+dtrace: 1 speculative drop
+dtrace: 1 speculative drop
+dtrace: 1 speculative drop
test/unittest/speculation/tst.SpecSizeVariations.sh new file +74 -0

74 lines not on this page · raw message

test/unittest/speculation/tst.SpecSizeVariations4.d deleted +0 -66

66 lines not on this page · raw message

test/unittest/speculation/tst.SpecSizeVariations4.r deleted +0 -5
deleted file mode 100644
index 7c4bb3b7..00000000
@@ -1,5 +0,0 @@
-Speculative buffer ID: 1
-Statement wasn't executed
-
--- @@stderr --
-dtrace: 1 speculative drop
test/unittest/speculation/tst.SpecSizeVariations5.d deleted +0 -61

61 lines not on this page · raw message

test/unittest/speculation/tst.SpecSizeVariations5.r deleted +0 -7
deleted file mode 100644
index d09013a2..00000000
@@ -1,7 +0,0 @@
-Speculative buffer ID: 1
-123456789: Lots of data
-123456789: Has to be crammed into this buffer
-123456789: Until it overflows
-123456789: And causes flops
-Statement was executed
-
Signature · 1 line
2.43.5
Reviewed-by on v1 15/22
#35 lore raw

Re: [PATCH 15/22] test: Clean up the specsize tests

Quoted 13 lines · On Thu, Aug 29, 2024 at 01:22:12AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

The tests had actions like

    printf("%lld: Lots of data\n", x);
    printf("%lld: Has to be crammed into this buffer\n", x);
    printf("%lld: Until it overflows\n", x);
    printf("%lld: And causes flops\n", x);

suggesting that these strings were crowding the buffer, but these strings are not passed from producer to consumer at all.

The tests also only tested one clause per speculation. It would be nice also to test multiple clauses per speculation.

Quoted 8 lines

There is much replicated code from one of the tests to the other, a shortcoming that is amplified if we want to test more specsize values, which is the case when we test multiple clauses per speculation.

Therefore, replace the multiple tests with a single test that checks multiple clauses per speculation and more values of specsize.

Quoted 335 lines
---
 .../speculation/tst.SpecSizeVariations.r      | 68 +++++++++++++++++
 .../speculation/tst.SpecSizeVariations.sh     | 74 +++++++++++++++++++
 .../speculation/tst.SpecSizeVariations4.d     | 66 -----------------
 .../speculation/tst.SpecSizeVariations4.r     |  5 --
 .../speculation/tst.SpecSizeVariations5.d     | 61 ---------------
 .../speculation/tst.SpecSizeVariations5.r     |  7 --
 6 files changed, 142 insertions(+), 139 deletions(-)
 create mode 100644 test/unittest/speculation/tst.SpecSizeVariations.r
 create mode 100755 test/unittest/speculation/tst.SpecSizeVariations.sh
 delete mode 100644 test/unittest/speculation/tst.SpecSizeVariations4.d
 delete mode 100644 test/unittest/speculation/tst.SpecSizeVariations4.r
 delete mode 100644 test/unittest/speculation/tst.SpecSizeVariations5.d
 delete mode 100644 test/unittest/speculation/tst.SpecSizeVariations5.r
test/unittest/speculation/tst.SpecSizeVariations.r new file +68 -0
new file mode 100644
index 00000000..51f0596c
@@ -0,0 +1,68 @@
+Speculative buffer ID: 1
+counts: 0 1
+
+Speculative buffer ID: 1
+123456700
+123456701
+123456702
+123456703
+123456704
+123456705
+123456706
+counts: 1 1
+
+Speculative buffer ID: 1
+123456700
+123456701
+123456702
+123456703
+123456704
+123456705
+123456706
+counts: 1 1
+
+Speculative buffer ID: 1
+123456700
+123456701
+123456702
+123456703
+123456704
+123456705
+123456706
+counts: 2 1
+
+Speculative buffer ID: 1
+123456700
+123456701
+123456702
+123456703
+123456704
+123456705
+123456706
+counts: 2 1
+
+Speculative buffer ID: 1
+123456700
+123456701
+123456702
+123456703
+123456704
+123456705
+123456706
+123456800
+123456801
+123456802
+123456803
+123456804
+123456805
+123456806
+123456807
+123456808
+counts: 2 1
+
+-- @@stderr --
+dtrace: 2 speculative drops
+dtrace: 1 speculative drop
+dtrace: 1 speculative drop
+dtrace: 1 speculative drop
+dtrace: 1 speculative drop
test/unittest/speculation/tst.SpecSizeVariations.sh new file +74 -0
new file mode 100755
index 00000000..75e527d9
@@ -0,0 +1,74 @@
+#!/bin/bash
+
+#
+# Oracle Linux DTrace.
+# Copyright (c) 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.
+#
+
+dtrace=$1
+
+for x in 63 64 79 80 143 144; do
+	$dtrace $dt_flags -xspecsize=$x -qn '
+	BEGIN
+	{
+		x = 123456700ll;
+		self->nspeculate = 0;
+		self->ncommit = 0;
+		self->spec = speculation();
+		printf("Speculative buffer ID: %d\n", self->spec);
+	}
+
+	/* 16 + 7 * 8 = 72 bytes */
+	BEGIN
+	{
+		speculate(self->spec);
+		printf("%lld\n", x++);
+		printf("%lld\n", x++);
+		printf("%lld\n", x++);
+		printf("%lld\n", x++);
+		printf("%lld\n", x++);
+		printf("%lld\n", x++);
+		printf("%lld\n", x++);
+		self->nspeculate++;
+	}
+
+	BEGIN
+	{
+		x = 123456800ll;
+	}
+
+	/* 16 + 9 * 8 = 88 bytes */
+	BEGIN
+	{
+		speculate(self->spec);
+		printf("%lld\n", x++);
+		printf("%lld\n", x++);
+		printf("%lld\n", x++);
+		printf("%lld\n", x++);
+		printf("%lld\n", x++);
+		printf("%lld\n", x++);
+		printf("%lld\n", x++);
+		printf("%lld\n", x++);
+		printf("%lld\n", x++);
+		self->nspeculate++;
+	}
+
+	BEGIN
+	{
+		commit(self->spec);
+		self->ncommit++;
+	}
+
+	BEGIN
+	{
+		printf("counts: %d %d\n", self->nspeculate, self->ncommit);
+		exit(0);
+	}
+
+	ERROR
+	{
+		exit(1);
+	}'
+done
test/unittest/speculation/tst.SpecSizeVariations4.d deleted +0 -66
deleted file mode 100644
index 4221c89e..00000000
@@ -1,66 +0,0 @@
-/*
- * Oracle Linux DTrace.
- * Copyright (c) 2006, 2023, 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:
- * Verify the behavior of speculations with changes in specsize.
- *
- * SECTION: Speculative Tracing/Options and Tuning;
- *	Options and Tunables/specsize
- *
- */
-
-#pragma D option quiet
-#pragma D option specsize=39
-
-long long x;
-
-BEGIN
-{
-	x = 123456789;
-	self->speculateFlag = 0;
-	self->commitFlag = 0;
-	self->spec = speculation();
-	printf("Speculative buffer ID: %d\n", self->spec);
-}
-
-BEGIN
-{
-	speculate(self->spec);
-	printf("%lld: Lots of data\n", x);
-	printf("%lld: Has to be crammed into this buffer\n", x);
-	printf("%lld: Until it overflows\n", x);
-	printf("%lld: And causes flops\n", x);
-	self->speculateFlag++;
-
-}
-
-BEGIN
-/1 <= self->speculateFlag/
-{
-	commit(self->spec);
-	self->commitFlag++;
-}
-
-BEGIN
-/1 <= self->commitFlag/
-{
-	printf("Statement was executed\n");
-	exit(1);
-}
-
-BEGIN
-/1 > self->commitFlag/
-{
-	printf("Statement wasn't executed\n");
-	exit(0);
-}
-
-ERROR
-{
-	exit(1);
-}
test/unittest/speculation/tst.SpecSizeVariations4.r deleted +0 -5
deleted file mode 100644
index 7c4bb3b7..00000000
@@ -1,5 +0,0 @@
-Speculative buffer ID: 1
-Statement wasn't executed
-
--- @@stderr --
-dtrace: 1 speculative drop
test/unittest/speculation/tst.SpecSizeVariations5.d deleted +0 -61
deleted file mode 100644
index fb71dfed..00000000
@@ -1,61 +0,0 @@
-/*
- * Oracle Linux DTrace.
- * 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.
- */
-
-/*
- * ASSERTION:
- * Verify the behavior of speculations with changes in specsize.
- *
- * SECTION: Speculative Tracing/Options and Tuning;
- *	Options and Tunables/specsize
- *
- */
-
-#pragma D option quiet
-#pragma D option specsize=40
-
-long long x;
-
-BEGIN
-{
-	x = 123456789;
-	self->speculateFlag = 0;
-	self->commitFlag = 0;
-	self->spec = speculation();
-	printf("Speculative buffer ID: %d\n", self->spec);
-}
-
-BEGIN
-{
-	speculate(self->spec);
-	printf("%lld: Lots of data\n", x);
-	printf("%lld: Has to be crammed into this buffer\n", x);
-	printf("%lld: Until it overflows\n", x);
-	printf("%lld: And causes flops\n", x);
-	self->speculateFlag++;
-
-}
-
-BEGIN
-/1 <= self->speculateFlag/
-{
-	commit(self->spec);
-	self->commitFlag++;
-}
-
-BEGIN
-/1 <= self->commitFlag/
-{
-	printf("Statement was executed\n");
-	exit(0);
-}
-
-BEGIN
-/1 > self->commitFlag/
-{
-	printf("Statement wasn't executed\n");
-	exit(1);
-}
test/unittest/speculation/tst.SpecSizeVariations5.r deleted +0 -7
deleted file mode 100644
index d09013a2..00000000
@@ -1,7 +0,0 @@
-Speculative buffer ID: 1
-123456789: Lots of data
-123456789: Has to be crammed into this buffer
-123456789: Until it overflows
-123456789: And causes flops
-Statement was executed
-
Signature · 1 line
2.43.5
#36 lore raw

PATCH 16/22 test: Fix the speculative tests that checked bufsize

In reply to [email protected]

From: Eugene Loh <[email protected]>

Ever since speculations were reimplemented, these tests simply were not testing what they claimed to test. Among other things:

1) There is a simple dependence on bufsize that is independent of speculations. So speculations have no special role in bufsize tests.

2) The messages in the print statements were not taxing bufsize. (A single default string would be enough to exhaust 60 bytes, but the producer wasn't passing the consumer these strings at all. The bufsize is being set by the implicit ERROR probe.)

3) The various size ranges described in the comments do not exist and were not being tested anyhow.

So remove these tests, and just rely on the other bufsize tests.

To be fair, there seemed to have been no other "negative bufsize" test, but add a more straightforward such test and add it to where the other bufsize tests are.

---
 test/unittest/options/err.bufsize-negative.d  | 24 +++++++
 test/unittest/options/err.bufsize-negative.r  |  2 +
 .../speculation/err.BufSizeVariations1.d      | 67 -------------------
 .../speculation/err.BufSizeVariations2.d      | 67 -------------------
 .../speculation/err.NegativeBufSize.d         | 67 -------------------
 .../speculation/err.NegativeBufSize.r         |  2 -
 6 files changed, 26 insertions(+), 203 deletions(-)
 create mode 100644 test/unittest/options/err.bufsize-negative.d
 create mode 100644 test/unittest/options/err.bufsize-negative.r
 delete mode 100644 test/unittest/speculation/err.BufSizeVariations1.d
 delete mode 100644 test/unittest/speculation/err.BufSizeVariations2.d
 delete mode 100644 test/unittest/speculation/err.NegativeBufSize.d
 delete mode 100644 test/unittest/speculation/err.NegativeBufSize.r
test/unittest/options/err.bufsize-negative.d new file +24 -0
new file mode 100644
index 00000000..ac194dc8
@@ -0,0 +1,24 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 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: The -xbufsize option sets the trace buffer size.
+ *
+ * SECTION: Options and Tunables/Consumer Options
+ */
+
+/* @@runtest-opts: -xbufsize=-1 */
+
+BEGIN
+{
+	exit(0);
+}
+
+ERROR
+{
+	exit(1);
+}
test/unittest/options/err.bufsize-negative.r new file +2 -0
new file mode 100644
index 00000000..ea3089e9
@@ -0,0 +1,2 @@
+-- @@stderr --
+dtrace: failed to set -x bufsize: Invalid value for specified option
test/unittest/speculation/err.BufSizeVariations1.d deleted +0 -67

67 lines not on this page · raw message

test/unittest/speculation/err.BufSizeVariations2.d deleted +0 -67

67 lines not on this page · raw message

test/unittest/speculation/err.NegativeBufSize.d deleted +0 -67

67 lines not on this page · raw message

test/unittest/speculation/err.NegativeBufSize.r deleted +0 -2
deleted file mode 100644
index 9d7be6c0..00000000
@@ -1,2 +0,0 @@
--- @@stderr --
-dtrace: failed to compile script test/unittest/speculation/err.NegativeBufSize.d: line 27: failed to set option 'bufsize' to '-72': Invalid value for specified option
Signature · 1 line
2.43.5
Reviewed-by on v1 16/22
#37 lore raw

Re: [PATCH 16/22] test: Fix the speculative tests that checked bufsize

Quoted 16 lines · On Thu, Aug 29, 2024 at 01:22:13AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

Ever since speculations were reimplemented, these tests simply were not testing what they claimed to test. Among other things:

1) There is a simple dependence on bufsize that is independent of speculations. So speculations have no special role in bufsize tests.

2) The messages in the print statements were not taxing bufsize. (A single default string would be enough to exhaust 60 bytes, but the producer wasn't passing the consumer these strings at all. The bufsize is being set by the implicit ERROR probe.)

3) The various size ranges described in the comments do not exist and were not being tested anyhow.

Quoted 7 lines

So remove these tests, and just rely on the other bufsize tests.

To be fair, there seemed to have been no other "negative bufsize" test, but add a more straightforward such test and add it to where the other bufsize tests are.

Quoted 283 lines
---
 test/unittest/options/err.bufsize-negative.d  | 24 +++++++
 test/unittest/options/err.bufsize-negative.r  |  2 +
 .../speculation/err.BufSizeVariations1.d      | 67 -------------------
 .../speculation/err.BufSizeVariations2.d      | 67 -------------------
 .../speculation/err.NegativeBufSize.d         | 67 -------------------
 .../speculation/err.NegativeBufSize.r         |  2 -
 6 files changed, 26 insertions(+), 203 deletions(-)
 create mode 100644 test/unittest/options/err.bufsize-negative.d
 create mode 100644 test/unittest/options/err.bufsize-negative.r
 delete mode 100644 test/unittest/speculation/err.BufSizeVariations1.d
 delete mode 100644 test/unittest/speculation/err.BufSizeVariations2.d
 delete mode 100644 test/unittest/speculation/err.NegativeBufSize.d
 delete mode 100644 test/unittest/speculation/err.NegativeBufSize.r
test/unittest/options/err.bufsize-negative.d new file +24 -0
new file mode 100644
index 00000000..ac194dc8
@@ -0,0 +1,24 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 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: The -xbufsize option sets the trace buffer size.
+ *
+ * SECTION: Options and Tunables/Consumer Options
+ */
+
+/* @@runtest-opts: -xbufsize=-1 */
+
+BEGIN
+{
+	exit(0);
+}
+
+ERROR
+{
+	exit(1);
+}
test/unittest/options/err.bufsize-negative.r new file +2 -0
new file mode 100644
index 00000000..ea3089e9
@@ -0,0 +1,2 @@
+-- @@stderr --
+dtrace: failed to set -x bufsize: Invalid value for specified option
test/unittest/speculation/err.BufSizeVariations1.d deleted +0 -67
deleted file mode 100644
index c6e29b78..00000000
@@ -1,67 +0,0 @@
-/*
- * Oracle Linux DTrace.
- * Copyright (c) 2006, 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:
- * Verify the behavior of variations in bufsize.
- *
- * SECTION: Speculative Tracing/Options and Tuning;
- *	Options and Tunables/bufsize
- *
- * NOTES: This test behaves differently depending on the values
- * assigned to bufsize.
- * 1. 0 > bufsize.
- * 2. 0 == bufsize.
- * 3. 0 < bufsize <= 7
- * 4. 8 <= bufsize <= 31
- * 5. 32 <= bufsize <= 47
- * 6. 48 <= bufsize <= 71
- * 7. 72 <= bufsize
- */
-
-#pragma D option quiet
-#pragma D option bufsize=41
-
-BEGIN
-{
-	self->speculateFlag = 0;
-	self->commitFlag = 0;
-	self->spec = speculation();
-	printf("Speculative buffer ID: %d\n", self->spec);
-}
-
-BEGIN
-{
-	speculate(self->spec);
-	printf("Lots of data\n");
-	printf("Has to be crammed into this buffer\n");
-	printf("Until it overflows\n");
-	printf("And causes flops\n");
-	self->speculateFlag++;
-
-}
-
-BEGIN
-/1 <= self->speculateFlag/
-{
-	commit(self->spec);
-	self->commitFlag++;
-}
-
-BEGIN
-/1 <= self->commitFlag/
-{
-	printf("Statement was executed\n");
-	exit(0);
-}
-
-BEGIN
-/1 > self->commitFlag/
-{
-	printf("Statement wasn't executed\n");
-	exit(1);
-}
test/unittest/speculation/err.BufSizeVariations2.d deleted +0 -67
deleted file mode 100644
index 8094cd0b..00000000
@@ -1,67 +0,0 @@
-/*
- * Oracle Linux DTrace.
- * Copyright (c) 2006, 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:
- * Verify the behavior of variations in bufsize.
- *
- * SECTION: Speculative Tracing/Options and Tuning;
- *	    Options and Tunables/bufsize
- *
- * NOTES: This test behaves differently depending on the values
- * assigned to bufsize.
- * 1. 0 > bufsize.
- * 2. 0 == bufsize.
- * 3. 0 < bufsize <= 7
- * 4. 8 <= bufsize <= 31
- * 5. 32 <= bufsize <= 47
- * 6. 48 <= bufsize <= 71
- * 7. 72 <= bufsize
- */
-
-#pragma D option quiet
-#pragma D option bufsize=4
-
-BEGIN
-{
-	self->speculateFlag = 0;
-	self->commitFlag = 0;
-	self->spec = speculation();
-	printf("Speculative buffer ID: %d\n", self->spec);
-}
-
-BEGIN
-{
-	speculate(self->spec);
-	printf("Lots of data\n");
-	printf("Has to be crammed into this buffer\n");
-	printf("Until it overflows\n");
-	printf("And causes flops\n");
-	self->speculateFlag++;
-
-}
-
-BEGIN
-/1 <= self->speculateFlag/
-{
-	commit(self->spec);
-	self->commitFlag++;
-}
-
-BEGIN
-/1 <= self->commitFlag/
-{
-	printf("Statement was executed\n");
-	exit(0);
-}
-
-BEGIN
-/1 > self->commitFlag/
-{
-	printf("Statement wasn't executed\n");
-	exit(1);
-}
test/unittest/speculation/err.NegativeBufSize.d deleted +0 -67
deleted file mode 100644
index a0154ccb..00000000
@@ -1,67 +0,0 @@
-/*
- * Oracle Linux DTrace.
- * Copyright (c) 2006, 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:
- * Verify the behavior of variations in bufsize.
- *
- * SECTION: Speculative Tracing/Options and Tuning;
- *	Options and Tunables/bufsize
- *
- * NOTES: This test behaves differently depending on the values
- * assigned to bufsize.
- * 1. 0 > bufsize.
- * 2. 0 == bufsize.
- * 3. 0 < bufsize <= 7
- * 4. 8 <= bufsize <= 31
- * 5. 32 <= bufsize <= 47
- * 6. 48 <= bufsize <= 71
- * 7. 72 <= bufsize
- */
-
-#pragma D option quiet
-#pragma D option bufsize=-72
-
-BEGIN
-{
-	self->speculateFlag = 0;
-	self->commitFlag = 0;
-	self->spec = speculation();
-	printf("Speculative buffer ID: %d\n", self->spec);
-}
-
-BEGIN
-{
-	speculate(self->spec);
-	printf("Lots of data\n");
-	printf("Has to be crammed into this buffer\n");
-	printf("Until it overflows\n");
-	printf("And causes flops\n");
-	self->speculateFlag++;
-
-}
-
-BEGIN
-/1 <= self->speculateFlag/
-{
-	commit(self->spec);
-	self->commitFlag++;
-}
-
-BEGIN
-/1 <= self->commitFlag/
-{
-	printf("Statement was executed\n");
-	exit(0);
-}
-
-BEGIN
-/1 > self->commitFlag/
-{
-	printf("Statement wasn't executed\n");
-	exit(1);
-}
test/unittest/speculation/err.NegativeBufSize.r deleted +0 -2
deleted file mode 100644
index 9d7be6c0..00000000
@@ -1,2 +0,0 @@
--- @@stderr --
-dtrace: failed to compile script test/unittest/speculation/err.NegativeBufSize.d: line 27: failed to set option 'bufsize' to '-72': Invalid value for specified option
Signature · 1 line
2.43.5
#38 lore raw

PATCH 17/22 test: Tweak spec sizes to bracket size jumps more narrowly

In reply to [email protected]

From: Eugene Loh <[email protected]>

---
 .../speculation/tst.SpecSizeVariations.r      | 22 -------------------
 .../speculation/tst.SpecSizeVariations.sh     |  2 +-
 2 files changed, 1 insertion(+), 23 deletions(-)
test/unittest/speculation/tst.SpecSizeVariations.r +0 -22
index 51f0596c..2748b307 100644
@@ -11,26 +11,6 @@ Speculative buffer ID: 1
 123456706
 counts: 1 1
 
-Speculative buffer ID: 1
-123456700
-123456701
-123456702
-123456703
-123456704
-123456705
-123456706
-counts: 1 1
-
-Speculative buffer ID: 1
-123456700
-123456701
-123456702
-123456703
-123456704
-123456705
-123456706
-counts: 2 1
-
 Speculative buffer ID: 1
 123456700
 123456701
@@ -64,5 +44,3 @@ counts: 2 1
 dtrace: 2 speculative drops
 dtrace: 1 speculative drop
 dtrace: 1 speculative drop
-dtrace: 1 speculative drop
-dtrace: 1 speculative drop
test/unittest/speculation/tst.SpecSizeVariations.sh +1 -1
index 75e527d9..79995b59 100755
@@ -9,7 +9,7 @@
 
 dtrace=$1
 
-for x in 63 64 79 80 143 144; do
+for x in 71 72 159 160; do
 	$dtrace $dt_flags -xspecsize=$x -qn '
 	BEGIN
 	{
Signature · 1 line
2.43.5
#39 lore raw

Re: [PATCH 17/22] test: Tweak spec sizes to bracket size jumps more narrowly

This test gives me faqilures.

runtest.log in attachment

Quoted 61 lines · On Thu, Aug 29, 2024 at 01:22:14AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

---
 .../speculation/tst.SpecSizeVariations.r      | 22 -------------------
 .../speculation/tst.SpecSizeVariations.sh     |  2 +-
 2 files changed, 1 insertion(+), 23 deletions(-)
test/unittest/speculation/tst.SpecSizeVariations.r +0 -22
index 51f0596c..2748b307 100644
@@ -11,26 +11,6 @@ Speculative buffer ID: 1
 123456706
 counts: 1 1
 
-Speculative buffer ID: 1
-123456700
-123456701
-123456702
-123456703
-123456704
-123456705
-123456706
-counts: 1 1
-
-Speculative buffer ID: 1
-123456700
-123456701
-123456702
-123456703
-123456704
-123456705
-123456706
-counts: 2 1
-
 Speculative buffer ID: 1
 123456700
 123456701
@@ -64,5 +44,3 @@ counts: 2 1
 dtrace: 2 speculative drops
 dtrace: 1 speculative drop
 dtrace: 1 speculative drop
-dtrace: 1 speculative drop
-dtrace: 1 speculative drop
test/unittest/speculation/tst.SpecSizeVariations.sh +1 -1
index 75e527d9..79995b59 100755
@@ -9,7 +9,7 @@
 
 dtrace=$1
 
-for x in 63 64 79 80 143 144; do
+for x in 71 72 159 160; do
 	$dtrace $dt_flags -xspecsize=$x -qn '
 	BEGIN
 	{
Signature · 1 line
2.43.5

dtrace: Oracle D 2.0
This is DTrace 2.0.1
dtrace(1) version-control ID: 76d327b2d33c377041b8f1b3dbd67de7f2cc7b65 libdtrace version-control ID: 76d327b2d33c377041b8f1b3dbd67de7f2cc7b65
Linux kvh-deb-bpf3 6.8.8 #1 SMP PREEMPT_DYNAMIC Mon Apr 29 14:26:32 EDT 2024 x86_64 GNU/Linux testsuite version-control ID: 76d327b2d33c377041b8f1b3dbd67de7f2cc7b65

test/unittest/speculation/tst.SpecSizeVariations.sh: Running timeout --signal=TERM 41 test/unittest/speculation/tst.SpecSizeVariations.sh /scratch/dtrace-bpf-user/build/dtrace
FAIL: expected results differ.
Speculative buffer ID: 1
123456700
123456701
123456702
123456703
123456704
123456705
123456706
counts: 1 1

Speculative buffer ID: 1
123456700
123456701
123456702
123456703
123456704
123456705
123456706
counts: 1 1

Speculative buffer ID: 1
123456700
123456701
123456702
123456703
123456704
123456705
123456706
123456800
123456801
123456802
123456803
123456804
123456805
123456806
123456807
123456808
counts: 2 1

Speculative buffer ID: 1
123456700
123456701
123456702
123456703
123456704
123456705
123456706
123456800
123456801
123456802
123456803
123456804
123456805
123456806
123456807
123456808
counts: 2 1

-- @@stderr --
dtrace: 1 speculative drop
dtrace: 1 speculative drop
Diff against expected:

tmp/runtest.27272/test.out renamed from unittest/speculation/tst.SpecSizeVariations.r +17 -2
@@ -1,5 +1,12 @@
 Speculative buffer ID: 1
-counts: 0 1
+123456700
+123456701
+123456702
+123456703
+123456704
+123456705
+123456706
+counts: 1 1
 
 Speculative buffer ID: 1
 123456700
@@ -19,6 +26,15 @@
 123456704
 123456705
 123456706
+123456800
+123456801
+123456802
+123456803
+123456804
+123456805
+123456806
+123456807
+123456808
 counts: 2 1
 
 Speculative buffer ID: 1
@@ -41,6 +57,5 @@
 counts: 2 1
 
 -- @@stderr --
-dtrace: 2 speculative drops
 dtrace: 1 speculative drop
 dtrace: 1 speculative drop

Cleaning took 0.022518012 (0 kprobes, 0 uprobes)

1 cases (0 PASS, 1 FAIL, 0 XPASS, 0 XFAIL, 0 SKIP)

author
#40 lore raw

Re: [PATCH 17/22] test: Tweak spec sizes to bracket size jumps more narrowly

Yeah.  I think this is due to patch ordering.  The sizes depend on the new "Deprecate EPID" patch;  that patch, in turn, needs new sizes, whether narrow or not.

I guess I'll withdraw this 17/22 patch and just squash it into the already large 03/19 "Deprecate enabled probe ID (epid)"... v6.

Quoted 66 lines · Kris Van Hees

This test gives me faqilures.

runtest.log in attachment

Quoted 61 lines · On Thu, Aug 29, 2024 at 01:22:14AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

---
  .../speculation/tst.SpecSizeVariations.r      | 22 -------------------
  .../speculation/tst.SpecSizeVariations.sh     |  2 +-
  2 files changed, 1 insertion(+), 23 deletions(-)
test/unittest/speculation/tst.SpecSizeVariations.r +0 -22
index 51f0596c..2748b307 100644
@@ -11,26 +11,6 @@ Speculative buffer ID: 1
  123456706
  counts: 1 1
 
-Speculative buffer ID: 1
-123456700
-123456701
-123456702
-123456703
-123456704
-123456705
-123456706
-counts: 1 1
-
-Speculative buffer ID: 1
-123456700
-123456701
-123456702
-123456703
-123456704
-123456705
-123456706
-counts: 2 1
-
  Speculative buffer ID: 1
  123456700
  123456701
@@ -64,5 +44,3 @@ counts: 2 1
  dtrace: 2 speculative drops
  dtrace: 1 speculative drop
  dtrace: 1 speculative drop
-dtrace: 1 speculative drop
-dtrace: 1 speculative drop
test/unittest/speculation/tst.SpecSizeVariations.sh +1 -1
index 75e527d9..79995b59 100755
@@ -9,7 +9,7 @@
 
  dtrace=$1
 
-for x in 63 64 79 80 143 144; do
+for x in 71 72 159 160; do
  	$dtrace $dt_flags -xspecsize=$x -qn '
  	BEGIN
  	{
Signature · 1 line
2.43.5
#41 lore raw

PATCH 18/22 test: Remove tst.DTRACEFLT_BADADDR2.d dependency on specific PC

In reply to [email protected]

From: Eugene Loh <[email protected]>

---
 test/unittest/error/tst.DTRACEFLT_BADADDR2.d | 12 +++---------
 test/unittest/error/tst.DTRACEFLT_BADADDR2.r |  4 ++--
 2 files changed, 5 insertions(+), 11 deletions(-)
test/unittest/error/tst.DTRACEFLT_BADADDR2.d +3 -9
index 23663f3c..a822e63a 100644
@@ -1,26 +1,23 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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.
  */
-/* @@xfail: dtv2 */
 
 /*
  * ASSERTION:
  *	To test DTRACEFLT_BADADDR error with non-NULL address
  *
  * SECTION: dtrace Provider
- *
  */
 
-
 #pragma D option quiet
 
 ERROR
 {
-	printf("The arguments are %u %u %u %u %u\n",
-		arg1, arg2, arg3, arg4, arg5);
+	printf("The arguments are %u %u %u %u\n",
+		arg1, arg2, arg4, arg5);
 	printf("The value of arg4 should be %u\n", DTRACEFLT_BADADDR);
 	printf("The value of arg5 should be %u\n", 0x4000);
 	exit(0);
@@ -28,9 +25,6 @@ ERROR
 
 BEGIN
 {
-/*
-	x = (int *)64;
- */
 	x = (int *)0x4000;
 	y = *x;
 	trace(y);
test/unittest/error/tst.DTRACEFLT_BADADDR2.r +2 -2
index ada685d6..6c5fa119 100644
@@ -1,6 +1,6 @@
-The arguments are 2 2 4 1 16384
+The arguments are 3 1 1 16384
 The value of arg4 should be 1
 The value of arg5 should be 16384
 
 -- @@stderr --
-dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #2 at BPF pc NNN
+dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
Signature · 1 line
2.43.5
Reviewed-by on v1 18/22
#42 lore raw

Re: [PATCH 18/22] test: Remove tst.DTRACEFLT_BADADDR2.d dependency on specific PC

Quoted 3 lines · On Thu, Aug 29, 2024 at 01:22:15AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

Quoted 65 lines
---
 test/unittest/error/tst.DTRACEFLT_BADADDR2.d | 12 +++---------
 test/unittest/error/tst.DTRACEFLT_BADADDR2.r |  4 ++--
 2 files changed, 5 insertions(+), 11 deletions(-)
test/unittest/error/tst.DTRACEFLT_BADADDR2.d +3 -9
index 23663f3c..a822e63a 100644
@@ -1,26 +1,23 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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.
  */
-/* @@xfail: dtv2 */
 
 /*
  * ASSERTION:
  *	To test DTRACEFLT_BADADDR error with non-NULL address
  *
  * SECTION: dtrace Provider
- *
  */
 
-
 #pragma D option quiet
 
 ERROR
 {
-	printf("The arguments are %u %u %u %u %u\n",
-		arg1, arg2, arg3, arg4, arg5);
+	printf("The arguments are %u %u %u %u\n",
+		arg1, arg2, arg4, arg5);
 	printf("The value of arg4 should be %u\n", DTRACEFLT_BADADDR);
 	printf("The value of arg5 should be %u\n", 0x4000);
 	exit(0);
@@ -28,9 +25,6 @@ ERROR
 
 BEGIN
 {
-/*
-	x = (int *)64;
- */
 	x = (int *)0x4000;
 	y = *x;
 	trace(y);
test/unittest/error/tst.DTRACEFLT_BADADDR2.r +2 -2
index ada685d6..6c5fa119 100644
@@ -1,6 +1,6 @@
-The arguments are 2 2 4 1 16384
+The arguments are 3 1 1 16384
 The value of arg4 should be 1
 The value of arg5 should be 16384
 
 -- @@stderr --
-dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #2 at BPF pc NNN
+dtrace: error on enabled probe ID 3 (ID 1: dtrace:::BEGIN): invalid address ({ptr}) in action #1 at BPF pc NNN
Signature · 1 line
2.43.5
#43 lore raw

PATCH 19/22 test: Fix tst.probestar.d trigger

In reply to [email protected]

From: Eugene Loh <[email protected]>

This test was relying on a trigger that uses the obsolete dt_test, even though dt_test is irrelevant to the test.

Use a different trigger.

---
 test/unittest/probes/tst.probestar.d | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
test/unittest/probes/tst.probestar.d +3 -4
index dad7741e..b6da42e1 100644
@@ -1,11 +1,11 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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.
  */
-/* @@xfail: dtv2 */
-/* @@trigger: testprobe */
+/* @@trigger: readwholedir */
+/* FIXME */
 
 /*
  * ASSERTION:
@@ -16,7 +16,6 @@
  *
  */
 
-
 #pragma D option quiet
 
 int i;
Signature · 1 line
2.43.5
#44 lore raw

Re: [PATCH 19/22] test: Fix tst.probestar.d trigger

Given that the patch also adds a FIXME, I think that it would be better to resolve whatever that FIXME is meant to refer to before we merge this.

Quoted 42 lines · :On Thu, Aug 29, 2024 at 01:22:16AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

This test was relying on a trigger that uses the obsolete dt_test, even though dt_test is irrelevant to the test.

Use a different trigger.

---
 test/unittest/probes/tst.probestar.d | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
test/unittest/probes/tst.probestar.d +3 -4
index dad7741e..b6da42e1 100644
@@ -1,11 +1,11 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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.
  */
-/* @@xfail: dtv2 */
-/* @@trigger: testprobe */
+/* @@trigger: readwholedir */
+/* FIXME */
 
 /*
  * ASSERTION:
@@ -16,7 +16,6 @@
  *
  */
 
-
 #pragma D option quiet
 
 int i;
Signature · 1 line
2.43.5
author
#45 lore raw

Re: [PATCH 19/22] test: Fix tst.probestar.d trigger

Yeah, weird.  I have no idea what the FIXME meant.  The fixed test works now.  I'll post a v2 without the FIXME comment.

Quoted 46 lines · Kris Van Hees

Given that the patch also adds a FIXME, I think that it would be better to resolve whatever that FIXME is meant to refer to before we merge this.

Quoted 42 lines · :On Thu, Aug 29, 2024 at 01:22:16AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

This test was relying on a trigger that uses the obsolete dt_test, even though dt_test is irrelevant to the test.

Use a different trigger.

---
  test/unittest/probes/tst.probestar.d | 7 +++----
  1 file changed, 3 insertions(+), 4 deletions(-)
test/unittest/probes/tst.probestar.d +3 -4
index dad7741e..b6da42e1 100644
@@ -1,11 +1,11 @@
  /*
   * Oracle Linux DTrace.
- * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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.
   */
-/* @@xfail: dtv2 */
-/* @@trigger: testprobe */
+/* @@trigger: readwholedir */
+/* FIXME */
 
  /*
   * ASSERTION:
@@ -16,7 +16,6 @@
   *
   */
 
-
  #pragma D option quiet
 
  int i;
Signature · 1 line
2.43.5
#46 lore raw

PATCH 20/22 test: Annotate some XFAILs

In reply to [email protected]

From: Eugene Loh <[email protected]>

---
 test/unittest/assocs/tst.invalidref.d         |  2 +-
 test/unittest/builtinvar/tst.ipl.d            |  2 +-
 test/unittest/builtinvar/tst.ipl1.d           |  2 +-
 test/unittest/builtinvar/tst.vtimestamp.d     |  2 +-
 test/unittest/builtinvar/tst.vtimestamp2.d    |  2 +-
 .../lquantize/tst.32bit-bug26268136.sh        | 29 ++++++++++++++++++-
 .../printa/err.D_PRINTF_ARG_TYPE.jstack.d     |  2 +-
 test/unittest/printa/tst.jstack.d             |  2 +-
 .../tst.jstack_unprintable-bug26045010.sh     |  2 +-
 test/unittest/variables/bvar/tst.ipl.d        |  2 +-
 test/unittest/variables/bvar/tst.vtimestamp.d |  2 +-
 11 files changed, 38 insertions(+), 11 deletions(-)
test/unittest/assocs/tst.invalidref.d +1 -1
index 0ed17959..34367c6b 100644
@@ -4,7 +4,7 @@
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+/* @@xfail: dtv2 no support for index of assoc array; last_cmds[1][3]=0 dumps BPF */
 
 /*
  * Test to ensure that invalid stores to a global associative array
test/unittest/builtinvar/tst.ipl.d +1 -1
index c2b9850f..41a89b00 100644
@@ -4,7 +4,7 @@
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+/* @@xfail: dtv2: need ipl support */
 
 /*
  * ASSERTION:
test/unittest/builtinvar/tst.ipl1.d +1 -1
index 1b489229..654b16ce 100644
@@ -4,7 +4,7 @@
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+/* @@xfail: dtv2: need ipl support */
 
 /*
  * ASSERTION:
test/unittest/builtinvar/tst.vtimestamp.d +1 -1
index c9e2a112..11ffae7b 100644
@@ -4,7 +4,7 @@
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+/* @@xfail: dtv2: need vtimestamp support */
 
 /*
  * ASSERTION:
test/unittest/builtinvar/tst.vtimestamp2.d +1 -1
index 087a11e3..68a57ea8 100644
@@ -4,7 +4,7 @@
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+/* @@xfail: dtv2: need vtimestamp support */
 
 /*
  * ASSERTION:
test/unittest/lquantize/tst.32bit-bug26268136.sh +28 -1
index d5f143f5..91f4b65c 100755
@@ -5,7 +5,34 @@
 # Licensed under the Universal Permissive License v 1.0 as shown at
 # http://oss.oracle.com/licenses/upl.
 #
-# @@xfail: dtv2
+# @@xfail: dtv2 since BPF verifier fails, see test source code
+
+# This test passes with BEGIN or even proc:::start but BPF verifier fails with proc:::exit.
+#
+# When the BPF verifier dives into
+#     uint64_t *dt_get_agg(const dt_dctx_t *dctx, uint32_t id, const char *key, uint64_t ival, const char *dflt) {
+#         uint64_t *genp;
+#         uint64_t *valp;
+#
+#         /* get the gen value */
+#         genp = bpf_map_lookup_elem(&agggen, &id);
+#         if (genp == 0)
+#             return dt_no_agg();
+#
+#         /* place the variable ID at the beginning of the key */
+#         *(uint32_t *)key = id;
+#
+#         /* try to look up the key */
+#         valp = bpf_map_lookup_elem(dctx->agg, key);
+# it tries to look up the key.  For the first argument (dctx->agg, where DCTX_AGG==64),
+# the BPF verifier shows
+#     (79) r1 = *(u64 *)(r8 +64)      R1= invP(id=0)
+# Since nothing is known about the first argument, the BPF verifier complains about
+# bpf_map_lookup_elem():
+#     R1 type=inv expected=map_ptr
+# In contrast, with proc:::start, we get
+#     (79) r1 = *(u64 *)(r8 +64)      R1= map_ptr(id=0,off=0,ks=12,vs=56,imm=0)
+# and the BPF verifier is then happy with the bpf_map_lookup_elem() call.
 
 if [ $# != 1 ]; then
 	echo expected one argument: '<'dtrace-path'>'
test/unittest/printa/err.D_PRINTF_ARG_TYPE.jstack.d +1 -1
index f04f9778..d2fccff7 100644
@@ -4,7 +4,7 @@
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+/* @@xfail: dtv2 jstack not implemented */
 BEGIN
 {
 	@[jstack()] = count();
test/unittest/printa/tst.jstack.d +1 -1
index 4ef1ed58..7a404a09 100644
@@ -4,7 +4,7 @@
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+/* @@xfail: dtv2 jstack not implemented */
 
 BEGIN
 {
test/unittest/ustack/tst.jstack_unprintable-bug26045010.sh +1 -1
index c5fca2a5..e6d8b43c 100755
@@ -5,7 +5,7 @@
 # Licensed under the Universal Permissive License v 1.0 as shown at
 # http://oss.oracle.com/licenses/upl.
 #
-# @@xfail: dtv2
+# @@xfail: dtv2 jstack not implemented
 if [ $# != 1 ]; then
 	echo expected one argument: '<'dtrace-path'>'
 	exit 2
test/unittest/variables/bvar/tst.ipl.d +1 -1
index a61e3b5b..7e2a432f 100644
@@ -4,7 +4,7 @@
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+/* @@xfail: dtv2 need ipl support */
 
 /*
  * ASSERTION: The 'ipl' variable can be accessed and is not -1.
test/unittest/variables/bvar/tst.vtimestamp.d +1 -1
index dc985ad1..b72eb8a7 100644
@@ -4,7 +4,7 @@
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+/* @@xfail: dtv2 need vtimestamp support */
 
 /*
  * ASSERTION: The 'vtimestamp' variable can be accessed and is not -1.
Signature · 1 line
2.43.5
Reviewed-by on v1 20/22
#47 lore raw

Re: [PATCH 20/22] test: Annotate some XFAILs

Partial

I am applying this for all tests
EXCEPT test/unittest/lquantize/tst.32bit-bug26268136.sh

That test is supposed to exercise a reported bug concerning overflow. But the test commit message is being updated to indicate that the test does pass with BEGIN or proc:::start as trigger probe, but fails with proc:::exit. That would mean that the test verifies correctly that the bug has been fixed. But it also indicates that there is another (almost certainly unrelated) bug that causes bad code to be generated if the trigger probe is proc:::exit.

So, this test should be adjusted to use a trigger probe that works and a *NEW* test should be added to exercise the problem that is being seen with the proc:::exit probe.

There, I'm applying the patch changes to all tests except that one, and a new patch should be submitteed for review to address the issue with the one test.

Quoted 190 lines · On Thu, Aug 29, 2024 at 01:22:17AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

---
 test/unittest/assocs/tst.invalidref.d         |  2 +-
 test/unittest/builtinvar/tst.ipl.d            |  2 +-
 test/unittest/builtinvar/tst.ipl1.d           |  2 +-
 test/unittest/builtinvar/tst.vtimestamp.d     |  2 +-
 test/unittest/builtinvar/tst.vtimestamp2.d    |  2 +-
 .../lquantize/tst.32bit-bug26268136.sh        | 29 ++++++++++++++++++-
 .../printa/err.D_PRINTF_ARG_TYPE.jstack.d     |  2 +-
 test/unittest/printa/tst.jstack.d             |  2 +-
 .../tst.jstack_unprintable-bug26045010.sh     |  2 +-
 test/unittest/variables/bvar/tst.ipl.d        |  2 +-
 test/unittest/variables/bvar/tst.vtimestamp.d |  2 +-
 11 files changed, 38 insertions(+), 11 deletions(-)
test/unittest/assocs/tst.invalidref.d +1 -1
index 0ed17959..34367c6b 100644
@@ -4,7 +4,7 @@
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+/* @@xfail: dtv2 no support for index of assoc array; last_cmds[1][3]=0 dumps BPF */
 
 /*
  * Test to ensure that invalid stores to a global associative array
test/unittest/builtinvar/tst.ipl.d +1 -1
index c2b9850f..41a89b00 100644
@@ -4,7 +4,7 @@
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+/* @@xfail: dtv2: need ipl support */
 
 /*
  * ASSERTION:
test/unittest/builtinvar/tst.ipl1.d +1 -1
index 1b489229..654b16ce 100644
@@ -4,7 +4,7 @@
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+/* @@xfail: dtv2: need ipl support */
 
 /*
  * ASSERTION:
test/unittest/builtinvar/tst.vtimestamp.d +1 -1
index c9e2a112..11ffae7b 100644
@@ -4,7 +4,7 @@
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+/* @@xfail: dtv2: need vtimestamp support */
 
 /*
  * ASSERTION:
test/unittest/builtinvar/tst.vtimestamp2.d +1 -1
index 087a11e3..68a57ea8 100644
@@ -4,7 +4,7 @@
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+/* @@xfail: dtv2: need vtimestamp support */
 
 /*
  * ASSERTION:
test/unittest/lquantize/tst.32bit-bug26268136.sh +28 -1
index d5f143f5..91f4b65c 100755
@@ -5,7 +5,34 @@
 # Licensed under the Universal Permissive License v 1.0 as shown at
 # http://oss.oracle.com/licenses/upl.
 #
-# @@xfail: dtv2
+# @@xfail: dtv2 since BPF verifier fails, see test source code
+
+# This test passes with BEGIN or even proc:::start but BPF verifier fails with proc:::exit.
+#
+# When the BPF verifier dives into
+#     uint64_t *dt_get_agg(const dt_dctx_t *dctx, uint32_t id, const char *key, uint64_t ival, const char *dflt) {
+#         uint64_t *genp;
+#         uint64_t *valp;
+#
+#         /* get the gen value */
+#         genp = bpf_map_lookup_elem(&agggen, &id);
+#         if (genp == 0)
+#             return dt_no_agg();
+#
+#         /* place the variable ID at the beginning of the key */
+#         *(uint32_t *)key = id;
+#
+#         /* try to look up the key */
+#         valp = bpf_map_lookup_elem(dctx->agg, key);
+# it tries to look up the key.  For the first argument (dctx->agg, where DCTX_AGG==64),
+# the BPF verifier shows
+#     (79) r1 = *(u64 *)(r8 +64)      R1= invP(id=0)
+# Since nothing is known about the first argument, the BPF verifier complains about
+# bpf_map_lookup_elem():
+#     R1 type=inv expected=map_ptr
+# In contrast, with proc:::start, we get
+#     (79) r1 = *(u64 *)(r8 +64)      R1= map_ptr(id=0,off=0,ks=12,vs=56,imm=0)
+# and the BPF verifier is then happy with the bpf_map_lookup_elem() call.
 
 if [ $# != 1 ]; then
 	echo expected one argument: '<'dtrace-path'>'
test/unittest/printa/err.D_PRINTF_ARG_TYPE.jstack.d +1 -1
index f04f9778..d2fccff7 100644
@@ -4,7 +4,7 @@
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+/* @@xfail: dtv2 jstack not implemented */
 BEGIN
 {
 	@[jstack()] = count();
test/unittest/printa/tst.jstack.d +1 -1
index 4ef1ed58..7a404a09 100644
@@ -4,7 +4,7 @@
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+/* @@xfail: dtv2 jstack not implemented */
 
 BEGIN
 {
test/unittest/ustack/tst.jstack_unprintable-bug26045010.sh +1 -1
index c5fca2a5..e6d8b43c 100755
@@ -5,7 +5,7 @@
 # Licensed under the Universal Permissive License v 1.0 as shown at
 # http://oss.oracle.com/licenses/upl.
 #
-# @@xfail: dtv2
+# @@xfail: dtv2 jstack not implemented
 if [ $# != 1 ]; then
 	echo expected one argument: '<'dtrace-path'>'
 	exit 2
test/unittest/variables/bvar/tst.ipl.d +1 -1
index a61e3b5b..7e2a432f 100644
@@ -4,7 +4,7 @@
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+/* @@xfail: dtv2 need ipl support */
 
 /*
  * ASSERTION: The 'ipl' variable can be accessed and is not -1.
test/unittest/variables/bvar/tst.vtimestamp.d +1 -1
index dc985ad1..b72eb8a7 100644
@@ -4,7 +4,7 @@
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+/* @@xfail: dtv2 need vtimestamp support */
 
 /*
  * ASSERTION: The 'vtimestamp' variable can be accessed and is not -1.
Signature · 1 line
2.43.5
#48 lore raw

PATCH 21/22 test: Fix DIRNAME

In reply to [email protected]

From: Eugene Loh <[email protected]>

---
 test/unittest/dtrace-util/tst.ListProbesNameUSDT.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
test/unittest/dtrace-util/tst.ListProbesNameUSDT.sh +1 -1
index c5dfc72b..f9b1d8bf 100755
@@ -26,7 +26,7 @@ dtrace=$1
 CC=/usr/bin/gcc
 CFLAGS=
 
-DIRNAME="$tmpdir/list-probes-func-usdt.$$.$RANDOM"
+DIRNAME="$tmpdir/list-probes-name-usdt.$$.$RANDOM"
 mkdir -p $DIRNAME
 cd $DIRNAME
 
Signature · 1 line
2.43.5
#49 lore raw

Re: [DTrace-devel] [PATCH 21/22] test: Fix DIRNAME

Quoted 12 lines · eugene.loh--- via DTrace-devel

From: Eugene Loh <[email protected]>

---
 test/unittest/dtrace-util/tst.ListProbesNameUSDT.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
test/unittest/dtrace-util/tst.ListProbesNameUSDT.sh +0 -0
index c5dfc72b..f9b1d8bf 100755

test/unittest/dtrace-util/tst.ListProbesNameUSDT.sh dtrace=$1 · line 31

Quoted 7 lines
test/unittest/dtrace-util/tst.ListProbesNameUSDT.sh +1 -1
@@ -26,7 +26,7 @@ dtrace=$1
 CC=/usr/bin/gcc
 CFLAGS=
 
-DIRNAME="$tmpdir/list-probes-func-usdt.$$.$RANDOM"
+DIRNAME="$tmpdir/list-probes-name-usdt.$$.$RANDOM"
 mkdir -p $DIRNAME
 cd $DIRNAME

Feel like this is crying out for $(mktemp -d) instead in both this and the test it was copied from...

Reviewed-by on v1 21/22
#50 lore raw

Re: [PATCH 21/22] test: Fix DIRNAME

In reply to [email protected]
Quoted 3 lines · On Thu, Aug 29, 2024 at 01:22:18AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

Quoted 20 lines
---
 test/unittest/dtrace-util/tst.ListProbesNameUSDT.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
test/unittest/dtrace-util/tst.ListProbesNameUSDT.sh +1 -1
index c5dfc72b..f9b1d8bf 100755
@@ -26,7 +26,7 @@ dtrace=$1
 CC=/usr/bin/gcc
 CFLAGS=
 
-DIRNAME="$tmpdir/list-probes-func-usdt.$$.$RANDOM"
+DIRNAME="$tmpdir/list-probes-name-usdt.$$.$RANDOM"
 mkdir -p $DIRNAME
 cd $DIRNAME
 
Signature · 1 line
2.43.5
#51 lore raw

PATCH 22/22 test: Update tst.newprobes.sh xfail message

In reply to [email protected]

From: Eugene Loh <[email protected]>

---
 test/unittest/pid/tst.newprobes.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
test/unittest/pid/tst.newprobes.sh +1 -1
index a4944688..1a88c3a8 100755
@@ -6,7 +6,7 @@
 # http://oss.oracle.com/licenses/upl.
 #
 
-# @@xfail: not working yet
+# @@xfail: we do not support wildcard pids for pid probes
 
 if [ $# != 1 ]; then
 	echo expected one argument: '<'dtrace-path'>'
Signature · 1 line
2.43.5
#52 lore raw

Re: [PATCH 22/22] test: Update tst.newprobes.sh xfail message

Quoted 12 lines · On Thu, Aug 29, 2024 at 01:22:19AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

---
 test/unittest/pid/tst.newprobes.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
test/unittest/pid/tst.newprobes.sh +0 -0
index a4944688..1a88c3a8 100755

test/unittest/pid/tst.newprobes.sh line 9

Quoted 5 lines
test/unittest/pid/tst.newprobes.sh +1 -1
@@ -6,7 +6,7 @@
 # http://oss.oracle.com/licenses/upl.
 #
 
-# @@xfail: not working yet
+# @@xfail: we do not support wildcard pids for pid probes

I think it would be more accurate to say that 'dtrace' does not support wildcards pids for pid probe. It is not our choice or lack of support in our implementation - dtrace never did support it.

Updated it to be:

# @@xfail: dtrace does not support wildcard pids for pid probes

Quoted 6 lines
test/unittest/pid/tst.newprobes.sh +0 -0
 if [ $# != 1 ]; then
 	echo expected one argument: '<'dtrace-path'>'
Signature · 1 line
2.43.5
#53 lore raw
In reply to [email protected]
Quoted 158 lines · On Thu, Aug 29, 2024 at 01:21:58AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

The ERROR probe's arg3 reports the culprit PC, whose value can vary with minor implementation changes. On the one hand, we do not want tests to be overly sensitive to this value. On the other hand, we do at least want to check the value is reasonable.

Therefore:

*) Change tests that dump ERROR's args to omit arg3.

*) Add a new test that checks that ERROR's arg3 is reasonable.

---
 test/unittest/error/tst.DTRACEFLT_UNKNOWN.d   |  6 +-
 test/unittest/error/tst.DTRACEFLT_UNKNOWN.r   |  2 +-
 .../regression/tst.DTRACEFLT_BADADDR.d_path.d |  8 +-
 .../regression/tst.DTRACEFLT_BADADDR.d_path.r |  2 +-
 test/unittest/variables/bvar/tst.arg3-ERROR.d | 92 +++++++++++++++++++
 5 files changed, 101 insertions(+), 9 deletions(-)
 create mode 100644 test/unittest/variables/bvar/tst.arg3-ERROR.d
test/unittest/error/tst.DTRACEFLT_UNKNOWN.d +3 -3
index 001903ff..bfc77bf5 100644
@@ -1,6 +1,6 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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.
  */
@@ -19,8 +19,8 @@
 
 ERROR
 {
-	printf("The arguments are %u %u %u %u %u\n",
-		arg1, arg2, arg3, arg4, arg5);
+	printf("The arguments are %u %u PC %u %u\n",
+		arg1, arg2, arg4, arg5);
 	printf("The value of arg4 = %u\n", DTRACEFLT_UNKNOWN);
 	exit(0);
 }
test/unittest/error/tst.DTRACEFLT_UNKNOWN.r +1 -1
index b11f6c99..3e7caac4 100644
@@ -1,4 +1,4 @@
-The arguments are 2 2 4 1 64
+The arguments are 2 2 PC 1 64
 The value of arg4 = 0
 
 -- @@stderr --
test/unittest/regression/tst.DTRACEFLT_BADADDR.d_path.d +4 -4
index c23f9503..ec519f4f 100644
@@ -1,10 +1,10 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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.
  */
-/* @@xfail: dtv2 */
+/* @@xfail: dtv2 d_path */
 
 /*
  * ASSERTION:
@@ -18,8 +18,7 @@
 
 ERROR
 {
-	printf("The arguments are %u %u %u %u %u\n",
-		arg1, arg2, arg3, arg4, arg5);
+	printf("The arguments are %u %u PC %u %u\n", arg1, arg2, arg4, arg5);
 	printf("The value of arg4 should be %u\n", DTRACEFLT_BADADDR);
 	printf("The value of arg5 should be %u\n", 0x18);
 	exit(0);
@@ -29,4 +28,5 @@ BEGIN
 {
 	d = d_path((struct path *)0x18);
 	trace(d);
+	exit(1);
 }
test/unittest/regression/tst.DTRACEFLT_BADADDR.d_path.r +1 -1
index 8c601a43..be1f6d5b 100644
@@ -1,4 +1,4 @@
-The arguments are 2 1 28 1 24
+The arguments are 2 1 PC 1 24
 The value of arg4 should be 1
 The value of arg5 should be 24
 
test/unittest/variables/bvar/tst.arg3-ERROR.d new file +52 -0
new file mode 100644
index 00000000..6c2f5206
@@ -0,0 +1,92 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 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: The 'arg3' variable can be accessed in the ERROR probe
+ *	and its value (PC) is reasonable.
+ *
+ * SECTION: Variables/Built-in Variables/arg3
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+	nerrs = 0;
+}
+
+BEGIN
+{
+	x = (int *)64;
+	y = *x;                       /* Error at PC[0] */
+	trace(y);
+}
+
+BEGIN
+{
+	x = (int *)64;
+	y = *x;                       /* Error at PC[1] */
+	trace(y);
+}
+
+BEGIN
+{
+	x = (int *)64;
+	y = *x;                       /* Error at PC[2] */
+	trace(y);
+}
+
+BEGIN
+{
+	x = (int *)64;
+	y = *x;                       /* Error at PC[3] */
+	trace(y);
+}
+
+ERROR
+{
+	/* Record the problematic PC and continue execution. */

test/unittest/variables/bvar/tst.arg3-ERROR.d line 62

Quoted 10 lines
test/unittest/variables/bvar/tst.arg3-ERROR.d new file +10 -0
+	PC[nerrs++] = arg3;
+}
+
+/*
+ * The problematic PCs are likely to satisfy the following
+ * reasonable checks, though it's possible that some radically
+ * different implementation in the future might violate one or
+ * more checks.
+ *
+ * The first problematic PC is expected in the some range.

"in the same range" ?? Changing to "some range".

Quoted 9 lines
test/unittest/variables/bvar/tst.arg3-ERROR.d new file +9 -0
+ *
+ * The next problematic PC is expected to be PC[0] plus some
+ * delta, including some special functions that are loaded.
+ *
+ * Then, the next PC is expected to be PC[1] plus some delta
+ * that is smaller and narrower since those special functions
+ * do not need to be reloaded.
+ *
+ * The last PC is expected to be PC[2] plus some predictable,

test/unittest/variables/bvar/tst.arg3-ERROR.d line 81

Quoted 10 lines
test/unittest/variables/bvar/tst.arg3-ERROR.d new file +10 -0
+ * small and narrow, delta PC[2]-PC[1].
+ */
+BEGIN
+/PC[0] >   100 &&
+ PC[0] <  2000 &&
+ PC[1] >  PC[0] +  100 &&
+ PC[1] <  PC[0] + 2000 &&
+ PC[2] >  PC[1] +   30 &&
+ PC[2] <  PC[1] +  500 &&
+ PC[3] == PC[2] + (PC[2] - PC[1])/

These ranges seem quite big. I realize that code generator changes and changes to linked in code can cause these error locations to drift over time, but I think I'd rather have smaller ranges with the downfall of needing to update the test at some point rather than having ranges that are so big that the test itself may not really verify much anymore.

For that matter, perhaps it would be better to rework the test to actually compare the error locations with the disassembler output because we know the mechanism that sets the PC for the error location and thus we know what instructions to expect there. That would allow exact verification of the PC values.

Quoted 14 lines
test/unittest/variables/bvar/tst.arg3-ERROR.d new file +11 -0
+{
+	printf("PCs: %d %d %d %d\n", PC[0], PC[1], PC[2], PC[3]);
+	exit(0);
+}
+
+BEGIN
+{
+	printf("ERROR!  PCs do not seem reasonable: %d %d %d %d\n",
+		   PC[0], PC[1], PC[2], PC[3]);
+	exit(1);
+}
Signature · 1 line
2.43.5