summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorahl <none@none>2006-09-19 16:29:20 -0700
committerahl <none@none>2006-09-19 16:29:20 -0700
commit2b6e762c557496a41438c0b105d604f60c593682 (patch)
treed2b6b9529da4f0bc18f1bf902a2cd4e4cf23ce11 /usr/src
parentc6939658adb0a356a77bc28f7df252ceb4a8f6cc (diff)
downloadillumos-gate-2b6e762c557496a41438c0b105d604f60c593682.tar.gz
6282214 Byte Ordering Functions in libdtrace
6353438 syscall arguments past the 5th are incorrect 6432394 some sort of #define to denote the availability of USDT 6435862 dtrace -G can generate malformed string tables 6443592 dtrace(1M) leaves a breakpoint in rtld_db_dlactivity on error 6455174 assertion failed: new_pc != 0, file: ../../intel/dtrace/fasttrap_isa.c, line: 1606 6456626 dtrace -G should be able to 'guess' output format 6461522 Availability of dummy-macros for USDT probes in non-DTrace-supported environments 6462995 the syscall provider truncates return values on 32-bit x86 kernels 6465195 assertion failed: -1 <= rmindex && rmindex < tp->ftt_size 6472119 fasttrap should optimize the nop case on x86 6472121 dtest.pl should use the right compilers
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/dtrace/Makefile.com10
-rw-r--r--usr/src/cmd/dtrace/dtrace.c71
-rw-r--r--usr/src/cmd/dtrace/test/cmd/scripts/dtest.pl4
-rw-r--r--usr/src/cmd/dtrace/test/pkg/SUNWdtrt/prototype_com11
-rw-r--r--usr/src/cmd/dtrace/test/pkg/SUNWdtrt/prototype_i3864
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/aggs/tst.subr.d6
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/funcs/tst.hton.d97
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/safety/tst.hton.d78
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/syscall/tst.args.c40
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/syscall/tst.args.d46
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/usdt/tst.badguess.ksh78
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/usdt/tst.guess32.ksh90
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/usdt/tst.guess64.ksh94
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/usdt/tst.include.ksh61
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/usdt/tst.nodtrace.ksh84
-rw-r--r--usr/src/cmd/dtrace/test/tst/i386/pid/tst.badinstr.d40
-rw-r--r--usr/src/cmd/dtrace/test/tst/i386/pid/tst.badinstr.s38
-rw-r--r--usr/src/lib/libdtrace/common/dt_link.c121
-rw-r--r--usr/src/lib/libdtrace/common/dt_open.c18
-rw-r--r--usr/src/lib/libdtrace/common/dt_program.c65
-rw-r--r--usr/src/lib/libdtrace/common/dt_strtab.c30
-rw-r--r--usr/src/lib/libdtrace/common/dt_strtab.h9
-rw-r--r--usr/src/uts/common/dtrace/dtrace.c43
-rw-r--r--usr/src/uts/common/dtrace/systrace.c2
-rw-r--r--usr/src/uts/common/os/sysent.c14
-rw-r--r--usr/src/uts/common/sys/dtrace.h10
-rw-r--r--usr/src/uts/common/sys/feature_tests.h14
-rw-r--r--usr/src/uts/common/sys/systrace.h12
-rw-r--r--usr/src/uts/intel/dtrace/fasttrap_isa.c32
-rw-r--r--usr/src/uts/intel/sys/fasttrap_isa.h1
30 files changed, 1102 insertions, 121 deletions
diff --git a/usr/src/cmd/dtrace/Makefile.com b/usr/src/cmd/dtrace/Makefile.com
index 7c275fee27..86cac039cc 100644
--- a/usr/src/cmd/dtrace/Makefile.com
+++ b/usr/src/cmd/dtrace/Makefile.com
@@ -2,9 +2,8 @@
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
@@ -19,8 +18,9 @@
#
# CDDL HEADER END
#
+
#
-# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
@@ -34,7 +34,7 @@ include ../../Makefile.cmd
CFLAGS += $(CCVERBOSE)
CFLAGS64 += $(CCVERBOSE)
-LDLIBS += -ldtrace -lproc -lctf
+LDLIBS += -ldtrace -lproc -lctf -lelf
FILEMODE = 0555
GROUP = bin
diff --git a/usr/src/cmd/dtrace/dtrace.c b/usr/src/cmd/dtrace/dtrace.c
index c725e79346..81a6953b63 100644
--- a/usr/src/cmd/dtrace/dtrace.c
+++ b/usr/src/cmd/dtrace/dtrace.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -214,6 +213,12 @@ dfatal(const char *fmt, ...)
dtrace_errmsg(g_dtp, dtrace_errno(g_dtp)));
}
+ /*
+ * Close the DTrace handle to ensure that any controlled processes are
+ * correctly restored and continued.
+ */
+ dtrace_close(g_dtp);
+
exit(E_ERROR);
}
@@ -640,7 +645,7 @@ link_prog(dtrace_cmd_t *dcp)
}
if (dtrace_program_link(g_dtp, dcp->dc_prog, DTRACE_D_PROBES,
- dcp->dc_ofile, g_objc - 1, g_objv + 1) != 0)
+ dcp->dc_ofile, g_objc, g_objv) != 0)
dfatal("failed to link %s %s", dcp->dc_desc, dcp->dc_name);
}
@@ -1269,6 +1274,56 @@ main(int argc, char *argv[])
return (printf("%s: %s\n", g_pname, _dtrace_version) <= 0);
/*
+ * If we're in linker mode and the data model hasn't been specified,
+ * we try to guess the appropriate setting by examining the object
+ * files. We ignore certain errors since we'll catch them later when
+ * we actually process the object files.
+ */
+ if (g_mode == DMODE_LINK &&
+ (g_oflags & (DTRACE_O_ILP32 | DTRACE_O_LP64)) == 0 &&
+ elf_version(EV_CURRENT) != EV_NONE) {
+ int fd;
+ Elf *elf;
+ GElf_Ehdr ehdr;
+
+ for (i = 1; i < g_argc; i++) {
+ if ((fd = open64(g_argv[i], O_RDONLY)) == -1)
+ break;
+
+ if ((elf = elf_begin(fd, ELF_C_READ, NULL)) == NULL) {
+ (void) close(fd);
+ break;
+ }
+
+ if (elf_kind(elf) != ELF_K_ELF ||
+ gelf_getehdr(elf, &ehdr) == NULL) {
+ (void) close(fd);
+ (void) elf_end(elf);
+ break;
+ }
+
+ (void) close(fd);
+ (void) elf_end(elf);
+
+ if (ehdr.e_ident[EI_CLASS] == ELFCLASS64) {
+ if (g_oflags & DTRACE_O_ILP32) {
+ fatal("can't mix 32-bit and 64-bit "
+ "object files\n");
+ }
+ g_oflags |= DTRACE_O_LP64;
+ } else if (ehdr.e_ident[EI_CLASS] == ELFCLASS32) {
+ if (g_oflags & DTRACE_O_LP64) {
+ fatal("can't mix 32-bit and 64-bit "
+ "object files\n");
+ }
+ g_oflags |= DTRACE_O_ILP32;
+ } else {
+ break;
+ }
+ }
+ }
+
+ /*
* Open libdtrace. If we are not actually going to be enabling any
* instrumentation attempt to reopen libdtrace using DTRACE_O_NODEV.
*/
@@ -1295,8 +1350,12 @@ main(int argc, char *argv[])
(void) dtrace_setopt(g_dtp, "linkmode", "dynamic");
(void) dtrace_setopt(g_dtp, "unodefs", NULL);
- g_objc = g_argc;
- g_objv = g_argv;
+ /*
+ * Use the remaining arguments as the list of object files
+ * when in linker mode.
+ */
+ g_objc = g_argc - 1;
+ g_objv = g_argv + 1;
/*
* We still use g_argv[0], the name of the executable.
diff --git a/usr/src/cmd/dtrace/test/cmd/scripts/dtest.pl b/usr/src/cmd/dtrace/test/cmd/scripts/dtest.pl
index bb5fbffb41..c1d215cfb6 100644
--- a/usr/src/cmd/dtrace/test/cmd/scripts/dtest.pl
+++ b/usr/src/cmd/dtrace/test/cmd/scripts/dtest.pl
@@ -24,7 +24,7 @@
# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-#ident "%Z%%M% %I% %E% SMI"
+# ident "%Z%%M% %I% %E% SMI"
require 5.6.1;
@@ -213,7 +213,7 @@ if ($opt_g) {
# Ensure that $PATH contains a cc(1) so that we can execute the
# test programs that require compilation of C code.
#
-$ENV{'PATH'} = $ENV{'PATH'} . ':/ws/on10-tools/SUNWspro/SOS8/bin';
+$ENV{'PATH'} = $ENV{'PATH'} . ':/ws/onnv-tools/SUNWspro/SS11/bin';
if ($opt_b) {
logmsg("badioctl'ing ... ");
diff --git a/usr/src/cmd/dtrace/test/pkg/SUNWdtrt/prototype_com b/usr/src/cmd/dtrace/test/pkg/SUNWdtrt/prototype_com
index a320f3b579..f1d9821a13 100644
--- a/usr/src/cmd/dtrace/test/pkg/SUNWdtrt/prototype_com
+++ b/usr/src/cmd/dtrace/test/pkg/SUNWdtrt/prototype_com
@@ -23,7 +23,7 @@
# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-#ident "%Z%%M% %I% %E% SMI"
+# ident "%Z%%M% %I% %E% SMI"
#
i pkginfo
i copyright
@@ -513,6 +513,7 @@ f none opt/SUNWdtrt/tst/common/funcs/tst.default.d 0444 root bin
f none opt/SUNWdtrt/tst/common/funcs/tst.freopen.ksh 0444 root bin
f none opt/SUNWdtrt/tst/common/funcs/tst.ftruncate.ksh 0444 root bin
f none opt/SUNWdtrt/tst/common/funcs/tst.ftruncate.ksh.out 0444 root bin
+f none opt/SUNWdtrt/tst/common/funcs/tst.hton.d 0444 root bin
f none opt/SUNWdtrt/tst/common/funcs/tst.index.d 0444 root bin
f none opt/SUNWdtrt/tst/common/funcs/tst.index.d.out 0444 root bin
f none opt/SUNWdtrt/tst/common/funcs/tst.lltostr.d 0444 root bin
@@ -948,6 +949,7 @@ f none opt/SUNWdtrt/tst/common/safety/tst.cleanpath.d 0444 root bin
f none opt/SUNWdtrt/tst/common/safety/tst.copyin.d 0444 root bin
f none opt/SUNWdtrt/tst/common/safety/tst.ddi_pathname.d 0444 root bin
f none opt/SUNWdtrt/tst/common/safety/tst.dirname.d 0444 root bin
+f none opt/SUNWdtrt/tst/common/safety/tst.hton.d 0444 root bin
f none opt/SUNWdtrt/tst/common/safety/tst.errno.d 0444 root bin
f none opt/SUNWdtrt/tst/common/safety/tst.gid.d 0444 root bin
f none opt/SUNWdtrt/tst/common/safety/tst.index.d 0444 root bin
@@ -1140,6 +1142,8 @@ f none opt/SUNWdtrt/tst/common/struct/tst.clauselocal.d 0444 root bin
f none opt/SUNWdtrt/tst/common/struct/tst.clauselocal.d.out 0444 root bin
d none opt/SUNWdtrt/tst/common/syscall 0755 root bin
f none opt/SUNWdtrt/tst/common/syscall/tst.openret.ksh 0444 root bin
+f none opt/SUNWdtrt/tst/common/syscall/tst.args.d 0444 root bin
+f none opt/SUNWdtrt/tst/common/syscall/tst.args.exe 0555 root bin
d none opt/SUNWdtrt/tst/common/tick-n 0755 root bin
f none opt/SUNWdtrt/tst/common/tick-n/err.D_PDESC_ZERO.tick.d 0444 root bin
f none opt/SUNWdtrt/tst/common/tick-n/err.D_PDESC_ZEROonens.d 0444 root bin
@@ -1287,6 +1291,7 @@ f none opt/SUNWdtrt/tst/common/usdt/tst.argmap.d 0444 root bin
f none opt/SUNWdtrt/tst/common/usdt/tst.argmap.exe 0555 root bin
f none opt/SUNWdtrt/tst/common/usdt/tst.args.d 0444 root bin
f none opt/SUNWdtrt/tst/common/usdt/tst.args.exe 0555 root bin
+f none opt/SUNWdtrt/tst/common/usdt/tst.badguess.ksh 0555 root bin
f none opt/SUNWdtrt/tst/common/usdt/tst.enabled.ksh 0444 root bin
f none opt/SUNWdtrt/tst/common/usdt/tst.enabled.ksh.out 0444 root bin
f none opt/SUNWdtrt/tst/common/usdt/tst.entryreturn.ksh 0444 root bin
@@ -1297,11 +1302,15 @@ f none opt/SUNWdtrt/tst/common/usdt/tst.dlclose2.ksh 0444 root bin
f none opt/SUNWdtrt/tst/common/usdt/tst.dlclose2.ksh.out 0444 root bin
f none opt/SUNWdtrt/tst/common/usdt/tst.fork.ksh 0444 root bin
f none opt/SUNWdtrt/tst/common/usdt/tst.fork.ksh.out 0444 root bin
+f none opt/SUNWdtrt/tst/common/usdt/tst.guess32.ksh 0555 root bin
+f none opt/SUNWdtrt/tst/common/usdt/tst.guess64.ksh 0555 root bin
f none opt/SUNWdtrt/tst/common/usdt/tst.header.ksh 0555 root bin
+f none opt/SUNWdtrt/tst/common/usdt/tst.include.ksh 0555 root bin
f none opt/SUNWdtrt/tst/common/usdt/tst.linkpriv.ksh 0555 root bin
f none opt/SUNWdtrt/tst/common/usdt/tst.linkunpriv.ksh 0555 root bin
f none opt/SUNWdtrt/tst/common/usdt/tst.multiple.ksh 0444 root bin
f none opt/SUNWdtrt/tst/common/usdt/tst.multiple.ksh.out 0444 root bin
+f none opt/SUNWdtrt/tst/common/usdt/tst.nodtrace.ksh 0444 root bin
f none opt/SUNWdtrt/tst/common/usdt/tst.onlyenabled.ksh 0444 root bin
f none opt/SUNWdtrt/tst/common/usdt/tst.reeval.ksh 0444 root bin
f none opt/SUNWdtrt/tst/common/usdt/tst.static.ksh 0444 root bin
diff --git a/usr/src/cmd/dtrace/test/pkg/SUNWdtrt/prototype_i386 b/usr/src/cmd/dtrace/test/pkg/SUNWdtrt/prototype_i386
index db0ce3593f..bda4ac9fa0 100644
--- a/usr/src/cmd/dtrace/test/pkg/SUNWdtrt/prototype_i386
+++ b/usr/src/cmd/dtrace/test/pkg/SUNWdtrt/prototype_i386
@@ -23,7 +23,7 @@
# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-#ident "%Z%%M% %I% %E% SMI"
+# ident "%Z%%M% %I% %E% SMI"
!include prototype_com
@@ -40,6 +40,8 @@ f none opt/SUNWdtrt/tst/i386/funcs/tst.badcopyinstr.d 0444 root bin
f none opt/SUNWdtrt/tst/i386/funcs/tst.badcopyout.d 0444 root bin
f none opt/SUNWdtrt/tst/i386/funcs/tst.badcopyoutstr.d 0444 root bin
d none opt/SUNWdtrt/tst/i386/pid 0755 root bin
+f none opt/SUNWdtrt/tst/i386/pid/tst.badinstr.d 0444 root bin
+f none opt/SUNWdtrt/tst/i386/pid/tst.badinstr.exe 0555 root bin
f none opt/SUNWdtrt/tst/i386/pid/tst.branch.d 0444 root bin
f none opt/SUNWdtrt/tst/i386/pid/tst.branch.exe 0555 root bin
f none opt/SUNWdtrt/tst/i386/pid/tst.embedded.d 0444 root bin
diff --git a/usr/src/cmd/dtrace/test/tst/common/aggs/tst.subr.d b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.subr.d
index d38514c559..c7a809b39e 100644
--- a/usr/src/cmd/dtrace/test/tst/common/aggs/tst.subr.d
+++ b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.subr.d
@@ -89,6 +89,12 @@ STRFUNC(strtok("The SystemTap, The.", "T"))
STRFUNC(substr("The SystemTap, The.", 0))
INTFUNC(index("The SystemTap, The.", "The"))
INTFUNC(rindex("The SystemTap, The.", "The"))
+INTFUNC(htons(0x1234))
+INTFUNC(htonl(0x12345678))
+INTFUNC(htonll(0x1234567890abcdefL))
+INTFUNC(ntohs(0x1234))
+INTFUNC(ntohl(0x12345678))
+INTFUNC(ntohll(0x1234567890abcdefL))
BEGIN
/subr == DIF_SUBR_MAX + 1/
diff --git a/usr/src/cmd/dtrace/test/tst/common/funcs/tst.hton.d b/usr/src/cmd/dtrace/test/tst/common/funcs/tst.hton.d
new file mode 100644
index 0000000000..f01188386c
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/funcs/tst.hton.d
@@ -0,0 +1,97 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Test network byte-ordering routines.
+ */
+
+#include <sys/isa_defs.h>
+
+BEGIN
+{
+ before[0] = 0x1122LL;
+ before[1] = 0x11223344LL;
+ before[2] = 0x1122334455667788LL;
+
+#ifdef _LITTLE_ENDIAN
+ after[0] = 0x2211LL;
+ after[1] = 0x44332211LL;
+ after[2] = 0x8877665544332211LL;
+#else
+ after[0] = 0x1122LL;
+ after[1] = 0x11223344LL;
+ after[2] = 0x1122334455667788LL;
+#endif
+}
+
+BEGIN
+/after[0] != htons(before[0])/
+{
+ printf("%x rather than %x", htons(before[0]), after[0]);
+ exit(1);
+}
+
+BEGIN
+/after[0] != ntohs(before[0])/
+{
+ printf("%x rather than %x", ntohs(before[0]), after[0]);
+ exit(1);
+}
+
+BEGIN
+/after[1] != htonl(before[1])/
+{
+ printf("%x rather than %x", htonl(before[1]), after[1]);
+ exit(1);
+}
+
+BEGIN
+/after[1] != ntohl(before[1])/
+{
+ printf("%x rather than %x", ntohl(before[1]), after[1]);
+ exit(1);
+}
+
+BEGIN
+/after[2] != htonll(before[2])/
+{
+ printf("%x rather than %x", htonll(before[2]), after[2]);
+ exit(1);
+}
+
+BEGIN
+/after[2] != ntohll(before[2])/
+{
+ printf("%x rather than %x", ntohll(before[2]), after[2]);
+ exit(1);
+}
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/usr/src/cmd/dtrace/test/tst/common/safety/tst.hton.d b/usr/src/cmd/dtrace/test/tst/common/safety/tst.hton.d
new file mode 100644
index 0000000000..d573bfd1e9
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/safety/tst.hton.d
@@ -0,0 +1,78 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma D option bufsize=1000
+#pragma D option bufpolicy=ring
+#pragma D option statusrate=10ms
+
+fbt:::
+{
+ on = (timestamp / 1000000000) & 1;
+}
+
+fbt:::
+/on/
+{
+ trace(htons(0x1122));
+}
+
+fbt:::
+/on/
+{
+ trace(htonl(0x11223344));
+}
+
+fbt:::
+/on/
+{
+ trace(htonll(0x1122334455667788));
+}
+
+fbt:::
+/on/
+{
+ trace(ntohs(0x1122));
+}
+
+fbt:::
+/on/
+{
+ trace(ntohl(0x11223344));
+}
+
+fbt:::
+/on/
+{
+ trace(ntohll(0x1122334455667788));
+}
+
+tick-1sec
+/n++ == 10/
+{
+ exit(0);
+}
diff --git a/usr/src/cmd/dtrace/test/tst/common/syscall/tst.args.c b/usr/src/cmd/dtrace/test/tst/common/syscall/tst.args.c
new file mode 100644
index 0000000000..96d6f3d490
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/syscall/tst.args.c
@@ -0,0 +1,40 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/mman.h>
+
+/*ARGSUSED*/
+int
+main(int argc, char **argv)
+{
+ for (;;) {
+ (void) mmap(NULL, 1, 2, 3, -1, 0x12345678);
+ }
+
+ return (0);
+}
diff --git a/usr/src/cmd/dtrace/test/tst/common/syscall/tst.args.d b/usr/src/cmd/dtrace/test/tst/common/syscall/tst.args.d
new file mode 100644
index 0000000000..fe38f902e6
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/syscall/tst.args.d
@@ -0,0 +1,46 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Make sure we're correctly reporting arguments to syscall probes.
+ */
+
+#pragma D option quiet
+
+syscall::mmap*:entry
+/pid == $1 && arg0 == 0 && arg1 == 1 && arg2 == 2 && arg3 == 3 &&
+ (int)arg4 == -1 && arg5 == 0x12345678/
+{
+ exit(0);
+}
+
+tick-1s
+/i++ == 3/
+{
+ exit(0);
+}
diff --git a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.badguess.ksh b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.badguess.ksh
new file mode 100644
index 0000000000..fe0f6fbd89
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.badguess.ksh
@@ -0,0 +1,78 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > prov.d <<EOF
+provider test_prov {
+ probe go();
+};
+EOF
+
+dtrace -h -s prov.d
+if [ $? -ne 0 ]; then
+ print -u2 "failed to generate header file"
+ exit 1
+fi
+
+cat > test.c <<EOF
+#include <sys/types.h>
+#include "prov.h"
+
+int
+main(int argc, char **argv)
+{
+ if (TEST_PROV_GO_ENABLED()) {
+ TEST_PROV_GO();
+ }
+}
+EOF
+
+cc -xarch=generic64 -c -o test64.o test.c
+if [ $? -ne 0 ]; then
+ print -u2 "failed to compile test.c 64-bit"
+ exit 1
+fi
+cc -xarch=generic -c -o test32.o test.c
+if [ $? -ne 0 ]; then
+ print -u2 "failed to compile test.c 32-bit"
+ exit 1
+fi
+
+dtrace -G -s prov.d test32.o test64.o
+if [ $? -eq 0 ]; then
+ print -u2 "DOF generation failed to generate a warning"
+ exit 1
+fi
+
+cd /
+/usr/bin/rm -rf $DIR
+
+exit 0
diff --git a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.guess32.ksh b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.guess32.ksh
new file mode 100644
index 0000000000..47b98075da
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.guess32.ksh
@@ -0,0 +1,90 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > prov.d <<EOF
+provider test_prov {
+ probe go();
+};
+EOF
+
+dtrace -h -s prov.d
+if [ $? -ne 0 ]; then
+ print -u2 "failed to generate header file"
+ exit 1
+fi
+
+cat > test.c <<EOF
+#include <sys/types.h>
+#include "prov.h"
+
+int
+main(int argc, char **argv)
+{
+ if (TEST_PROV_GO_ENABLED()) {
+ TEST_PROV_GO();
+ }
+}
+EOF
+
+cc -xarch=generic -c test.c
+if [ $? -ne 0 ]; then
+ print -u2 "failed to compile test.c"
+ exit 1
+fi
+dtrace -G -s prov.d test.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to create DOF"
+ exit 1
+fi
+cc -xarch=generic -o test test.o prov.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to link final executable"
+ exit 1
+fi
+
+script()
+{
+ dtrace -c ./test -qs /dev/stdin <<EOF
+ test_prov\$target:::
+ {
+ printf("%s:%s:%s\n", probemod, probefunc, probename);
+ }
+EOF
+}
+
+script
+status=$?
+
+cd /
+/usr/bin/rm -rf $DIR
+
+exit $status
diff --git a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.guess64.ksh b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.guess64.ksh
new file mode 100644
index 0000000000..72764caa5f
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.guess64.ksh
@@ -0,0 +1,94 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > prov.d <<EOF
+provider test_prov {
+ probe go();
+};
+EOF
+
+dtrace -h -s prov.d
+if [ $? -ne 0 ]; then
+ print -u2 "failed to generate header file"
+ exit 1
+fi
+
+cat > test.c <<EOF
+#include <sys/types.h>
+#include "prov.h"
+
+int
+main(int argc, char **argv)
+{
+ if (TEST_PROV_GO_ENABLED()) {
+ TEST_PROV_GO();
+ }
+}
+EOF
+
+cc -xarch=generic64 -c test.c
+if [ $? -ne 0 ]; then
+ print -u2 "failed to compile test.c"
+ exit 1
+fi
+dtrace -G -s prov.d test.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to create DOF"
+ exit 1
+fi
+cc -xarch=generic64 -o test test.o prov.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to link final executable"
+ exit 1
+fi
+
+script()
+{
+ dtrace -c ./test -qs /dev/stdin <<EOF
+ test_prov\$target:::
+ {
+ printf("%s:%s:%s\n", probemod, probefunc, probename);
+ }
+EOF
+}
+
+if [ `isainfo -b` -ne '64']; then
+ script
+ status=$?
+else
+ status=0
+fi
+
+cd /
+/usr/bin/rm -rf $DIR
+
+exit $status
diff --git a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.include.ksh b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.include.ksh
new file mode 100644
index 0000000000..5683f47d42
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.include.ksh
@@ -0,0 +1,61 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+# Make sure <unistd.h> defines _DTRACE_VERSION
+
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+cat > test.c <<EOF
+#include <unistd.h>
+
+int
+main(int argc, char **argv)
+{
+#ifdef _DTRACE_VERSION
+ return (0);
+#else
+ return (1);
+#endif
+}
+EOF
+
+cc -xarch=generic -o test test.c
+if [ $? -ne 0 ]; then
+ print -u2 "failed to compile test.c"
+ exit 1
+fi
+
+./test
+status=$?
+
+cd /
+/usr/bin/rm -rf $DIR
+
+exit $status
diff --git a/usr/src/cmd/dtrace/test/tst/common/usdt/tst.nodtrace.ksh b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.nodtrace.ksh
new file mode 100644
index 0000000000..8d2b89481e
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/usdt/tst.nodtrace.ksh
@@ -0,0 +1,84 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+
+# Fake up a scenario where _DTRACE_VERSION is not defined by having our own
+# <unistd.h>. This tests that dtrace -h will produce a header file which can
+# be used on a system where DTrace is not present.
+
+DIR=/var/tmp/dtest.$$
+
+mkdir $DIR
+cd $DIR
+
+touch unistd.h
+
+cat > prov.d <<EOF
+provider test_prov {
+ probe go();
+};
+EOF
+
+dtrace -h -s prov.d
+if [ $? -ne 0 ]; then
+ print -u2 "failed to generate header file"
+ exit 1
+fi
+
+cat > test.c <<EOF
+#include "prov.h"
+
+int
+main(int argc, char **argv)
+{
+ TEST_PROV_GO();
+
+ if (TEST_PROV_GO_ENABLED()) {
+ TEST_PROV_GO();
+ }
+
+ return (0);
+}
+EOF
+
+cc -I. -xarch=generic -c test.c
+if [ $? -ne 0 ]; then
+ print -u2 "failed to compile test.c"
+ exit 1
+fi
+cc -xarch=generic -o test test.o
+if [ $? -ne 0 ]; then
+ print -u2 "failed to link final executable"
+ exit 1
+fi
+
+./test
+status=$?
+
+cd /
+/usr/bin/rm -rf $DIR
+
+exit $status
diff --git a/usr/src/cmd/dtrace/test/tst/i386/pid/tst.badinstr.d b/usr/src/cmd/dtrace/test/tst/i386/pid/tst.badinstr.d
new file mode 100644
index 0000000000..50753b8a18
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/i386/pid/tst.badinstr.d
@@ -0,0 +1,40 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+/*
+ * ASSERTION: Make sure that DTrace doesn't explode on an invalid instruction.
+ */
+
+pid$1:a.out:badfunc:entry
+{
+}
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/usr/src/cmd/dtrace/test/tst/i386/pid/tst.badinstr.s b/usr/src/cmd/dtrace/test/tst/i386/pid/tst.badinstr.s
new file mode 100644
index 0000000000..9c0a734518
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/i386/pid/tst.badinstr.s
@@ -0,0 +1,38 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/asm_linkage.h>
+
+ ENTRY(badfunc)
+ .byte 0xff
+ .byte 0xff
+ SET_SIZE(badfunc)
+
+ ENTRY(main)
+1: jmp 1b
+ SET_SIZE(main)
diff --git a/usr/src/lib/libdtrace/common/dt_link.c b/usr/src/lib/libdtrace/common/dt_link.c
index 60fe4b5f36..4092b19a46 100644
--- a/usr/src/lib/libdtrace/common/dt_link.c
+++ b/usr/src/lib/libdtrace/common/dt_link.c
@@ -86,23 +86,23 @@ static const char DOFSTR[] = "__SUNW_dof";
static const char DOFLAZYSTR[] = "___SUNW_dof";
typedef struct dt_link_pair {
- struct dt_link_pair *dlp_next; /* next pair in linked list */
- void *dlp_str; /* buffer for string table */
- void *dlp_sym; /* buffer for symbol table */
+ struct dt_link_pair *dlp_next; /* next pair in linked list */
+ void *dlp_str; /* buffer for string table */
+ void *dlp_sym; /* buffer for symbol table */
} dt_link_pair_t;
typedef struct dof_elf32 {
- uint32_t de_nrel; /* relocation count */
+ uint32_t de_nrel; /* relocation count */
#ifdef __sparc
- Elf32_Rela *de_rel; /* array of relocations for sparc */
+ Elf32_Rela *de_rel; /* array of relocations for sparc */
#else
- Elf32_Rel *de_rel; /* array of relocations for x86 */
+ Elf32_Rel *de_rel; /* array of relocations for x86 */
#endif
- uint32_t de_nsym; /* symbol count */
- Elf32_Sym *de_sym; /* array of symbols */
- uint32_t de_strlen; /* size of of string table */
- char *de_strtab; /* string table */
- uint32_t de_global; /* index of the first global symbol */
+ uint32_t de_nsym; /* symbol count */
+ Elf32_Sym *de_sym; /* array of symbols */
+ uint32_t de_strlen; /* size of of string table */
+ char *de_strtab; /* string table */
+ uint32_t de_global; /* index of the first global symbol */
} dof_elf32_t;
static int
@@ -994,9 +994,10 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
dt_provider_t *pvp;
dt_probe_t *prp;
uint32_t off, eclass, emachine1, emachine2;
- size_t count_sym, count_str, symsize;
+ size_t symsize, nsym, isym, istr, len;
key_t objkey;
dt_link_pair_t *pair, *bufs = NULL;
+ dt_strtab_t *strtab;
if ((fd = open64(obj, O_RDWR)) == -1) {
return (dt_link_error(dtp, elf, fd, bufs,
@@ -1130,11 +1131,12 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
* $dtrace<key>.<function>
*
* We take a first pass through all the relocations to
- * calculate an upper bound on the number of symbols we may
- * need to add as well as the size of the strings we may need
- * to add to the string table for those symbols.
+ * populate our string table and count the number of extra
+ * symbols we'll require.
*/
- count_sym = count_str = 0;
+ strtab = dt_strtab_create(1);
+ nsym = 0;
+
for (i = 0; i < shdr_rel.sh_size / shdr_rel.sh_entsize; i++) {
if (shdr_rel.sh_type == SHT_RELA) {
@@ -1150,8 +1152,10 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
}
if (gelf_getsym(data_sym, GELF_R_SYM(rela.r_info),
- &rsym) == NULL)
+ &rsym) == NULL) {
+ dt_strtab_destroy(strtab);
goto err;
+ }
s = (char *)data_str->d_buf + rsym.st_name;
@@ -1159,14 +1163,18 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
continue;
if (dt_symtab_lookup(data_sym, rela.r_offset,
- shdr_rel.sh_info, &fsym) != 0)
+ shdr_rel.sh_info, &fsym) != 0) {
+ dt_strtab_destroy(strtab);
goto err;
+ }
if (GELF_ST_BIND(fsym.st_info) != STB_LOCAL)
continue;
- if (fsym.st_name > data_str->d_size)
+ if (fsym.st_name > data_str->d_size) {
+ dt_strtab_destroy(strtab);
goto err;
+ }
s = (char *)data_str->d_buf + fsym.st_name;
@@ -1175,13 +1183,26 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
* driven off the rails or the object file is corrupt.
*/
if (GELF_ST_TYPE(fsym.st_info) != STT_FUNC) {
+ dt_strtab_destroy(strtab);
return (dt_link_error(dtp, elf, fd, bufs,
"expected %s to be of type function", s));
}
- count_sym++;
- count_str += 1 + snprintf(NULL, 0, dt_symfmt,
- dt_symprefix, objkey, s);
+ len = snprintf(NULL, 0, dt_symfmt, dt_symprefix,
+ objkey, s) + 1;
+ if ((p = dt_alloc(dtp, len)) == NULL) {
+ dt_strtab_destroy(strtab);
+ goto err;
+ }
+ (void) snprintf(p, len, dt_symfmt, dt_symprefix,
+ objkey, s);
+
+ if (dt_strtab_index(strtab, p) == -1) {
+ nsym++;
+ (void) dt_strtab_insert(strtab, p);
+ }
+
+ dt_free(dtp, p);
}
/*
@@ -1192,20 +1213,29 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
* are still responsible for freeing them once we're done with
* the elf handle.
*/
- if (count_sym > 0) {
- assert(count_str > 0);
+ if (nsym > 0) {
+ /*
+ * The first byte of the string table is reserved for
+ * the \0 entry.
+ */
+ len = dt_strtab_size(strtab) - 1;
+
+ assert(len > 0);
+ assert(dt_strtab_index(strtab, "") == 0);
+
+ dt_strtab_destroy(strtab);
if ((pair = dt_alloc(dtp, sizeof (*pair))) == NULL)
goto err;
if ((pair->dlp_str = dt_alloc(dtp, data_str->d_size +
- count_str)) == NULL) {
+ len)) == NULL) {
dt_free(dtp, pair);
goto err;
}
if ((pair->dlp_sym = dt_alloc(dtp, data_sym->d_size +
- count_sym * symsize)) == NULL) {
+ nsym * symsize)) == NULL) {
dt_free(dtp, pair->dlp_str);
dt_free(dtp, pair);
goto err;
@@ -1214,25 +1244,31 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
pair->dlp_next = bufs;
bufs = pair;
+ istr = data_str->d_size;
+ isym = data_sym->d_size / symsize;
+
bcopy(data_str->d_buf, pair->dlp_str, data_str->d_size);
data_str->d_buf = pair->dlp_str;
- data_str->d_size += count_str;
+ data_str->d_size += len;
(void) elf_flagdata(data_str, ELF_C_SET, ELF_F_DIRTY);
- shdr_str.sh_size += count_str;
+ shdr_str.sh_size += len;
(void) gelf_update_shdr(scn_str, &shdr_str);
bcopy(data_sym->d_buf, pair->dlp_sym, data_sym->d_size);
data_sym->d_buf = pair->dlp_sym;
- data_sym->d_size += count_sym * symsize;
+ data_sym->d_size += nsym * symsize;
(void) elf_flagdata(data_sym, ELF_C_SET, ELF_F_DIRTY);
- shdr_sym.sh_size += count_sym * symsize;
+ shdr_sym.sh_size += nsym * symsize;
(void) gelf_update_shdr(scn_sym, &shdr_sym);
- }
- count_str = shdr_str.sh_size - count_str;
- count_sym = data_sym->d_size / symsize - count_sym;
+ nsym += isym;
+ } else {
+ istr = 0;
+ isym = 0;
+ dt_strtab_destroy(strtab);
+ }
/*
* Now that the tables have been allocated, perform the
@@ -1315,17 +1351,17 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
if (GELF_ST_BIND(fsym.st_info) == STB_LOCAL) {
dsym = fsym;
- dsym.st_name = count_str;
+ dsym.st_name = istr;
dsym.st_info = GELF_ST_INFO(STB_GLOBAL,
STT_FUNC);
dsym.st_other = ELF64_ST_VISIBILITY(STV_HIDDEN);
- (void) gelf_update_sym(data_sym, count_sym,
- &dsym);
+ (void) gelf_update_sym(data_sym, isym, &dsym);
- r = (char *)data_str->d_buf + count_str;
- count_str += 1 + sprintf(r, dt_symfmt,
+ r = (char *)data_str->d_buf + istr;
+ istr += 1 + sprintf(r, dt_symfmt,
dt_symprefix, objkey, s);
- count_sym++;
+ isym++;
+ assert(isym <= nsym);
} else if (strncmp(s, dt_symprefix,
strlen(dt_symprefix)) == 0) {
@@ -1373,13 +1409,6 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
(void) gelf_update_sym(data_sym, ndx, &rsym);
}
}
-
- /*
- * The full buffer may not have been used so shrink them here
- * to match the sizes actually used.
- */
- data_str->d_size = count_str;
- data_sym->d_size = count_sym * symsize;
}
if (mod && elf_update(elf, ELF_C_WRITE) == -1)
diff --git a/usr/src/lib/libdtrace/common/dt_open.c b/usr/src/lib/libdtrace/common/dt_open.c
index e2358ce89c..5a9321b178 100644
--- a/usr/src/lib/libdtrace/common/dt_open.c
+++ b/usr/src/lib/libdtrace/common/dt_open.c
@@ -98,8 +98,9 @@
#define DT_VERS_1_2 DT_VERSION_NUMBER(1, 2, 0)
#define DT_VERS_1_2_1 DT_VERSION_NUMBER(1, 2, 1)
#define DT_VERS_1_2_2 DT_VERSION_NUMBER(1, 2, 2)
-#define DT_VERS_LATEST DT_VERS_1_2_2
-#define DT_VERS_STRING "Sun D 1.2.2"
+#define DT_VERS_1_3 DT_VERSION_NUMBER(1, 3, 0)
+#define DT_VERS_LATEST DT_VERS_1_3
+#define DT_VERS_STRING "Sun D 1.3"
const dt_version_t _dtrace_versions[] = {
DT_VERS_1_0, /* D API 1.0.0 (PSARC 2001/466) Solaris 10 FCS */
@@ -107,6 +108,7 @@ const dt_version_t _dtrace_versions[] = {
DT_VERS_1_2, /* D API 1.2.0 Solaris 10 Update 1 */
DT_VERS_1_2_1, /* D API 1.2.1 Solaris Express 4/06 */
DT_VERS_1_2_2, /* D API 1.2.2 Solaris Express 6/06 */
+ DT_VERS_1_3, /* D API 1.3 Solaris Express 10/06 */
0
};
@@ -214,6 +216,12 @@ static const dt_ident_t _dtrace_globals[] = {
{ "getminor", DT_IDENT_FUNC, 0, DIF_SUBR_GETMINOR,
DT_ATTR_EVOLCMN, DT_VERS_1_0,
&dt_idops_func, "genunix`minor_t(genunix`dev_t)" },
+{ "htonl", DT_IDENT_FUNC, 0, DIF_SUBR_HTONL, DT_ATTR_EVOLCMN, DT_VERS_1_3,
+ &dt_idops_func, "uint32_t(uint32_t)" },
+{ "htonll", DT_IDENT_FUNC, 0, DIF_SUBR_HTONLL, DT_ATTR_EVOLCMN, DT_VERS_1_3,
+ &dt_idops_func, "uint64_t(uint64_t)" },
+{ "htons", DT_IDENT_FUNC, 0, DIF_SUBR_HTONS, DT_ATTR_EVOLCMN, DT_VERS_1_3,
+ &dt_idops_func, "uint16_t(uint16_t)" },
{ "gid", DT_IDENT_SCALAR, 0, DIF_VAR_GID, DT_ATTR_STABCMN, DT_VERS_1_0,
&dt_idops_type, "gid_t" },
{ "id", DT_IDENT_SCALAR, 0, DIF_VAR_ID, DT_ATTR_STABCMN, DT_VERS_1_0,
@@ -253,6 +261,12 @@ static const dt_ident_t _dtrace_globals[] = {
{ "mutex_type_spin", DT_IDENT_FUNC, 0, DIF_SUBR_MUTEX_TYPE_SPIN,
DT_ATTR_EVOLCMN, DT_VERS_1_0,
&dt_idops_func, "int(genunix`kmutex_t *)" },
+{ "ntohl", DT_IDENT_FUNC, 0, DIF_SUBR_NTOHL, DT_ATTR_EVOLCMN, DT_VERS_1_3,
+ &dt_idops_func, "uint32_t(uint32_t)" },
+{ "ntohll", DT_IDENT_FUNC, 0, DIF_SUBR_NTOHLL, DT_ATTR_EVOLCMN, DT_VERS_1_3,
+ &dt_idops_func, "uint64_t(uint64_t)" },
+{ "ntohs", DT_IDENT_FUNC, 0, DIF_SUBR_NTOHS, DT_ATTR_EVOLCMN, DT_VERS_1_3,
+ &dt_idops_func, "uint16_t(uint16_t)" },
{ "normalize", DT_IDENT_ACTFUNC, 0, DT_ACT_NORMALIZE, DT_ATTR_STABCMN,
DT_VERS_1_0, &dt_idops_func, "void(...)" },
{ "panic", DT_IDENT_ACTFUNC, 0, DT_ACT_PANIC, DT_ATTR_STABCMN, DT_VERS_1_0,
diff --git a/usr/src/lib/libdtrace/common/dt_program.c b/usr/src/lib/libdtrace/common/dt_program.c
index d751c4817b..8497dab01e 100644
--- a/usr/src/lib/libdtrace/common/dt_program.c
+++ b/usr/src/lib/libdtrace/common/dt_program.c
@@ -355,9 +355,9 @@ typedef struct dt_header_info {
FILE *dthi_out; /* output file */
char *dthi_pmname; /* provider macro name */
char *dthi_pfname; /* provider function name */
+ int dthi_empty; /* should we generate empty macros */
} dt_header_info_t;
-
static void
dt_header_fmt_macro(char *buf, const char *str)
{
@@ -472,32 +472,40 @@ dt_header_probe(dt_idhash_t *dhp, dt_ident_t *idp, void *data)
return (dt_set_errno(dtp, errno));
}
- if (fprintf(infop->dthi_out, ") \\\n\t") < 0)
- return (dt_set_errno(dtp, errno));
-
- if (fprintf(infop->dthi_out, "__dtrace_%s___%s(",
- infop->dthi_pfname, fname) < 0)
- return (dt_set_errno(dtp, errno));
-
- for (i = 0; i < prp->pr_nargc; i++) {
- if (fprintf(infop->dthi_out, "arg%d", i) < 0)
+ if (!infop->dthi_empty) {
+ if (fprintf(infop->dthi_out, ") \\\n\t") < 0)
return (dt_set_errno(dtp, errno));
- if (i + 1 != prp->pr_nargc &&
- fprintf(infop->dthi_out, ", ") < 0)
+ if (fprintf(infop->dthi_out, "__dtrace_%s___%s(",
+ infop->dthi_pfname, fname) < 0)
return (dt_set_errno(dtp, errno));
+
+ for (i = 0; i < prp->pr_nargc; i++) {
+ if (fprintf(infop->dthi_out, "arg%d", i) < 0)
+ return (dt_set_errno(dtp, errno));
+
+ if (i + 1 != prp->pr_nargc &&
+ fprintf(infop->dthi_out, ", ") < 0)
+ return (dt_set_errno(dtp, errno));
+ }
}
if (fprintf(infop->dthi_out, ")\n") < 0)
return (dt_set_errno(dtp, errno));
- if (fprintf(infop->dthi_out, "#define\t%s_%s_ENABLED() \\\n",
- infop->dthi_pmname, mname) < 0)
- return (dt_set_errno(dtp, errno));
+ if (!infop->dthi_empty) {
+ if (fprintf(infop->dthi_out, "#define\t%s_%s_ENABLED() \\\n",
+ infop->dthi_pmname, mname) < 0)
+ return (dt_set_errno(dtp, errno));
- if (fprintf(infop->dthi_out, "\t__dtraceenabled_%s___%s()\n",
- infop->dthi_pfname, fname) < 0)
- return (dt_set_errno(dtp, errno));
+ if (fprintf(infop->dthi_out, "\t__dtraceenabled_%s___%s()\n",
+ infop->dthi_pfname, fname) < 0)
+ return (dt_set_errno(dtp, errno));
+ } else {
+ if (fprintf(infop->dthi_out, "#define\t%s_%s_ENABLED() (0)\n",
+ infop->dthi_pmname, mname) < 0)
+ return (dt_set_errno(dtp, errno));
+ }
return (0);
}
@@ -512,12 +520,17 @@ dt_header_provider(dtrace_hdl_t *dtp, dt_provider_t *pvp, FILE *out)
if (pvp->pv_flags & DT_PROVIDER_IMPL)
return (0);
+ /*
+ * Count the instances of the '-' character since we'll need to double
+ * those up.
+ */
p = pvp->pv_desc.dtvd_name;
for (i = 0; (p = strchr(p, '-')) != NULL; i++)
p++;
info.dthi_dtp = dtp;
info.dthi_out = out;
+ info.dthi_empty = 0;
info.dthi_pmname = alloca(strlen(pvp->pv_desc.dtvd_name) + 1);
dt_header_fmt_macro(info.dthi_pmname, pvp->pv_desc.dtvd_name);
@@ -525,6 +538,8 @@ dt_header_provider(dtrace_hdl_t *dtp, dt_provider_t *pvp, FILE *out)
info.dthi_pfname = alloca(strlen(pvp->pv_desc.dtvd_name) + 1 + i);
dt_header_fmt_func(info.dthi_pfname, pvp->pv_desc.dtvd_name);
+ if (fprintf(out, "#if _DTRACE_VERSION\n\n") < 0)
+ return (dt_set_errno(dtp, errno));
if (dt_idhash_iter(pvp->pv_probes, dt_header_probe, &info) != 0)
return (-1); /* dt_errno is set for us */
@@ -533,6 +548,17 @@ dt_header_provider(dtrace_hdl_t *dtp, dt_provider_t *pvp, FILE *out)
if (dt_idhash_iter(pvp->pv_probes, dt_header_decl, &info) != 0)
return (-1); /* dt_errno is set for us */
+ if (fprintf(out, "\n#else\n\n") < 0)
+ return (dt_set_errno(dtp, errno));
+
+ info.dthi_empty = 1;
+
+ if (dt_idhash_iter(pvp->pv_probes, dt_header_probe, &info) != 0)
+ return (-1); /* dt_errno is set for us */
+
+ if (fprintf(out, "\n#endif\n\n") < 0)
+ return (dt_set_errno(dtp, errno));
+
return (0);
}
@@ -553,6 +579,9 @@ dtrace_program_header(dtrace_hdl_t *dtp, FILE *out, const char *fname)
return (dt_set_errno(dtp, errno));
}
+ if (fprintf(out, "#include <unistd.h>\n\n") < 0)
+ return (-1);
+
if (fprintf(out, "#ifdef\t__cplusplus\nextern \"C\" {\n#endif\n\n") < 0)
return (-1);
diff --git a/usr/src/lib/libdtrace/common/dt_strtab.c b/usr/src/lib/libdtrace/common/dt_strtab.c
index 42739eab6e..cf6bc48341 100644
--- a/usr/src/lib/libdtrace/common/dt_strtab.c
+++ b/usr/src/lib/libdtrace/common/dt_strtab.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -19,8 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -204,7 +204,7 @@ err:
}
ssize_t
-dt_strtab_insert(dt_strtab_t *sp, const char *str)
+dt_strtab_index(dt_strtab_t *sp, const char *str)
{
dt_strhash_t *hp;
size_t len;
@@ -215,15 +215,27 @@ dt_strtab_insert(dt_strtab_t *sp, const char *str)
h = dt_strtab_hash(str, &len) % sp->str_hashsz;
- /*
- * If the string is already in our hash table, just return the offset
- * of the existing string element and do not add a duplicate string.
- */
for (hp = sp->str_hash[h]; hp != NULL; hp = hp->str_next) {
if (dt_strtab_compare(sp, hp, str, len + 1) == 0)
return (hp->str_off);
}
+ return (-1);
+}
+
+ssize_t
+dt_strtab_insert(dt_strtab_t *sp, const char *str)
+{
+ dt_strhash_t *hp;
+ size_t len;
+ ssize_t off;
+ ulong_t h;
+
+ if ((off = dt_strtab_index(sp, str)) != -1)
+ return (off);
+
+ h = dt_strtab_hash(str, &len) % sp->str_hashsz;
+
/*
* Create a new hash bucket, initialize it, and insert it at the front
* of the hash chain for the appropriate bucket.
diff --git a/usr/src/lib/libdtrace/common/dt_strtab.h b/usr/src/lib/libdtrace/common/dt_strtab.h
index 1f0b2912c1..551dabbf67 100644
--- a/usr/src/lib/libdtrace/common/dt_strtab.h
+++ b/usr/src/lib/libdtrace/common/dt_strtab.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -19,8 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -58,6 +58,7 @@ typedef ssize_t dt_strtab_write_f(const char *, size_t, size_t, void *);
extern dt_strtab_t *dt_strtab_create(size_t);
extern void dt_strtab_destroy(dt_strtab_t *);
+extern ssize_t dt_strtab_index(dt_strtab_t *, const char *);
extern ssize_t dt_strtab_insert(dt_strtab_t *, const char *);
extern size_t dt_strtab_size(const dt_strtab_t *);
extern ssize_t dt_strtab_write(const dt_strtab_t *,
diff --git a/usr/src/uts/common/dtrace/dtrace.c b/usr/src/uts/common/dtrace/dtrace.c
index c7f655adde..cebde39620 100644
--- a/usr/src/uts/common/dtrace/dtrace.c
+++ b/usr/src/uts/common/dtrace/dtrace.c
@@ -333,6 +333,11 @@ static kmutex_t dtrace_errlock;
(((uint64_t)1 << 61) - 1)) | ((uint64_t)intr << 61); \
}
+#define DT_BSWAP_8(x) ((x) & 0xff)
+#define DT_BSWAP_16(x) ((DT_BSWAP_8(x) << 8) | DT_BSWAP_8((x) >> 8))
+#define DT_BSWAP_32(x) ((DT_BSWAP_16(x) << 16) | DT_BSWAP_16((x) >> 16))
+#define DT_BSWAP_64(x) ((DT_BSWAP_32(x) << 32) | DT_BSWAP_32((x) >> 32))
+
#define DTRACE_STORE(type, tomax, offset, what) \
*((type *)((uintptr_t)(tomax) + (uintptr_t)offset)) = (type)(what);
@@ -3478,6 +3483,36 @@ dtrace_dif_subr(uint_t subr, uint_t rd, uint64_t *regs,
break;
}
+ case DIF_SUBR_HTONS:
+ case DIF_SUBR_NTOHS:
+#ifdef _BIG_ENDIAN
+ regs[rd] = (uint16_t)tupregs[0].dttk_value;
+#else
+ regs[rd] = DT_BSWAP_16((uint16_t)tupregs[0].dttk_value);
+#endif
+ break;
+
+
+ case DIF_SUBR_HTONL:
+ case DIF_SUBR_NTOHL:
+#ifdef _BIG_ENDIAN
+ regs[rd] = (uint32_t)tupregs[0].dttk_value;
+#else
+ regs[rd] = DT_BSWAP_32((uint32_t)tupregs[0].dttk_value);
+#endif
+ break;
+
+
+ case DIF_SUBR_HTONLL:
+ case DIF_SUBR_NTOHLL:
+#ifdef _BIG_ENDIAN
+ regs[rd] = (uint64_t)tupregs[0].dttk_value;
+#else
+ regs[rd] = DT_BSWAP_64((uint64_t)tupregs[0].dttk_value);
+#endif
+ break;
+
+
case DIF_SUBR_DIRNAME:
case DIF_SUBR_BASENAME: {
char *dest = (char *)mstate->dtms_scratch_ptr;
@@ -7589,7 +7624,13 @@ dtrace_difo_validate_helper(dtrace_difo_t *dp)
subr == DIF_SUBR_STRCHR ||
subr == DIF_SUBR_STRJOIN ||
subr == DIF_SUBR_STRRCHR ||
- subr == DIF_SUBR_STRSTR)
+ subr == DIF_SUBR_STRSTR ||
+ subr == DIF_SUBR_HTONS ||
+ subr == DIF_SUBR_HTONL ||
+ subr == DIF_SUBR_HTONLL ||
+ subr == DIF_SUBR_NTOHS ||
+ subr == DIF_SUBR_NTOHL ||
+ subr == DIF_SUBR_NTOHLL)
break;
err += efunc(pc, "invalid subr %u\n", subr);
diff --git a/usr/src/uts/common/dtrace/systrace.c b/usr/src/uts/common/dtrace/systrace.c
index 5dea20a911..be14660b04 100644
--- a/usr/src/uts/common/dtrace/systrace.c
+++ b/usr/src/uts/common/dtrace/systrace.c
@@ -241,7 +241,7 @@ systrace_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
return (DDI_FAILURE);
}
- systrace_probe = dtrace_probe;
+ systrace_probe = (void (*)())dtrace_probe;
membar_enter();
if (ddi_create_minor_node(devi, "systrace", S_IFCHR, 0,
diff --git a/usr/src/uts/common/os/sysent.c b/usr/src/uts/common/os/sysent.c
index 8211e23d01..93fb6a0d75 100644
--- a/usr/src/uts/common/os/sysent.c
+++ b/usr/src/uts/common/os/sysent.c
@@ -1133,12 +1133,12 @@ char **syscallnames;
systrace_sysent_t *systrace_sysent;
void (*systrace_probe)(dtrace_id_t, uintptr_t, uintptr_t,
- uintptr_t, uintptr_t, uintptr_t);
+ uintptr_t, uintptr_t, uintptr_t, uintptr_t);
/*ARGSUSED*/
void
systrace_stub(dtrace_id_t id, uintptr_t arg0, uintptr_t arg1,
- uintptr_t arg2, uintptr_t arg3, uintptr_t arg4)
+ uintptr_t arg2, uintptr_t arg3, uintptr_t arg4, uintptr_t arg5)
{}
/*ARGSUSED*/
@@ -1152,7 +1152,7 @@ dtrace_systrace_syscall(uintptr_t arg0, uintptr_t arg1, uintptr_t arg2,
proc_t *p;
if ((id = sy->stsy_entry) != DTRACE_IDNONE)
- (*systrace_probe)(id, arg0, arg1, arg2, arg3, arg4);
+ (*systrace_probe)(id, arg0, arg1, arg2, arg3, arg4, arg5);
/*
* We want to explicitly allow DTrace consumers to stop a process
@@ -1173,7 +1173,7 @@ dtrace_systrace_syscall(uintptr_t arg0, uintptr_t arg1, uintptr_t arg2,
if ((id = sy->stsy_return) != DTRACE_IDNONE)
(*systrace_probe)(id, (uintptr_t)rval, (uintptr_t)rval,
- 0, 0, 0);
+ (uintptr_t)((int64_t)rval >> 32), 0, 0, 0);
return (rval);
}
@@ -1193,7 +1193,7 @@ dtrace_systrace_syscall32(uintptr_t arg0, uintptr_t arg1, uintptr_t arg2,
proc_t *p;
if ((id = sy->stsy_entry) != DTRACE_IDNONE)
- (*systrace_probe)(id, arg0, arg1, arg2, arg3, arg4);
+ (*systrace_probe)(id, arg0, arg1, arg2, arg3, arg4, arg5);
/*
* We want to explicitly allow DTrace consumers to stop a process
@@ -1214,7 +1214,7 @@ dtrace_systrace_syscall32(uintptr_t arg0, uintptr_t arg1, uintptr_t arg2,
if ((id = sy->stsy_return) != DTRACE_IDNONE)
(*systrace_probe)(id, (uintptr_t)rval, (uintptr_t)rval,
- 0, 0, 0);
+ (uintptr_t)((uint64_t)rval >> 32), 0, 0, 0);
return (rval);
}
@@ -1242,5 +1242,5 @@ dtrace_systrace_rtt(void)
}
if ((id = sy->stsy_return) != DTRACE_IDNONE)
- (*systrace_probe)(id, 0, 0, 0, 0, 0);
+ (*systrace_probe)(id, 0, 0, 0, 0, 0, 0);
}
diff --git a/usr/src/uts/common/sys/dtrace.h b/usr/src/uts/common/sys/dtrace.h
index 5bd2a0866a..d53b88ab82 100644
--- a/usr/src/uts/common/sys/dtrace.h
+++ b/usr/src/uts/common/sys/dtrace.h
@@ -273,8 +273,14 @@ typedef enum dtrace_probespec {
#define DIF_SUBR_SUBSTR 32
#define DIF_SUBR_INDEX 33
#define DIF_SUBR_RINDEX 34
-
-#define DIF_SUBR_MAX 34 /* max subroutine value */
+#define DIF_SUBR_HTONS 35
+#define DIF_SUBR_HTONL 36
+#define DIF_SUBR_HTONLL 37
+#define DIF_SUBR_NTOHS 38
+#define DIF_SUBR_NTOHL 39
+#define DIF_SUBR_NTOHLL 40
+
+#define DIF_SUBR_MAX 40 /* max subroutine value */
typedef uint32_t dif_instr_t;
diff --git a/usr/src/uts/common/sys/feature_tests.h b/usr/src/uts/common/sys/feature_tests.h
index dbf75d22c6..43339a83cd 100644
--- a/usr/src/uts/common/sys/feature_tests.h
+++ b/usr/src/uts/common/sys/feature_tests.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -19,8 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -383,6 +383,12 @@ extern "C" {
*/
#define _ISO_C_9899_1999
+/*
+ * The following macro indicates header support for DTrace. The value is an
+ * integer that corresponds to the major version number for DTrace.
+ */
+#define _DTRACE_VERSION 1
+
#ifdef __cplusplus
}
#endif
diff --git a/usr/src/uts/common/sys/systrace.h b/usr/src/uts/common/sys/systrace.h
index fae89e0a2c..d43974451e 100644
--- a/usr/src/uts/common/sys/systrace.h
+++ b/usr/src/uts/common/sys/systrace.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -19,8 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -47,9 +47,9 @@ extern systrace_sysent_t *systrace_sysent;
extern systrace_sysent_t *systrace_sysent32;
extern void (*systrace_probe)(dtrace_id_t, uintptr_t, uintptr_t,
- uintptr_t, uintptr_t, uintptr_t);
+ uintptr_t, uintptr_t, uintptr_t, uintptr_t);
extern void systrace_stub(dtrace_id_t, uintptr_t, uintptr_t,
- uintptr_t, uintptr_t, uintptr_t);
+ uintptr_t, uintptr_t, uintptr_t, uintptr_t);
extern int64_t dtrace_systrace_syscall(uintptr_t arg0, uintptr_t arg1,
uintptr_t arg2, uintptr_t arg3, uintptr_t arg4, uintptr_t arg5);
diff --git a/usr/src/uts/intel/dtrace/fasttrap_isa.c b/usr/src/uts/intel/dtrace/fasttrap_isa.c
index 5b0c0a9383..c8f222e429 100644
--- a/usr/src/uts/intel/dtrace/fasttrap_isa.c
+++ b/usr/src/uts/intel/dtrace/fasttrap_isa.c
@@ -104,6 +104,8 @@
#define FASTTRAP_JLE 0x7e
#define FASTTRAP_JG 0x7f
+#define FASTTRAP_NOP 0x90
+
#define FASTTRAP_MOV_EAX 0xb8
#define FASTTRAP_MOV_ECX 0xb9
@@ -230,7 +232,7 @@ fasttrap_tracepoint_init(proc_t *p, fasttrap_tracepoint_t *tp, uintptr_t pc,
size_t len = FASTTRAP_MAX_INSTR_SIZE;
size_t first = MIN(len, PAGESIZE - (pc & PAGEOFFSET));
uint_t start = 0;
- int rmindex;
+ int rmindex, size;
uint8_t seg, rex = 0;
/*
@@ -252,14 +254,13 @@ fasttrap_tracepoint_init(proc_t *p, fasttrap_tracepoint_t *tp, uintptr_t pc,
/*
* If the disassembly fails, then we have a malformed instruction.
*/
- if ((tp->ftt_size = dtrace_instr_size_isa(instr, p->p_model,
- &rmindex)) <= 0)
+ if ((size = dtrace_instr_size_isa(instr, p->p_model, &rmindex)) <= 0)
return (-1);
/*
* Make sure the disassembler isn't completely broken.
*/
- ASSERT(-1 <= rmindex && rmindex < tp->ftt_size);
+ ASSERT(-1 <= rmindex && rmindex < size);
/*
* If the computed size is greater than the number of bytes read,
@@ -267,9 +268,10 @@ fasttrap_tracepoint_init(proc_t *p, fasttrap_tracepoint_t *tp, uintptr_t pc,
* page boundary and the subsequent page was missing or because of
* some malicious user.
*/
- if (tp->ftt_size > len)
+ if (size > len)
return (-1);
+ tp->ftt_size = (uint8_t)size;
tp->ftt_segment = FASTTRAP_SEG_NONE;
/*
@@ -503,6 +505,21 @@ fasttrap_tracepoint_init(proc_t *p, fasttrap_tracepoint_t *tp, uintptr_t pc,
tp->ftt_type = FASTTRAP_T_PUSHL_EBP;
break;
+ case FASTTRAP_NOP:
+#ifdef __amd64
+ ASSERT(p->p_model == DATAMODEL_LP64 || rex == 0);
+
+ /*
+ * On amd64 we have to be careful not to confuse a nop
+ * (actually xchgl %eax, %eax) with an instruction using
+ * the same opcode, but that does something different
+ * (e.g. xchgl %r8d, %eax or xcghq %r8, %rax).
+ */
+ if (FASTTRAP_REX_B(rex) == 0)
+#endif
+ tp->ftt_type = FASTTRAP_T_NOP;
+ break;
+
case FASTTRAP_INT3:
/*
* The pid provider shares the int3 trap with debugger
@@ -1253,6 +1270,10 @@ fasttrap_pid_probe(struct regs *rp)
break;
}
+ case FASTTRAP_T_NOP:
+ new_pc = pc + tp->ftt_size;
+ break;
+
case FASTTRAP_T_JMP:
case FASTTRAP_T_CALL:
if (tp->ftt_code == 0) {
@@ -1603,7 +1624,6 @@ done:
}
}
- ASSERT(new_pc != 0);
rp->r_pc = new_pc;
return (0);
diff --git a/usr/src/uts/intel/sys/fasttrap_isa.h b/usr/src/uts/intel/sys/fasttrap_isa.h
index 2406791710..9fee8cdb6b 100644
--- a/usr/src/uts/intel/sys/fasttrap_isa.h
+++ b/usr/src/uts/intel/sys/fasttrap_isa.h
@@ -85,6 +85,7 @@ typedef struct fasttrap_machtp {
* For performance rather than correctness.
*/
#define FASTTRAP_T_PUSHL_EBP 0x10 /* pushl %ebp (for function entry) */
+#define FASTTRAP_T_NOP 0x11 /* nop */
#define FASTTRAP_RIP_1 0x1
#define FASTTRAP_RIP_2 0x2