Skip to content

Commit

Permalink
Fix disasm for endian operations
Browse files Browse the repository at this point in the history
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 11, 2023
1 parent 4f45d37 commit 79719f6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libdtrace/dt_dis.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,9 @@ static const struct opent {
INSN3(ALU, DIV, X) = { "div", dt_dis_op2 },
INSN3(ALU, MOD, X) = { "mod", dt_dis_op2 },
INSN2(ALU, NEG) = { "neg", dt_dis_op1 },
INSN3(ALU, END, TO_BE) = { "tobe", dt_dis_op2 },
INSN3(ALU, END, TO_LE) = { "tole", dt_dis_op2 },
/* 32-bit ALU ops, op(dst, imm) */
INSN3(ALU, END, TO_BE) = { "tobe", dt_dis_op2imm },
INSN3(ALU, END, TO_LE) = { "tole", dt_dis_op2imm },
INSN3(ALU, ADD, K) = { "add", dt_dis_op2imm },
INSN3(ALU, SUB, K) = { "sub", dt_dis_op2imm },
INSN3(ALU, AND, K) = { "and", dt_dis_op2imm },
Expand Down
3 changes: 3 additions & 0 deletions test/unittest/disasm/tst.ann-endian.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dc X 0 0000 00000010 tobe %rX, 16
dc X 0 0000 00000020 tobe %rX, 32
dc X 0 0000 00000040 tobe %rX, 64
26 changes: 26 additions & 0 deletions test/unittest/disasm/tst.ann-endian.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
#
# Oracle Linux DTrace.
# Copyright (c) 2023, 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

$dtrace $dt_flags -Sen '
sdt:task::task_rename
{
htons(1234);
htonl(1234);
htonll(1234);
}
' 2>&1 | \
awk '/ tobe / {
sub(/^[^:]+: /, "");
sub(/^dc [0-9] /, "dc X ");
sub(/%r[0-9],/, "%rX,");
print;
}'

exit $?

0 comments on commit 79719f6

Please sign in to comment.