xref: /onnv-gate/usr/src/cmd/sgs/link_audit/common/perfcnt.ksh (revision 12927:a27c46eb192b)
10Sstevel@tonic-gate#!/bin/ksh
20Sstevel@tonic-gate#
30Sstevel@tonic-gate# CDDL HEADER START
40Sstevel@tonic-gate#
50Sstevel@tonic-gate# The contents of this file are subject to the terms of the
6*12927SRod.Evans@Sun.COM# Common Development and Distribution License (the "License").
7*12927SRod.Evans@Sun.COM# You may not use this file except in compliance with the License.
80Sstevel@tonic-gate#
90Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate# See the License for the specific language governing permissions
120Sstevel@tonic-gate# and limitations under the License.
130Sstevel@tonic-gate#
140Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate#
200Sstevel@tonic-gate# CDDL HEADER END
210Sstevel@tonic-gate#
22*12927SRod.Evans@Sun.COM
230Sstevel@tonic-gate#
24*12927SRod.Evans@Sun.COM# Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
25*12927SRod.Evans@Sun.COM#
260Sstevel@tonic-gate
270Sstevel@tonic-gateusage() {
280Sstevel@tonic-gate	echo "usage: perfcnt -[$optlet] utility [utility arguments]"
290Sstevel@tonic-gate	echo "	-f <bindfromlist>"
300Sstevel@tonic-gate	echo "		A colon seperated list of libraries that are to be"
310Sstevel@tonic-gate	echo "		traced.  Only calls from these libraries will be"
320Sstevel@tonic-gate	echo "		traced.  The default is to trace all calls."
330Sstevel@tonic-gate	echo "	-t <bindtolist>"
340Sstevel@tonic-gate	echo "		A colon seperated list of libraries that are to be"
350Sstevel@tonic-gate	echo "		traced.  Only calls to these libraries will be"
360Sstevel@tonic-gate	echo "		traced.  The default is to trace all calls."
370Sstevel@tonic-gate	echo "	-l <perfcntlib>"
380Sstevel@tonic-gate	echo "		Specify an alternate perfcnt.so to use."
390Sstevel@tonic-gate}
400Sstevel@tonic-gate
410Sstevel@tonic-gatebindto=""
420Sstevel@tonic-gatebindfrom=""
430Sstevel@tonic-gateperfcntlib32="/opt/SUNWonld/lib/32/perfcnt.so.1"
440Sstevel@tonic-gateperfcntlib64="/opt/SUNWonld/lib/64/perfcnt.so.1"
450Sstevel@tonic-gate
460Sstevel@tonic-gateoptlet="f:t:l:"
470Sstevel@tonic-gate
480Sstevel@tonic-gateif [[ $# -lt 1 ]]; then
490Sstevel@tonic-gate	usage
500Sstevel@tonic-gate	exit 1
510Sstevel@tonic-gatefi
520Sstevel@tonic-gate
530Sstevel@tonic-gatewhile getopts $optlet c
540Sstevel@tonic-gatedo
550Sstevel@tonic-gate	case $c in
560Sstevel@tonic-gate	f)
570Sstevel@tonic-gate		bindfrom="$OPTARG"
580Sstevel@tonic-gate		;;
590Sstevel@tonic-gate	t)
600Sstevel@tonic-gate		bindto="$OPTARG"
610Sstevel@tonic-gate		;;
620Sstevel@tonic-gate	l)
630Sstevel@tonic-gate		perfcntlib32="$OPTARG"
640Sstevel@tonic-gate		perfcntlib64="$OPTARG"
650Sstevel@tonic-gate		;;
660Sstevel@tonic-gate	\?)
670Sstevel@tonic-gate		usage
680Sstevel@tonic-gate		exit 1
690Sstevel@tonic-gate		;;
700Sstevel@tonic-gate	esac
710Sstevel@tonic-gatedone
720Sstevel@tonic-gateshift `expr $OPTIND - 1`
730Sstevel@tonic-gate
740Sstevel@tonic-gate#
750Sstevel@tonic-gate# Build environment variables
760Sstevel@tonic-gate#
770Sstevel@tonic-gate
780Sstevel@tonic-gatePERFCNT_BINDTO="$bindto" \
790Sstevel@tonic-gatePERFCNT_BINDFROM="$bindfrom" \
800Sstevel@tonic-gateLD_AUDIT_32="$perfcntlib32" \
810Sstevel@tonic-gateLD_AUDIT_64="$perfcntlib64" \
820Sstevel@tonic-gate$*
830Sstevel@tonic-gate
840Sstevel@tonic-gateexit 0
85