[DTrace-devel] [PATCH v2 06/12] Add support for mod() and sym()
eugene.loh at oracle.com
eugene.loh at oracle.com
Wed Jun 9 18:41:30 PDT 2021
From: Eugene Loh <eugene.loh at oracle.com>
Also add a new test, since existing tests do not yet work. (They depend
on indexed aggregations.) Further, the sym() tests are very weak.
Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
---
libdtrace/dt_cg.c | 4 +++
libdtrace/dt_consume.c | 8 +++++
test/unittest/actions/symmod/tst.symmod.sh | 42 ++++++++++++++++++++++
3 files changed, 54 insertions(+)
create mode 100755 test/unittest/actions/symmod/tst.symmod.sh
diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
index 241402f6..458ac7b3 100644
--- a/libdtrace/dt_cg.c
+++ b/libdtrace/dt_cg.c
@@ -1397,6 +1397,10 @@ dt_cg_act_stop(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind)
static void
dt_cg_act_symmod(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind)
{
+ dt_node_t *arg = dnp->dn_args;
+
+ assert(arg != NULL);
+ dt_cg_store_val(pcb, arg, kind, NULL, 0);
}
static void
diff --git a/libdtrace/dt_consume.c b/libdtrace/dt_consume.c
index 755e645e..d5f92b9f 100644
--- a/libdtrace/dt_consume.c
+++ b/libdtrace/dt_consume.c
@@ -2069,6 +2069,14 @@ dt_consume_one(dtrace_hdl_t *dtp, FILE *fp, char *buf,
return -1;
continue;
}
+ case DTRACEACT_SYM:
+ if (dt_print_sym(dtp, fp, NULL, recdata) < 0)
+ return -1;
+ continue;
+ case DTRACEACT_MOD:
+ if (dt_print_mod(dtp, fp, NULL, recdata) < 0)
+ return -1;
+ continue;
case DTRACEACT_PRINTF:
func = dtrace_fprintf;
break;
diff --git a/test/unittest/actions/symmod/tst.symmod.sh b/test/unittest/actions/symmod/tst.symmod.sh
new file mode 100755
index 00000000..2f9b08d1
--- /dev/null
+++ b/test/unittest/actions/symmod/tst.symmod.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 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.
+#
+
+dtrace=$1
+
+# pick a test symbol from /proc/kallmodsyms
+read ADD NAM MOD <<< `awk '/ksys_write/ {print $1, $4, $5}' /proc/kallmodsyms`
+
+# a blank module means the module is vmlinux
+if [ x$MOD == x ]; then
+ MOD=vmlinux
+fi
+
+# add the module to the name
+NAM=$MOD'`'$NAM
+
+# run DTrace to test mod() and sym()
+read MYMOD MYNAM <<< `$dtrace -qn 'BEGIN {mod(0x'$ADD'); sym(0x'$ADD'); exit(0) }'`
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+
+# reporting
+echo test $ADD $MOD $NAM
+echo expect $MOD $NAM
+echo actual $MYMOD $MYNAM
+
+if [ $MOD != $MYMOD ]; then
+ echo fail: $MOD does not match $MYMOD
+ exit 1
+fi
+if [ $NAM != $MYNAM ]; then
+ echo fail: $NAM does not match $MYNAM
+ exit 1
+fi
+
+exit 0
--
2.18.4
More information about the DTrace-devel
mailing list