xref: /illumos-gate/usr/src/cmd/sgs/link_audit/common/perfcnt.ksh (revision 0250c53ad267726f2438e3c6556199a0bbf588a2)
1#!/bin/ksh
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22
23#
24# Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
25#
26
27usage() {
28	echo "usage: perfcnt -[$optlet] utility [utility arguments]"
29	echo "	-f <bindfromlist>"
30	echo "		A colon seperated list of libraries that are to be"
31	echo "		traced.  Only calls from these libraries will be"
32	echo "		traced.  The default is to trace all calls."
33	echo "	-t <bindtolist>"
34	echo "		A colon seperated list of libraries that are to be"
35	echo "		traced.  Only calls to these libraries will be"
36	echo "		traced.  The default is to trace all calls."
37	echo "	-l <perfcntlib>"
38	echo "		Specify an alternate perfcnt.so to use."
39}
40
41bindto=""
42bindfrom=""
43perfcntlib32="/opt/SUNWonld/lib/32/perfcnt.so.1"
44perfcntlib64="/opt/SUNWonld/lib/64/perfcnt.so.1"
45
46optlet="f:t:l:"
47
48if [[ $# -lt 1 ]]; then
49	usage
50	exit 1
51fi
52
53while getopts $optlet c
54do
55	case $c in
56	f)
57		bindfrom="$OPTARG"
58		;;
59	t)
60		bindto="$OPTARG"
61		;;
62	l)
63		perfcntlib32="$OPTARG"
64		perfcntlib64="$OPTARG"
65		;;
66	\?)
67		usage
68		exit 1
69		;;
70	esac
71done
72shift `expr $OPTIND - 1`
73
74#
75# Build environment variables
76#
77
78PERFCNT_BINDTO="$bindto" \
79PERFCNT_BINDFROM="$bindfrom" \
80LD_AUDIT_32="$perfcntlib32" \
81LD_AUDIT_64="$perfcntlib64" \
82$*
83
84exit 0
85