changeset 11237:0d23e47ed228

6795386 macro arguments and globbing in DTrace probe descriptions don't mix 6779011 libdtrace sometimes dumps core when running tst.1.0.d 6712247 dtrace -c runs the program despite errors Contributed by Chad Mynhier <cmynhier@gmail.com>
author Jonathan Haslam <Jonathan.Haslam@Sun.COM>
date Thu, 03 Dec 2009 13:39:19 +0000
parents 1127b4f9e96b
children 675860752184
files usr/src/cmd/dtrace/test/tst/common/misc/tst.macroglob.ksh usr/src/cmd/dtrace/test/tst/common/misc/tst.macroglob.ksh.out usr/src/cmd/dtrace/test/tst/common/pid/tst.killonerror.ksh usr/src/lib/libdtrace/common/dt_proc.c usr/src/lib/libdtrace/common/dt_subr.c usr/src/lib/libdtrace/common/ip.d.in usr/src/pkgdefs/SUNWdtrt/prototype_com
diffstat 7 files changed, 156 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/dtrace/test/tst/common/misc/tst.macroglob.ksh	Thu Dec 03 13:39:19 2009 +0000
@@ -0,0 +1,41 @@
+#
+# 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 2009 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+
+if [ $# != 1 ]; then
+	echo expected one argument: '<'dtrace-path'>'
+	exit 2
+fi
+
+dtrace=$1
+
+$dtrace -ln 'syscall::*$1:entry' read | awk '{print $(NF-1),$NF}' | sort
+$dtrace -ln 'syscall::$1*:entry' read | awk '{print $(NF-1),$NF}' | sort
+$dtrace -ln 'syscall::re$1*:entry' ad | awk '{print $(NF-1),$NF}' | sort
+$dtrace -ln 'syscall::$1l*:entry' read | awk '{print $(NF-1),$NF}' | sort
+$dtrace -ln 'syscall::p$1[0-9][0-9]:entry' read | awk '{print $(NF-1),$NF}' | \
+ sort
+
+exit $status
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/dtrace/test/tst/common/misc/tst.macroglob.ksh.out	Thu Dec 03 13:39:19 2009 +0000
@@ -0,0 +1,15 @@
+FUNCTION NAME
+pread entry
+read entry
+FUNCTION NAME
+read entry
+readlink entry
+readv entry
+FUNCTION NAME
+read entry
+readlink entry
+readv entry
+FUNCTION NAME
+readlink entry
+FUNCTION NAME
+pread64 entry
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/cmd/dtrace/test/tst/common/pid/tst.killonerror.ksh	Thu Dec 03 13:39:19 2009 +0000
@@ -0,0 +1,41 @@
+#!/bin/ksh -p
+#
+# 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 2009 Sun Microsystems, Inc.  All rights reserved.
+# Use is subject to license terms.
+#
+
+if [ $# != 1 ]; then
+	echo expected one argument: '<'dtrace-path'>'
+	exit 2
+fi
+
+dtrace=$1
+
+#
+# Make sure we kill a process if the dtrace(1M) command fails.
+#
+
+rc=`$dtrace -c date -n jarod 2>/dev/null | /usr/bin/wc -l`
+
+exit $rc
--- a/usr/src/lib/libdtrace/common/dt_proc.c	Thu Dec 03 04:39:22 2009 -0800
+++ b/usr/src/lib/libdtrace/common/dt_proc.c	Thu Dec 03 13:39:19 2009 +0000
@@ -20,12 +20,10 @@
  */
 
 /*
- * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 /*
  * DTrace Process Control
  *
@@ -712,9 +710,12 @@
 	if (!(Pstatus(dpr->dpr_proc)->pr_flags & (PR_KLC | PR_RLC))) {
 		dt_dprintf("abandoning pid %d\n", (int)dpr->dpr_pid);
 		rflag = PRELEASE_HANG;
+	} else if (Pstatus(dpr->dpr_proc)->pr_flags & PR_KLC) {
+		dt_dprintf("killing pid %d\n", (int)dpr->dpr_pid);
+		rflag = PRELEASE_KILL; /* apply kill-on-last-close */
 	} else {
 		dt_dprintf("releasing pid %d\n", (int)dpr->dpr_pid);
-		rflag = 0; /* apply kill or run-on-last-close */
+		rflag = 0; /* apply run-on-last-close */
 	}
 
 	if (dpr->dpr_tid) {
--- a/usr/src/lib/libdtrace/common/dt_subr.c	Thu Dec 03 04:39:22 2009 -0800
+++ b/usr/src/lib/libdtrace/common/dt_subr.c	Thu Dec 03 13:39:19 2009 +0000
@@ -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.
@@ -20,12 +19,10 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 #include <sys/sysmacros.h>
 
 #include <strings.h>
@@ -57,8 +54,8 @@
 dtrace_xstr2desc(dtrace_hdl_t *dtp, dtrace_probespec_t spec,
     const char *s, int argc, char *const argv[], dtrace_probedesc_t *pdp)
 {
-	size_t off, len, vlen;
-	const char *p, *q, *v;
+	size_t off, len, vlen, wlen;
+	const char *p, *q, *v, *w;
 
 	char buf[32]; /* for id_t as %d (see below) */
 
@@ -74,6 +71,8 @@
 
 		q = p + 1;
 		vlen = 0;
+		w = NULL;
+		wlen = 0;
 
 		if ((v = strchr(q, '$')) != NULL && v < q + len) {
 			/*
@@ -98,14 +97,14 @@
 			}
 
 			if (isdigit(v[1])) {
-				char *end;
 				long i;
 
 				errno = 0;
-				i = strtol(v + 1, &end, 10);
+				i = strtol(v + 1, (char **)&w, 10);
 
-				if (i < 0 || i >= argc ||
-				    errno != 0 || end != v + vlen)
+				wlen = vlen - (w - v);
+
+				if (i < 0 || i >= argc || errno != 0)
 					return (dt_set_errno(dtp, EDT_BADSPCV));
 
 				v = argv[i];
@@ -141,7 +140,7 @@
 		off = dtrace_probespecs[spec--].dtps_offset;
 		bcopy(q, (char *)pdp + off, len);
 		bcopy(v, (char *)pdp + off + len, vlen);
-
+		bcopy(w, (char *)pdp + off + len + vlen, wlen);
 	} while (--p >= s);
 
 	pdp->dtpd_id = DTRACE_IDNONE;
--- a/usr/src/lib/libdtrace/common/ip.d.in	Thu Dec 03 04:39:22 2009 -0800
+++ b/usr/src/lib/libdtrace/common/ip.d.in	Thu Dec 03 13:39:19 2009 +0000
@@ -19,75 +19,73 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 #pragma D depends_on module ip
 #pragma D depends_on provider ip
 
 inline int IPH_DF = @IPH_DF@;
-#pragma D binding "1.0" IPH_DF
+#pragma D binding "1.5" IPH_DF
 inline int IPH_MF = @IPH_MF@;
-#pragma D binding "1.0" IPH_MF
+#pragma D binding "1.5" IPH_MF
 
-#pragma D binding "1.0" IPPROTO_IP
+#pragma D binding "1.5" IPPROTO_IP
 inline int IPPROTO_IP = @IPPROTO_IP@;
-#pragma D binding "1.0" IPPROTO_HOPOPTS
+#pragma D binding "1.5" IPPROTO_HOPOPTS
 inline int IPPROTO_HOPOPTS = @IPPROTO_HOPOPTS@;
-#pragma D binding "1.0" IPPROTO_ICMP
+#pragma D binding "1.5" IPPROTO_ICMP
 inline int IPPROTO_ICMP = @IPPROTO_ICMP@;
-#pragma D binding "1.0" IPPROTO_IGMP
+#pragma D binding "1.5" IPPROTO_IGMP
 inline int IPPROTO_IGMP = @IPPROTO_IGMP@;
-#pragma D binding "1.0" IPPROTO_GGP
+#pragma D binding "1.5" IPPROTO_GGP
 inline int IPPROTO_GGP = @IPPROTO_GGP@;
-#pragma D binding "1.0" IPPROTO_ENCAP
+#pragma D binding "1.5" IPPROTO_ENCAP
 inline int IPPROTO_ENCAP = @IPPROTO_ENCAP@;
-#pragma D binding "1.0" IPPROTO_TCP
+#pragma D binding "1.5" IPPROTO_TCP
 inline int IPPROTO_TCP = @IPPROTO_TCP@;
-#pragma D binding "1.0" IPPROTO_EGP
+#pragma D binding "1.5" IPPROTO_EGP
 inline int IPPROTO_EGP = @IPPROTO_EGP@;
-#pragma D binding "1.0" IPPROTO_PUP
+#pragma D binding "1.5" IPPROTO_PUP
 inline int IPPROTO_PUP = @IPPROTO_PUP@;
-#pragma D binding "1.0" IPPROTO_UDP
+#pragma D binding "1.5" IPPROTO_UDP
 inline int IPPROTO_UDP = @IPPROTO_UDP@;
-#pragma D binding "1.0" IPPROTO_IDP
+#pragma D binding "1.5" IPPROTO_IDP
 inline int IPPROTO_IDP = @IPPROTO_IDP@;
-#pragma D binding "1.0" IPPROTO_IPV6
+#pragma D binding "1.5" IPPROTO_IPV6
 inline int IPPROTO_IPV6 = @IPPROTO_IPV6@;
-#pragma D binding "1.0" IPPROTO_ROUTING
+#pragma D binding "1.5" IPPROTO_ROUTING
 inline int IPPROTO_ROUTING = @IPPROTO_ROUTING@;
-#pragma D binding "1.0" IPPROTO_FRAGMENT
+#pragma D binding "1.5" IPPROTO_FRAGMENT
 inline int IPPROTO_FRAGMENT = @IPPROTO_FRAGMENT@;
-#pragma D binding "1.0" IPPROTO_RSVP
+#pragma D binding "1.5" IPPROTO_RSVP
 inline int IPPROTO_RSVP = @IPPROTO_RSVP@;
-#pragma D binding "1.0" IPPROTO_ESP
+#pragma D binding "1.5" IPPROTO_ESP
 inline int IPPROTO_ESP = @IPPROTO_ESP@;
-#pragma D binding "1.0" IPPROTO_AH
+#pragma D binding "1.5" IPPROTO_AH
 inline int IPPROTO_AH = @IPPROTO_AH@;
-#pragma D binding "1.0" IPPROTO_ICMPV6
+#pragma D binding "1.5" IPPROTO_ICMPV6
 inline int IPPROTO_ICMPV6 = @IPPROTO_ICMPV6@;
-#pragma D binding "1.0" IPPROTO_NONE
+#pragma D binding "1.5" IPPROTO_NONE
 inline int IPPROTO_NONE = @IPPROTO_NONE@;
-#pragma D binding "1.0" IPPROTO_DSTOPTS
+#pragma D binding "1.5" IPPROTO_DSTOPTS
 inline int IPPROTO_DSTOPTS = @IPPROTO_DSTOPTS@;
-#pragma D binding "1.0" IPPROTO_HELLO
+#pragma D binding "1.5" IPPROTO_HELLO
 inline int IPPROTO_HELLO = @IPPROTO_HELLO@;
-#pragma D binding "1.0" IPPROTO_ND
+#pragma D binding "1.5" IPPROTO_ND
 inline int IPPROTO_ND = @IPPROTO_ND@;
-#pragma D binding "1.0" IPPROTO_EON
+#pragma D binding "1.5" IPPROTO_EON
 inline int IPPROTO_EON = @IPPROTO_EON@;
-#pragma D binding "1.0" IPPROTO_OSPF
+#pragma D binding "1.5" IPPROTO_OSPF
 inline int IPPROTO_OSPF = @IPPROTO_OSPF@;
-#pragma D binding "1.0" IPPROTO_PIM
+#pragma D binding "1.5" IPPROTO_PIM
 inline int IPPROTO_PIM = @IPPROTO_PIM@;
-#pragma D binding "1.0" IPPROTO_SCTP
+#pragma D binding "1.5" IPPROTO_SCTP
 inline int IPPROTO_SCTP = @IPPROTO_SCTP@;
-#pragma D binding "1.0" IPPROTO_RAW
+#pragma D binding "1.5" IPPROTO_RAW
 inline int IPPROTO_RAW = @IPPROTO_RAW@;
-#pragma D binding "1.0" IPPROTO_MAX
+#pragma D binding "1.5" IPPROTO_MAX
 inline int IPPROTO_MAX = @IPPROTO_MAX@;
 
 /*
@@ -183,17 +181,17 @@
  */
 typedef ill_t __dtrace_ipsr_ill_t;
 
-#pragma D binding "1.0" translator
+#pragma D binding "1.5" translator
 translator pktinfo_t < mblk_t *M > {
 	pkt_addr = NULL;
 };
 
-#pragma D binding "1.0" translator
+#pragma D binding "1.5" translator
 translator csinfo_t < conn_t *C > {
 	cs_addr = NULL;
 };
 
-#pragma D binding "1.0" translator
+#pragma D binding "1.5" translator
 translator ipinfo_t < ipha_t *I > {
 	ip_ver = I->ipha_version_and_hdr_length >> 4;
 	ip_plength = ntohs(I->ipha_length) -
@@ -202,7 +200,7 @@
 	ip_daddr = inet_ntoa(&I->ipha_dst);
 };
 
-#pragma D binding "1.0" translator
+#pragma D binding "1.5" translator
 translator ipinfo_t < ip6_t *I > {
 	ip_ver = *(uint8_t *)I >> 4;
 	ip_plength = ntohs(I->ip6_ctlun.ip6_un1.ip6_un1_plen);
@@ -210,7 +208,7 @@
 	ip_daddr = inet_ntoa6(&I->ip6_dst);
 };
 
-#pragma D binding "1.0" translator
+#pragma D binding "1.5" translator
 translator ipinfo_t < void_ip_t *I > {
 	ip_ver = I != NULL ? *(uint8_t *)I >> 4 : 0;
 	ip_plength = I != NULL ? (*(uint8_t *)I >> 4 == 4 ?
@@ -226,7 +224,7 @@
 	    inet_ntoa6(&((ip6_t *)I)->ip6_dst) : "<unknown>") : "<unknown>";
 };
 
-#pragma D binding "1.0" translator
+#pragma D binding "1.5" translator
 translator ifinfo_t < __dtrace_ipsr_ill_t *I > {
 	if_name = I != NULL ? stringof(I->ill_name) : "<null>";
 	if_ipstack = I != NULL ? I->ill_ipst->ips_netstack->netstack_stackid
@@ -235,7 +233,7 @@
 	if_addr = (uintptr_t)I;
 };
 
-#pragma D binding "1.0" translator
+#pragma D binding "1.5" translator
 translator ipv4info_t < ipha_t *I > {
 	ipv4_ver = I != NULL ? I->ipha_version_and_hdr_length >> 4 : 0;
 	ipv4_ihl = I != NULL ? (I->ipha_version_and_hdr_length & 0xf) << 2 : 0;
@@ -272,7 +270,7 @@
 	ipv4_hdr = I;
 };
 
-#pragma D binding "1.0" translator
+#pragma D binding "1.5" translator
 translator ipv6info_t < ip6_t *I > {
 	ipv6_ver = I != NULL ? I->ip6_ctlun.ip6_un2_vfc >> 4 : 0;
 	ipv6_tclass = I != NULL ? ((I->ip6_ctlun.ip6_un1.ip6_un1_flow &&
--- a/usr/src/pkgdefs/SUNWdtrt/prototype_com	Thu Dec 03 04:39:22 2009 -0800
+++ b/usr/src/pkgdefs/SUNWdtrt/prototype_com	Thu Dec 03 13:39:19 2009 +0000
@@ -650,6 +650,8 @@
 f none SUNWdtrt/tst/common/misc/tst.enablerace.ksh 0444 root bin
 f none SUNWdtrt/tst/common/misc/tst.haslam.d 0444 root bin
 f none SUNWdtrt/tst/common/misc/tst.include.ksh 0444 root bin
+f none SUNWdtrt/tst/common/misc/tst.macroglob.ksh 0444 root bin
+f none SUNWdtrt/tst/common/misc/tst.macroglob.ksh.out 0444 root bin
 f none SUNWdtrt/tst/common/misc/tst.roch.d 0444 root bin
 f none SUNWdtrt/tst/common/misc/tst.schrock.ksh 0444 root bin
 d none SUNWdtrt/tst/common/multiaggs 0755 root bin
@@ -725,6 +727,7 @@
 f none SUNWdtrt/tst/common/pid/tst.fork.exe 0555 root bin
 f none SUNWdtrt/tst/common/pid/tst.gcc.d 0444 root bin
 f none SUNWdtrt/tst/common/pid/tst.gcc.exe 0555 root bin
+f none SUNWdtrt/tst/common/pid/tst.killonerror.ksh 0444 root bin
 f none SUNWdtrt/tst/common/pid/tst.main.ksh 0444 root bin
 f none SUNWdtrt/tst/common/pid/tst.manypids.ksh 0444 root bin
 f none SUNWdtrt/tst/common/pid/tst.newprobes.ksh 0444 root bin