1apptrace(1)                      User Commands                     apptrace(1)
2
3
4

NAME

6       apptrace - trace application function calls to Solaris shared libraries
7

SYNOPSIS

9       apptrace [-f] [-F [!] tracefromlist] [-T [!] tracetolist]
10            [-o outputfile] [ [-tv] [!] call ,...] command
11            [command arguments]
12
13

DESCRIPTION

15       The  apptrace  utility runs the executable program specified by command
16       and traces all function calls that  the  programcommand  makes  to  the
17       Solaris  shared  libraries.  For  each function call that is traceable,
18       apptrace reports the name of the library interface called,  the  values
19       of the arguments passed, and the return value.
20
21
22       By  default,  apptrace traces calls directly from the executable object
23       to any of the shared objects it depends on. Indirect  calls  (that  is,
24       calls made between shared objects that the executable depends upon) are
25       not reported by default.
26
27
28       Calls from or to additional shared objects may be traced using  the  -F
29       or -T options (see below).
30
31
32       The default reporting format is a single line per call, with no format‐
33       ted printing of arguments passed by reference or of data structures.
34
35
36       Formatted printing providing additional argument  details  is  obtained
37       using the -v option (see below).
38
39
40       By  default,  every  interface provided by a shared object is traced if
41       called. However, the set of interfaces to be traced can be  restricted,
42       using the -t and/or -v options.
43
44
45       Since  it  is  generally  possible  to  trace  calls between any of the
46       dynamic objects linked at runtime (the executable object and any of the
47       shared objects depended upon), the report of each traced call gives the
48       name of the object from which the call was made.
49
50
51       apptrace traces all of the procedure calls that occur  between  dynamic
52       objects  via the procedure linkage table, so only those procedure calls
53       which are bound via the table  will  be  traced.  See  the  Linker  and
54       Libraries Guide.
55

OPTIONS

57       The following options are supported:
58
59       -f                      Follows  all  children created by fork(2). This
60                               option will also cause the  process  id  to  be
61                               printed at the beginning of each line.
62
63
64       -F [!]tracefromlist     Traces  calls  from  a  comma-separated list of
65                               shared objects. Only calls  from  these  shared
66                               objects will be traced. The default is to trace
67                               calls from the main executable only.  Only  the
68                               basename  of the shared object is required. For
69                               example, libc  will  match  /usr/lib/libc.so.1.
70                               Additionally,  shell  style wildcard characters
71                               are supported as  described  in  fnmatch(5).  A
72                               list  preceded  by  a  ``!''  defines a list of
73                               objects from which calls should not be  traced.
74                               If   the  tracing  of  calls  from  command  is
75                               required, then command  must  be  a  member  of
76                               tracefromlist.
77
78
79       -o outputfile           apptrace output will be directed to the output‐
80                               file. By default, apptrace output is placed  on
81                               the stderr stream of the process being traced.
82
83
84       -t [!]call,...          Traces  or excludes function calls. Those calls
85                               specified in the comma-separated list call  are
86                               traced. If the list begins with a !, the speci‐
87                               fied function calls are excluded from the trace
88                               output.  The  default is -t *. The use of shell
89                               style wildcards is allowed.
90
91
92       -T [!]tracetolist       Traces  calls  to  a  comma-separated  list  of
93                               shared  objects.  The default is to trace calls
94                               to all shared objects. As above,  the  basename
95                               is  all  that  is  required  and wildcarding is
96                               allowed. A list preceded by a ``!''  denotes  a
97                               list  of  objects  to which calls should not be
98                               traced.
99
100
101       -v [!]call,...          Provides verbose, formatted output of the argu‐
102                               ments  and return values of  the function calls
103                               specified (as above in the -t  option).  Unlike
104                               truss(1),  calls  named by the -v option do not
105                               have to be named by the -t option. For example,
106                               apptrace -v open is equivalent to truss -t open
107                               -v open.
108
109

EXAMPLES

111       Example 1 Tracing the date command
112
113         % apptrace date
114         -> date     -> libc.so.1:atexit(0xff3bf9ac, 0x22000, 0x0) ** NR
115         -> date     -> libc.so.1:atexit(0x11550, 0xfefeef80, 0xab268) ** NR
116         -> date     -> libc.so.1:setlocale(0x6, 0x11560, 0x0) ** NR
117         -> date     -> libc.so.1:textdomain(0x11564, 0xfefce156, 0xff160200) ** NR
118         -> date     -> libc.so.1:int getopt(int = 0x1,
119                                 const char * * = 0xffbffa5c,
120                                 const char * = 0x11574 "a:u")
121         <- date     -> libc.so.1:getopt() = 0xffffffff
122         -> date     -> libc.so.1:time_t time(time_t * = 0x225c0)
123         <- date     -> libc.so.1:time() = 0x41ab6e82
124         -> date     -> libc.so.1:char * nl_langinfo(nl_item = 0x3a)
125         <- date     -> libc.so.1:nl_langinfo() = 0xfefd3e10
126         -> date     -> libc.so.1:struct tm * localtime(const time_t * = 0x225c0)
127         <- date     -> libc.so.1:localtime() = 0xff160240
128         -> date     -> libc_psr.so.1:memcpy(0xffbff9cc, 0xff160240, 0x24) ** NR
129         -> date     -> libc.so.1:size_t strftime(char * = 0x225c4 "",
130                                 size_t = 0x400,
131                                 const char * = 0xfefd3e10 "%a %b %e %T %Z %Y",
132                                 const struct tm * = 0xffbff9cc)
133         <- date     -> libc.so.1:strftime() = 0x1c
134         -> date     -> libc.so.1:int puts(const char * = 0x225c4
135                                 "Mon Nov 29 10:46:26 PST 2004")
136                                 Mon Nov 29 10:46:26 PST 2004
137         <- date     -> libc.so.1:puts() = 0x1d
138         -> date     -> libc.so.1:exit(0x0, 0x22400, 0x0) ** NR
139
140
141
142       Example 2 Tracing a specific set of interfaces with verbosity set
143
144         % apptrace -v localtime,strftime,puts date
145         -> date     -> libc.so.1:struct tm * localtime(const time_t * = 0x225c0)
146                 arg0 = (const time_t *) 0x225c0
147                 return = (struct tm *) 0xff160280 (struct tm) {
148                 tm_sec: (int) 0x4
149                 tm_min: (int) 0x34
150                 tm_hour: (int) 0xa
151                 tm_mday: (int) 0x1d
152                 tm_mon: (int) 0xa
153                 tm_year: (int) 0x68
154                 tm_wday: (int) 0x1
155                 tm_yday: (int) 0x14d
156                 tm_isdst: (int) 0
157                 }
158         <- date     -> libc.so.1:localtime() = 0xff160280
159         -> date     -> libc.so.1:size_t strftime(char * = 0x225c4 "",
160                                 size_t = 0x400,
161                                 const char * = 0xfefd3e10 "%a %b %e %T %Z %Y",
162                                 const struct tm * = 0xffbff99c)
163                 arg0 = (char *) 0x225c4 ""
164                 arg1 = (size_t) 0x400
165                 arg2 = (const char *) 0xfefd3e10 "%a %b %e %T %Z %Y"
166                 arg3 = (const struct tm *) 0xffbff99c (struct tm) {
167                 tm_sec: (int) 0x4
168                 tm_min: (int) 0x34
169                 tm_hour: (int) 0xa
170                 tm_mday: (int) 0x1d
171                 tm_mon: (int) 0xa
172                 tm_year: (int) 0x68
173                 tm_wday: (int) 0x1
174                 tm_yday: (int) 0x14d
175                 tm_isdst: (int) 0
176                 }
177                 return = (size_t) 0x1c
178         <- date     -> libc.so.1:strftime() = 0x1c
179         -> date     -> libc.so.1:int puts(const char * = 0x225c4
180                                 "Mon Nov 29 10:52:04 PST 2004")
181                 arg0 = (const char *) 0x225c4 "Mon Nov 29 10:52:04 PST 2004"
182                                 Mon Nov 29 10:52:04 PST 2004
183                 return = (int) 0x1d
184         <- date     -> libc.so.1:puts() = 0x1d
185
186
187
188
189       ** NR - The return value of a function call will not be traced.
190

FILES

192       Basic runtime support for apptrace is provided  by  the  link  auditing
193       feature  of  the  Solaris  runtime linker (ld.so.1(1)) and the apptrace
194       command's use of this facility  relies  on  an  auditing  object  (app‐
195       trace.so.1) kept in /usr/lib/abi.
196

LIMITATIONS

198       In general, apptrace cannot trace calls to functions accepting variable
199       argument lists. There has been some clever coding in  several  specific
200       cases  to  work  around this limitation, most notably in the printf and
201       scanf families.
202
203
204       The apptrace utility can not trace the return value of a function  call
205       whose return type is a struct or union.
206
207
208       Functions that attempt to probe the stack or otherwise extract informa‐
209       tion about the caller cannot be traced. Some  examples  are  [gs]etcon‐
210       text(), [sig]longjmp(), [sig]setjmp(), and vfork().
211
212
213       Functions  such  as  exit(2)  that do not return will not be traced for
214       their return values.
215
216
217       For security reasons, only those processes with appropriate  privileges
218       can use apptrace to trace setuid/setgid programs.
219
220
221       Tracing  functions  whose  usage requires the inclusion of <varargs.h>,
222       such as vwprintw(3XCURSES) and vwscanw(3XCURSES), will not provide for‐
223       matted  printing of arguments.
224

ATTRIBUTES

226       See attributes(5) for descriptions of the following attributes:
227
228
229
230
231       ┌─────────────────────────────┬─────────────────────────────┐
232       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
233       ├─────────────────────────────┼─────────────────────────────┤
234       │Availability                 │SUNWcstl (32-bit)            │
235       │                             │SUNWcstlx (64-bit)           │
236       ├─────────────────────────────┼─────────────────────────────┤
237       │Interface Stability          │Unstable                     │
238       └─────────────────────────────┴─────────────────────────────┘
239

SEE ALSO

241       ld.so.1(1),     truss(1),     vwprintw(3XCURSES),    vwscanw(3XCURSES),
242       attributes(5), fnmatch(5)
243
244
245       Linker and Libraries Guide
246
247
248
249SunOS 5.11                        29 Nov 2004                      apptrace(1)
Impressum