[DTrace-devel] [PATCH 04/13] Change dt_cg_agg_lquantize() arg check to agree with message

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


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

We check limitval<baseval, but the error message is "base must
be less than limit".  Make the check more stringent to agree
with the error message.

Note that this behavior dates back to DTrace v1:
     # dtrace -n 'BEGIN {@ = lquantize(8, 4, 4); exit(0) }'
     dtrace: invalid probe specifier:
     lquantize( ) step (argument #3) too large:
     must have at least one quantization level
That is, the arguments pass the check but are then caught by a
later, rather confusing, message.

Add a test to catch this case.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>
---
 libdtrace/dt_cg.c                             |  2 +-
 .../aggs/err.D_LQUANT_MISMATCH.lqbadarg2.d    | 33 +++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)
 create mode 100644 test/unittest/aggs/err.D_LQUANT_MISMATCH.lqbadarg2.d

diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
index 17159e24..29426d23 100644
--- a/libdtrace/dt_cg.c
+++ b/libdtrace/dt_cg.c
@@ -3359,7 +3359,7 @@ dt_cg_agg_lquantize(dt_pcb_t *pcb, dt_ident_t *aid, dt_node_t *dnp,
 		dnerror(arg2, D_LQUANT_LIMVAL, "lquantize( ) argument #2 must "
 			"be a 32-bit quantity\n");
 
-	if (limitval < baseval)
+	if (limitval <= baseval)
 		dnerror(dnp, D_LQUANT_MISMATCH,
 			"lquantize( ) base (argument #1) must be less than "
 			"limit (argument #2)\n");
diff --git a/test/unittest/aggs/err.D_LQUANT_MISMATCH.lqbadarg2.d b/test/unittest/aggs/err.D_LQUANT_MISMATCH.lqbadarg2.d
new file mode 100644
index 00000000..e281c955
--- /dev/null
+++ b/test/unittest/aggs/err.D_LQUANT_MISMATCH.lqbadarg2.d
@@ -0,0 +1,33 @@
+/*
+ * 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:
+ * 	Upper bound must be greater than lower bound argument
+ *
+ * SECTION: Aggregations/Aggregations
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+	i = 0;
+}
+
+tick-1
+/i < 1000/
+{
+	@ = lquantize(i, 1100, 1100, -100 );
+	i += 100;
+}
+
+tick-1
+/i == 1000/
+{
+	exit(0);
+}
-- 
2.18.4




More information about the DTrace-devel mailing list