xref: /illumos-gate/usr/src/cmd/dtrace/test/tst/common/pid/tst.main.ksh (revision dcafa303bc5c0028c4ebf51300caac6e2ea88d74)
1*dcafa303Sahl#!/bin/ksh -p
2*dcafa303Sahl#
3*dcafa303Sahl# CDDL HEADER START
4*dcafa303Sahl#
5*dcafa303Sahl# The contents of this file are subject to the terms of the
6*dcafa303Sahl# Common Development and Distribution License (the "License").
7*dcafa303Sahl# You may not use this file except in compliance with the License.
8*dcafa303Sahl#
9*dcafa303Sahl# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*dcafa303Sahl# or http://www.opensolaris.org/os/licensing.
11*dcafa303Sahl# See the License for the specific language governing permissions
12*dcafa303Sahl# and limitations under the License.
13*dcafa303Sahl#
14*dcafa303Sahl# When distributing Covered Code, include this CDDL HEADER in each
15*dcafa303Sahl# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*dcafa303Sahl# If applicable, add the following below this CDDL HEADER, with the
17*dcafa303Sahl# fields enclosed by brackets "[]" replaced with your own identifying
18*dcafa303Sahl# information: Portions Copyright [yyyy] [name of copyright owner]
19*dcafa303Sahl#
20*dcafa303Sahl# CDDL HEADER END
21*dcafa303Sahl#
22*dcafa303Sahl
23*dcafa303Sahl#
24*dcafa303Sahl# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
25*dcafa303Sahl# Use is subject to license terms.
26*dcafa303Sahl#
27*dcafa303Sahl# ident	"%Z%%M%	%I%	%E% SMI"
28*dcafa303Sahl#
29*dcafa303Sahl
30*dcafa303Sahlif [ $# != 1 ]; then
31*dcafa303Sahl	echo expected one argument: '<'dtrace-path'>'
32*dcafa303Sahl	exit 2
33*dcafa303Sahlfi
34*dcafa303Sahl
35*dcafa303Sahldtrace=$1
36*dcafa303Sahl
37*dcafa303Sahl#
38*dcafa303Sahl# Make sure we can trace main:entry properly -- this was problematic because
39*dcafa303Sahl# we also set a breakpoint on the same spot in libdtrace.
40*dcafa303Sahl#
41*dcafa303Sahl
42*dcafa303Sahl$dtrace -c date -s /dev/stdin <<EOF
43*dcafa303Sahl	BEGIN
44*dcafa303Sahl	{
45*dcafa303Sahl		status = 1;
46*dcafa303Sahl	}
47*dcafa303Sahl
48*dcafa303Sahl	pid\$target::main:entry
49*dcafa303Sahl	{
50*dcafa303Sahl		status = 0;
51*dcafa303Sahl	}
52*dcafa303Sahl
53*dcafa303Sahl	END
54*dcafa303Sahl	{
55*dcafa303Sahl		exit(status);
56*dcafa303Sahl	}
57*dcafa303SahlEOF
58*dcafa303Sahl
59*dcafa303Sahlexit $?
60