Also update new programs
[platform/upstream/glibc.git] / elf / sotruss.ksh
1 #! @KSH@
2 # Copyright (C) 2011, 2012 Free Software Foundation, Inc.
3 # This file is part of the GNU C Library.
4
5 # The GNU C Library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
9
10 # The GNU C Library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 # Lesser General Public License for more details.
14
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with the GNU C Library; if not, write to the Free
17 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 # 02111-1307 USA.
19
20 # We should be able to find the translation right at the beginning.
21 TEXTDOMAIN=libc
22 TEXTDOMAINDIR=@TEXTDOMAINDIR@
23
24 unset SOTRUSS_FROMLIST
25 unset SOTRUSS_TOLIST
26 unset SOTRUSS_OUTNAME
27 unset SOTRUSS_EXIT
28 unset SOTRUSS_NOINDENT
29 SOTRUSS_WHICH=$$
30 lib='@PREFIX@/$LIB/audit/sotruss-lib.so'
31
32 function do_help {
33   echo $"Usage: sotruss [OPTION...] [--] EXECUTABLE [EXECUTABLE-OPTION...]
34   -F, --from FROMLIST     Trace calls from objects on FROMLIST
35   -T, --to TOLIST         Trace calls to objects on TOLIST
36
37   -e, --exit              Also show exits from the function calls
38   -f, --follow            Trace child processes
39   -o, --output FILENAME   Write output to FILENAME (or FILENAME.$PID in case
40                           -f is also used) instead of standard error
41
42   -?, --help              Give this help list
43       --usage             Give a short usage message
44       --version           Print program version"
45
46   echo
47   printf $"Mandatory arguments to long options are also mandatory for any corresponding\nshort options.\n"
48   echo
49
50   printf $"For bug reporting instructions, please see:
51 <http://www.gnu.org/software/libc/bugs.html>.
52 "
53   exit 0
54 }
55
56 function do_missing_arg {
57   printf >&2 $"%s: option requires an argument -- '%s'\n" sotruss "$1"
58   printf >&2 $"Try \`%s --help' or \`%s --usage' for more information.\n" sotruss sotruss
59   exit 1
60 }
61
62 function do_ambiguous {
63   printf >&2 $"%s: option is ambiguous; possibilities:"
64   while test $# -gt 0; do
65     printf >&2 " '%s'" $1
66     shift
67   done
68   printf >&2 "\n"
69   printf >&2 $"Try \`%s --help' or \`%s --usage' for more information.\n" sotruss sotruss
70   exit 1
71 }
72
73 while test $# -gt 0; do
74   case "$1" in
75   --v | --ve | --ver | --vers | --versi | --versio | --version)
76     echo "sotruss (GNU libc) @VERSION@"
77     printf $"Copyright (C) %s Free Software Foundation, Inc.
78 This is free software; see the source for copying conditions.  There is NO
79 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
80 " "2012"
81     printf $"Written by %s.\n" "Ulrich Drepper"
82     exit 0
83     ;;
84   -\? | --h | --he | --hel | --help)
85     do_help
86     ;;
87   --u | --us | --usa | --usag | --usage)
88     printf $"Usage: %s [-ef] [-F FROMLIST] [-o FILENAME] [-T TOLIST] [--exit]
89             [--follow] [--from FROMLIST] [--output FILENAME] [--to TOLIST]
90             [--help] [--usage] [--version] [--]
91             EXECUTABLE [EXECUTABLE-OPTION...]\n" sotruss
92     exit 0
93     ;;
94   -F | --fr | --fro | --from)
95     if test $# -eq 1; then
96       do_missing_arg "$1"
97     fi
98     shift
99     SOTRUSS_FROMLIST="$2"
100     ;;
101   -T | --t | --to)
102     if test $# -eq 1; then
103       do_missing_arg "$1"
104     fi
105     shift
106     SOTRUSS_TOLIST="$2"
107     ;;
108   -o | --o | --ou | --out | --outp | --outpu | --output)
109     if test $# -eq 1; then
110       do_missing_arg "$1"
111     fi
112     shift
113     SOTRUSS_OUTNAME="$1"
114     ;;
115   -f | --fo | --fol | --foll | --follo | --follow)
116     unset SOTRUSS_WHICH
117     ;;
118   -l | --l | --li | --lib)
119     if test $# -eq 1; then
120       do_missing_arg "$1"
121     fi
122     shift
123     lib="$1"
124     ;;
125   -e | --e | --ex | --exi | --exit)
126     SOTRUSS_EXIT=1
127     ;;
128   --f)
129     do_ambiguous '--from' '--follow'
130     ;;
131   --)
132     shift
133     break
134     ;;
135   -*)
136     printf >&2 $"%s: unrecognized option '%c%s'\n" sotruss '-' ${1#-}
137     printf >&2 $"Try \`%s --help' or \`%s --usage' for more information.\n" sotruss sotruss
138     exit 1
139     ;;
140   *)
141     break
142     ;;
143   esac
144   shift
145 done
146
147 export SOTRUSS_FROMLIST
148 export SOTRUSS_TOLIST
149 export SOTRUSS_OUTNAME
150 export SOTRUSS_WHICH
151 export SOTRUSS_EXIT
152 export LD_AUDIT="$lib"
153
154 exec "$@"
155 # Local Variables:
156 #  mode:ksh
157 # End: