1#!/bin/ksh -p 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# Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. 23 24usage() { 25 echo "usage: sotruss [-F:-T:-o:-f] utility [utility arguments]" 26 echo " -F <bindfromlist>" 27 echo " A colon seperated list of libraries that are to be" 28 echo " traced. Only calls from these libraries will be" 29 echo " traced. The default is to trace calls from the" 30 echo " main executable." 31 echo " -T <bindtolist>" 32 echo " A colon seperated list of libraries that are to be" 33 echo " traced. Only calls to these libraries will be" 34 echo " traced. The default is to trace all calls." 35 echo " -o <outputfile>" 36 echo " sotruss output will be directed to 'outputfile'." 37 echo " by default it is placed on stdout." 38 echo " -f" 39 echo " Follow all children created by fork() and also" 40 echo " print truss output for the children. This also" 41 echo " causes a 'pid' to be added to each truss output line." 42} 43 44bindto="" 45bindfrom="" 46outfile="" 47noindentopt="" 48trusslib32="/usr/lib/link_audit/32/truss.so.1" 49trusslib64="/usr/lib/link_audit/64/truss.so.1" 50pidopt="" 51noexitopt="1" 52 53optlet="eF:T:o:fl:i" 54 55if [[ $# -lt 1 ]]; then 56 usage 57 exit 1 58fi 59 60while getopts $optlet c 61do 62 case $c in 63 F) 64 bindfrom="$OPTARG" 65 ;; 66 T) 67 bindto="$OPTARG" 68 ;; 69 o) 70 outfile="$OPTARG" 71 ;; 72 l) 73 trusslib32="$OPTARG" 74 trusslib64="$OPTARG" 75 ;; 76 f) 77 pidopt="1" 78 ;; 79 i) 80 noindentopt="1" 81 ;; 82 e) 83 noexitopt="" 84 ;; 85 \?) 86 usage 87 exit 1 88 ;; 89 esac 90done 91shift `expr $OPTIND - 1` 92 93# 94# Build environment variables 95# 96 97TRUSS_BINDTO="$bindto" \ 98TRUSS_BINDFROM="$bindfrom" \ 99TRUSS_OUTPUT="$outfile" \ 100TRUSS_PID="$pidopt" \ 101TRUSS_NOINDENT="$noindentopt" \ 102TRUSS_NOEXIT="$noexitopt" \ 103LD_AUDIT_32="$trusslib32" \ 104LD_AUDIT_64="$trusslib64" \ 105"$@" 106 107exit 0 108