2 .\" Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH APPTRACE 1 "Nov 29, 2004"
8 apptrace \- trace application function calls to Solaris shared libraries
12 \fBapptrace\fR [\fB-f\fR] [\fB-F\fR [!] \fItracefromlist\fR] [\fB-T\fR [!] \fItracetolist\fR]
13 [\fB-o\fR \fIoutputfile\fR] [ [\fB-tv\fR] [!] \fIcall\fR ,...] \fIcommand\fR
14 [\fIcommand\fR \fIarguments\fR]
20 The \fBapptrace\fR utility runs the executable program specified by
21 \fIcommand\fR and traces all function calls that the program\fIcommand\fR makes
22 to the Solaris shared libraries. For each function call that is traceable,
23 \fBapptrace\fR reports the name of the library interface called, the values of
24 the arguments passed, and the return value.
27 By default, \fBapptrace\fR traces calls directly from the executable object to
28 any of the shared objects it depends on. Indirect calls (that is, calls made
29 between shared objects that the executable depends upon) are not reported by
33 Calls from or to additional shared objects may be traced using the \fB-F\fR or
34 \fB-T\fR options (see below).
37 The default reporting format is a single line per call, with no formatted
38 printing of arguments passed by reference or of data structures.
41 Formatted printing providing additional argument details is obtained using the
42 \fB-v\fR option (see below).
45 By default, every interface provided by a shared object is traced if called.
46 However, the set of interfaces to be traced can be restricted, using the
47 \fB-t\fR and/or \fB-v\fR options.
50 Since it is generally possible to trace calls between any of the dynamic
51 objects linked at runtime (the executable object and any of the shared objects
52 depended upon), the report of each traced call gives the name of the object
53 from which the call was made.
56 \fBapptrace\fR traces all of the procedure calls that occur between dynamic
57 objects via the procedure linkage table, so only those procedure calls which
58 are bound via the table will be traced. See the \fILinker and Libraries
63 The following options are supported:
70 Follows all children created by \fBfork\fR(2). This option will also cause the
71 process id to be printed at the beginning of each line.
77 \fB\fB-F\fR \fB[!]\fR\fItracefromlist\fR \fR
80 Traces calls from a comma-separated list of shared objects. Only calls from
81 these shared objects will be traced. The default is to trace calls from the
82 main executable only. Only the basename of the shared object is required. For
83 example, \fIlibc\fR will match \fI/usr/lib/libc.so.1\fR. Additionally, shell
84 style wildcard characters are supported as described in \fBfnmatch\fR(5). A
85 list preceded by a ``!'' defines a list of objects from which calls should not
86 be traced. If the tracing of calls from \fIcommand\fR is required, then
87 \fIcommand\fR must be a member of \fItracefromlist\fR.
93 \fB\fB-o\fR \fIoutputfile\fR \fR
96 \fBapptrace\fR output will be directed to the \fIoutputfile\fR. By default,
97 \fBapptrace\fR output is placed on the stderr stream of the process being
104 \fB\fB-t\fR [\fB!\fR]\fIcall,\|.\|.\|.\fR\fR
107 Traces or excludes function calls. Those calls specified in the comma-separated
108 list \fIcall\fR are traced. If the list begins with a !, the specified function
109 calls are excluded from the trace output. The default is \fB-t\fR \fB*\fR. The
110 use of shell style wildcards is allowed.
116 \fB\fB-T\fR \fB[!]\fR\fItracetolist\fR \fR
119 Traces calls to a comma-separated list of shared objects. The default is to
120 trace calls to all shared objects. As above, the basename is all that is
121 required and wildcarding is allowed. A list preceded by a ``!'' denotes a list
122 of objects to which calls should not be traced.
128 \fB\fB-v\fR [\fB!\fR]\fIcall,\|.\|.\|.\fR\fR
131 Provides verbose, formatted output of the arguments and return values of the
132 function calls specified (as above in the \fB-t\fR option). Unlike
133 \fBtruss\fR(1), calls named by the \fB-v\fR option do not have to be named by
134 the \fB-t\fR option. For example, \fBapptrace\fR \fB-v\fR \fBopen\fR is
135 equivalent to \fBtruss\fR \fB-t\fR \fBopen\fR \fB-v\fR \fBopen\fR.
140 \fBExample 1 \fRTracing the date command
144 % \fBapptrace date\fR
145 -> date -> libc.so.1:atexit(0xff3bf9ac, 0x22000, 0x0) ** NR
146 -> date -> libc.so.1:atexit(0x11550, 0xfefeef80, 0xab268) ** NR
147 -> date -> libc.so.1:setlocale(0x6, 0x11560, 0x0) ** NR
148 -> date -> libc.so.1:textdomain(0x11564, 0xfefce156, 0xff160200) ** NR
149 -> date -> libc.so.1:int getopt(int = 0x1,
150 const char * * = 0xffbffa5c,
151 const char * = 0x11574 "a:u")
152 <- date -> libc.so.1:getopt() = 0xffffffff
153 -> date -> libc.so.1:time_t time(time_t * = 0x225c0)
154 <- date -> libc.so.1:time() = 0x41ab6e82
155 -> date -> libc.so.1:char * nl_langinfo(nl_item = 0x3a)
156 <- date -> libc.so.1:nl_langinfo() = 0xfefd3e10
157 -> date -> libc.so.1:struct tm * localtime(const time_t * = 0x225c0)
158 <- date -> libc.so.1:localtime() = 0xff160240
159 -> date -> libc_psr.so.1:memcpy(0xffbff9cc, 0xff160240, 0x24) ** NR
160 -> date -> libc.so.1:size_t strftime(char * = 0x225c4 "",
162 const char * = 0xfefd3e10 "%a %b %e %T %Z %Y",
163 const struct tm * = 0xffbff9cc)
164 <- date -> libc.so.1:strftime() = 0x1c
165 -> date -> libc.so.1:int puts(const char * = 0x225c4
166 "Mon Nov 29 10:46:26 PST 2004")
167 Mon Nov 29 10:46:26 PST 2004
168 <- date -> libc.so.1:puts() = 0x1d
169 -> date -> libc.so.1:exit(0x0, 0x22400, 0x0) ** NR
175 \fBExample 2 \fRTracing a specific set of interfaces with verbosity set
179 % \fBapptrace -v localtime,strftime,puts date\fR
180 -> date -> libc.so.1:struct tm * localtime(const time_t * = 0x225c0)
181 arg0 = (const time_t *) 0x225c0
182 return = (struct tm *) 0xff160280 (struct tm) {
193 <- date -> libc.so.1:localtime() = 0xff160280
194 -> date -> libc.so.1:size_t strftime(char * = 0x225c4 "",
196 const char * = 0xfefd3e10 "%a %b %e %T %Z %Y",
197 const struct tm * = 0xffbff99c)
198 arg0 = (char *) 0x225c4 ""
199 arg1 = (size_t) 0x400
200 arg2 = (const char *) 0xfefd3e10 "%a %b %e %T %Z %Y"
201 arg3 = (const struct tm *) 0xffbff99c (struct tm) {
212 return = (size_t) 0x1c
213 <- date -> libc.so.1:strftime() = 0x1c
214 -> date -> libc.so.1:int puts(const char * = 0x225c4
215 "Mon Nov 29 10:52:04 PST 2004")
216 arg0 = (const char *) 0x225c4 "Mon Nov 29 10:52:04 PST 2004"
217 Mon Nov 29 10:52:04 PST 2004
219 <- date -> libc.so.1:puts() = 0x1d
226 ** NR - The return value of a function call will not be traced.
230 Basic runtime support for \fBapptrace\fR is provided by the link auditing
231 feature of the Solaris runtime linker (\fBld.so.1\fR(1)) and the \fBapptrace\fR
232 command's use of this facility relies on an auditing object
233 (\fBapptrace.so.1\fR) kept in \fB/usr/lib/abi\fR.
237 In general, \fBapptrace\fR cannot trace calls to functions accepting variable
238 argument lists. There has been some clever coding in several specific cases to
239 work around this limitation, most notably in the \fBprintf\fR and \fBscanf\fR
243 The \fBapptrace\fR utility can not trace the return value of a function call
244 whose return type is a \fBstruct\fR or \fBunion\fR.
247 Functions that attempt to probe the stack or otherwise extract information
248 about the caller cannot be traced. Some examples are \fB[gs]etcontext()\fR,
249 \fB[sig]longjmp()\fR, \fB[sig]setjmp()\fR, and \fBvfork()\fR.
252 Functions such as \fBexit\fR(2) that do not return will not be traced for their
256 For security reasons, only those processes with appropriate privileges can use
257 \fBapptrace\fR to trace \fBsetuid\fR/\fBsetgid\fR programs.
260 Tracing functions whose usage requires the inclusion of <\fBvarargs.h\fR>, such
261 as \fBvwprintw\fR(3XCURSES) and \fBvwscanw\fR(3XCURSES), will not provide
262 formatted printing of arguments.
266 See \fBattributes\fR(5) for descriptions of the following attributes:
274 ATTRIBUTE TYPE ATTRIBUTE VALUE
276 Interface Stability Unstable
282 \fBld.so.1\fR(1), \fBtruss\fR(1), \fBvwprintw\fR(3XCURSES),
283 \fBvwscanw\fR(3XCURSES), \fBattributes\fR(5), \fBfnmatch\fR(5)
286 \fILinker and Libraries Guide\fR