Update DTrace userland code to the latest available.

Summary of changes:

- libdtrace

changeset:   12902:3bb859a7330c
user:        Bryan Cantrill <Bryan.Cantrill@Sun.COM>
date:        Fri Jul 23 17:34:02 2010 -0700
summary:     6679140 asymmetric alloc/dealloc activity can induce dynamic variable drops

changeset:   12692:4341b447c069
user:        Ali Bahrami <Ali.Bahrami@Oracle.COM>
date:        Thu Jun 24 18:16:42 2010 -0600
summary:     6916796 OSnet mapfiles should use version 2 link-editor syntax

changeset:   12507:501806a754d2
user:        Alan Maguire <Alan.Maguire@Sun.COM>
date:        Thu May 27 17:29:51 2010 -0400
summary:     PSARC 2010/106 DTrace TCP and UDP providers

changeset:   11798:1e7f1f154004
user:        Roger A. Faulkner <Roger.Faulkner@Sun.COM>
date:        Sun Feb 28 18:42:20 2010 -0800
summary:     PSARC 2009/657 delete obsolete system call traps

changeset:   11466:d60272412fb0
user:        Roger A. Faulkner <Roger.Faulkner@Sun.COM>
date:        Mon Jan 11 17:42:13 2010 -0800
summary:     6915578 MUTEX_HELD() and RW_LOCK_HELD() macros should be available to Posix threads

changeset:   11237:0d23e47ed228
user:        Jonathan Haslam <Jonathan.Haslam@Sun.COM>
date:        Thu Dec 03 13:39:19 2009 +0000
summary:     6795386 macro arguments and globbing in DTrace probe descriptions don't mix

changeset:   10791:944abfb5b345
user:        Jonathan Haslam <Jonathan.Haslam@Sun.COM>
date:        Wed Oct 14 11:25:23 2009 +0100
summary:     6886953 large symbols lead to stack exhaustion

changeset:   10326:8e3fbeec2d76
user:        Siddheshwar Mahesh <Siddheshwar.Mahesh@Sun.COM>
date:        Mon Aug 17 13:26:49 2009 -0500
summary:     6868411 NFS provider generates error on ci_remote on RDMA operations

changeset:   10207:87c40ea3fc4b
user:        jmcp <James.McPherson@Sun.COM>
date:        Wed Jul 29 16:56:03 2009 -0700
summary:     6864230 hiho, hiho, it'ch chtime for CH to go

changeset:   10044:2643c1cd9e2a
user:        Priya Krishnan <Priya.Krishnan@Sun.COM>
date:        Mon Jul 06 21:19:41 2009 -0400
summary:     6855027 iscsit.d breaks dtrace in osol based on snv_117

changeset:   9900:1b86d65a4f9e
user:        Ali Bahrami <Ali.Bahrami@Sun.COM>
date:        Thu Jun 18 13:16:39 2009 -0600
summary:     6851224 elf_getshnum() and elf_getshstrndx() incompatible with 2002 ELF gABI agreement

changeset:   9885:a3d5e9d9e779
user:        Robert Mastors <Robert.Mastors@Sun.COM>
date:        Tue Jun 16 15:25:25 2009 -0500
summary:     6711844 assert: vp->v_shrlocks == 0L, file: ../../common/fs/vnode.c, line: 2333

changeset:   9881:741c9e4e094c
user:        Charles Ting <Charles.Ting@Sun.COM>
date:        Tue Jun 16 14:51:40 2009 -0400
summary:     6849606 SRP DTrace Probe for xfer-done misses completion of READ transfers

changeset:   9829:e8059fcaee97
user:        Charles Ting <Charles.Ting@Sun.COM>
date:        Tue Jun 09 10:11:35 2009 -0400
summary:     6804431 Add Dtrace probes to SRPT

changeset:   9812:a2990074321f
user:        Priya Krishnan <Priya.Krishnan@Sun.COM>
date:        Mon Jun 08 09:49:48 2009 -0400
summary:     6847237 The iscsit.d DTrace translator should include iscsi.d for the definition of iscsiinfo_t

changeset:   9721:4f7e194c7c37
user:        Priya Krishnan <Priya.Krishnan@Sun.COM>
date:        Tue May 26 10:40:43 2009 -0400
summary:     6809997 COMSTAR iscsi target DTrace Provider needed

changeset:   9625:8aa5731291b4
user:        Sam Cramer <Sam.Cramer@Sun.COM>
date:        Wed May 13 17:10:06 2009 -0700
summary:     6840354 "/usr/lib/dtrace/fc.d", line 59: syntax error near "fct_local_port_t"

changeset:   9609:8874cc8d5e3f
user:        Sam Cramer <Sam.Cramer@Sun.COM>
date:        Mon May 11 21:02:27 2009 -0700
summary:     6809580 fct DTrace providers needed for qlt

changeset:   9578:c4b38ec17f4e
user:        Sam Cramer <Sam.Cramer@Sun.COM>
date:        Fri May 08 12:12:40 2009 -0700
summary:     6809580 fct DTrace providers needed for qlt

changeset:   9531:dc8924ef7839
user:        Rafael Vanoni <rafael.vanoni@sun.com>
date:        Mon May 04 11:48:15 2009 -0700
summary:     6730130 dtrace missing printf handler for stdev

changeset:   9389:750ed3471e90
user:        Vamsi Nagineni <Vamsi.Krishna@Sun.COM>
date:        Fri Apr 17 06:26:47 2009 -0700
summary:     6812050 dtrace should translate curpsinfo->pr_contract

changeset:   9085:ff7eb0bace56
user:        Ali Bahrami <Ali.Bahrami@Sun.COM>
date:        Wed Mar 18 13:28:28 2009 -0600
summary:     6813909 generalize eh_frame support to non-amd64 platforms

changeset:   8803:8c01b39012c9
user:        Jonathan Haslam <Jonathan.Haslam@Sun.COM>
date:        Fri Feb 13 07:13:13 2009 +0000
summary:     PSARC 2008/480 DTrace CPC Provider

changeset:   8744:03d5725cda56
user:        Ali Bahrami <Ali.Bahrami@Sun.COM>
date:        Tue Feb 10 09:38:02 2009 -0700
summary:     6798660 Cadmium .NOT file processing problem with CWD relative file paths

changeset:   8337:079ecc003ca6
user:        Jonathan Haslam <Jonathan.Haslam@Sun.COM>
date:        Thu Dec 11 11:26:47 2008 +0000
summary:     6750659 drti.o crashes app due to corrupt environment

changeset:   7991:d3b751ef3d85
user:        Jonathan Haslam <Jonathan.Haslam@Sun.COM>
date:        Mon Nov 03 10:26:23 2008 +0000
summary:     6738982 Representative thread after DTrace stop() action is incorrect

changeset:   7208:568549b138d8
user:        vv149972
date:        Mon Jul 28 23:14:31 2008 -0700
summary:     6696397 NFS v3 provider reports all UDP clients as 0.0.0.0

changeset:   6878:360e73ea6b0c
user:        brendan
date:        Fri Jun 13 19:06:55 2008 -0700
summary:     PSARC 2008/302 DTrace IP Provider

changeset:   6554:b5817e112852
user:        ahl
date:        Mon May 05 14:38:24 2008 -0700
summary:     6677812 race between dtrace activities in non-local zones

----

- ctf tools:

changeset:   12177:800b7f847f1e
user:        Surya Prakki <Surya.Prakki@Sun.COM>
date:        Sun Apr 18 23:59:57 2010 -0700
summary:     6941452 ctfconvert fails on VLAs with code generated by SS12u1

changeset:   11432:c1c450bf62f2
user:        John Levon <john.levon@sun.com>
date:        Tue Jan 05 06:57:53 2010 -0800
summary:     6905711 anonymous and empty SOUs crash ctfconvert

changeset:   11227:cd2ac59c39f2
user:        Ali Bahrami <Ali.Bahrami@Sun.COM>
date:        Wed Dec 02 15:37:55 2009 -0700
summary:     6900241 ld should track SHT_GROUP sections by symbol name, not section name

changeset:   10380:5394a7172e1f
user:        Ali Bahrami <Ali.Bahrami@Sun.COM>
date:        Tue Aug 25 13:51:43 2009 -0600
summary:     6866605 SUNWonbld ELF analysis tools need overhaul (fix ctfmerge/libc dependency)

changeset:   10207:87c40ea3fc4b
user:        jmcp <James.McPherson@Sun.COM>
date:        Wed Jul 29 16:56:03 2009 -0700
summary:     6864230 hiho, hiho, it'ch chtime for CH to go

changeset:   10206:51f52702df72
user:        John Levon <john.levon@sun.com>
date:        Wed Jul 29 14:36:30 2009 -0700
summary:     6854065 CTF tools should error out given 1024+-member structures

changeset:   7230:429b4f7acf1a
user:        sn199410
date:        Wed Jul 30 16:10:30 2008 -0700
summary:     6575435 ctf tools cannot handle C99 VLAs ("variable length arrays")

changeset:   6936:72189fcd99e4
user:        sommerfe
date:        Sun Jun 22 09:13:44 2008 -0700
summary:     6716983 left-for-dead ctfmerge worker threads awake to take out maker

----

- dtrace command utility:

changeset:   12507:501806a754d2
user:        Alan Maguire <Alan.Maguire@Sun.COM>
date:        Thu May 27 17:29:51 2010 -0400
summary:     PSARC 2010/106 DTrace TCP and UDP providers

changeset:   11838:32bb5d254240
user:        Liane Praza <Liane.Praza@Sun.COM>
date:        Tue Mar 02 19:29:26 2010 -0700
summary:     PSARC 2010/067 Interim modernization updates

changeset:   11270:47a962fe7b45
user:        Frank Van Der Linden <Frank.Vanderlinden@Sun.COM>
date:        Mon Dec 07 13:47:36 2009 -0800
summary:     6907170 fix for 6875656 left out updates to DTrace test suite

changeset:   11237:0d23e47ed228
user:        Jonathan Haslam <Jonathan.Haslam@Sun.COM>
date:        Thu Dec 03 13:39:19 2009 +0000
summary:     6795386 macro arguments and globbing in DTrace probe descriptions don't mix

changeset:   11153:dec430d20576
user:        Frank Van Der Linden <Frank.Vanderlinden@Sun.COM>
date:        Sun Nov 22 19:22:26 2009 -0800
summary:     6875656 xdt needs to support more XenTrace probes

changeset:   11102:b91faef0c984
user:        Gavin Maltby <Gavin.Maltby@Sun.COM>
date:        Thu Nov 19 15:28:11 2009 +1100
summary:     PSARC/2009/554 door_xcreate - extended door creation interface for private doors

changeset:   11066:cebb50cbe4f9
user:        Rafael Vanoni <rafael.vanoni@sun.com>
date:        Fri Nov 13 01:32:32 2009 -0800
summary:     PSARC/2009/396 Tickless Kernel Architecture / lbolt decoupling

changeset:   10791:944abfb5b345
user:        Jonathan Haslam <Jonathan.Haslam@Sun.COM>
date:        Wed Oct 14 11:25:23 2009 +0100
summary:     6886953 large symbols lead to stack exhaustion

changeset:   10207:87c40ea3fc4b
user:        jmcp <James.McPherson@Sun.COM>
date:        Wed Jul 29 16:56:03 2009 -0700
summary:     6864230 hiho, hiho, it'ch chtime for CH to go

changeset:   9531:dc8924ef7839
user:        Rafael Vanoni <rafael.vanoni@sun.com>
date:        Mon May 04 11:48:15 2009 -0700
summary:     6730130 dtrace missing printf handler for stdev

changeset:   9397:e667d620a75c
user:        Jonathan Haslam <Jonathan.Haslam@Sun.COM>
date:        Mon Apr 20 07:58:44 2009 +0100
summary:     6806023 cpc provider event name validation needs to be a bit tighter

changeset:   8803:8c01b39012c9
user:        Jonathan Haslam <Jonathan.Haslam@Sun.COM>
date:        Fri Feb 13 07:13:13 2009 +0000
summary:     PSARC 2008/480 DTrace CPC Provider

changeset:   8605:0189cb9c5358
user:        Jonathan Haslam <Jonathan.Haslam@Sun.COM>
date:        Thu Jan 22 12:09:13 2009 +0000
summary:     6749441 intrstat(1M) shows zeroed values after suspend/resume

changeset:   8337:079ecc003ca6
user:        Jonathan Haslam <Jonathan.Haslam@Sun.COM>
date:        Thu Dec 11 11:26:47 2008 +0000
summary:     6750659 drti.o crashes app due to corrupt environment

changeset:   8287:771477e4b843
user:        John Sonnenschein <John.Sonnenschein@Sun.COM>
date:        Fri Dec 05 19:08:38 2008 -0800
summary:     PSARC 2005/462 Removal of Perl 5.6.1 from Solaris 11

changeset:   7991:d3b751ef3d85
user:        Jonathan Haslam <Jonathan.Haslam@Sun.COM>
date:        Mon Nov 03 10:26:23 2008 +0000
summary:     6738982 Representative thread after DTrace stop() action is incorrect

changeset:   7502:da077e5d991e
user:        Aruna Ramakrishna <aruna@cs.umn.edu>
date:        Sat Sep 06 05:36:02 2008 -0400
summary:     6706947 tcp_trace should be replaced with dtrace probes.

changeset:   7484:a48e950bad22
user:        Tom Erickson <tomee@eng.sun.com>
date:        Wed Sep 03 15:14:25 2008 -0700
summary:     6737926 getAggregate() method fails to specify anonymous aggregation explicitly

changeset:   7299:d9a056040774
user:        John Beck <John.Beck@Sun.COM>
date:        Thu Aug 07 12:44:26 2008 -0700
summary:     6734627 protocmp complains about opt/SUNWdtrt/README after TW -> Hg switch

changeset:   6998:58787ea78303
user:        brendan
date:        Tue Jul 01 18:28:22 2008 -0700
summary:     6721426 tst.sdtargs.d passes despite dtrace "invalid address" error

changeset:   6878:360e73ea6b0c
user:        brendan
date:        Fri Jun 13 19:06:55 2008 -0700
summary:     PSARC 2008/302 DTrace IP Provider

changeset:   6670:1961a43f2335
user:        tariq
date:        Tue May 20 15:08:16 2008 -0700
summary:     6685348 Hypervisor event provider for DTrace

changeset:   6554:b5817e112852
user:        ahl
date:        Mon May 05 14:38:24 2008 -0700
summary:     6677812 race between dtrace activities in non-local zones

changeset:   6543:465433824d87
user:        rie
date:        Fri May 02 15:01:06 2008 -0700
summary:     6683064 check_rtime could do with some spring cleaning
This commit is contained in:
Rui Paulo 2010-08-02 12:13:33 +00:00
parent 37ddcfe2bb
commit e0ea83ebb1
114 changed files with 4464 additions and 297 deletions

View File

@ -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"
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
@ -162,7 +160,7 @@ main(int argc, char **argv)
FILE *fp;
unsigned char *dof, *copy;
if (argc < 1)
if (argc < 2)
fatal("expected D script as argument\n");
if ((fp = fopen(filename, "r")) == NULL)

View File

@ -20,12 +20,10 @@
*/
/*
* Copyright 2006 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 <strings.h>
#include <unistd.h>
#include <dtrace.h>
@ -35,6 +33,7 @@ static int g_errs;
static int g_fd;
static int g_verbose;
static int g_errexit;
static char *g_progname;
static int
probe(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp, void *data)
@ -91,9 +90,11 @@ main(int argc, char *argv[])
int err, c;
char *p;
g_progname = argv[0];
if ((dtp = dtrace_open(DTRACE_VERSION, 0, &err)) == NULL) {
(void) fprintf(stderr, "%s: failed to open dtrace: %s\n",
argv[0], dtrace_errmsg(dtp, err));
g_progname, dtrace_errmsg(dtp, err));
return (1);
}
@ -111,7 +112,7 @@ main(int argc, char *argv[])
if (dtrace_setopt(dtp, optarg, p) != 0) {
(void) fprintf(stderr, "%s: failed to set "
"option -x %s: %s\n", argv[0], optarg,
"option -x %s: %s\n", g_progname, optarg,
dtrace_errmsg(dtp, dtrace_errno(dtp)));
return (2);
}
@ -119,7 +120,7 @@ main(int argc, char *argv[])
default:
(void) fprintf(stderr, "Usage: %s [-ev] "
"[-x opt[=arg]] [probedesc]\n", argv[0]);
"[-x opt[=arg]] [probedesc]\n", g_progname);
return (2);
}
}
@ -128,9 +129,9 @@ main(int argc, char *argv[])
argc -= optind;
if (argc > 0) {
if (dtrace_str2desc(dtp, DTRACE_PROBESPEC_NAME, argv[1], &pd)) {
if (dtrace_str2desc(dtp, DTRACE_PROBESPEC_NAME, argv[0], &pd)) {
(void) fprintf(stderr, "%s: invalid probe description "
"%s: %s\n", argv[0], argv[1],
"%s: %s\n", g_progname, argv[0],
dtrace_errmsg(dtp, dtrace_errno(dtp)));
return (2);
}

View File

@ -23,7 +23,7 @@
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#ident "%Z%%M% %I% %E% SMI"
# ident "%Z%%M% %I% %E% SMI"
# Exception list: names tests that are bypassed when running in Java
# mode (relative to /opt/SUNWdtrt/tst)
@ -49,6 +49,7 @@ common/usdt/tst.dlclose2.ksh
common/usdt/tst.dlclose3.ksh
common/usdt/tst.eliminate.ksh
common/usdt/tst.enabled.ksh
common/usdt/tst.enabled2.ksh
common/usdt/tst.entryreturn.ksh
common/usdt/tst.fork.ksh
common/usdt/tst.header.ksh

View File

@ -21,12 +21,11 @@
#
#
# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#pragma ident "%Z%%M% %I% %E% SMI"
require 5.6.1;
require 5.8.4;
$PNAME = $0;
$PNAME =~ s:.*/::;

View File

@ -24,9 +24,8 @@
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
require 5.6.1;
require 5.8.4;
use File::Find;
use File::Basename;
@ -40,6 +39,7 @@ $OPTSTR = 'abd:fghi:jlnqsx:';
$USAGE = "Usage: $PNAME [-abfghjlnqs] [-d dir] [-i isa] "
. "[-x opt[=arg]] [file | dir ...]\n";
($MACH = `uname -p`) =~ s/\W*\n//;
($PLATFORM = `uname -i`) =~ s/\W*\n//;
@dtrace_argv = ();
@ -215,17 +215,17 @@ sub is_exception {
}
#
# Iterate over the set of test files specified on the command-line or by
# a find on "$defdir/common" and "$defdir/$MACH" and execute each one.
# If the test file is executable, we fork and exec it. If the test is a
# .ksh file, we run it with $ksh_path. Otherwise we run dtrace -s on it.
# If the file is named tst.* we assume it should return exit status 0.
# If the file is named err.* we assume it should return exit status 1.
# If the file is named err.D_[A-Z0-9]+[.*].d we use dtrace -xerrtags and
# examine stderr to ensure that a matching error tag was produced.
# If the file is named drp.[A-Z0-9]+[.*].d we use dtrace -xdroptags and
# examine stderr to ensure that a matching drop tag was produced.
# If any *.out or *.err files are found we perform output comparisons.
# Iterate over the set of test files specified on the command-line or by a find
# on "$defdir/common", "$defdir/$MACH" and "$defdir/$PLATFORM" and execute each
# one. If the test file is executable, we fork and exec it. If the test is a
# .ksh file, we run it with $ksh_path. Otherwise we run dtrace -s on it. If
# the file is named tst.* we assume it should return exit status 0. If the
# file is named err.* we assume it should return exit status 1. If the file is
# named err.D_[A-Z0-9]+[.*].d we use dtrace -xerrtags and examine stderr to
# ensure that a matching error tag was produced. If the file is named
# drp.[A-Z0-9]+[.*].d we use dtrace -xdroptags and examine stderr to ensure
# that a matching drop tag was produced. If any *.out or *.err files are found
# we perform output comparisons.
#
# run_tests takes two arguments: The first is the pathname of the dtrace
# command to invoke when running the tests. The second is the pathname
@ -548,6 +548,7 @@ $bindir = -d $dt_bin ? $dt_bin : '.';
find(\&wanted, "$defdir/common") if (scalar(@ARGV) == 0);
find(\&wanted, "$defdir/$MACH") if (scalar(@ARGV) == 0);
find(\&wanted, "$defdir/$PLATFORM") if (scalar(@ARGV) == 0);
die $USAGE if (scalar(@files) == 0);
$dtrace_path = '/usr/sbin/dtrace';

View File

@ -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.
*/
/*
* ASSERTION:
* stddev() should not accept a non-scalar value
*
* SECTION: Aggregations/Aggregations
*
*/
#pragma D option quiet
BEGIN
{
@a[pid] = stddev(probefunc);
}

View File

@ -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.
*/
/*
* ASSERTION:
* stddev() should not accept a call with no arguments
*
* SECTION: Aggregations/Aggregations
*
*/
#pragma D option quiet
BEGIN
{
@a[1] = stddev();
}

View File

@ -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.
*/
/*
* ASSERTION:
* stddev() should not have more than one argument
*
* SECTION: Aggregations/Aggregations
*
*/
#pragma D option quiet
BEGIN
{
@a[1] = stddev(1, 2);
}

View File

@ -0,0 +1,57 @@
/*
* 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.
*/
/*
* ASSERTION:
* Positive stddev() test
*
* SECTION: Aggregations/Aggregations
*
* NOTES:
* Verifies that printing a clear()'d aggregation with an stddev()
* aggregation function doesn't cause problems.
*
*/
#pragma D option quiet
tick-10ms
/i++ < 5/
{
@a = stddev(timestamp);
}
tick-10ms
/i == 5/
{
exit(2);
}
END
{
clear(@a);
exit(0);
}

View File

@ -0,0 +1,2 @@
0

View File

@ -20,15 +20,13 @@
*/
/*
* Copyright 2006 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"
/*
* ASSERTION:
* Multiple aggregates can be used within the same D script.
* Multiple aggregates can be used within the same D script.
*
* SECTION: Aggregations/Aggregations
*
@ -52,9 +50,11 @@ tick-10ms
@c[pid] = avg(new_time);
@d[pid] = sum(new_time);
@e[pid] = quantize(new_time);
@f[timestamp] = max(new_time);
@g[timestamp] = quantize(new_time);
@h[timestamp] = lquantize(new_time, 0, 10000, 1000);
@f[pid] = stddev(new_time);
@g[timestamp] = max(new_time);
@h[timestamp] = quantize(new_time);
@i[timestamp] = lquantize(new_time, 0, 10000, 1000);
time_1 = time_2;
i++;
}

View File

@ -20,18 +20,16 @@
*/
/*
* Copyright 2006 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"
/*
* ASSERTION:
* Test multiple aggregations and the default output order
* Test multiple aggregations and the default output order
*
* SECTION: Aggregations/Aggregations;
* Aggregations/Output
* Aggregations/Output
*
*/
@ -51,6 +49,7 @@ tick-10ms
@d = max(i);
@e = quantize(i);
@f = lquantize(i, 0, 1000, 100);
@g = stddev(i);
i += 100;
}

View File

@ -34,3 +34,4 @@
900 |@@@@ 1
>= 1000 | 0
287

View File

@ -20,19 +20,17 @@
*/
/*
* Copyright 2006 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"
/*
* ASSERTION:
* Test multiple aggregations and overriding default order with
* printa() statements.
* Test multiple aggregations and overriding default order with
* printa() statements.
*
* SECTION: Aggregations/Aggregations;
* Aggregations/Output
* Aggregations/Output
*
* NOTES: This is a simple verifiable test.
*
@ -55,6 +53,7 @@ tick-10ms
@e = max(i);
@f = quantize(i);
@g = lquantize(i, 0, 1000, 100);
@h = stddev(i);
i += 100;
}
@ -62,6 +61,7 @@ tick-10ms
tick-10ms
/i == 1000/
{
printa("%@d\n", @h);
printa("%@d\n", @g);
printa("%@d\n", @f);
printa("%@d\n", @e);

View File

@ -1,3 +1,4 @@
287
value ------------- Distribution ------------- count
< 0 | 0

View File

@ -20,20 +20,19 @@
*/
/*
* Copyright 2008 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"
/*
* ASSERTION:
* Positive stddev() test
* Positive stddev() test
*
* SECTION: Aggregations/Aggregations
*
* NOTES: This is a simple verifiable positive test of the stddev() function.
* printa() for one aggregation, default printing behavior for the other
* so that we exercise both code paths.
*/
#pragma D option quiet
@ -60,5 +59,6 @@ BEGIN
@b = stddev(-5000000700);
@b = stddev(-5000000800);
@b = stddev(-5000000900);
printa("%@d\n", @a);
exit(0);
}

View File

@ -1,3 +1,3 @@
287
287
287

View File

@ -0,0 +1,45 @@
/*
* 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.
*/
/*
* Test to check that attempting to enable a valid event with a frequency
* lower than the default platform limit will fail.
*
* This test will fail if:
* 1) The system under test does not define the 'PAPI_tot_ins' event.
* 2) The 'dcpc-min-overflow' variable in dcpc.conf has been modified.
*/
#pragma D option quiet
BEGIN
{
exit(0);
}
cpc:::PAPI_tot_ins-all-100
{
}

View File

@ -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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Tests that specifying an overflow value containing extraneous characters
* (only digits are allowed) will fail.
*/
BEGIN
{
exit(0);
}
cpc:::PAPI_tot_ins-all-10000bonehead
{
@[probename] = count();
}

View File

@ -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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Tests that attempting to enable a probe containing a non existent event
* will fail.
*/
BEGIN
{
exit(0);
}
cpc:::PAPI_cpc_bad-all-10000
{
@[probename] = count();
}

View File

@ -0,0 +1,78 @@
#!/bin/ksh
#
# 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.
#
#
# This tests that cpustat(1) should fail to start if the cpc provider
# is already calling the shots.
#
# This script will fail if:
# 1) The system under test does not define the 'PAPI_tot_ins'
# generic event.
script()
{
$dtrace -o $dtraceout -s /dev/stdin <<EOF
#pragma D option bufsize=128k
cpc:::PAPI_tot_ins-all-10000
{
@[probename] = count();
}
EOF
}
if [ $# != 1 ]; then
echo expected one argument: '<'dtrace-path'>'
exit 2
fi
dtrace=$1
dtraceout=/tmp/dtrace.out.$$
script 2>/dev/null &
timeout=15
#
# Sleep while the above script fires into life. To guard against dtrace dying
# and us sleeping forever we allow 15 secs for this to happen. This should be
# enough for even the slowest systems.
#
while [ ! -f $dtraceout ]; do
sleep 1
timeout=$(($timeout-1))
if [ $timeout -eq 0 ]; then
echo "dtrace failed to start. Exiting."
exit 1
fi
done
cpustat -c PAPI_tot_ins 1 5
status=$?
rm $dtraceout
exit $status

View File

@ -0,0 +1,70 @@
#!/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.
#
#
# This tests that enablings from the cpc provider will fail if cpustat(1) is
# already master of the universe.
#
# This script will fail if:
# 1) The system under test does not define the 'PAPI_tot_ins'
# generic event.
script()
{
$dtrace -s /dev/stdin <<EOF
#pragma D option bufsize=128k
BEGIN
{
exit(0);
}
cpc:::PAPI_tot_ins-all-10000
{
@[probename] = count();
}
EOF
}
if [ $# != 1 ]; then
echo expected one argument: '<'dtrace-path'>'
exit 2
fi
dtrace=$1
dtraceout=/tmp/dtrace.out.$$
cpustat -c PAPI_tot_ins 1 20 &
pid=$!
sleep 5
script 2>/dev/null
status=$?
kill $pid
exit $status

View File

@ -0,0 +1,77 @@
#!/bin/ksh
#
# 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.
#
# This script ensures that cputrack(1M) will fail to start when the cpc
# provider has active enablings.
#
# The script will fail if:
# 1) The system under test does not define the 'PAPI_tot_ins' event.
#
script()
{
$dtrace -o $dtraceout -s /dev/stdin <<EOF
#pragma D option bufsize=128k
cpc:::PAPI_tot_ins-all-10000
{
@[probename] = count();
}
EOF
}
if [ $# != 1 ]; then
echo expected one argument: '<'dtrace-path'>'
exit 2
fi
dtrace=$1
dtraceout=/tmp/dtrace.out.$$
script 2>/dev/null &
timeout=15
#
# Sleep while the above script fires into life. To guard against dtrace dying
# and us sleeping forever we allow 15 secs for this to happen. This should be
# enough for even the slowest systems.
#
while [ ! -f $dtraceout ]; do
sleep 1
timeout=$(($timeout-1))
if [ $timeout -eq 0 ]; then
echo "dtrace failed to start. Exiting."
exit 1
fi
done
cputrack -c PAPI_tot_ins sleep 10
status=$?
rm $dtraceout
exit $status

View File

@ -0,0 +1,70 @@
#!/bin/ksh
#
# 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.
#
# This script ensures that cputrack(1) will terminate when the cpc provider
# kicks into life.
#
# The script will fail if:
# 1) The system under test does not define the 'PAPI_tot_ins' event.
#
script()
{
$dtrace -s /dev/stdin <<EOF
#pragma D option bufsize=128k
cpc:::PAPI_tot_ins-all-10000
{
@[probename] = count();
}
tick-1s
/n++ > 10/
{
exit(0);
}
EOF
}
if [ $# != 1 ]; then
echo expected one argument: '<'dtrace-path'>'
exit 2
fi
dtrace=$1
cputrack -c PAPI_tot_ins sleep 20 &
cputrack_pid=$!
sleep 5
script 2>/dev/null &
wait $cputrack_pid
status=$?
rm $dtraceout
exit $status

View File

@ -0,0 +1,55 @@
/*
* 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.
*/
/*
* Test to check that attempting to enable too many probes will fail.
*
* This test will fail if:
* 1) We ever execute on a platform which is capable of programming 10
* 'PAPI_tot_ins' events simultaneously (which no current platforms are
* capable of doing).
* 2) The system under test does not define the 'PAPI_tot_ins' event.
*/
#pragma D option quiet
BEGIN
{
exit(0);
}
cpc:::PAPI_tot_ins-all-10000,
cpc:::PAPI_tot_ins-all-10001,
cpc:::PAPI_tot_ins-all-10002,
cpc:::PAPI_tot_ins-all-10003,
cpc:::PAPI_tot_ins-all-10004,
cpc:::PAPI_tot_ins-all-10005,
cpc:::PAPI_tot_ins-all-10006,
cpc:::PAPI_tot_ins-all-10007,
cpc:::PAPI_tot_ins-all-10008,
cpc:::PAPI_tot_ins-all-10009
{
}

View File

@ -0,0 +1,107 @@
#!/bin/ksh
#
# 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.
#
#
# This script verifies that we can fire a probe on each CPU that is in
# an online state.
#
# The script will fail if:
# 1) The system under test does not define the 'PAPI_tot_ins' event.
#
if [ $# != 1 ]; then
echo expected one argument: '<'dtrace-path'>'
exit 2
fi
dtrace=$1
numproc=`psrinfo | tail -1 | cut -f1`
cpu=0
dtraceout=/var/tmp/dtrace.out.$$
scriptout=/var/tmp/script.out.$$
spin()
{
while [ 1 ]; do
:
done
}
script()
{
$dtrace -o $dtraceout -s /dev/stdin <<EOF
#pragma D option bufsize=128k
#pragma D option quiet
cpc:::PAPI_tot_ins-user-10000
/cpus[cpu] != 1/
{
cpus[cpu] = 1;
@a[cpu] = count();
}
tick-1s
/n++ > 10/
{
printa(@a);
exit(0);
}
EOF
}
echo "" > $scriptout
while [ $cpu -le $numproc ]
do
if [ "`psrinfo -s $cpu 2> /dev/null`" -eq 1 ]; then
printf "%9d %16d\n" $cpu 1 >> $scriptout
spin &
allpids[$cpu]=$!
pbind -b $cpu $!
fi
cpu=$(($cpu+1))
done
echo "" >> $scriptout
script
diff $dtraceout $scriptout >/dev/null 2>&1
status=$?
# kill off the spinner processes
cpu=0
while [ $cpu -le $numproc ]
do
if [ "`psrinfo -s $cpu 2> /dev/null`" -eq 1 ]; then
kill ${allpids[$cpu]}
fi
cpu=$(($cpu+1))
done
rm $dtraceout
rm $scriptout
exit $status

View File

@ -0,0 +1,48 @@
/*
* 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.
*/
/*
* Test that we can successfully enable a probe using a generic event.
* Currently, all platforms implement 'PAPI_tot_ins' so we'll use that.
* Note that this test will fail if the system under test does not
* implement that event.
*
* This test will fail if:
* 1) The system under test does not define the 'PAPI_tot_ins' event.
*/
#pragma D option quiet
#pragma D option bufsize=128k
cpc:::PAPI_tot_ins-all-10000
{
@[probename] = count();
}
tick-1s
/n++ > 10/
{
exit(0);
}

View File

@ -0,0 +1,81 @@
#!/bin/ksh
#
# 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.
#
#
# This script ensures that we can enable a probe which specifies a platform
# specific event.
#
if [ $# != 1 ]; then
print -u2 "expected one argument: <dtrace-path>"
exit 2
fi
dtrace=$1
get_event()
{
perl /dev/stdin /dev/stdout << EOF
open CPUSTAT, '/usr/sbin/cpustat -h |'
or die "Couldn't run cpustat: \$!\n";
while (<CPUSTAT>) {
if (/(\s+)event\[*[0-9]-*[0-9]*\]*:/ && !/PAPI/) {
@a = split(/ /, \$_);
\$event = \$a[\$#a-1];
}
}
close CPUSTAT;
print "\$event\n";
EOF
}
script()
{
$dtrace -s /dev/stdin << EOD
#pragma D option quiet
#pragma D option bufsize=128k
cpc:::$1-all-10000
{
@[probename] = count();
}
tick-1s
/n++ > 5/
{
exit(0);
}
EOD
}
event=$(get_event)
script $event
status=$?
exit $status

View File

@ -0,0 +1,104 @@
#!/usr/bin/perl -w
#
# 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 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#pragma ident "%Z%%M% %I% %E% SMI"
#
# get.ipv4remote.pl [tcpport]
#
# Find an IPv4 reachable remote host using both ifconfig(1M) and ping(1M).
# If a tcpport is specified, return a host that is also listening on this
# TCP port. Print the local address and the remote address, or an
# error message if no suitable remote host was found. Exit status is 0 if
# a host was found.
#
use strict;
use IO::Socket;
my $MAXHOSTS = 32; # max hosts to port scan
my $TIMEOUT = 3; # connection timeout
my $tcpport = @ARGV == 1 ? $ARGV[0] : 0;
#
# Determine local IP address
#
my $local = "";
my $remote = "";
my %Broadcast;
my $up;
open IFCONFIG, '/usr/sbin/ifconfig -a |' or die "Couldn't run ifconfig: $!\n";
while (<IFCONFIG>) {
next if /^lo/;
# "UP" is always printed first (see print_flags() in ifconfig.c):
$up = 1 if /^[a-z].*<UP,/;
$up = 0 if /^[a-z].*<,/;
# assume output is "inet X ... broadcast Z":
if (/inet (\S+) .* broadcast (\S+)/) {
my ($addr, $bcast) = ($1, $2);
$Broadcast{$addr} = $bcast;
$local = $addr if $up and $local eq "";
$up = 0;
}
}
close IFCONFIG;
die "Could not determine local IP address" if $local eq "";
#
# Find the first remote host that responds to an icmp echo,
# which isn't a local address.
#
open PING, "/usr/sbin/ping -ns $Broadcast{$local} 56 $MAXHOSTS |" or
die "Couldn't run ping: $!\n";
while (<PING>) {
if (/bytes from (.*): / and not defined $Broadcast{$1}) {
my $addr = $1;
if ($tcpport != 0) {
#
# Test TCP
#
my $socket = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr => $addr,
PeerPort => $tcpport,
Timeout => $TIMEOUT,
);
next unless $socket;
close $socket;
}
$remote = $addr;
last;
}
}
close PING;
die "Can't find a remote host for testing: No suitable response from " .
"$Broadcast{$local}\n" if $remote eq "";
print "$local $remote\n";

View File

@ -0,0 +1,88 @@
#!/usr/bin/perl -w
#
# 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 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#pragma ident "%Z%%M% %I% %E% SMI"
#
# get.ipv6remote.pl
#
# Find an IPv6 reachable remote host using both ifconfig(1M) and ping(1M).
# Print the local address and the remote address, or print nothing if either
# no IPv6 interfaces or remote hosts were found. (Remote IPv6 testing is
# considered optional, and so not finding another IPv6 host is not an error
# state we need to log.) Exit status is 0 if a host was found.
#
use strict;
use IO::Socket;
my $MAXHOSTS = 32; # max hosts to scan
my $TIMEOUT = 3; # connection timeout
my $MULTICAST = "FF02::1"; # IPv6 multicast address
#
# Determine local IP address
#
my $local = "";
my $remote = "";
my %Local;
my $up;
open IFCONFIG, '/usr/sbin/ifconfig -a inet6 |'
or die "Couldn't run ifconfig: $!\n";
while (<IFCONFIG>) {
next if /^lo/;
# "UP" is always printed first (see print_flags() in ifconfig.c):
$up = 1 if /^[a-z].*<UP,/;
$up = 0 if /^[a-z].*<,/;
# assume output is "inet6 ...":
if (m:inet6 (\S+)/:) {
my $addr = $1;
$Local{$addr} = 1;
$local = $addr if $up and $local eq "";
$up = 0;
}
}
close IFCONFIG;
exit 1 if $local eq "";
#
# Find the first remote host that responds to an icmp echo,
# which isn't a local address.
#
open PING, "/usr/sbin/ping -ns -A inet6 $MULTICAST 56 $MAXHOSTS |" or
die "Couldn't run ping: $!\n";
while (<PING>) {
if (/bytes from (.*): / and not defined $Local{$1}) {
$remote = $1;
last;
}
}
close PING;
exit 2 if $remote eq "";
print "$local $remote\n";

View File

@ -0,0 +1,70 @@
#!/usr/bin/ksh
#
# 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 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#pragma ident "%Z%%M% %I% %E% SMI"
#
# Test ip:::{send,receive} of IPv4 ICMP to a local address.
#
# This may fail due to:
#
# 1. A change to the ip stack breaking expected probe behavior,
# which is the reason we are testing.
# 2. The lo0 interface missing or not up.
# 3. Unrelated ICMP on lo0 traced by accident.
#
if (( $# != 1 )); then
print -u2 "expected one argument: <dtrace-path>"
exit 2
fi
dtrace=$1
local=127.0.0.1
$dtrace -c "/usr/sbin/ping $local 3" -qs /dev/stdin <<EOF | sort -n
ip:::send
/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
args[4]->ipv4_protocol == IPPROTO_ICMP/
{
printf("1 ip:::send (");
printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
printf("args[4]: %d %d %d %d %d)\n",
args[4]->ipv4_ver, args[4]->ipv4_length, args[4]->ipv4_flags,
args[4]->ipv4_offset, args[4]->ipv4_ttl);
}
ip:::receive
/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
args[4]->ipv4_protocol == IPPROTO_ICMP/
{
printf("2 ip:::receive (");
printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
printf("args[4]: %d %d %d %d %d)\n",
args[4]->ipv4_ver, args[4]->ipv4_length, args[4]->ipv4_flags,
args[4]->ipv4_offset, args[4]->ipv4_ttl);
}
EOF

View File

@ -0,0 +1,6 @@
1 ip:::send (args[2]: 4 64, args[4]: 4 84 0 0 255)
1 ip:::send (args[2]: 4 64, args[4]: 4 84 0 0 255)
2 ip:::receive (args[2]: 4 64, args[4]: 4 84 0 0 255)
2 ip:::receive (args[2]: 4 64, args[4]: 4 84 0 0 255)
127.0.0.1 is alive

View File

@ -0,0 +1,125 @@
#!/usr/bin/ksh
#
# 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 (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
#
#
# Test {ip,tcp}:::{send,receive} of IPv4 TCP to local host.
#
# This may fail due to:
#
# 1. A change to the ip stack breaking expected probe behavior,
# which is the reason we are testing.
# 2. The lo0 interface missing or not up.
# 3. The local ssh service is not online.
# 4. An unlikely race causes the unlocked global send/receive
# variables to be corrupted.
#
# This test performs a TCP connection and checks that at least the
# following packet counts were traced:
#
# 3 x ip:::send (2 during the TCP handshake, then a FIN)
# 3 x tcp:::send (2 during the TCP handshake, then a FIN)
# 2 x ip:::receive (1 during the TCP handshake, then the FIN ACK)
# 2 x tcp:::receive (1 during the TCP handshake, then the FIN ACK)
# The actual count tested is 5 each way, since we are tracing both
# source and destination events.
#
# For this test to work, we are assuming that the TCP handshake and
# TCP close will enter the IP code path and not use tcp fusion.
#
if (( $# != 1 )); then
print -u2 "expected one argument: <dtrace-path>"
exit 2
fi
dtrace=$1
local=127.0.0.1
tcpport=22
DIR=/var/tmp/dtest.$$
mkdir $DIR
cd $DIR
cat > test.pl <<-EOPERL
use IO::Socket;
my \$s = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr => "$local",
PeerPort => $tcpport,
Timeout => 3);
die "Could not connect to host $local port $tcpport" unless \$s;
close \$s;
EOPERL
$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin <<EODTRACE
BEGIN
{
ipsend = tcpsend = ipreceive = tcpreceive = 0;
}
ip:::send
/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
args[4]->ipv4_protocol == IPPROTO_TCP/
{
ipsend++;
}
tcp:::send
/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local"/
{
tcpsend++;
}
ip:::receive
/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
args[4]->ipv4_protocol == IPPROTO_TCP/
{
ipreceive++;
}
tcp:::receive
/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local"/
{
tcpreceive++;
}
END
{
printf("Minimum TCP events seen\n\n");
printf("ip:::send - %s\n", ipsend >= 5 ? "yes" : "no");
printf("ip:::receive - %s\n", ipreceive >= 5 ? "yes" : "no");
printf("tcp:::send - %s\n", tcpsend >= 5 ? "yes" : "no");
printf("tcp:::receive - %s\n", tcpreceive >= 5 ? "yes" : "no");
}
EODTRACE
status=$?
cd /
/usr/bin/rm -rf $DIR
exit $status

View File

@ -0,0 +1,7 @@
Minimum TCP events seen
ip:::send - yes
ip:::receive - yes
tcp:::send - yes
tcp:::receive - yes

View File

@ -0,0 +1,93 @@
#!/usr/bin/ksh
#
# 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 (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
#
#
# Test ip:::{send,receive} of IPv4 UDP to a local address.
#
# This may fail due to:
#
# 1. A change to the ip stack breaking expected probe behavior,
# which is the reason we are testing.
# 2. No physical network interface is plumbed and up.
# 3. No other hosts on this subnet are reachable and listening on rpcbind.
# 4. An unlikely race causes the unlocked global send/receive
# variables to be corrupted.
#
# This test sends a UDP message using ping and checks that at least the
# following counts were traced:
#
# 1 x ip:::send (UDP sent to ping's base UDP port)
# 1 x udp:::send (UDP sent to ping's base UDP port)
# 1 x ip:::receive (UDP received)
#
# No udp:::receive event is expected as the response ping -U elicits is
# an ICMP PORT_UNREACHABLE response rather than a UDP packet, and locally
# the echo request UDP packet only reaches IP, so the udp:::receive probe
# is not triggered by it.
#
if (( $# != 1 )); then
print -u2 "expected one argument: <dtrace-path>"
exit 2
fi
dtrace=$1
local=127.0.0.1
$dtrace -c "/usr/sbin/ping -U $local" -qs /dev/stdin <<EOF | grep -v 'is alive'
BEGIN
{
ipsend = udpsend = ipreceive = 0;
}
ip:::send
/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
args[4]->ipv4_protocol == IPPROTO_UDP/
{
ipsend++;
}
udp:::send
/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local"/
{
udpsend++;
}
ip:::receive
/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
args[4]->ipv4_protocol == IPPROTO_UDP/
{
ipreceive++;
}
END
{
printf("Minimum UDP events seen\n\n");
printf("ip:::send - %s\n", ipsend >= 1 ? "yes" : "no");
printf("ip:::receive - %s\n", ipreceive >= 1 ? "yes" : "no");
printf("udp:::send - %s\n", udpsend >= 1 ? "yes" : "no");
}
EOF

View File

@ -0,0 +1,6 @@
Minimum UDP events seen
ip:::send - yes
ip:::receive - yes
udp:::send - yes

View File

@ -0,0 +1,81 @@
#!/usr/bin/ksh
#
# 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 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#pragma ident "%Z%%M% %I% %E% SMI"
#
# Test ip:::{send,receive} of IPv4 ICMP to a remote host.
#
# This may fail due to:
#
# 1. A change to the ip stack breaking expected probe behavior,
# which is the reason we are testing.
# 2. No physical network interface is plumbed and up.
# 3. No other hosts on this subnet are reachable.
# 4. An unrelated ICMP between these hosts was traced by accident.
#
if (( $# != 1 )); then
print -u2 "expected one argument: <dtrace-path>"
exit 2
fi
dtrace=$1
getaddr=./get.ipv4remote.pl
if [[ ! -x $getaddr ]]; then
print -u2 "could not find or execute sub program: $getaddr"
exit 3
fi
$getaddr | read source dest
if (( $? != 0 )); then
exit 4
fi
$dtrace -c "/usr/sbin/ping $dest 3" -qs /dev/stdin <<EOF | \
grep -v 'is alive' | sort -n
ip:::send
/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&
args[4]->ipv4_protocol == IPPROTO_ICMP/
{
printf("1 ip:::send (");
printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
printf("args[4]: %d %d %d %d %d)\n",
args[4]->ipv4_ver, args[4]->ipv4_length, args[4]->ipv4_flags,
args[4]->ipv4_offset, args[4]->ipv4_ttl);
}
ip:::receive
/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" &&
args[4]->ipv4_protocol == IPPROTO_ICMP/
{
printf("2 ip:::receive (");
printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
printf("args[4]: %d %d %d %d %d)\n",
args[4]->ipv4_ver, args[4]->ipv4_length, args[4]->ipv4_flags,
args[4]->ipv4_offset, args[4]->ipv4_ttl);
}
EOF

View File

@ -0,0 +1,3 @@
1 ip:::send (args[2]: 4 64, args[4]: 4 84 0 0 255)
2 ip:::receive (args[2]: 4 64, args[4]: 4 84 4 0 255)

View File

@ -0,0 +1,128 @@
#!/usr/bin/ksh
#
# 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 (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
#
#
# Test {tcp,ip}:::{send,receive} of IPv4 TCP to a remote host.
#
# This may fail due to:
#
# 1. A change to the ip stack breaking expected probe behavior,
# which is the reason we are testing.
# 2. No physical network interface is plumbed and up.
# 3. No other hosts on this subnet are reachable and listening on ssh.
# 4. An unlikely race causes the unlocked global send/receive
# variables to be corrupted.
#
# This test performs a TCP connection and checks that at least the
# following packet counts were traced:
#
# 3 x ip:::send (2 during the TCP handshake, then a FIN)
# 3 x tcp:::send (2 during the TCP handshake, then a FIN)
# 2 x ip:::receive (1 during the TCP handshake, then the FIN ACK)
# 2 x tcp:::receive (1 during the TCP handshake, then the FIN ACK)
#
if (( $# != 1 )); then
print -u2 "expected one argument: <dtrace-path>"
exit 2
fi
dtrace=$1
getaddr=./get.ipv4remote.pl
tcpport=22
DIR=/var/tmp/dtest.$$
if [[ ! -x $getaddr ]]; then
print -u2 "could not find or execute sub program: $getaddr"
exit 3
fi
$getaddr $tcpport | read source dest
if (( $? != 0 )); then
exit 4
fi
mkdir $DIR
cd $DIR
cat > test.pl <<-EOPERL
use IO::Socket;
my \$s = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr => "$dest",
PeerPort => $tcpport,
Timeout => 3);
die "Could not connect to host $dest port $tcpport" unless \$s;
close \$s;
EOPERL
$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin <<EODTRACE
BEGIN
{
ipsend = tcpsend = ipreceive = tcpreceive = 0;
}
ip:::send
/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&
args[4]->ipv4_protocol == IPPROTO_TCP/
{
ipsend++;
}
tcp:::send
/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest"/
{
tcpsend++;
}
ip:::receive
/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" &&
args[4]->ipv4_protocol == IPPROTO_TCP/
{
ipreceive++;
}
tcp:::receive
/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source"/
{
tcpreceive++;
}
END
{
printf("Minimum TCP events seen\n\n");
printf("ip:::send - %s\n", ipsend >= 3 ? "yes" : "no");
printf("ip:::receive - %s\n", ipreceive >= 2 ? "yes" : "no");
printf("tcp:::send - %s\n", tcpsend >= 3 ? "yes" : "no");
printf("tcp:::receive - %s\n", tcpreceive >= 2 ? "yes" : "no");
}
EODTRACE
status=$?
cd /
/usr/bin/rm -rf $DIR
exit $?

View File

@ -0,0 +1,7 @@
Minimum TCP events seen
ip:::send - yes
ip:::receive - yes
tcp:::send - yes
tcp:::receive - yes

View File

@ -0,0 +1,88 @@
#!/usr/bin/ksh
#
# 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 (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
#
#
# Test {udp,ip}:::{send,receive} of IPv4 UDP to a remote host.
#
# This may fail due to:
#
# 1. A change to the ip stack breaking expected probe behavior,
# which is the reason we are testing.
# 2. No physical network interface is plumbed and up.
# 3. No other hosts on this subnet are reachable and listening on rpcbind.
# 4. An unlikely race causes the unlocked global send/receive
# variables to be corrupted.
#
# This test sends a UDP message using ping and checks that at least the
# following counts were traced:
#
# 1 x ip:::send (UDP sent to ping's base UDP port)
# 1 x udp:::send (UDP sent to ping's base UDP port)
#
if (( $# != 1 )); then
print -u2 "expected one argument: <dtrace-path>"
exit 2
fi
dtrace=$1
getaddr=./get.ipv4remote.pl
if [[ ! -x $getaddr ]]; then
print -u2 "could not find or execute sub program: $getaddr"
exit 3
fi
$getaddr | read source dest
if (( $? != 0 )); then
exit 4
fi
$dtrace -c "/usr/sbin/ping -U $dest" -qs /dev/stdin <<EOF | grep -v 'is alive'
BEGIN
{
ipsend = udpsend = 0;
}
ip:::send
/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&
args[4]->ipv4_protocol == IPPROTO_UDP/
{
ipsend++;
}
udp:::send
/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest"/
{
udpsend++;
}
END
{
printf("Minimum UDP events seen\n\n");
printf("ip:::send - %s\n", ipsend >= 1 ? "yes" : "no");
printf("udp:::send - %s\n", udpsend >= 1 ? "yes" : "no");
}
EOF

View File

@ -0,0 +1,5 @@
Minimum UDP events seen
ip:::send - yes
udp:::send - yes

View File

@ -0,0 +1,82 @@
#!/usr/bin/ksh
#
# 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 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#pragma ident "%Z%%M% %I% %E% SMI"
#
# Test ip:::{send,receive} of IPv6 ICMP to a local address. This creates a
# temporary lo0/inet6 interface if one doesn't already exist.
#
# This may fail due to:
#
# 1. A change to the ip stack breaking expected probe behavior,
# which is the reason we are testing.
# 2. Unrelated ICMPv6 on lo0 traced by accident.
#
if (( $# != 1 )); then
print -u2 "expected one argument: <dtrace-path>"
exit 2
fi
dtrace=$1
local=::1
if ! ifconfig lo0 inet6 > /dev/null 2>&1; then
if ! ifconfig lo0 inet6 plumb up; then
print -u2 "could not plumb lo0 inet6 for testing"
exit 3
fi
removeinet6=1
else
removeinet6=0
fi
$dtrace -c "/usr/sbin/ping -A inet6 $local 3" -qs /dev/stdin <<EOF | sort -n
ip:::send
/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
args[5]->ipv6_nexthdr == IPPROTO_ICMPV6/
{
printf("1 ip:::send (");
printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
printf("args[5]: %d %d %d)\n",
args[5]->ipv6_ver, args[5]->ipv6_tclass, args[5]->ipv6_plen);
}
ip:::receive
/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
args[5]->ipv6_nexthdr == IPPROTO_ICMPV6/
{
printf("2 ip:::receive (");
printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
printf("args[5]: %d %d %d)\n",
args[5]->ipv6_ver, args[5]->ipv6_tclass, args[5]->ipv6_plen);
}
EOF
if (( removeinet6 )); then
ifconfig lo0 inet6 unplumb
fi

View File

@ -0,0 +1,6 @@
::1 is alive
1 ip:::send (args[2]: 6 64, args[5]: 6 0 64)
1 ip:::send (args[2]: 6 64, args[5]: 6 0 64)
2 ip:::receive (args[2]: 6 64, args[5]: 6 0 64)
2 ip:::receive (args[2]: 6 64, args[5]: 6 0 64)

View File

@ -0,0 +1,88 @@
#!/usr/bin/ksh
#
# 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 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#pragma ident "%Z%%M% %I% %E% SMI"
#
# Test ip:::{send,receive} of IPv6 ICMP to a remote host. This test is
# skipped if there are no physical interfaces configured with IPv6, or no
# other IPv6 hosts are reachable.
#
# This may fail due to:
#
# 1. A change to the ip stack breaking expected probe behavior,
# which is the reason we are testing.
# 2. An unrelated ICMPv6 between these hosts was traced by accident.
#
if (( $# != 1 )); then
print -u2 "expected one argument: <dtrace-path>"
exit 2
fi
dtrace=$1
getaddr=./get.ipv6remote.pl
if [[ ! -x $getaddr ]]; then
print -u2 "could not find or execute sub program: $getaddr"
exit 3
fi
$getaddr | read source dest
if (( $? != 0 )); then
print -nu2 "Could not find a local IPv6 interface and a remote IPv6 "
print -u2 "host. Aborting test.\n"
print -nu2 "For this test to continue, a \"ping -ns -A inet6 FF02::1\" "
print -u2 "must respond with a\nremote IPv6 host."
exit 3
fi
#
# Shake loose any ICMPv6 Neighbor advertisement messages before tracing.
#
/usr/sbin/ping $dest 3 > /dev/null 2>&1
$dtrace -c "/usr/sbin/ping $dest 3" -qs /dev/stdin <<EOF | \
grep -v 'is alive' | sort -n
ip:::send
/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&
args[5]->ipv6_nexthdr == IPPROTO_ICMPV6/
{
printf("1 ip:::send (");
printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
printf("args[5]: %d %d %d)\n",
args[5]->ipv6_ver, args[5]->ipv6_tclass, args[5]->ipv6_plen);
}
ip:::receive
/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" &&
args[5]->ipv6_nexthdr == IPPROTO_ICMPV6/
{
printf("2 ip:::receive (");
printf("args[2]: %d %d, ", args[2]->ip_ver, args[2]->ip_plength);
printf("args[5]: %d %d %d)\n",
args[5]->ipv6_ver, args[5]->ipv6_tclass, args[5]->ipv6_plen);
}
EOF

View File

@ -0,0 +1,3 @@
1 ip:::send (args[2]: 6 64, args[5]: 6 0 64)
2 ip:::receive (args[2]: 6 64, args[5]: 6 0 64)

View File

@ -0,0 +1,182 @@
#!/usr/bin/ksh
#
# 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 (c) 2010, Oracle and/or its affiliates. All rights reserved.
#
#
# Test tcp:::state-change and tcp:::{send,receive} by connecting to
# the local ssh service and sending a test message. This should result
# in a "Protocol mismatch" response and a close of the connection.
# A number of state transition events along with tcp fusion send and
# receive events for the message should result.
#
# This may fail due to:
#
# 1. A change to the ip stack breaking expected probe behavior,
# which is the reason we are testing.
# 2. The lo0 interface missing or not up.
# 3. The local ssh service is not online.
# 4. An unlikely race causes the unlocked global send/receive
# variables to be corrupted.
#
# This test performs a TCP connection to the ssh service (port 22) and
# checks that at least the following packet counts were traced:
#
# 3 x ip:::send (2 during the TCP handshake, then a FIN)
# 4 x tcp:::send (2 during the TCP handshake, 1 message then a FIN)
# 2 x ip:::receive (1 during the TCP handshake, then the FIN ACK)
# 3 x tcp:::receive (1 during the TCP handshake, 1 message then the FIN ACK)
#
# The actual ip count tested is 5 each way, since we are tracing both
# source and destination events. The actual tcp count tested is 7
# each way, since the TCP fusion send/receive events will not reach IP.
#
# For this test to work, we are assuming that the TCP handshake and
# TCP close will enter the IP code path and not use tcp fusion.
#
if (( $# != 1 )); then
print -u2 "expected one argument: <dtrace-path>"
exit 2
fi
dtrace=$1
local=127.0.0.1
tcpport=22
DIR=/var/tmp/dtest.$$
mkdir $DIR
cd $DIR
cat > test.pl <<-EOPERL
use IO::Socket;
my \$s = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr => "$local",
PeerPort => $tcpport,
Timeout => 3);
die "Could not connect to host $local port $tcpport" unless \$s;
print \$s "testing state machine transitions";
close \$s;
EOPERL
$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin <<EODTRACE
BEGIN
{
ipsend = tcpsend = ipreceive = tcpreceive = 0;
connreq = connest = connaccept = 0;
}
ip:::send
/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
args[4]->ipv4_protocol == IPPROTO_TCP/
{
ipsend++;
}
tcp:::send
/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
(args[4]->tcp_sport == $tcpport || args[4]->tcp_dport == $tcpport)/
{
tcpsend++;
}
ip:::receive
/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
args[4]->ipv4_protocol == IPPROTO_TCP/
{
ipreceive++;
}
tcp:::receive
/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
(args[4]->tcp_sport == $tcpport || args[4]->tcp_dport == $tcpport)/
{
tcpreceive++;
}
tcp:::state-change
{
state_event[args[3]->tcps_state]++;
}
tcp:::connect-request
/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
args[4]->tcp_dport == $tcpport/
{
connreq++;
}
tcp:::connect-established
/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
args[4]->tcp_sport == $tcpport/
{
connest++;
}
tcp:::accept-established
/args[2]->ip_saddr == "$local" && args[2]->ip_daddr == "$local" &&
args[4]->tcp_dport == $tcpport/
{
connaccept++;
}
END
{
printf("Minimum TCP events seen\n\n");
printf("ip:::send - %s\n", ipsend >= 5 ? "yes" : "no");
printf("ip:::receive - %s\n", ipreceive >= 5 ? "yes" : "no");
printf("tcp:::send - %s\n", tcpsend >= 7 ? "yes" : "no");
printf("tcp:::receive - %s\n", tcpreceive >= 7 ? "yes" : "no");
printf("tcp:::state-change to syn-sent - %s\n",
state_event[TCP_STATE_SYN_SENT] >=1 ? "yes" : "no");
printf("tcp:::state-change to syn-received - %s\n",
state_event[TCP_STATE_SYN_RECEIVED] >=1 ? "yes" : "no");
printf("tcp:::state-change to established - %s\n",
state_event[TCP_STATE_ESTABLISHED] >= 2 ? "yes" : "no");
printf("tcp:::state-change to fin-wait-1 - %s\n",
state_event[TCP_STATE_FIN_WAIT_1] >= 1 ? "yes" : "no");
printf("tcp:::state-change to close-wait - %s\n",
state_event[TCP_STATE_CLOSE_WAIT] >= 1 ? "yes" : "no");
printf("tcp:::state-change to fin-wait-2 - %s\n",
state_event[TCP_STATE_FIN_WAIT_2] >= 1 ? "yes" : "no");
printf("tcp:::state-change to last-ack - %s\n",
state_event[TCP_STATE_LAST_ACK] >= 1 ? "yes" : "no");
printf("tcp:::state-change to time-wait - %s\n",
state_event[TCP_STATE_TIME_WAIT] >= 1 ? "yes" : "no");
printf("tcp:::connect-request - %s\n",
connreq >=1 ? "yes" : "no");
printf("tcp:::connect-established - %s\n",
connest >=1 ? "yes" : "no");
printf("tcp:::accept-established - %s\n",
connaccept >=1 ? "yes" : "no");
}
EODTRACE
status=$?
cd /
/usr/bin/rm -rf $DIR
exit $status

View File

@ -0,0 +1,18 @@
Minimum TCP events seen
ip:::send - yes
ip:::receive - yes
tcp:::send - yes
tcp:::receive - yes
tcp:::state-change to syn-sent - yes
tcp:::state-change to syn-received - yes
tcp:::state-change to established - yes
tcp:::state-change to fin-wait-1 - yes
tcp:::state-change to close-wait - yes
tcp:::state-change to fin-wait-2 - yes
tcp:::state-change to last-ack - yes
tcp:::state-change to time-wait - yes
tcp:::connect-request - yes
tcp:::connect-established - yes
tcp:::accept-established - yes

View File

@ -0,0 +1,172 @@
#!/usr/bin/ksh
#
# 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 (c) 2010, Oracle and/or its affiliates. All rights reserved.
#
#
# Test tcp:::state-change and tcp:::{send,receive} by connecting to
# the remote ssh service and sending a test message. This should result
# in a "Protocol mismatch" response and a close of the connection.
# A number of state transition events along with tcp send and receive
# events for the message should result.
#
# This may fail due to:
#
# 1. A change to the ip stack breaking expected probe behavior,
# which is the reason we are testing.
# 2. The lo0 interface missing or not up.
# 3. The remote ssh service is not online.
# 4. An unlikely race causes the unlocked global send/receive
# variables to be corrupted.
#
# This test performs a TCP connection to the ssh service (port 22) and
# checks that at least the following packet counts were traced:
#
# 4 x ip:::send (2 during the TCP handshake, the message, then a FIN)
# 4 x tcp:::send (2 during the TCP handshake, the messages, then a FIN)
# 3 x ip:::receive (1 during the TCP handshake, the response, then the FIN ACK)
# 3 x tcp:::receive (1 during the TCP handshake, the response, then the FIN ACK)
#
# For this test to work, we are assuming that the TCP handshake and
# TCP close will enter the IP code path and not use tcp fusion.
#
if (( $# != 1 )); then
print -u2 "expected one argument: <dtrace-path>"
exit 2
fi
dtrace=$1
getaddr=./get.ipv4remote.pl
tcpport=22
DIR=/var/tmp/dtest.$$
if [[ ! -x $getaddr ]]; then
print -u2 "could not find or execute sub program: $getaddr"
exit 3
fi
$getaddr $tcpport | read source dest
if (( $? != 0 )); then
exit 4
fi
mkdir $DIR
cd $DIR
cat > test.pl <<-EOPERL
use IO::Socket;
my \$s = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr => "$dest",
PeerPort => $tcpport,
Timeout => 3);
die "Could not connect to host $dest port $tcpport" unless \$s;
print \$s "testing state machine transitions";
close \$s;
EOPERL
$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin <<EODTRACE
BEGIN
{
ipsend = tcpsend = ipreceive = tcpreceive = 0;
connreq = connest = 0;
}
ip:::send
/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&
args[4]->ipv4_protocol == IPPROTO_TCP/
{
ipsend++;
}
tcp:::send
/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&
args[4]->tcp_dport == $tcpport/
{
tcpsend++;
}
ip:::receive
/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" &&
args[4]->ipv4_protocol == IPPROTO_TCP/
{
ipreceive++;
}
tcp:::receive
/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" &&
args[4]->tcp_sport == $tcpport/
{
tcpreceive++;
}
tcp:::state-change
{
state_event[args[3]->tcps_state]++;
}
tcp:::connect-request
/args[2]->ip_saddr == "$source" && args[2]->ip_daddr == "$dest" &&
args[4]->tcp_dport == $tcpport/
{
connreq++;
}
tcp:::connect-established
/args[2]->ip_saddr == "$dest" && args[2]->ip_daddr == "$source" &&
args[4]->tcp_sport == $tcpport/
{
connest++;
}
END
{
printf("Minimum TCP events seen\n\n");
printf("ip:::send - %s\n", ipsend >= 4 ? "yes" : "no");
printf("ip:::receive - %s\n", ipreceive >= 3 ? "yes" : "no");
printf("tcp:::send - %s\n", tcpsend >= 4 ? "yes" : "no");
printf("tcp:::receive - %s\n", tcpreceive >= 3 ? "yes" : "no");
printf("tcp:::state-change to syn-sent - %s\n",
state_event[TCP_STATE_SYN_SENT] >=1 ? "yes" : "no");
printf("tcp:::state-change to established - %s\n",
state_event[TCP_STATE_ESTABLISHED] >= 1 ? "yes" : "no");
printf("tcp:::state-change to fin-wait-1 - %s\n",
state_event[TCP_STATE_FIN_WAIT_1] >= 1 ? "yes" : "no");
printf("tcp:::state-change to fin-wait-2 - %s\n",
state_event[TCP_STATE_FIN_WAIT_2] >= 1 ? "yes" : "no");
printf("tcp:::state-change to time-wait - %s\n",
state_event[TCP_STATE_TIME_WAIT] >= 1 ? "yes" : "no");
printf("tcp:::connect-request - %s\n",
connreq >=1 ? "yes" : "no");
printf("tcp:::connect-established - %s\n",
connest >=1 ? "yes" : "no");
}
EODTRACE
status=$?
cd /
/usr/bin/rm -rf $DIR
exit $status

View File

@ -0,0 +1,15 @@
Minimum TCP events seen
ip:::send - yes
ip:::receive - yes
tcp:::send - yes
tcp:::receive - yes
tcp:::state-change to syn-sent - yes
tcp:::state-change to established - yes
tcp:::state-change to fin-wait-1 - yes
tcp:::state-change to close-wait - yes
tcp:::state-change to fin-wait-2 - yes
tcp:::state-change to time-wait - yes
tcp:::connect-request - yes
tcp:::connect-established - yes

View File

@ -20,10 +20,8 @@
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* ident "%Z%%M% %I% %E% SMI"
*/
import org.opensolaris.os.dtrace.*;
@ -70,7 +68,7 @@ public class TestFunctionLookup {
long addr = (Long)address;
f = consumer.lookupKernelFunction(addr);
}
if (f.equals("genunix`setrun")) {
if (f.equals("genunix`cv_wakeup")) {
System.out.println(f);
done = true;
}

View File

@ -0,0 +1,252 @@
/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
import org.opensolaris.os.dtrace.*;
import java.util.*;
/**
* Assert getAggregate() can explicitly specify the anonymous aggregation.
*/
public class TestGetAggregate {
static final String programString =
"profile:::tick-50ms" +
"{" +
" @ = count();" +
" @a = count();" +
"}";
static final String ANONYMOUS_AGGREGATION = "";
static final int TICK = 50;
static final int EXPECTED_TICKS = 3;
static final int INTERVALS = 4;
static void
testIncluded(Consumer consumer, String ... aggregationNames)
throws DTraceException, InterruptedException
{
Aggregate aggregate;
Set <String> included = new HashSet <String> ();
int n = 1;
for (String name : aggregationNames) {
included.add(name);
}
// Wait up to a full second to obtain aggregate data. Without a
// time limit, we'll loop forever if no aggregation was
// successfully included.
do {
Thread.sleep(TICK);
aggregate = consumer.getAggregate(included, null);
} while (aggregate.asMap().isEmpty() && n++ < (1000 / TICK));
for (String name : included) {
if (aggregate.getAggregation(name) == null) {
throw new IllegalStateException("@" + name +
" was explicitly included but did not appear " +
"in the aggregate");
}
}
for (Aggregation a : aggregate.getAggregations()) {
if (!included.contains(a.getName())) {
throw new IllegalStateException("@" + a.getName() +
" was not explicitly included but appeared " +
"in the aggregate anyway");
}
}
if (!consumer.isRunning()) {
throw new IllegalStateException("consumer exited");
}
}
static void
testCleared(Consumer consumer, String ... aggregationNames)
throws DTraceException, InterruptedException
{
Aggregate aggregate;
AggregationRecord rec;
long value;
Long firstValue;
int n = 1;
Map <String, Long> firstValues = new HashMap <String, Long> ();
Set <String> cleared = new HashSet <String> ();
for (String name : aggregationNames) {
cleared.add(name);
}
do {
Thread.sleep(TICK);
aggregate = consumer.getAggregate(null, cleared);
} while (aggregate.asMap().isEmpty() && n++ < (1000 / TICK));
n = 1;
do {
Thread.sleep(TICK * EXPECTED_TICKS);
aggregate = consumer.getAggregate(null, cleared);
for (Aggregation a : aggregate.getAggregations()) {
if (!firstValues.containsKey(a.getName())) {
rec = a.getRecord(Tuple.EMPTY);
value = rec.getValue().getValue().longValue();
firstValues.put(a.getName(), value);
}
}
} while (consumer.isRunning() && n++ < INTERVALS);
for (Aggregation a : aggregate.getAggregations()) {
rec = a.getRecord(Tuple.EMPTY);
value = rec.getValue().getValue().longValue();
firstValue = firstValues.get(a.getName());
if (cleared.contains(a.getName())) {
// last value should be about the same as first value
if (value > (firstValue * 2)) {
throw new IllegalStateException(
"@" + a.getName() + " should have " +
"been cleared but instead grew from " +
firstValue + " to " + value);
}
} else {
// last value should be about (INTERVALS * firstValue)
if (value < (firstValue * 2)) {
throw new IllegalStateException(
"@" + a.getName() + " should have " +
"accumulated a running total but " +
"instead went from " +
firstValue + " to " + value);
}
}
}
if (!consumer.isRunning()) {
throw new IllegalStateException("consumer exited");
}
}
static Integer includedStatus;
static Integer clearedStatus;
static void
startIncludedTest()
{
final Consumer consumer = new LocalConsumer();
consumer.addConsumerListener(new ConsumerAdapter() {
public void consumerStarted(ConsumerEvent e) {
new Thread(new Runnable() {
public void run() {
try {
testIncluded(consumer, ANONYMOUS_AGGREGATION);
includedStatus = 0;
} catch (Exception e) {
includedStatus = 1;
e.printStackTrace();
} finally {
consumer.abort();
}
}
}).start();
}
});
try {
consumer.open();
consumer.setOption(Option.aggrate, Option.millis(TICK));
consumer.compile(programString);
consumer.enable();
consumer.go();
} catch (Exception e) {
includedStatus = 1;
e.printStackTrace();
}
}
static void
startClearedTest()
{
final Consumer consumer = new LocalConsumer();
consumer.addConsumerListener(new ConsumerAdapter() {
public void consumerStarted(ConsumerEvent e) {
new Thread(new Runnable() {
public void run() {
try {
testCleared(consumer, ANONYMOUS_AGGREGATION);
clearedStatus = 0;
} catch (Exception e) {
clearedStatus = 1;
e.printStackTrace();
} finally {
consumer.abort();
}
}
}).start();
}
});
try {
consumer.open();
consumer.setOption(Option.aggrate, Option.millis(TICK));
consumer.compile(programString);
consumer.enable();
consumer.go();
} catch (Exception e) {
clearedStatus = 1;
e.printStackTrace();
}
}
public static void
main(String[] args)
{
startIncludedTest();
do {
try {
Thread.sleep(TICK);
} catch (InterruptedException e) {
e.printStackTrace();
}
} while (includedStatus == null);
startClearedTest();
do {
try {
Thread.sleep(TICK);
} catch (InterruptedException e) {
e.printStackTrace();
}
} while (clearedStatus == null);
if (includedStatus != 0 || clearedStatus != 0) {
System.out.println("Failure");
System.exit(1);
}
System.out.println("Success");
}
}

View File

@ -1,3 +1,3 @@
genunix`setrun
genunix`cv_wakeup
3
tst.FunctionLookup.exe`f1

View File

@ -0,0 +1,36 @@
#!/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 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
############################################################################
# ASSERTION:
# getAggregate() can explicitly specify the anonymous aggregation
#
# SECTION: Java API
#
############################################################################
java -cp test.jar TestGetAggregate

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,29 @@
#!/bin/ksh
#
# 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"
sleep 1000000

View File

@ -0,0 +1,29 @@
#!/bin/bash
#
# 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"
sleep 1000000

View File

@ -0,0 +1,29 @@
#!/bin/ksh
#
# 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"
sleep 1000000

View File

@ -0,0 +1,29 @@
#!/bin/ksh
#
# 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"
sleep 1000000

View File

@ -0,0 +1,29 @@
#!/bin/ksh
#
# 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"
sleep 1000000

View File

@ -0,0 +1,29 @@
#!/bin/ksh
#
# 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"
sleep 1000000

View File

@ -0,0 +1,29 @@
#!/bin/ksh
#
# 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"
sleep 1000000

View File

@ -0,0 +1,29 @@
#!/bin/ksh
#
# 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"
sleep 1000000

View File

@ -0,0 +1,29 @@
#!/usr/bin/ksh
#
# 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"
while true; do env > /dev/null; done

View File

@ -0,0 +1,29 @@
#!/usr/bin/ksh
#
# 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"
exec find / > /dev/null 2>&1

View File

@ -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

View File

@ -21,11 +21,9 @@
#
#
# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
#
if [ $# != 1 ]; then
echo expected one argument: '<'dtrace-path'>'
@ -40,7 +38,7 @@ dtrace=$1
# (and therefore 'libc' and 'libc.so') as it's definitely there.
#
for lib in libc libc.so libc.so.1; do
for lib in libc libc.so libc.so.1 'lib[c]*'; do
sleep 60 &
pid=$!
dtrace -n "pid$pid:$lib::entry" -n 'tick-2s{exit(0);}'

View File

@ -0,0 +1,29 @@
#!/usr/bin/ksh
#
# 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"
sleep 100000000

View File

@ -0,0 +1,29 @@
#!/usr/bin/ksh
#
# 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"
sleep 100000000

View File

@ -20,15 +20,13 @@
*/
/*
* Copyright 2006 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"
/*
* ASSERTION:
* Test the basic formatting of all the supported kinds of aggregations.
* Test the basic formatting of all the supported kinds of aggregations.
*
* SECTION: Output Formatting/printa()
*
@ -45,6 +43,7 @@ BEGIN
@e = min(1);
@f = sum(1);
@g = quantize(1);
@h = stddev(1);
printa("@a = %@u\n", @a);
printa("@b = %@u\n", @b);
@ -53,6 +52,7 @@ BEGIN
printa("@e = %@u\n", @e);
printa("@f = %@u\n", @f);
printa("@g = %@d\n", @g);
printa("@h = %@d\n", @h);
exit(0);
}

View File

@ -15,4 +15,5 @@
1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
2 | 0
@h = 0

View File

@ -0,0 +1,83 @@
#
# 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
DIR=/var/tmp/dtest.$$
mkdir $DIR
cd $DIR
cat > test.c <<EOF
void
thequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydog(void)
{
while (1)
;
}
int
main(int argc, char *argv[])
{
thequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydog();
}
EOF
cc -o test test.c
if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
script()
{
$dtrace -c ./test -qs /dev/stdin <<EOF
profile:::profile-1001hz
/pid == \$target/
{
@[arg1] = count();
}
tick-1s
/n++ > 10/
{
printa("%A %@d\n", @);
exit(0);
}
EOF
}
script
status=$?
cd /
/usr/bin/rm -rf $DIR
exit $status

View File

@ -20,12 +20,10 @@
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* ASSERTION:
* Test printf() with a simple string argument.
@ -38,6 +36,6 @@
BEGIN
{
printf("rootfs = %s", `rootfs.bo_fstype);
printf("sysname = %s", `utsname.sysname);
exit(0);
}

View File

@ -1 +1 @@
rootfs = ufs
sysname = SunOS

View File

@ -0,0 +1,45 @@
/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <unistd.h>
#include <sys/uadmin.h>
int
main(int argc, char **argv)
{
while (1) {
if (uadmin(A_SDTTEST, 0, 0) < 0) {
perror("uadmin");
return (1);
}
sleep(1);
}
return (0);
}

View File

@ -0,0 +1,67 @@
/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* ASSERTION: Verify that argN (1..7) variables are properly remapped.
*/
BEGIN
{
/* Timeout after 5 seconds */
timeout = timestamp + 5000000000;
ignore = $1;
}
ERROR
{
printf("sdt:::test failed.\n");
exit(1);
}
sdt:::test
/arg0 != 1 || arg1 != 2 || arg2 != 3 || arg3 != 4 || arg4 != 5 || arg5 != 6 ||
arg6 != 7/
{
printf("sdt arg mismatch\n\n");
printf("args are : %d, %d, %d, %d, %d, %d, %d\n", arg0, arg1, arg2,
arg3, arg4, arg5, arg6);
printf("should be : 1, 2, 3, 4, 5, 6, 7\n");
exit(1);
}
sdt:::test
{
exit(0);
}
profile:::tick-1
/timestamp > timeout/
{
trace("test timed out");
exit(1);
}

View File

@ -0,0 +1,65 @@
/*
* 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.
*/
/*
* ASSERTION:
* Aggregating actions may never be speculative.
*
* SECTION: Speculative Tracing/Using a Speculation
*
*/
#pragma D option quiet
BEGIN
{
i = 0;
}
profile:::tick-1sec
/i < 1/
{
var = speculation();
speculate(var);
printf("Speculation ID: %d", var);
@sdev["speculate"] = stddev(i);
i++;
}
profile:::tick-1sec
/1 == i/
{
exit(0);
}
ERROR
{
exit(0);
}
END
{
exit(0);
}

View File

@ -19,12 +19,10 @@
* 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"
#include <libsysevent.h>
#include <stdio.h>
@ -42,7 +40,7 @@ main(int argc, char **argv)
for (;;) {
if (sysevent_evc_publish(ch, "class_dtest", "subclass_dtest",
"vendor_dtest", "publisher_dtest", NULL, EVCH_SLEEP) != 0) {
sysevent_evc_unbind(ch);
(void) sysevent_evc_unbind(ch);
(void) fprintf(stderr, "failed to publisth sysevent\n");
return (1);
}

View File

@ -0,0 +1,107 @@
#!/usr/bin/ksh
#
# 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 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# This test verifies that a program that corrupts its own environment
# without inducing a crash does not crash solely due to drti.o's use of
# getenv(3C).
#
PATH=/usr/bin:/usr/sbin:$PATH
if (( $# != 1 )); then
print -u2 'expected one argument: <dtrace-path>'
exit 2
fi
#
# jdtrace does not implement the -h option that is required to generate
# C header files.
#
if [[ "$1" == */jdtrace ]]; then
exit 0
fi
dtrace="$1"
startdir="$PWD"
dir=$(mktemp -td drtiXXXXXX)
if (( $? != 0 )); then
print -u2 'Could not create safe temporary directory'
exit 2
fi
cd "$dir"
cat > Makefile <<EOF
all: main
main: main.o prov.o
\$(CC) -o main main.o prov.o
main.o: main.c prov.h
\$(CC) -c main.c
prov.h: prov.d
$dtrace -h -s prov.d
prov.o: prov.d main.o
$dtrace -G -32 -s prov.d main.o
EOF
cat > prov.d <<EOF
provider tester {
probe entry();
};
EOF
cat > main.c <<EOF
#include <stdlib.h>
#include <sys/sdt.h>
#include "prov.h"
int
main(int argc, char **argv, char **envp)
{
envp[0] = (char*)0xff;
TESTER_ENTRY();
return 0;
}
EOF
make > /dev/null
status=$?
if (( $status != 0 )) ; then
print -u2 "failed to build"
else
./main
status=$?
fi
cd "$startdir"
rm -rf "$dir"
exit $status

View File

@ -0,0 +1,113 @@
#
# 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 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#ident "%Z%%M% %I% %E% SMI"
#
# This test is primarily intended to verify a fix for SPARC, but there's no
# harm in running it on other platforms. Here, we verify that is-enabled
# probes don't interfere with return values from previously invoked functions.
#
if [ $# != 1 ]; then
echo expected one argument: '<'dtrace-path'>'
exit 2
fi
dtrace=$1
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 <stdio.h>
#include "prov.h"
int
foo(void)
{
return (24);
}
int
main(int argc, char **argv)
{
int a = foo();
if (TEST_PROV_GO_ENABLED()) {
TEST_PROV_GO();
}
(void) printf("%d %d %d\n", a, a, a);
return (0);
}
EOF
cc -c -xO2 test.c
if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1
fi
cc -o test test.o prov.o
if [ $? -ne 0 ]; then
print -u2 "failed to link final executable"
exit 1
fi
script()
{
./test
$dtrace -c ./test -qs /dev/stdin <<EOF
test_prov\$target:::
{
}
EOF
}
script
status=$?
cd /
/usr/bin/rm -rf $DIR
exit $status

View File

@ -0,0 +1,3 @@
24 24 24
24 24 24

View File

@ -20,12 +20,10 @@
*/
/*
* Copyright 2006 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"
/*
* ASSERTION:
* On IA/32, there is a single 32-bit address space that is partitioned
@ -43,11 +41,12 @@
BEGIN
{
lbolt = copyin((uintptr_t)&`lbolt, sizeof (int));
dtrace_zero = copyin((uintptr_t)&`dtrace_zero, sizeof (int));
exit(1);
}
ERROR
{
exit(arg4 == DTRACEFLT_BADADDR && arg5 == (uint64_t)&`lbolt ? 0 : 1);
exit(arg4 == DTRACEFLT_BADADDR &&
arg5 == (uint64_t)&`dtrace_zero ? 0 : 1);
}

View File

@ -0,0 +1,77 @@
#
# 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.
#
#
# ASSERTION: Make sure that we can map in and read the Xen trace buffers.
#
if [ $# != 1 ]; then
echo expected one argument: '<'dtrace-path'>'
exit 2
fi
#
# Do not fail the test in a domU
#
if [ ! -c /dev/xen/privcmd ]; then
exit 0
fi
dtrace=$1
script()
{
$dtrace -qs /dev/stdin <<EOF
xdt:sched::on-cpu
/arg0 == 0/
{
self->on++;
}
xdt:sched::off-cpu
/arg0 == 0 && self->on/
{
self->off++;
}
xdt:sched::off-cpu
/self->on > 50 && self->off > 50/
{
exit(0);
}
profile:::tick-1sec
/n++ > 10/
{
exit(1);
}
EOF
}
script
status=$?
exit $status

View File

@ -0,0 +1,64 @@
#
# 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 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
#
#
# ASSERTION: HVM probes should enable successfully.
#
if [ $# != 1 ]; then
echo expected one argument: '<'dtrace-path'>'
exit 2
fi
#
# Do not fail the test in a domU
#
if [ ! -c /dev/xen/privcmd ]; then
exit 0
fi
dtrace=$1
script()
{
$dtrace -qs /dev/stdin <<EOF
dtrace:::BEGIN
{
exit(0);
}
xdt:hvm::vmentry,
xdt:hvm::vmexit
{}
EOF
}
script
status=$?
exit $status

View File

@ -0,0 +1,65 @@
#
# 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 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
#
#
# ASSERTION: Mem probes should enable successfully.
#
if [ $# != 1 ]; then
echo expected one argument: '<'dtrace-path'>'
exit 2
fi
#
# Do not fail the test in a domU
#
if [ ! -c /dev/xen/privcmd ]; then
exit 0
fi
dtrace=$1
script()
{
$dtrace -qs /dev/stdin <<EOF
dtrace:::BEGIN
{
exit(0);
}
xdt:mem::page-grant-map,
xdt:mem::page-grant-unmap,
xdt:mem::page-grant-transfer
{}
EOF
}
script
status=$?
exit $status

View File

@ -0,0 +1,121 @@
#
# 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.
#
#
# ASSERTION: Sched probe arguments should be valid.
#
if [ $# != 1 ]; then
echo expected one argument: '<'dtrace-path'>'
exit 2
fi
#
# do not fail test in a domU
#
if [ ! -c /dev/xen/privcmd ]; then
exit 0
fi
dtrace=$1
outf=/tmp/sched.args.$$
script()
{
$dtrace -c '/usr/bin/sleep 10' -o $outf -qs /dev/stdin <<EOF
xdt:sched::off-cpu,
xdt:sched::on-cpu,
xdt:sched::block,
xdt:sched::sleep,
xdt:sched::wake,
xdt:sched::yield
{
/* print domid vcpu pcpu probename */
printf("%d %d %d %s\n", arg0, arg1, \`xdt_curpcpu, probename);
}
EOF
}
validate()
{
/usr/bin/nawk '
BEGIN {
while (("/usr/sbin/xm vcpu-list" | getline)) {
if ($1 != "Name") {
domid = $2
vcpu = $3
vcpumap[domid, vcpu] = 1
split($7, affinity, ",")
for (i in affinity) {
if (split(affinity[i], p, "-") > 1) {
for (pcpu = p[1]; pcpu <= p[2];\
pcpu++) {
cpumap[domid, vcpu,
pcpu] = 1
}
} else {
cpumap[domid, vcpu,
affinity[i]] = 1
}
}
}
}
}
/^$/ { next }
/wake/ {
if (vcpumap[$1, $2]) {
next
} else {
print "error: " $0
exit 1
}
}
{
if (cpumap[$1, $2, "any"] || cpumap[$1, $2, $3]) {
next
} else {
print "error: " $0
exit 1
}
}
' $outf
}
script
status=$?
if [ $status == 0 ]; then
validate
status=$?
fi
rm $outf
exit $status

View File

@ -0,0 +1,74 @@
#
# 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 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
#
#
# ASSERTION: Sched probes should enable successfully.
#
if [ $# != 1 ]; then
echo expected one argument: '<'dtrace-path'>'
exit 2
fi
#
# do not fail test in a domU
#
if [ ! -c /dev/xen/privcmd ]; then
exit 0
fi
dtrace=$1
script()
{
$dtrace -qs /dev/stdin <<EOF
dtrace:::BEGIN
{
exit(0);
}
xdt:sched::off-cpu,
xdt:sched::on-cpu,
xdt:sched::idle-off-cpu,
xdt:sched::idle-on-cpu,
xdt:sched::block,
xdt:sched::sleep,
xdt:sched::wake,
xdt:sched::yield,
xdt:sched::shutdown-poweroff,
xdt:sched::shutdown-reboot,
xdt:sched::shutdown-suspend,
xdt:sched::shutdown-crash
{}
EOF
}
script
status=$?
exit $status

View File

@ -0,0 +1,29 @@
#!/bin/ksh
#
# 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"
sleep 1000000

View File

@ -19,13 +19,10 @@
* CDDL HEADER END
*/
/*
* Copyright 2006 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"
/*
* AVL - generic AVL tree implementation for kernel use
*
@ -243,7 +240,7 @@ avl_nearest(avl_tree_t *tree, avl_index_t where, int direction)
* "void *" of the found tree node
*/
void *
avl_find(avl_tree_t *tree, void *value, avl_index_t *where)
avl_find(avl_tree_t *tree, const void *value, avl_index_t *where)
{
avl_node_t *node;
avl_node_t *prev = NULL;
@ -808,6 +805,64 @@ avl_remove(avl_tree_t *tree, void *data)
} while (parent != NULL);
}
#define AVL_REINSERT(tree, obj) \
avl_remove((tree), (obj)); \
avl_add((tree), (obj))
boolean_t
avl_update_lt(avl_tree_t *t, void *obj)
{
void *neighbor;
ASSERT(((neighbor = AVL_NEXT(t, obj)) == NULL) ||
(t->avl_compar(obj, neighbor) <= 0));
neighbor = AVL_PREV(t, obj);
if ((neighbor != NULL) && (t->avl_compar(obj, neighbor) < 0)) {
AVL_REINSERT(t, obj);
return (B_TRUE);
}
return (B_FALSE);
}
boolean_t
avl_update_gt(avl_tree_t *t, void *obj)
{
void *neighbor;
ASSERT(((neighbor = AVL_PREV(t, obj)) == NULL) ||
(t->avl_compar(obj, neighbor) >= 0));
neighbor = AVL_NEXT(t, obj);
if ((neighbor != NULL) && (t->avl_compar(obj, neighbor) > 0)) {
AVL_REINSERT(t, obj);
return (B_TRUE);
}
return (B_FALSE);
}
boolean_t
avl_update(avl_tree_t *t, void *obj)
{
void *neighbor;
neighbor = AVL_PREV(t, obj);
if ((neighbor != NULL) && (t->avl_compar(obj, neighbor) < 0)) {
AVL_REINSERT(t, obj);
return (B_TRUE);
}
neighbor = AVL_NEXT(t, obj);
if ((neighbor != NULL) && (t->avl_compar(obj, neighbor) > 0)) {
AVL_REINSERT(t, obj);
return (B_TRUE);
}
return (B_FALSE);
}
/*
* initialize a new AVL tree
*/
@ -853,6 +908,12 @@ avl_numnodes(avl_tree_t *tree)
return (tree->avl_numnodes);
}
boolean_t
avl_is_empty(avl_tree_t *tree)
{
ASSERT(tree);
return (tree->avl_numnodes == 0);
}
#define CHILDBIT (1L)

View File

@ -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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <unistd.h>
#include <fcntl.h>
#include <dlfcn.h>
@ -61,13 +58,14 @@ static const char *olddevname = "/devices/pseudo/dtrace@0:helper";
static const char *modname; /* Name of this load object */
static int gen; /* DOF helper generation */
extern dof_hdr_t __SUNW_dof; /* DOF defined in the .SUNW_dof section */
static boolean_t dof_init_debug = B_FALSE; /* From DTRACE_DOF_INIT_DEBUG */
static void
dprintf(int debug, const char *fmt, ...)
{
va_list ap;
if (debug && getenv("DTRACE_DOF_INIT_DEBUG") == NULL)
if (debug && !dof_init_debug)
return;
va_start(ap, fmt);
@ -104,6 +102,9 @@ dtrace_dof_init(void)
if (getenv("DTRACE_DOF_INIT_DISABLE") != NULL)
return;
if (getenv("DTRACE_DOF_INIT_DEBUG") != NULL)
dof_init_debug = B_TRUE;
if (dlinfo(RTLD_SELF, RTLD_DI_LINKMAP, &lmp) == -1 || lmp == NULL) {
dprintf(1, "couldn't discover module name or address\n");
return;

View File

@ -20,12 +20,9 @@
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* DTrace D Language Compiler
*
@ -2069,11 +2066,11 @@ dt_compile(dtrace_hdl_t *dtp, int context, dtrace_probespec_t pspec, void *arg,
if (dt_list_next(&dtp->dt_lib_path) != NULL && dt_load_libs(dtp) != 0)
return (NULL); /* errno is set for us */
(void) ctf_discard(dtp->dt_cdefs->dm_ctfp);
(void) ctf_discard(dtp->dt_ddefs->dm_ctfp);
if (dtp->dt_globals->dh_nelems != 0)
(void) dt_idhash_iter(dtp->dt_globals, dt_idreset, NULL);
(void) dt_idhash_iter(dtp->dt_globals, dt_idreset, NULL);
(void) dt_idhash_iter(dtp->dt_tls, dt_idreset, NULL);
if (dtp->dt_tls->dh_nelems != 0)
(void) dt_idhash_iter(dtp->dt_tls, dt_idreset, NULL);
if (fp && (cflags & DTRACE_C_CPP) && (fp = dt_preproc(dtp, fp)) == NULL)
return (NULL); /* errno is set for us */

View File

@ -19,12 +19,10 @@
* CDDL HEADER END
*/
/*
* Copyright 2008 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 <stdlib.h>
#include <strings.h>
#include <errno.h>
@ -1063,7 +1061,7 @@ dt_print_usym(dtrace_hdl_t *dtp, FILE *fp, caddr_t addr, dtrace_actkind_t act)
do {
n = len;
s = alloca(n);
} while ((len = dtrace_uaddr2str(dtp, pid, pc, s, n)) >= n);
} while ((len = dtrace_uaddr2str(dtp, pid, pc, s, n)) > n);
return (dt_printf(dtp, fp, format, s));
}

View File

@ -20,12 +20,9 @@
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/types.h>
#include <sys/sysmacros.h>
@ -834,7 +831,6 @@ dtrace_dof_create(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t flags)
*/
h.dofh_secnum = ddo->ddo_nsecs;
ssize = sizeof (h) + dt_buf_len(&ddo->ddo_secs);
assert(ssize == sizeof (h) + sizeof (dof_sec_t) * ddo->ddo_nsecs);
h.dofh_loadsz = ssize +
dt_buf_len(&ddo->ddo_ldata) +
@ -860,6 +856,7 @@ dtrace_dof_create(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t flags)
sp = dt_buf_ptr(&ddo->ddo_secs);
assert(sp[ddo->ddo_strsec].dofs_type == DOF_SECT_STRTAB);
assert(ssize == sizeof (h) + sizeof (dof_sec_t) * ddo->ddo_nsecs);
sp[ddo->ddo_strsec].dofs_offset = ssize + dt_buf_len(&ddo->ddo_ldata);
sp[ddo->ddo_strsec].dofs_size = dt_buf_len(&ddo->ddo_strs);

View File

@ -19,12 +19,10 @@
* 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"
#include <strings.h>
#include <dt_impl.h>
@ -105,7 +103,8 @@ static const struct {
{ EDT_BADSETOPT, "Invalid setopt() library action" },
{ EDT_BADSTACKPC, "Invalid stack program counter size" },
{ EDT_BADAGGVAR, "Invalid aggregation variable identifier" },
{ EDT_OVERSION, "Client requested deprecated version of library" }
{ EDT_OVERSION, "Client requested deprecated version of library" },
{ EDT_ENABLING_ERR, "Failed to enable probe" }
};
static const int _dt_nerr = sizeof (_dt_errlist) / sizeof (_dt_errlist[0]);

View File

@ -20,21 +20,20 @@
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _DT_IMPL_H
#define _DT_IMPL_H
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/param.h>
#include <sys/objfs.h>
#include <setjmp.h>
#include <libctf.h>
#include <dtrace.h>
#include <gelf.h>
#include <synch.h>
#ifdef __cplusplus
extern "C" {
@ -498,7 +497,8 @@ enum {
EDT_BADSETOPT, /* invalid setopt library action */
EDT_BADSTACKPC, /* invalid stack program counter size */
EDT_BADAGGVAR, /* invalid aggregation variable identifier */
EDT_OVERSION /* client is requesting deprecated version */
EDT_OVERSION, /* client is requesting deprecated version */
EDT_ENABLING_ERR /* failed to enable probe */
};
/*
@ -568,17 +568,8 @@ extern int dt_buffered_flush(dtrace_hdl_t *, dtrace_probedata_t *,
extern void dt_buffered_disable(dtrace_hdl_t *);
extern void dt_buffered_destroy(dtrace_hdl_t *);
extern int dt_rw_read_held(pthread_rwlock_t *);
extern int dt_rw_write_held(pthread_rwlock_t *);
extern int dt_mutex_held(pthread_mutex_t *);
extern uint64_t dt_stddev(uint64_t *, uint64_t);
#define DT_RW_READ_HELD(x) dt_rw_read_held(x)
#define DT_RW_WRITE_HELD(x) dt_rw_write_held(x)
#define DT_RW_LOCK_HELD(x) (DT_RW_READ_HELD(x) || DT_RW_WRITE_HELD(x))
#define DT_MUTEX_HELD(x) dt_mutex_held(x)
extern int dt_options_load(dtrace_hdl_t *);
extern void dt_dprintf(const char *, ...);

View File

@ -18,12 +18,11 @@
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <string.h>
#include <stdlib.h>
@ -803,7 +802,7 @@ input(void)
else if (yypcb->pcb_fileptr != NULL)
c = fgetc(yypcb->pcb_fileptr);
else if (yypcb->pcb_strptr < yypcb->pcb_string + yypcb->pcb_strlen)
c = *yypcb->pcb_strptr++;
c = *(unsigned char *)(yypcb->pcb_strptr++);
else
c = EOF;

View File

@ -776,15 +776,19 @@ dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela,
/*
* We may have already processed this object file in an earlier linker
* invocation. Check to see if the present instruction sequence matches
* the one we would install.
* the one we would install below.
*/
if (isenabled) {
if (ip[0] == DT_OP_CLR_O0)
if (ip[0] == DT_OP_NOP) {
(*off) += sizeof (ip[0]);
return (0);
}
} else {
if (DT_IS_RESTORE(ip[1])) {
if (ip[0] == DT_OP_RET)
if (ip[0] == DT_OP_RET) {
(*off) += sizeof (ip[0]);
return (0);
}
} else if (DT_IS_MOV_O7(ip[1])) {
if (DT_IS_RETL(ip[0]))
return (0);
@ -818,7 +822,17 @@ dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela,
return (-1);
}
ip[0] = DT_OP_CLR_O0;
/*
* On SPARC, we take advantage of the fact that the first
* argument shares the same register as for the return value.
* The macro handles the work of zeroing that register so we
* don't need to do anything special here. We instrument the
* instruction in the delay slot as we'll need to modify the
* return register after that instruction has been emulated.
*/
ip[0] = DT_OP_NOP;
(*off) += sizeof (ip[0]);
} else {
/*
* If the call is followed by a restore, it's a tail call so
@ -827,11 +841,16 @@ dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela,
* so change the call to a retl-like instruction that returns
* to that register value + 8 (rather than the typical %o7 +
* 8); the delay slot instruction is left, but should have no
* effect. Otherwise we change the call to be a nop. In the
* first and the last case we adjust the offset to land on what
* was once the delay slot of the call so we correctly get all
* the arguments as they would have been passed in a normal
* function call.
* effect. Otherwise we change the call to be a nop. We
* identify the subsequent instruction as the probe point in
* all but the leaf tail-call case to ensure that arguments to
* the probe are complete and consistent. An astute, though
* largely hypothetical, observer would note that there is the
* possibility of a false-positive probe firing if the function
* contained a branch to the instruction in the delay slot of
* the call. Fixing this would require significant in-kernel
* modifications, and isn't worth doing until we see it in the
* wild.
*/
if (DT_IS_RESTORE(ip[1])) {
ip[0] = DT_OP_RET;

View File

@ -18,12 +18,10 @@
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <sys/types.h>
#include <sys/modctl.h>
@ -66,6 +64,10 @@ dt_module_symhash_insert(dt_module_t *dmp, const char *name, uint_t id)
static uint_t
dt_module_syminit32(dt_module_t *dmp)
{
#if STT_NUM != (STT_TLS + 1)
#error "STT_NUM has grown. update dt_module_syminit32()"
#endif
const Elf32_Sym *sym = dmp->dm_symtab.cts_data;
const char *base = dmp->dm_strtab.cts_data;
size_t ss_size = dmp->dm_strtab.cts_size;
@ -95,6 +97,10 @@ dt_module_syminit32(dt_module_t *dmp)
static uint_t
dt_module_syminit64(dt_module_t *dmp)
{
#if STT_NUM != (STT_TLS + 1)
#error "STT_NUM has grown. update dt_module_syminit64()"
#endif
const Elf64_Sym *sym = dmp->dm_symtab.cts_data;
const char *base = dmp->dm_strtab.cts_data;
size_t ss_size = dmp->dm_strtab.cts_size;
@ -468,7 +474,7 @@ dt_module_load_sect(dtrace_hdl_t *dtp, dt_module_t *dmp, ctf_sect_t *ctsp)
Elf_Data *dp;
Elf_Scn *sp;
if (elf_getshstrndx(dmp->dm_elf, &shstrs) == 0)
if (elf_getshdrstrndx(dmp->dm_elf, &shstrs) == -1)
return (dt_set_errno(dtp, EDT_NOTLOADED));
for (sp = NULL; (sp = elf_nextscn(dmp->dm_elf, sp)) != NULL; ) {
@ -711,10 +717,25 @@ dt_module_unload(dtrace_hdl_t *dtp, dt_module_t *dmp)
void
dt_module_destroy(dtrace_hdl_t *dtp, dt_module_t *dmp)
{
uint_t h = dt_strtab_hash(dmp->dm_name, NULL) % dtp->dt_modbuckets;
dt_module_t **dmpp = &dtp->dt_mods[h];
dt_list_delete(&dtp->dt_modlist, dmp);
assert(dtp->dt_nmods != 0);
dtp->dt_nmods--;
/*
* Now remove this module from its hash chain. We expect to always
* find the module on its hash chain, so in this loop we assert that
* we don't run off the end of the list.
*/
while (*dmpp != dmp) {
dmpp = &((*dmpp)->dm_next);
assert(*dmpp != NULL);
}
*dmpp = dmp->dm_next;
dt_module_unload(dtp, dmp);
free(dmp);
}
@ -817,7 +838,7 @@ dt_module_update(dtrace_hdl_t *dtp, const char *name)
(void) close(fd);
if (dmp->dm_elf == NULL || err == -1 ||
elf_getshstrndx(dmp->dm_elf, &shstrs) == 0) {
elf_getshdrstrndx(dmp->dm_elf, &shstrs) == -1) {
dt_dprintf("failed to load %s: %s\n",
fname, elf_errmsg(elf_errno()));
dt_module_destroy(dtp, dmp);

View File

@ -20,12 +20,9 @@
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/types.h>
#include <sys/modctl.h>
#include <sys/systeminfo.h>
@ -104,8 +101,10 @@
#define DT_VERS_1_5 DT_VERSION_NUMBER(1, 5, 0)
#define DT_VERS_1_6 DT_VERSION_NUMBER(1, 6, 0)
#define DT_VERS_1_6_1 DT_VERSION_NUMBER(1, 6, 1)
#define DT_VERS_LATEST DT_VERS_1_6_1
#define DT_VERS_STRING "Sun D 1.6.1"
#define DT_VERS_1_6_2 DT_VERSION_NUMBER(1, 6, 2)
#define DT_VERS_1_6_3 DT_VERSION_NUMBER(1, 6, 3)
#define DT_VERS_LATEST DT_VERS_1_6_3
#define DT_VERS_STRING "Sun D 1.6.3"
const dt_version_t _dtrace_versions[] = {
DT_VERS_1_0, /* D API 1.0.0 (PSARC 2001/466) Solaris 10 FCS */
@ -119,6 +118,8 @@ const dt_version_t _dtrace_versions[] = {
DT_VERS_1_5, /* D API 1.5 Solaris Express 7/07 */
DT_VERS_1_6, /* D API 1.6 */
DT_VERS_1_6_1, /* D API 1.6.1 */
DT_VERS_1_6_2, /* D API 1.6.2 */
DT_VERS_1_6_3, /* D API 1.6.3 */
0
};

Some files were not shown because too many files have changed in this diff Show More