Skip to content

Commit

Permalink
Make sure disassembly distinguishes between gvars and agg vars
Browse files Browse the repository at this point in the history
When the disassembler recognizes access of a variable by value,
it looks up a variable name that matches the offset and scope.
The scope of aggregation variables is also "global", however,
and so the presence of aggregations can lead to incorrect
disassembly of global variables.

Check the variable "kind" when looking up variables accessed
by value.

When the disassembler recognizes aggregation names, a similar
test for them can be introduced.

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 Sep 6, 2022
1 parent 737104b commit 0f01ddb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions libdtrace/dt_dis.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ dt_dis_varname_off(const dtrace_difo_t *dp, uint_t off, uint_t scope, uint_t add
for (i = 0; i < dp->dtdo_varlen; i++) {
const dtrace_difv_t *dvp = &dp->dtdo_vartab[i];
if (dvp->dtdv_offset == off && dvp->dtdv_scope == scope &&
dvp->dtdv_kind != DIFV_KIND_AGGREGATE &&
dvp->dtdv_insn_from <= addr && addr <= dvp->dtdv_insn_to) {
if (dvp->dtdv_name < dp->dtdo_strlen)
return dt_difo_getstr(dp, dvp->dtdv_name);
Expand Down
1 change: 1 addition & 0 deletions test/unittest/disasm/tst.ann-gvar-agg.r
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
myvar_global
22 changes: 22 additions & 0 deletions test/unittest/disasm/tst.ann-gvar-agg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
#
# Oracle Linux DTrace.
# Copyright (c) 2022, 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

# Test that annotation of gvars is not confused by agg vars.

$dtrace $dt_flags -Sen '
BEGIN
{
@myvar_agg = count();
myvar_global = 0xdeadbeef;
exit(0);
}
' 2>&1 | grep -A4 deadbeef | awk '/myvar_/ {print $NF}'

exit $?

0 comments on commit 0f01ddb

Please sign in to comment.