[DTrace-devel] [PATCH 13/13] Restore error message

eugene.loh at oracle.com eugene.loh at oracle.com
Wed Dec 2 10:54:58 PST 2020


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

An error message was "#if 0"ed out during development,
producing behavior like this:
    # dtrace -n 'BEGIN {avg(1); exit(0)}'
    dt_cg_node() - FUNC aggregating function avg()
    dtrace: description 'BEGIN ' matched 1 probe
    BPF: call to invalid destination
    BPF: verification time 14 usec
    BPF: stack depth 0+0
    BPF: processed 0 insns (limit 1000000) max_states_per_insn 0 ...
    dtrace: could not enable tracing: BPF program load for 'dtrac...

Restore the message.  Add a test.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
---
 libdtrace/dt_cg.c                            |  4 ----
 test/unittest/aggs/err.D_CG_EXPR.from_expr.d | 21 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 4 deletions(-)
 create mode 100644 test/unittest/aggs/err.D_CG_EXPR.from_expr.d

diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
index 3a965265..fb67be58 100644
--- a/libdtrace/dt_cg.c
+++ b/libdtrace/dt_cg.c
@@ -2842,16 +2842,12 @@ dt_cg_node(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
 
 		switch (dnp->dn_kind) {
 		case DT_NODE_FUNC:
-if ((idp = dnp->dn_ident)->di_kind != DT_IDENT_FUNC)
-  fprintf(stderr, "%s() - FUNC %s %s()\n", __func__, dt_idkind_name(idp->di_kind), idp->di_name);
-#if 0
 			if ((idp = dnp->dn_ident)->di_kind != DT_IDENT_FUNC) {
 				dnerror(dnp, D_CG_EXPR, "%s %s( ) may not be "
 				    "called from a D expression (D program "
 				    "context required)\n",
 				    dt_idkind_name(idp->di_kind), idp->di_name);
 			}
-#endif
 
 			dt_cg_arglist(dnp->dn_ident, dnp->dn_args, dlp, drp);
 
diff --git a/test/unittest/aggs/err.D_CG_EXPR.from_expr.d b/test/unittest/aggs/err.D_CG_EXPR.from_expr.d
new file mode 100644
index 00000000..1b176412
--- /dev/null
+++ b/test/unittest/aggs/err.D_CG_EXPR.from_expr.d
@@ -0,0 +1,21 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2020, 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:
+ *	Aggregations cannot be called from D expressions.
+ *
+ * SECTION: Aggregations/Clearing aggregations
+ *
+ *
+ */
+
+BEGIN
+{
+	avg(1);
+	exit(0);
+}
-- 
2.18.4




More information about the DTrace-devel mailing list