Skip to content

Commit

Permalink
Add support for mod() and sym()
Browse files Browse the repository at this point in the history
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@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
  • Loading branch information
euloh authored and kvanhees committed Jun 18, 2021
1 parent 81e9939 commit 54581a2
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libdtrace/dt_cg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1415,6 +1415,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
Expand Down
8 changes: 8 additions & 0 deletions libdtrace/dt_consume.c
Original file line number Diff line number Diff line change
Expand Up @@ -2084,6 +2084,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;
Expand Down
42 changes: 42 additions & 0 deletions test/unittest/actions/symmod/tst.symmod.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 54581a2

Please sign in to comment.