[DTrace-devel] [PATCH] Manage clause flags

eugene.loh at oracle.com eugene.loh at oracle.com
Fri Mar 19 13:21:33 PDT 2021


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

Actions within a clause are subject to a variety of constraints --
e.g., that a speculate() may not follow a data-recording action.
An earlier patch ("Add clause flags") started to implement some
such constraints by tracking clause flags where code for the
functions was generated.  This costs a lot of duplicate code
since, for example, all data-recording actions should be treated
similarly, as should all aggregations.

Reimplement the management of clause flags.  Specifically,

- Remove the existing, customized management of dtsd_clauseflags.

- Remove the dead dt_stmt_append code from dt_cc.c
  (and inline what little would remain).

- Add a new dt_cg_clsflags() to dt_cg.c based on the old
  dt_stmt_append().

  Note that the old function, if it encountered a commit(), would
  then look ahead at future actions for an aggregation.  Without
  such look-ahead capabilities, the new function waits until an
  aggregation and then looks backwards for a commit().  Either way,
  an aggregation after a commit() will be caught, but it is
  conceivable that, in a clause with multiple problems, which
  problem is flagged will change.

  Also, handling of destructive actions is not yet complete.

- Call the new dt_cg_clsflags() before calling the function
  that generates code for the action.  This means that
  dt_cg_clsflags() is called from only two sites (one for
  aggregations and one for not aggregations) rather than
  from each action function.

  This also means that _dt_cg_actions[] must be populated
  with more dtrace_actkind_t values, so that dt_cg_clsflags()
  knows what sort of action it is dealing with.  On the other
  hand, the only action kinds that dt_cg_clsflags() cares about
  are:
        kind == DTRACEACT_COMMIT
        kind == DTRACEACT_SPECULATE
        kind == DTRACEACT_EXIT
        kind == DTRACEACT_DISCARD
        kind == DTRACEACT_DIFEXPR
        DTRACEACT_ISAGG(kind)
        DTRACEACT_ISDESTRUCTIVE(kind)
  So, for example, typical data-recording actions can get by
  with the default kind==0;  also, all aggregations can be
  handled with kind==DTRACEACT_AGGREGATION.

- Clean up the tests.  Some previously failing tests now pass.
  In some cases, this requires removing some indexing, which
  was not germane to the functionality being tested and has
  been removed in other recent similar changes.  Make some
  tests -- like the err.D_AGG_SPEC* tests -- more uniform.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
---
 libdtrace/dt_cc.c                             | 129 +-----------
 libdtrace/dt_cg.c                             | 184 ++++++++++++------
 .../err.D_ACT_SPEC.SpeculateWithBreakPoint.d  |   8 +-
 .../err.D_ACT_SPEC.SpeculateWithChill.d       |   8 +-
 .../err.D_ACT_SPEC.SpeculateWithCopyOut.d     |   6 +-
 .../err.D_ACT_SPEC.SpeculateWithCopyOutStr.d  |   5 +-
 .../err.D_ACT_SPEC.SpeculateWithPanic.d       |   8 +-
 .../err.D_ACT_SPEC.SpeculateWithRaise.d       |   7 +-
 .../err.D_ACT_SPEC.SpeculateWithStop.d        |   7 +-
 .../speculation/err.D_AGG_COMM.AggAftCommit.d |  14 +-
 .../err.D_AGG_SPEC.SpeculateWithAvg.d         |  15 +-
 .../err.D_AGG_SPEC.SpeculateWithCount.d       |  15 +-
 .../err.D_AGG_SPEC.SpeculateWithLquant.d      |  26 +--
 .../err.D_AGG_SPEC.SpeculateWithLquant.r      |   2 +-
 .../err.D_AGG_SPEC.SpeculateWithMax.d         |  10 +-
 .../err.D_AGG_SPEC.SpeculateWithMin.d         |  10 +-
 .../err.D_AGG_SPEC.SpeculateWithQuant.d       |  21 +-
 .../err.D_AGG_SPEC.SpeculateWithQuant.r       |   2 +-
 .../err.D_AGG_SPEC.SpeculateWithSum.d         |  10 +-
 .../speculation/tst.SpeculateWithRandom.d     |   9 +-
 20 files changed, 192 insertions(+), 304 deletions(-)

diff --git a/libdtrace/dt_cc.c b/libdtrace/dt_cc.c
index 2fe91ae4..0875fe70 100644
--- a/libdtrace/dt_cc.c
+++ b/libdtrace/dt_cc.c
@@ -133,129 +133,6 @@ dt_stmt_create(dtrace_hdl_t *dtp, dtrace_ecbdesc_t *edp,
 	return sdp;
 }
 
-#ifdef FIXME
-/*
- * Utility function to determine if a given action description is destructive.
- * The DIFOFLG_DESTRUCTIVE bit is set for us by the DIF assembler (see dt_as.c).
- */
-static int
-dt_action_destructive(const dtrace_actdesc_t *ap)
-{
-	return (DTRACEACT_ISDESTRUCTIVE(ap->dtad_kind) ||
-		(ap->dtad_kind == DTRACEACT_DIFEXPR &&
-		 (ap->dtad_difo->dtdo_flags & DIFOFLG_DESTRUCTIVE)));
-}
-#endif
-
-static void
-dt_stmt_append(dtrace_stmtdesc_t *sdp, const dt_node_t *dnp)
-{
-#ifdef FIXME
-	dtrace_ecbdesc_t *edp = sdp->dtsd_ecbdesc;
-	dtrace_actdesc_t *ap, *tap;
-	int commit = 0;
-	int speculate = 0;
-	int datarec = 0;
-
-	/*
-	 * Make sure that the new statement jibes with the rest of the ECB.
-	 * FIXME: Eliminate this code once it's incorporated elsewhere.
-	 */
-	for (ap = edp->dted_action; ap != NULL; ap = ap->dtad_next) {
-		if (ap->dtad_kind == DTRACEACT_COMMIT) {
-			if (commit) {
-				dnerror(dnp, D_COMM_COMM, "commit( ) may "
-				    "not follow commit( )\n");
-			}
-
-			if (datarec) {
-				dnerror(dnp, D_COMM_DREC, "commit( ) may "
-				    "not follow data-recording action(s)\n");
-			}
-
-			for (tap = ap; tap != NULL; tap = tap->dtad_next) {
-				if (!DTRACEACT_ISAGG(tap->dtad_kind))
-					continue;
-
-				dnerror(dnp, D_AGG_COMM, "aggregating actions "
-				    "may not follow commit( )\n");
-			}
-
-			commit = 1;
-			continue;
-		}
-
-		if (ap->dtad_kind == DTRACEACT_SPECULATE) {
-			if (speculate) {
-				dnerror(dnp, D_SPEC_SPEC, "speculate( ) may "
-				    "not follow speculate( )\n");
-			}
-
-			if (commit) {
-				dnerror(dnp, D_SPEC_COMM, "speculate( ) may "
-				    "not follow commit( )\n");
-			}
-
-			if (datarec) {
-				dnerror(dnp, D_SPEC_DREC, "speculate( ) may "
-				    "not follow data-recording action(s)\n");
-			}
-
-			speculate = 1;
-			continue;
-		}
-
-		if (DTRACEACT_ISAGG(ap->dtad_kind)) {
-			if (speculate) {
-				dnerror(dnp, D_AGG_SPEC, "aggregating actions "
-				    "may not follow speculate( )\n");
-			}
-
-			datarec = 1;
-			continue;
-		}
-
-		if (speculate) {
-			if (dt_action_destructive(ap)) {
-				dnerror(dnp, D_ACT_SPEC, "destructive actions "
-				    "may not follow speculate( )\n");
-			}
-
-			if (ap->dtad_kind == DTRACEACT_EXIT) {
-				dnerror(dnp, D_EXIT_SPEC, "exit( ) may not "
-				    "follow speculate( )\n");
-			}
-		}
-
-		/*
-		 * Exclude all non data-recording actions.
-		 */
-		if (dt_action_destructive(ap) ||
-		    ap->dtad_kind == DTRACEACT_DISCARD)
-			continue;
-
-		if (ap->dtad_kind == DTRACEACT_DIFEXPR &&
-		    ap->dtad_difo->dtdo_rtype.dtdt_kind == DIF_TYPE_CTF &&
-		    ap->dtad_difo->dtdo_rtype.dtdt_size == 0)
-			continue;
-
-		if (commit) {
-			dnerror(dnp, D_DREC_COMM, "data-recording actions "
-			    "may not follow commit( )\n");
-		}
-
-		if (!speculate)
-			datarec = 1;
-	}
-#endif
-
-	if (dtrace_stmt_add(yypcb->pcb_hdl, yypcb->pcb_prog, sdp) != 0)
-		longjmp(yypcb->pcb_jmpbuf, dtrace_errno(yypcb->pcb_hdl));
-
-	if (yypcb->pcb_stmt == sdp)
-		yypcb->pcb_stmt = NULL;
-}
-
 #ifdef FIXME
 /*
  * For the first element of an aggregation tuple or for printa(), we create a
@@ -1644,7 +1521,11 @@ dt_compile_one_clause(dtrace_hdl_t *dtp, dt_node_t *cnp, dt_node_t *pnp)
 	sdp->dtsd_clause = dt_clause_create(dtp, dt_as(yypcb));
 
 	assert(yypcb->pcb_stmt == sdp);
-	dt_stmt_append(sdp, cnp);
+	if (dtrace_stmt_add(yypcb->pcb_hdl, yypcb->pcb_prog, sdp) != 0)
+		longjmp(yypcb->pcb_jmpbuf, dtrace_errno(yypcb->pcb_hdl));
+
+	if (yypcb->pcb_stmt == sdp)
+		yypcb->pcb_stmt = NULL;
 
 	assert(yypcb->pcb_ecbdesc == edp);
 	dt_ecbdesc_release(dtp, edp);
diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
index 27b32c87..c6443b63 100644
--- a/libdtrace/dt_cg.c
+++ b/libdtrace/dt_cg.c
@@ -770,6 +770,104 @@ dt_cg_store_val(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind,
 	return -1;
 }
 
+#ifdef FIXME
+/*
+ * Utility function to determine if a given action description is destructive.
+ * The DIFOFLG_DESTRUCTIVE bit is set for us by the DIF assembler (see dt_as.c).
+ */
+static int
+dt_action_destructive(const dtrace_actdesc_t *ap)
+{
+	return (DTRACEACT_ISDESTRUCTIVE(ap->dtad_kind) ||
+		(ap->dtad_kind == DTRACEACT_DIFEXPR &&
+		 (ap->dtad_difo->dtdo_flags & DIFOFLG_DESTRUCTIVE)));
+}
+#endif
+
+static void
+dt_cg_clsflags(dt_pcb_t *pcb, dtrace_actkind_t kind, const dt_node_t *dnp)
+{
+	int		*cfp = &pcb->pcb_stmt->dtsd_clauseflags;
+
+	if (kind == DTRACEACT_COMMIT) {
+		if (*cfp & DT_CLSFLAG_COMMIT)
+			dnerror(dnp, D_COMM_COMM,
+			    "commit( ) may not follow commit( )\n");
+		if (*cfp & DT_CLSFLAG_DATAREC)
+			dnerror(dnp, D_COMM_DREC, "commit( ) may "
+			    "not follow data-recording action(s)\n");
+
+		*cfp |= DT_CLSFLAG_COMMIT;
+		return;
+	}
+
+	if (kind == DTRACEACT_SPECULATE) {
+		if (*cfp & DT_CLSFLAG_SPECULATE)
+			dnerror(dnp, D_SPEC_SPEC,
+			    "speculate( ) may not follow speculate( )\n");
+
+		if (*cfp & DT_CLSFLAG_COMMIT)
+			dnerror(dnp, D_SPEC_COMM,
+			    "speculate( ) may not follow commit( )\n");
+
+		if (*cfp & DT_CLSFLAG_DATAREC)
+			dnerror(dnp, D_SPEC_DREC, "speculate( ) may "
+			    "not follow data-recording action(s)\n");
+
+		*cfp |= DT_CLSFLAG_SPECULATE;
+		return;
+	}
+
+	if (DTRACEACT_ISAGG(kind)) {
+		if (*cfp & DT_CLSFLAG_COMMIT)
+			dnerror(dnp, D_AGG_COMM,
+			    "aggregating actions may not follow commit( )\n");
+		if (*cfp & DT_CLSFLAG_SPECULATE)
+			dnerror(dnp, D_AGG_SPEC, "aggregating actions "
+			    "may not follow speculate( )\n");
+
+		*cfp |= DT_CLSFLAG_DATAREC;
+		return;
+	}
+
+	if (*cfp & DT_CLSFLAG_SPECULATE) {
+#ifdef FIXME
+		if (dt_action_destructive(ap))
+#else
+		if (DTRACEACT_ISDESTRUCTIVE(kind))
+#endif
+			dnerror(dnp, D_ACT_SPEC, "destructive actions "
+			    "may not follow speculate( )\n");
+		if (kind == DTRACEACT_EXIT)
+			dnerror(dnp, D_EXIT_SPEC,
+			    "exit( ) may not follow speculate( )\n");
+	}
+
+	/*
+	 * Exclude all non data-recording actions.
+	 */
+#ifdef FIXME
+	if (dt_action_destructive(ap) || kind == DTRACEACT_DISCARD)
+#else
+	if (DTRACEACT_ISDESTRUCTIVE(kind) || kind == DTRACEACT_DISCARD)
+#endif
+		return;
+
+#ifdef FIXME
+	if (kind == DTRACEACT_DIFEXPR &&
+	    ap->dtad_difo->dtdo_rtype.dtdt_kind == DIF_TYPE_CTF &&
+	    ap->dtad_difo->dtdo_rtype.dtdt_size == 0)
+		return;
+#endif
+
+	if (*cfp & DT_CLSFLAG_COMMIT)
+		dnerror(dnp, D_DREC_COMM,
+		    "data-recording actions may not follow commit( )\n");
+
+	if (!(*cfp & DT_CLSFLAG_SPECULATE))
+		*cfp |= DT_CLSFLAG_DATAREC;
+}
+
 static void
 dt_cg_act_breakpoint(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind)
 {
@@ -828,16 +926,6 @@ dt_cg_act_commit(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind)
 {
 	dt_irlist_t	*dlp = &pcb->pcb_ir;
 	uint_t		off;
-	int		*cfp = &pcb->pcb_stmt->dtsd_clauseflags;
-
-	/* process clause flags */
-	if (*cfp & DT_CLSFLAG_COMMIT)
-		dnerror(dnp, D_COMM_COMM,
-		    "commit( ) may not follow commit( )\n");
-	if (*cfp & DT_CLSFLAG_DATAREC)
-		dnerror(dnp, D_COMM_DREC,
-		    "commit( ) may not follow data-recording action(s)\n");
-	*cfp |= DT_CLSFLAG_COMMIT;
 
 	dt_cg_node(dnp->dn_args, &pcb->pcb_ir, pcb->pcb_regs);
 
@@ -908,16 +996,6 @@ dt_cg_act_exit(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind)
 {
 	dt_irlist_t	*dlp = &pcb->pcb_ir;
 	dt_ident_t	*state = dt_dlib_get_map(pcb->pcb_hdl, "state");
-	int		*cfp = &pcb->pcb_stmt->dtsd_clauseflags;
-
-	/* process clause flags */
-	if (*cfp & DT_CLSFLAG_SPECULATE)
-		dnerror(dnp, D_EXIT_SPEC,
-		    "exit( ) may not follow speculate( )\n");
-	if (*cfp & DT_CLSFLAG_COMMIT)
-		dnerror(dnp, D_DREC_COMM,
-		    "data-recording actions may not follow commit( )\n");
-	*cfp |= DT_CLSFLAG_EXIT | DT_CLSFLAG_DATAREC;
 
 	/* Record the exit code. */
 	dt_cg_store_val(pcb, dnp->dn_args, DTRACEACT_EXIT, NULL, DT_ACT_EXIT);
@@ -1013,13 +1091,6 @@ dt_cg_act_printa(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind)
 	int		argc = 0, argr;
 	char		n[DT_TYPE_NAMELEN];
 	dt_ident_t	*aid, *fid;
-	int		*cfp = &pcb->pcb_stmt->dtsd_clauseflags;
-
-	/* process clause flags */
-	if (*cfp & DT_CLSFLAG_COMMIT)
-		dnerror(dnp, D_DREC_COMM,
-		    "data-recording actions may not follow commit( )\n");
-	*cfp |= DT_CLSFLAG_DATAREC;
 
 	/* Count the arguments. */
 	for (anp = dnp->dn_args; anp != NULL; anp = anp->dn_list)
@@ -1096,13 +1167,6 @@ dt_cg_act_printf(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind)
 	dt_pfargv_t	*pfp;
 	char		n[DT_TYPE_NAMELEN];
 	char		*str;
-	int		*cfp = &pcb->pcb_stmt->dtsd_clauseflags;
-
-	/* process clause flags */
-	if (*cfp & DT_CLSFLAG_COMMIT)
-		dnerror(dnp, D_DREC_COMM,
-		    "data-recording actions may not follow commit( )\n");
-	*cfp |= DT_CLSFLAG_DATAREC;
 
 	/*
 	 * Ensure that the format string is a string constant.
@@ -1226,19 +1290,6 @@ dt_cg_act_speculate(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind)
 {
 	dt_irlist_t	*dlp = &pcb->pcb_ir;
 	uint_t		off;
-	int		*cfp = &pcb->pcb_stmt->dtsd_clauseflags;
-
-	/* process clause flags */
-	if (*cfp & DT_CLSFLAG_SPECULATE)
-		dnerror(dnp, D_SPEC_SPEC,
-		    "speculate( ) may not follow speculate( )\n");
-	if (*cfp & DT_CLSFLAG_COMMIT)
-		dnerror(dnp, D_SPEC_COMM,
-		    "speculate( ) may not follow commit( )\n");
-	if (*cfp & DT_CLSFLAG_DATAREC)
-		dnerror(dnp, D_SPEC_DREC,
-		    "speculate( ) may not follow data-recording action(s)\n");
-	*cfp |= DT_CLSFLAG_SPECULATE;
 
 	dt_cg_node(dnp->dn_args, &pcb->pcb_ir, pcb->pcb_regs);
 
@@ -1287,13 +1338,6 @@ dt_cg_act_trace(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind)
 	char		n[DT_TYPE_NAMELEN];
 	dt_node_t	*arg = dnp->dn_args;
 	int		type = 0;
-	int		*cfp = &pcb->pcb_stmt->dtsd_clauseflags;
-
-	/* process clause flags */
-	if (*cfp & DT_CLSFLAG_COMMIT)
-		dnerror(dnp, D_DREC_COMM,
-		        "data-recording actions may not follow commit( )\n");
-	*cfp |= DT_CLSFLAG_DATAREC;
 
 	if (dt_node_is_void(arg))
 		dnerror(arg, D_TRACE_VOID,
@@ -1417,17 +1461,26 @@ static const dt_cg_actdesc_t _dt_cg_actions[DT_ACT_MAX] = {
 	[DT_ACT_IDX(DT_ACT_TRACE)]		= { &dt_cg_act_trace, },
 	[DT_ACT_IDX(DT_ACT_TRACEMEM)]		= { &dt_cg_act_tracemem, },
 	[DT_ACT_IDX(DT_ACT_STACK)]		= { &dt_cg_act_stack, },
-	[DT_ACT_IDX(DT_ACT_STOP)]		= { &dt_cg_act_stop, },
-	[DT_ACT_IDX(DT_ACT_BREAKPOINT)]		= { &dt_cg_act_breakpoint, },
-	[DT_ACT_IDX(DT_ACT_PANIC)]		= { &dt_cg_act_panic, },
-	[DT_ACT_IDX(DT_ACT_SPECULATE)]		= { &dt_cg_act_speculate, },
-	[DT_ACT_IDX(DT_ACT_COMMIT)]		= { &dt_cg_act_commit, },
-	[DT_ACT_IDX(DT_ACT_DISCARD)]		= { &dt_cg_act_discard, },
-	[DT_ACT_IDX(DT_ACT_CHILL)]		= { &dt_cg_act_chill, },
-	[DT_ACT_IDX(DT_ACT_EXIT)]		= { &dt_cg_act_exit, },
+	[DT_ACT_IDX(DT_ACT_STOP)]		= { &dt_cg_act_stop,
+						    DTRACEACT_STOP },
+	[DT_ACT_IDX(DT_ACT_BREAKPOINT)]		= { &dt_cg_act_breakpoint,
+						    DTRACEACT_BREAKPOINT },
+	[DT_ACT_IDX(DT_ACT_PANIC)]		= { &dt_cg_act_panic,
+						    DTRACEACT_PANIC },
+	[DT_ACT_IDX(DT_ACT_SPECULATE)]		= { &dt_cg_act_speculate,
+						    DTRACEACT_SPECULATE },
+	[DT_ACT_IDX(DT_ACT_COMMIT)]		= { &dt_cg_act_commit,
+						    DTRACEACT_COMMIT },
+	[DT_ACT_IDX(DT_ACT_DISCARD)]		= { &dt_cg_act_discard,
+						    DTRACEACT_DISCARD },
+	[DT_ACT_IDX(DT_ACT_CHILL)]		= { &dt_cg_act_chill,
+						    DTRACEACT_CHILL },
+	[DT_ACT_IDX(DT_ACT_EXIT)]		= { &dt_cg_act_exit,
+						    DTRACEACT_EXIT },
 	[DT_ACT_IDX(DT_ACT_USTACK)]		= { &dt_cg_act_ustack, },
 	[DT_ACT_IDX(DT_ACT_PRINTA)]		= { &dt_cg_act_printa, },
-	[DT_ACT_IDX(DT_ACT_RAISE)]		= { &dt_cg_act_raise, },
+	[DT_ACT_IDX(DT_ACT_RAISE)]		= { &dt_cg_act_raise,
+						    DTRACEACT_RAISE },
 	[DT_ACT_IDX(DT_ACT_CLEAR)]		= { &dt_cg_act_clear, },
 	[DT_ACT_IDX(DT_ACT_NORMALIZE)]		= { &dt_cg_act_normalize, },
 	[DT_ACT_IDX(DT_ACT_DENORMALIZE)]	= { &dt_cg_act_denormalize, },
@@ -4533,6 +4586,7 @@ dt_cg_agg(dt_pcb_t *pcb, dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
 
 	assert(fid->di_id >= DT_AGG_BASE && fid->di_id < DT_AGG_HIGHEST);
 
+	dt_cg_clsflags(pcb, DTRACEACT_AGGREGATION, dnp);
 	aggfp = _dt_cg_agg[DT_AGG_IDX(fid->di_id)];
 	assert(aggfp != NULL);
 
@@ -4588,9 +4642,11 @@ dt_cg(dt_pcb_t *pcb, dt_node_t *dnp)
 
 				idp = act->dn_expr->dn_ident;
 				actdp = &_dt_cg_actions[DT_ACT_IDX(idp->di_id)];
-				if (actdp->fun)
+				if (actdp->fun) {
+					dt_cg_clsflags(pcb, actdp->kind, act);
 					actdp->fun(pcb, act->dn_expr,
 						   actdp->kind);
+				}
 				break;
 			}
 			case DT_NODE_AGG:
diff --git a/test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithBreakPoint.d b/test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithBreakPoint.d
index ebbeb5e9..50bbf177 100644
--- a/test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithBreakPoint.d
+++ b/test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithBreakPoint.d
@@ -1,18 +1,16 @@
 #!/usr/sbin/dtrace -ws
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+
 /*
- * ASSERTION:
- * Destructive actions may never be speculative.
+ * ASSERTION: Destructive actions may never be speculative.
  *
  * SECTION: Speculative Tracing/Using a Speculation
  * SECTION: dtrace(1M) Utility/ -w option
- *
  */
 #pragma D option quiet
 
diff --git a/test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithChill.d b/test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithChill.d
index 13d0f3e3..47e248d2 100644
--- a/test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithChill.d
+++ b/test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithChill.d
@@ -1,18 +1,16 @@
 #!/usr/sbin/dtrace -ws
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+
 /*
- * ASSERTION:
- * Destructive actions may never be speculative.
+ * ASSERTION: Destructive actions may never be speculative.
  *
  * SECTION: Speculative Tracing/Using a Speculation
  * SECTION: dtrace (1M) Utility/ -w option
- *
  */
 #pragma D option quiet
 
diff --git a/test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithCopyOut.d b/test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithCopyOut.d
index 08caeb4d..aae3e4ff 100644
--- a/test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithCopyOut.d
+++ b/test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithCopyOut.d
@@ -1,18 +1,16 @@
 #!/usr/sbin/dtrace -ws
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
 /* @@xfail: dtv2 */
 /*
- * ASSERTION:
- * Destructive actions may never be speculative.
+ * ASSERTION: Destructive actions may never be speculative.
  *
  * SECTION: Speculative Tracing/Using a Speculation
  * SECTION: dtrace(1M) Utility/ -w option
- *
  */
 #pragma D option quiet
 
diff --git a/test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithCopyOutStr.d b/test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithCopyOutStr.d
index 00bd6faa..c75d1506 100644
--- a/test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithCopyOutStr.d
+++ b/test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithCopyOutStr.d
@@ -1,14 +1,13 @@
 #!/usr/sbin/dtrace -ws
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
 /* @@xfail: dtv2 */
 /*
- * ASSERTION:
- * Destructive actions may never be speculative.
+ * ASSERTION: Destructive actions may never be speculative.
  *
  * SECTION: Speculative Tracing/Using a Speculation
  * SECTION: dtrace(1M) Utility/ -w option
diff --git a/test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithPanic.d b/test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithPanic.d
index fb6d5e21..80a3204d 100644
--- a/test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithPanic.d
+++ b/test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithPanic.d
@@ -1,18 +1,16 @@
 #!/usr/sbin/dtrace -ws
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+
 /*
- * ASSERTION:
- * Destructive actions may never be speculative.
+ * ASSERTION: Destructive actions may never be speculative.
  *
  * SECTION: Speculative Tracing/Using a Speculation
  * SECTION: dtrace(1M) Utility/ -w option
- *
  */
 #pragma D option quiet
 
diff --git a/test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithRaise.d b/test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithRaise.d
index f1d392b1..a8c1c4d4 100644
--- a/test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithRaise.d
+++ b/test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithRaise.d
@@ -1,14 +1,13 @@
 #!/usr/sbin/dtrace -ws
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+
 /*
- * ASSERTION:
- * Destructive actions may never be speculative.
+ * ASSERTION: Destructive actions may never be speculative.
  *
  * SECTION: Speculative Tracing/Using a Speculation
  * SECTION: dtrace(1M) Utility/ -w option
diff --git a/test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithStop.d b/test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithStop.d
index 72cf1cfb..a0bca73d 100644
--- a/test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithStop.d
+++ b/test/unittest/speculation/err.D_ACT_SPEC.SpeculateWithStop.d
@@ -1,14 +1,13 @@
 #!/usr/sbin/dtrace -ws
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+
 /*
- * ASSERTION:
- * Destructive actions may never be speculative.
+ * ASSERTION: Destructive actions may never be speculative.
  *
  * SECTION: Speculative Tracing/Using a Speculation
  * SECTION: dtrace(1M) Utility/ -w option
diff --git a/test/unittest/speculation/err.D_AGG_COMM.AggAftCommit.d b/test/unittest/speculation/err.D_AGG_COMM.AggAftCommit.d
index bf121a7d..cf007da6 100644
--- a/test/unittest/speculation/err.D_AGG_COMM.AggAftCommit.d
+++ b/test/unittest/speculation/err.D_AGG_COMM.AggAftCommit.d
@@ -1,13 +1,12 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+
 /*
- * ASSERTION:
- * A clause cannot contain a commit() followed by an aggregating action.
+ * ASSERTION: A clause cannot contain a commit() followed by an aggregating action.
  *
  * SECTION: Speculative Tracing/Committing a Speculation;
  */
@@ -15,5 +14,10 @@
 BEGIN
 {
 	commit(1);
-	@a["foo"] = count();
+	@a = count();
+	exit(1);
+}
+ERROR
+{
+	exit(1);
 }
diff --git a/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithAvg.d b/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithAvg.d
index 8ed7f115..4c624787 100644
--- a/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithAvg.d
+++ b/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithAvg.d
@@ -1,16 +1,14 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+
 /*
- * ASSERTION:
- * Aggregating actions may never be speculative.
+ * ASSERTION: Aggregating functions may never be speculative.
  *
  * SECTION: Speculative Tracing/Using a Speculation
- *
  */
 #pragma D option quiet
 
@@ -25,7 +23,7 @@ profile:::tick-1sec
 	var = speculation();
 	speculate(var);
 	printf("Speculation ID: %d", var);
-	@avrg["speculate"] = avg(i);
+	@avrg = avg(i);
 	i++;
 }
 
@@ -39,8 +37,3 @@ ERROR
 {
 	exit(0);
 }
-
-END
-{
-	exit(0);
-}
diff --git a/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithCount.d b/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithCount.d
index 35e18465..475a6b26 100644
--- a/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithCount.d
+++ b/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithCount.d
@@ -1,16 +1,14 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+
 /*
- * ASSERTION:
- * Aggregating functions may never be speculative.
+ * ASSERTION: Aggregating functions may never be speculative.
  *
  * SECTION: Speculative Tracing/Using a Speculation
- *
  */
 #pragma D option quiet
 
@@ -25,7 +23,7 @@ profile:::tick-1sec
 	var = speculation();
 	speculate(var);
 	printf("Speculation ID: %d", var);
-	@counts["speculate"] = count();
+	@counts = count();
 	i++;
 }
 
@@ -39,8 +37,3 @@ ERROR
 {
 	exit(0);
 }
-
-END
-{
-	exit(0);
-}
diff --git a/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithLquant.d b/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithLquant.d
index 91c4f05e..bfd19544 100644
--- a/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithLquant.d
+++ b/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithLquant.d
@@ -1,16 +1,14 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+
 /*
- * ASSERTION:
- * Aggregating functions may never be speculative.
+ * ASSERTION: Aggregating functions may never be speculative.
  *
  * SECTION: Speculative Tracing/Using a Speculation
- *
  */
 #pragma D option quiet
 
@@ -19,22 +17,17 @@ BEGIN
 	i = 0;
 }
 
-syscall:::entry
-{
-	self->ts = timestamp;
-}
-
-syscall:::return
-/self->ts/
+profile:::tick-1sec
+/i < 1/
 {
 	var = speculation();
 	speculate(var);
 	printf("Speculation ID: %d", var);
-	@Lqauntus[execname] = lquantize(timestamp - self->ts, 0, 100, 1);
+	@Lquantus = lquantize(i, 0, 100, 1);
 	i++;
 }
 
-syscall:::
+profile:::tick-1sec
 /1 == i/
 {
 	exit(0);
@@ -44,8 +37,3 @@ ERROR
 {
 	exit(0);
 }
-
-END
-{
-	exit(0);
-}
diff --git a/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithLquant.r b/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithLquant.r
index e62f578e..30d3e12f 100644
--- a/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithLquant.r
+++ b/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithLquant.r
@@ -1,2 +1,2 @@
 -- @@stderr --
-dtrace: failed to compile script test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithLquant.d: [D_AGG_SPEC] line 33: aggregating actions may not follow speculate( )
+dtrace: failed to compile script test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithLquant.d: [D_AGG_SPEC] line 28: aggregating actions may not follow speculate( )
diff --git a/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithMax.d b/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithMax.d
index 31ea7f3f..39e3cebd 100644
--- a/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithMax.d
+++ b/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithMax.d
@@ -1,16 +1,14 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+
 /*
- * ASSERTION:
- * Aggregating functions may never be speculative.
+ * ASSERTION: Aggregating functions may never be speculative.
  *
  * SECTION: Speculative Tracing/Using a Speculation
- *
  */
 #pragma D option quiet
 
@@ -25,7 +23,7 @@ profile:::tick-1sec
 	var = speculation();
 	speculate(var);
 	printf("Speculation ID: %d", var);
-	@Maximus["speculate"] = max(i);
+	@Maximus = max(i);
 	i++;
 }
 
diff --git a/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithMin.d b/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithMin.d
index b9ebea4a..b3f6ee88 100644
--- a/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithMin.d
+++ b/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithMin.d
@@ -1,16 +1,14 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+
 /*
- * ASSERTION:
- * Aggregating functions may never be speculative.
+ * ASSERTION: Aggregating functions may never be speculative.
  *
  * SECTION: Speculative Tracing/Using a Speculation
- *
  */
 #pragma D option quiet
 
@@ -25,7 +23,7 @@ profile:::tick-1sec
 	var = speculation();
 	speculate(var);
 	printf("Speculation ID: %d", var);
-	@Minimus["speculate"] = min(i);
+	@Minimus = min(i);
 	i++;
 }
 
diff --git a/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithQuant.d b/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithQuant.d
index 4d34aafe..342971b2 100644
--- a/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithQuant.d
+++ b/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithQuant.d
@@ -1,16 +1,14 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+
 /*
- * ASSERTION:
- * Aggregating functions may never be speculative.
+ * ASSERTION: Aggregating functions may never be speculative.
  *
  * SECTION: Speculative Tracing/Using a Speculation
- *
  */
 #pragma D option quiet
 
@@ -19,22 +17,17 @@ BEGIN
 	i = 0;
 }
 
-syscall:::entry
-{
-	self->ts = timestamp;
-}
-
-syscall:::return
-/self->ts/
+profile:::tick-1sec
+/i < 1/
 {
 	var = speculation();
 	speculate(var);
 	printf("Speculation ID: %d", var);
-	@Qauntus[execname] = quantize(timestamp - self->ts);
+	@Quantus = quantize(i);
 	i++;
 }
 
-syscall:::
+profile:::tick-1sec
 /1 == i/
 {
 	exit(0);
diff --git a/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithQuant.r b/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithQuant.r
index 0fd3d5a2..e08a3b45 100644
--- a/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithQuant.r
+++ b/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithQuant.r
@@ -1,2 +1,2 @@
 -- @@stderr --
-dtrace: failed to compile script test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithQuant.d: [D_AGG_SPEC] line 33: aggregating actions may not follow speculate( )
+dtrace: failed to compile script test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithQuant.d: [D_AGG_SPEC] line 28: aggregating actions may not follow speculate( )
diff --git a/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithSum.d b/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithSum.d
index dd2720c1..a4fd0857 100644
--- a/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithSum.d
+++ b/test/unittest/speculation/err.D_AGG_SPEC.SpeculateWithSum.d
@@ -1,16 +1,14 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
+
 /*
- * ASSERTION:
- * Aggregating functions may never be speculative.
+ * ASSERTION: Aggregating functions may never be speculative.
  *
  * SECTION: Speculative Tracing/Using a Speculation
- *
  */
 #pragma D option quiet
 
@@ -25,7 +23,7 @@ profile:::tick-1sec
 	var = speculation();
 	speculate(var);
 	printf("Speculation ID: %d", var);
-	@sums["speculate"] = sum(i);
+	@sums = sum(i);
 	i++;
 }
 
diff --git a/test/unittest/speculation/tst.SpeculateWithRandom.d b/test/unittest/speculation/tst.SpeculateWithRandom.d
index 30ab3794..0e280974 100644
--- a/test/unittest/speculation/tst.SpeculateWithRandom.d
+++ b/test/unittest/speculation/tst.SpeculateWithRandom.d
@@ -1,18 +1,15 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved.
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 */
 
 /*
- * ASSERTION:
- * When speculate() is called with an inactive buffer number, it is
- * ignored.
+ * ASSERTION: When speculate() is called with an inactive buffer number,
+ * it is ignored.
  *
  * SECTION: Speculative Tracing/Creating a Speculation
- *
  */
 #pragma D option quiet
 BEGIN
-- 
2.18.4




More information about the DTrace-devel mailing list