2 * Copyright 1997 Sean Eric Fagan
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * 3. All advertising materials mentioning features or use of this software
13 * must display the following acknowledgement:
14 * This product includes software developed by Sean Eric Fagan
15 * 4. Neither the name of the author may be used to endorse or promote
16 * products derived from this software without specific prior written
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 static const char rcsid[] =
38 * This file has routines used to print out system calls and their
42 #include <sys/types.h>
44 #include <sys/procctl.h>
45 #include <sys/ptrace.h>
46 #include <sys/socket.h>
50 #include <netinet/in.h>
51 #include <arpa/inet.h>
52 #include <sys/ioccom.h>
53 #include <machine/atomic.h>
56 #include <sys/event.h>
58 #include <sys/resource.h>
77 /* 64-bit alignment on 32-bit platforms. */
84 /* Number of slots needed for a 64-bit argument. */
92 * This should probably be in its own file, sorted alphabetically.
94 static struct syscall syscalls[] = {
95 { .name = "fcntl", .ret_type = 1, .nargs = 3,
96 .args = { { Int, 0 } , { Fcntl, 1 }, { Fcntlflag | OUT, 2 } } },
97 { .name = "fork", .ret_type = 1, .nargs = 0 },
98 { .name = "vfork", .ret_type = 1, .nargs = 0 },
99 { .name = "rfork", .ret_type = 1, .nargs = 1,
100 .args = { { Rforkflags, 0 } } },
101 { .name = "getegid", .ret_type = 1, .nargs = 0 },
102 { .name = "geteuid", .ret_type = 1, .nargs = 0 },
103 { .name = "linux_readlink", .ret_type = 1, .nargs = 3,
104 .args = { { Name, 0 } , { Name | OUT, 1 }, { Int, 2 }}},
105 { .name = "linux_socketcall", .ret_type = 1, .nargs = 2,
106 .args = { { Int, 0 } , { LinuxSockArgs, 1 }}},
107 { .name = "getgid", .ret_type = 1, .nargs = 0 },
108 { .name = "getpid", .ret_type = 1, .nargs = 0 },
109 { .name = "getpgid", .ret_type = 1, .nargs = 1,
110 .args = { { Int, 0 } } },
111 { .name = "getpgrp", .ret_type = 1, .nargs = 0 },
112 { .name = "getppid", .ret_type = 1, .nargs = 0 },
113 { .name = "getsid", .ret_type = 1, .nargs = 1,
114 .args = { { Int, 0 } } },
115 { .name = "getuid", .ret_type = 1, .nargs = 0 },
116 { .name = "readlink", .ret_type = 1, .nargs = 3,
117 .args = { { Name, 0 } , { Readlinkres | OUT, 1 }, { Int, 2 } } },
118 { .name = "lseek", .ret_type = 2, .nargs = 3,
119 .args = { { Int, 0 }, { Quad, 1 + QUAD_ALIGN }, { Whence, 1 + QUAD_SLOTS + QUAD_ALIGN } } },
120 { .name = "linux_lseek", .ret_type = 2, .nargs = 3,
121 .args = { { Int, 0 }, { Int, 1 }, { Whence, 2 } } },
122 { .name = "mmap", .ret_type = 2, .nargs = 6,
123 .args = { { Ptr, 0 }, { Int, 1 }, { Mprot, 2 }, { Mmapflags, 3 }, { Int, 4 }, { Quad, 5 + QUAD_ALIGN } } },
124 { .name = "linux_mkdir", .ret_type = 1, .nargs = 2,
125 .args = { { Name | IN, 0} , {Int, 1}}},
126 { .name = "mprotect", .ret_type = 1, .nargs = 3,
127 .args = { { Ptr, 0 }, { Int, 1 }, { Mprot, 2 } } },
128 { .name = "open", .ret_type = 1, .nargs = 3,
129 .args = { { Name | IN, 0 } , { Open, 1 }, { Octal, 2 } } },
130 { .name = "mkdir", .ret_type = 1, .nargs = 2,
131 .args = { { Name, 0 } , { Octal, 1 } } },
132 { .name = "linux_open", .ret_type = 1, .nargs = 3,
133 .args = { { Name, 0 }, { Hex, 1 }, { Octal, 2 } } },
134 { .name = "close", .ret_type = 1, .nargs = 1,
135 .args = { { Int, 0 } } },
136 { .name = "link", .ret_type = 0, .nargs = 2,
137 .args = { { Name, 0 }, { Name, 1 } } },
138 { .name = "unlink", .ret_type = 0, .nargs = 1,
139 .args = { { Name, 0 } } },
140 { .name = "chdir", .ret_type = 0, .nargs = 1,
141 .args = { { Name, 0 } } },
142 { .name = "chroot", .ret_type = 0, .nargs = 1,
143 .args = { { Name, 0 } } },
144 { .name = "mknod", .ret_type = 0, .nargs = 3,
145 .args = { { Name, 0 }, { Octal, 1 }, { Int, 3 } } },
146 { .name = "chmod", .ret_type = 0, .nargs = 2,
147 .args = { { Name, 0 }, { Octal, 1 } } },
148 { .name = "chown", .ret_type = 0, .nargs = 3,
149 .args = { { Name, 0 }, { Int, 1 }, { Int, 2 } } },
150 { .name = "linux_stat64", .ret_type = 1, .nargs = 3,
151 .args = { { Name | IN, 0 }, { Ptr | OUT, 1 }, { Ptr | IN, 1 }}},
152 { .name = "mount", .ret_type = 0, .nargs = 4,
153 .args = { { Name, 0 }, { Name, 1 }, { Int, 2 }, { Ptr, 3 } } },
154 { .name = "umount", .ret_type = 0, .nargs = 2,
155 .args = { { Name, 0 }, { Int, 2 } } },
156 { .name = "fstat", .ret_type = 1, .nargs = 2,
157 .args = { { Int, 0 }, { Stat | OUT , 1 } } },
158 { .name = "stat", .ret_type = 1, .nargs = 2,
159 .args = { { Name | IN, 0 }, { Stat | OUT, 1 } } },
160 { .name = "lstat", .ret_type = 1, .nargs = 2,
161 .args = { { Name | IN, 0 }, { Stat | OUT, 1 } } },
162 { .name = "linux_newstat", .ret_type = 1, .nargs = 2,
163 .args = { { Name | IN, 0 }, { Ptr | OUT, 1 } } },
164 { .name = "linux_access", .ret_type = 1, .nargs = 2,
165 .args = { { Name, 0 }, { Int, 1 }}},
166 { .name = "linux_newfstat", .ret_type = 1, .nargs = 2,
167 .args = { { Int, 0 }, { Ptr | OUT, 1 } } },
168 { .name = "write", .ret_type = 1, .nargs = 3,
169 .args = { { Int, 0 }, { BinString | IN, 1 }, { Int, 2 } } },
170 { .name = "ioctl", .ret_type = 1, .nargs = 3,
171 .args = { { Int, 0 }, { Ioctl, 1 }, { Hex, 2 } } },
172 { .name = "break", .ret_type = 1, .nargs = 1,
173 .args = { { Ptr, 0 } } },
174 { .name = "exit", .ret_type = 0, .nargs = 1,
175 .args = { { Hex, 0 } } },
176 { .name = "access", .ret_type = 1, .nargs = 2,
177 .args = { { Name | IN, 0 }, { Int, 1 } } },
178 { .name = "sigaction", .ret_type = 1, .nargs = 3,
179 .args = { { Signal, 0 }, { Sigaction | IN, 1 }, { Sigaction | OUT, 2 } } },
180 { .name = "accept", .ret_type = 1, .nargs = 3,
181 .args = { { Int, 0 }, { Sockaddr | OUT, 1 }, { Ptr | OUT, 2 } } },
182 { .name = "bind", .ret_type = 1, .nargs = 3,
183 .args = { { Int, 0 }, { Sockaddr | IN, 1 }, { Int, 2 } } },
184 { .name = "connect", .ret_type = 1, .nargs = 3,
185 .args = { { Int, 0 }, { Sockaddr | IN, 1 }, { Int, 2 } } },
186 { .name = "getpeername", .ret_type = 1, .nargs = 3,
187 .args = { { Int, 0 }, { Sockaddr | OUT, 1 }, { Ptr | OUT, 2 } } },
188 { .name = "getsockname", .ret_type = 1, .nargs = 3,
189 .args = { { Int, 0 }, { Sockaddr | OUT, 1 }, { Ptr | OUT, 2 } } },
190 { .name = "recvfrom", .ret_type = 1, .nargs = 6,
191 .args = { { Int, 0 }, { BinString | OUT, 1 }, { Int, 2 }, { Hex, 3 }, { Sockaddr | OUT, 4 }, { Ptr | OUT, 5 } } },
192 { .name = "sendto", .ret_type = 1, .nargs = 6,
193 .args = { { Int, 0 }, { BinString | IN, 1 }, { Int, 2 }, { Hex, 3 }, { Sockaddr | IN, 4 }, { Ptr | IN, 5 } } },
194 { .name = "execve", .ret_type = 1, .nargs = 3,
195 .args = { { Name | IN, 0 }, { StringArray | IN, 1 }, { StringArray | IN, 2 } } },
196 { .name = "linux_execve", .ret_type = 1, .nargs = 3,
197 .args = { { Name | IN, 0 }, { StringArray | IN, 1 }, { StringArray | IN, 2 } } },
198 { .name = "kldload", .ret_type = 0, .nargs = 1,
199 .args = { { Name | IN, 0 } } },
200 { .name = "kldunload", .ret_type = 0, .nargs = 1,
201 .args = { { Int, 0 } } },
202 { .name = "kldfind", .ret_type = 0, .nargs = 1,
203 .args = { { Name | IN, 0 } } },
204 { .name = "kldnext", .ret_type = 0, .nargs = 1,
205 .args = { { Int, 0 } } },
206 { .name = "kldstat", .ret_type = 0, .nargs = 2,
207 .args = { { Int, 0 }, { Ptr, 1 } } },
208 { .name = "kldfirstmod", .ret_type = 0, .nargs = 1,
209 .args = { { Int, 0 } } },
210 { .name = "nanosleep", .ret_type = 0, .nargs = 1,
211 .args = { { Timespec, 0 } } },
212 { .name = "select", .ret_type = 1, .nargs = 5,
213 .args = { { Int, 0 }, { Fd_set, 1 }, { Fd_set, 2 }, { Fd_set, 3 }, { Timeval, 4 } } },
214 { .name = "poll", .ret_type = 1, .nargs = 3,
215 .args = { { Pollfd, 0 }, { Int, 1 }, { Int, 2 } } },
216 { .name = "gettimeofday", .ret_type = 1, .nargs = 2,
217 .args = { { Timeval | OUT, 0 }, { Ptr, 1 } } },
218 { .name = "clock_gettime", .ret_type = 1, .nargs = 2,
219 .args = { { Int, 0 }, { Timespec | OUT, 1 } } },
220 { .name = "getitimer", .ret_type = 1, .nargs = 2,
221 .args = { { Int, 0 }, { Itimerval | OUT, 2 } } },
222 { .name = "setitimer", .ret_type = 1, .nargs = 3,
223 .args = { { Int, 0 }, { Itimerval, 1 } , { Itimerval | OUT, 2 } } },
224 { .name = "kse_release", .ret_type = 0, .nargs = 1,
225 .args = { { Timespec, 0 } } },
226 { .name = "kevent", .ret_type = 0, .nargs = 6,
227 .args = { { Int, 0 }, { Kevent, 1 }, { Int, 2 }, { Kevent | OUT, 3 }, { Int, 4 }, { Timespec, 5 } } },
228 { .name = "sigprocmask", .ret_type = 0, .nargs = 3,
229 .args = { { Sigprocmask, 0 }, { Sigset, 1 }, { Sigset | OUT, 2 } } },
230 { .name = "unmount", .ret_type = 1, .nargs = 2,
231 .args = { { Name, 0 }, { Int, 1 } } },
232 { .name = "socket", .ret_type = 1, .nargs = 3,
233 .args = { { Sockdomain, 0 }, { Socktype, 1 }, { Int, 2 } } },
234 { .name = "getrusage", .ret_type = 1, .nargs = 2,
235 .args = { { Int, 0 }, { Rusage | OUT, 1 } } },
236 { .name = "__getcwd", .ret_type = 1, .nargs = 2,
237 .args = { { Name | OUT, 0 }, { Int, 1 } } },
238 { .name = "shutdown", .ret_type = 1, .nargs = 2,
239 .args = { { Int, 0 }, { Shutdown, 1 } } },
240 { .name = "getrlimit", .ret_type = 1, .nargs = 2,
241 .args = { { Resource, 0 }, { Rlimit | OUT, 1 } } },
242 { .name = "setrlimit", .ret_type = 1, .nargs = 2,
243 .args = { { Resource, 0 }, { Rlimit | IN, 1 } } },
244 { .name = "utimes", .ret_type = 1, .nargs = 2,
245 .args = { { Name | IN, 0 }, { Timeval2 | IN, 1 } } },
246 { .name = "lutimes", .ret_type = 1, .nargs = 2,
247 .args = { { Name | IN, 0 }, { Timeval2 | IN, 1 } } },
248 { .name = "futimes", .ret_type = 1, .nargs = 2,
249 .args = { { Int, 0 }, { Timeval | IN, 1 } } },
250 { .name = "chflags", .ret_type = 1, .nargs = 2,
251 .args = { { Name | IN, 0 }, { Hex, 1 } } },
252 { .name = "lchflags", .ret_type = 1, .nargs = 2,
253 .args = { { Name | IN, 0 }, { Hex, 1 } } },
254 { .name = "pathconf", .ret_type = 1, .nargs = 2,
255 .args = { { Name | IN, 0 }, { Pathconf, 1 } } },
256 { .name = "pipe", .ret_type = 1, .nargs = 1,
257 .args = { { Ptr, 0 } } },
258 { .name = "truncate", .ret_type = 1, .nargs = 3,
259 .args = { { Name | IN, 0 }, { Int | IN, 1 }, { Quad | IN, 2 } } },
260 { .name = "ftruncate", .ret_type = 1, .nargs = 3,
261 .args = { { Int | IN, 0 }, { Int | IN, 1 }, { Quad | IN, 2 } } },
262 { .name = "kill", .ret_type = 1, .nargs = 2,
263 .args = { { Int | IN, 0 }, { Signal | IN, 1 } } },
264 { .name = "munmap", .ret_type = 1, .nargs = 2,
265 .args = { { Ptr, 0 }, { Int, 1 } } },
266 { .name = "read", .ret_type = 1, .nargs = 3,
267 .args = { { Int, 0 }, { BinString | OUT, 1 }, { Int, 2 } } },
268 { .name = "rename", .ret_type = 1, .nargs = 2,
269 .args = { { Name , 0 } , { Name, 1 } } },
270 { .name = "symlink", .ret_type = 1, .nargs = 2,
271 .args = { { Name , 0 } , { Name, 1 } } },
272 { .name = "posix_openpt", .ret_type = 1, .nargs = 1,
273 .args = { { Open, 0 } } },
274 { .name = "wait4", .ret_type = 1, .nargs = 4,
275 .args = { { Int, 0 }, { ExitStatus | OUT, 1 }, { Waitoptions, 2 },
276 { Rusage | OUT, 3 } } },
277 { .name = "wait6", .ret_type = 1, .nargs = 6,
278 .args = { { Idtype, 0 }, { Int, 1 }, { ExitStatus | OUT, 2 },
279 { Waitoptions, 3 }, { Rusage | OUT, 4 }, { Ptr, 5 } } },
280 { .name = "procctl", .ret_type = 1, .nargs = 4,
281 .args = { { Idtype, 0 }, { Int, 1 }, { Procctl, 2 }, { Ptr, 3 } } },
282 { .name = "_umtx_op", .ret_type = 1, .nargs = 5,
283 .args = { { Ptr, 0 }, { Umtxop, 1 }, { LongHex, 2 }, { Ptr, 3 },
288 /* Xlat idea taken from strace */
294 #define X(a) { a, #a },
295 #define XEND { 0, NULL }
297 static struct xlat kevent_filters[] = {
298 X(EVFILT_READ) X(EVFILT_WRITE) X(EVFILT_AIO) X(EVFILT_VNODE)
299 X(EVFILT_PROC) X(EVFILT_SIGNAL) X(EVFILT_TIMER)
300 X(EVFILT_FS) X(EVFILT_READ) XEND
303 static struct xlat kevent_flags[] = {
304 X(EV_ADD) X(EV_DELETE) X(EV_ENABLE) X(EV_DISABLE) X(EV_ONESHOT)
305 X(EV_CLEAR) X(EV_FLAG1) X(EV_ERROR) X(EV_EOF) XEND
308 static struct xlat poll_flags[] = {
309 X(POLLSTANDARD) X(POLLIN) X(POLLPRI) X(POLLOUT) X(POLLERR)
310 X(POLLHUP) X(POLLNVAL) X(POLLRDNORM) X(POLLRDBAND)
311 X(POLLWRBAND) X(POLLINIGNEOF) XEND
314 static struct xlat mmap_flags[] = {
315 X(MAP_SHARED) X(MAP_PRIVATE) X(MAP_FIXED) X(MAP_RESERVED0020)
316 X(MAP_RESERVED0040) X(MAP_RESERVED0080) X(MAP_RESERVED0100)
317 X(MAP_HASSEMAPHORE) X(MAP_STACK) X(MAP_NOSYNC) X(MAP_ANON)
318 X(MAP_NOCORE) X(MAP_PREFAULT_READ)
325 static struct xlat mprot_flags[] = {
326 X(PROT_NONE) X(PROT_READ) X(PROT_WRITE) X(PROT_EXEC) XEND
329 static struct xlat whence_arg[] = {
330 X(SEEK_SET) X(SEEK_CUR) X(SEEK_END) XEND
333 static struct xlat sigaction_flags[] = {
334 X(SA_ONSTACK) X(SA_RESTART) X(SA_RESETHAND) X(SA_NOCLDSTOP)
335 X(SA_NODEFER) X(SA_NOCLDWAIT) X(SA_SIGINFO) XEND
338 static struct xlat fcntl_arg[] = {
339 X(F_DUPFD) X(F_GETFD) X(F_SETFD) X(F_GETFL) X(F_SETFL)
340 X(F_GETOWN) X(F_SETOWN) X(F_GETLK) X(F_SETLK) X(F_SETLKW) XEND
343 static struct xlat fcntlfd_arg[] = {
347 static struct xlat fcntlfl_arg[] = {
348 X(O_APPEND) X(O_ASYNC) X(O_FSYNC) X(O_NONBLOCK) X(O_NOFOLLOW)
352 static struct xlat sockdomain_arg[] = {
353 X(PF_UNSPEC) X(PF_LOCAL) X(PF_UNIX) X(PF_INET) X(PF_IMPLINK)
354 X(PF_PUP) X(PF_CHAOS) X(PF_NETBIOS) X(PF_ISO) X(PF_OSI)
355 X(PF_ECMA) X(PF_DATAKIT) X(PF_CCITT) X(PF_SNA) X(PF_DECnet)
356 X(PF_DLI) X(PF_LAT) X(PF_HYLINK) X(PF_APPLETALK) X(PF_ROUTE)
357 X(PF_LINK) X(PF_XTP) X(PF_COIP) X(PF_CNT) X(PF_SIP) X(PF_IPX)
358 X(PF_RTIP) X(PF_PIP) X(PF_ISDN) X(PF_KEY) X(PF_INET6)
359 X(PF_NATM) X(PF_ATM) X(PF_NETGRAPH) X(PF_SLOW) X(PF_SCLUSTER)
360 X(PF_ARP) X(PF_BLUETOOTH) XEND
363 static struct xlat socktype_arg[] = {
364 X(SOCK_STREAM) X(SOCK_DGRAM) X(SOCK_RAW) X(SOCK_RDM)
365 X(SOCK_SEQPACKET) XEND
368 static struct xlat open_flags[] = {
369 X(O_RDONLY) X(O_WRONLY) X(O_RDWR) X(O_ACCMODE) X(O_NONBLOCK)
370 X(O_APPEND) X(O_SHLOCK) X(O_EXLOCK) X(O_ASYNC) X(O_FSYNC)
371 X(O_NOFOLLOW) X(O_CREAT) X(O_TRUNC) X(O_EXCL) X(O_NOCTTY)
372 X(O_DIRECT) X(O_DIRECTORY) X(O_EXEC) X(O_TTY_INIT) X(O_CLOEXEC) XEND
375 static struct xlat shutdown_arg[] = {
376 X(SHUT_RD) X(SHUT_WR) X(SHUT_RDWR) XEND
379 static struct xlat resource_arg[] = {
380 X(RLIMIT_CPU) X(RLIMIT_FSIZE) X(RLIMIT_DATA) X(RLIMIT_STACK)
381 X(RLIMIT_CORE) X(RLIMIT_RSS) X(RLIMIT_MEMLOCK) X(RLIMIT_NPROC)
382 X(RLIMIT_NOFILE) X(RLIMIT_SBSIZE) X(RLIMIT_VMEM) XEND
385 static struct xlat pathconf_arg[] = {
386 X(_PC_LINK_MAX) X(_PC_MAX_CANON) X(_PC_MAX_INPUT)
387 X(_PC_NAME_MAX) X(_PC_PATH_MAX) X(_PC_PIPE_BUF)
388 X(_PC_CHOWN_RESTRICTED) X(_PC_NO_TRUNC) X(_PC_VDISABLE)
389 X(_PC_ASYNC_IO) X(_PC_PRIO_IO) X(_PC_SYNC_IO)
390 X(_PC_ALLOC_SIZE_MIN) X(_PC_FILESIZEBITS)
391 X(_PC_REC_INCR_XFER_SIZE) X(_PC_REC_MAX_XFER_SIZE)
392 X(_PC_REC_MIN_XFER_SIZE) X(_PC_REC_XFER_ALIGN)
393 X(_PC_SYMLINK_MAX) X(_PC_ACL_EXTENDED) X(_PC_ACL_PATH_MAX)
394 X(_PC_CAP_PRESENT) X(_PC_INF_PRESENT) X(_PC_MAC_PRESENT)
398 static struct xlat rfork_flags[] = {
399 X(RFPROC) X(RFNOWAIT) X(RFFDG) X(RFCFDG) X(RFTHREAD) X(RFMEM)
400 X(RFSIGSHARE) X(RFTSIGZMB) X(RFLINUXTHPN) XEND
403 static struct xlat wait_options[] = {
404 X(WNOHANG) X(WUNTRACED) X(WCONTINUED) X(WNOWAIT) X(WEXITED)
408 static struct xlat idtype_arg[] = {
409 X(P_PID) X(P_PPID) X(P_PGID) X(P_SID) X(P_CID) X(P_UID) X(P_GID)
410 X(P_ALL) X(P_LWPID) X(P_TASKID) X(P_PROJID) X(P_POOLID) X(P_JAILID)
411 X(P_CTID) X(P_CPUID) X(P_PSETID) XEND
414 static struct xlat procctl_arg[] = {
415 X(PROC_SPROTECT) XEND
418 static struct xlat umtx_ops[] = {
419 X(UMTX_OP_RESERVED0) X(UMTX_OP_RESERVED1) X(UMTX_OP_WAIT)
420 X(UMTX_OP_WAKE) X(UMTX_OP_MUTEX_TRYLOCK) X(UMTX_OP_MUTEX_LOCK)
421 X(UMTX_OP_MUTEX_UNLOCK) X(UMTX_OP_SET_CEILING) X(UMTX_OP_CV_WAIT)
422 X(UMTX_OP_CV_SIGNAL) X(UMTX_OP_CV_BROADCAST) X(UMTX_OP_WAIT_UINT)
423 X(UMTX_OP_RW_RDLOCK) X(UMTX_OP_RW_WRLOCK) X(UMTX_OP_RW_UNLOCK)
424 X(UMTX_OP_WAIT_UINT_PRIVATE) X(UMTX_OP_WAKE_PRIVATE)
425 X(UMTX_OP_MUTEX_WAIT) X(UMTX_OP_MUTEX_WAKE) X(UMTX_OP_SEM_WAIT)
426 X(UMTX_OP_SEM_WAKE) X(UMTX_OP_NWAKE_PRIVATE) X(UMTX_OP_MUTEX_WAKE2)
427 X(UMTX_OP_SEM2_WAIT) X(UMTX_OP_SEM2_WAKE)
435 * Searches an xlat array for a value, and returns it if found. Otherwise
436 * return a string representation.
439 lookup(struct xlat *xlat, int val, int base)
443 for (; xlat->str != NULL; xlat++)
444 if (xlat->val == val)
448 sprintf(tmp, "0%o", val);
451 sprintf(tmp, "0x%x", val);
454 sprintf(tmp, "%u", val);
457 errx(1,"Unknown lookup base");
464 xlookup(struct xlat *xlat, int val)
467 return (lookup(xlat, val, 16));
470 /* Searches an xlat array containing bitfield values. Remaining bits
471 set after removing the known ones are printed at the end:
474 xlookup_bits(struct xlat *xlat, int val)
477 static char str[512];
481 for (; xlat->str != NULL; xlat++) {
482 if ((xlat->val & rem) == xlat->val) {
483 /* don't print the "all-bits-zero" string unless all
484 bits are really zero */
485 if (xlat->val == 0 && val != 0)
487 len += sprintf(str + len, "%s|", xlat->str);
491 /* if we have leftover bits or didn't match anything */
493 len += sprintf(str + len, "0x%x", rem);
494 if (len && str[len - 1] == '|')
501 * If/when the list gets big, it might be desirable to do it
502 * as a hash table or binary search.
506 get_syscall(const char *name)
514 if (strcmp(name, sc->name) == 0)
524 * Copy a fixed amount of bytes from the process.
528 get_struct(pid_t pid, void *offset, void *buf, int len)
530 struct ptrace_io_desc iorequest;
532 iorequest.piod_op = PIOD_READ_D;
533 iorequest.piod_offs = offset;
534 iorequest.piod_addr = buf;
535 iorequest.piod_len = len;
536 if (ptrace(PT_IO, pid, (caddr_t)&iorequest, 0) < 0)
542 #define BLOCKSIZE 1024
545 * Copy a string from the process. Note that it is
546 * expected to be a C string, but if max is set, it will
547 * only get that much.
551 get_string(pid_t pid, void *offset, int max)
553 struct ptrace_io_desc iorequest;
555 int diff, i, size, totalsize;
558 totalsize = size = max ? (max + 1) : BLOCKSIZE;
559 buf = malloc(totalsize);
563 diff = totalsize - size;
564 iorequest.piod_op = PIOD_READ_D;
565 iorequest.piod_offs = (char *)offset + diff;
566 iorequest.piod_addr = buf + diff;
567 iorequest.piod_len = size;
568 if (ptrace(PT_IO, pid, (caddr_t)&iorequest, 0) < 0) {
572 for (i = 0 ; i < size; i++) {
573 if (buf[diff + i] == '\0')
576 if (totalsize < MAXSIZE - BLOCKSIZE && max == 0) {
577 totalsize += BLOCKSIZE;
578 buf = realloc(buf, totalsize);
581 buf[totalsize - 1] = '\0';
594 asprintf(&tmp, "%d", sig);
600 * Converts a syscall argument into a string. Said string is
601 * allocated via malloc(), so needs to be free()'d. The file
602 * descriptor is for the process' memory (via /proc), and is used
603 * to get any data (where the argument is a pointer). sc is
604 * a pointer to the syscall description (see above); args is
605 * an array of all of the system call arguments.
609 print_arg(struct syscall_args *sc, unsigned long *args, long retval,
610 struct trussinfo *trussinfo)
616 pid = trussinfo->pid;
617 switch (sc->type & ARG_MASK) {
619 asprintf(&tmp, "0x%x", (int)args[sc->offset]);
622 asprintf(&tmp, "0%o", (int)args[sc->offset]);
625 asprintf(&tmp, "%d", (int)args[sc->offset]);
628 asprintf(&tmp, "0x%lx", args[sc->offset]);
631 /* NULL-terminated string. */
633 tmp2 = get_string(pid, (void*)args[sc->offset], 0);
634 asprintf(&tmp, "\"%s\"", tmp2);
639 /* Binary block of data that might have printable characters.
640 XXX If type|OUT, assume that the length is the syscall's
641 return value. Otherwise, assume that the length of the block
642 is in the next syscall argument. */
643 int max_string = trussinfo->strsize;
644 char tmp2[max_string+1], *tmp3;
651 len = args[sc->offset + 1];
653 /* Don't print more than max_string characters, to avoid word
654 wrap. If we have to truncate put some ... after the string.
656 if (len > max_string) {
660 if (len && get_struct(pid, (void*)args[sc->offset], &tmp2, len)
662 tmp3 = malloc(len * 4 + 1);
664 if (strvisx(tmp3, tmp2, len,
665 VIS_CSTYLE|VIS_TAB|VIS_NL) <= max_string)
670 asprintf(&tmp, "\"%s\"%s", tmp3, truncated ?
674 asprintf(&tmp, "0x%lx", args[sc->offset]);
682 char *strarray[100]; /* XXX This is ugly. */
684 if (get_struct(pid, (void *)args[sc->offset],
685 (void *)&strarray, sizeof(strarray)) == -1)
686 err(1, "get_struct %p", (void *)args[sc->offset]);
690 /* Find out how large of a buffer we'll need. */
691 while (strarray[num] != NULL) {
692 string = get_string(pid, (void*)strarray[num], 0);
693 size += strlen(string);
697 size += 4 + (num * 4);
698 tmp = (char *)malloc(size);
701 tmp2 += sprintf(tmp2, " [");
702 for (i = 0; i < num; i++) {
703 string = get_string(pid, (void*)strarray[i], 0);
704 tmp2 += sprintf(tmp2, " \"%s\"%c", string,
705 (i + 1 == num) ? ' ' : ',');
708 tmp2 += sprintf(tmp2, "]");
713 asprintf(&tmp, "0x%lx", args[sc->offset]);
717 unsigned long long ll;
718 ll = *(unsigned long long *)(args + sc->offset);
719 asprintf(&tmp, "0x%llx", ll);
724 asprintf(&tmp, "0x%lx", args[sc->offset]);
732 tmp2 = get_string(pid, (void*)args[sc->offset], retval);
733 asprintf(&tmp, "\"%s\"", tmp2);
738 const char *temp = ioctlname(args[sc->offset]);
742 unsigned long arg = args[sc->offset];
743 asprintf(&tmp, "0x%lx { IO%s%s 0x%lx('%c'), %lu, %lu }",
744 arg, arg & IOC_OUT ? "R" : "",
745 arg & IOC_IN ? "W" : "", IOCGROUP(arg),
746 isprint(IOCGROUP(arg)) ? (char)IOCGROUP(arg) : '?',
747 arg & 0xFF, IOCPARM_LEN(arg));
753 if (get_struct(pid, (void *)args[sc->offset], &ts,
755 asprintf(&tmp, "{%ld.%09ld }", (long)ts.tv_sec,
758 asprintf(&tmp, "0x%lx", args[sc->offset]);
763 if (get_struct(pid, (void *)args[sc->offset], &tv, sizeof(tv))
765 asprintf(&tmp, "{%ld.%06ld }", (long)tv.tv_sec,
768 asprintf(&tmp, "0x%lx", args[sc->offset]);
772 struct timeval tv[2];
773 if (get_struct(pid, (void *)args[sc->offset], &tv, sizeof(tv))
775 asprintf(&tmp, "{%ld.%06ld, %ld.%06ld }",
776 (long)tv[0].tv_sec, tv[0].tv_usec,
777 (long)tv[1].tv_sec, tv[1].tv_usec);
779 asprintf(&tmp, "0x%lx", args[sc->offset]);
783 struct itimerval itv;
784 if (get_struct(pid, (void *)args[sc->offset], &itv,
786 asprintf(&tmp, "{%ld.%06ld, %ld.%06ld }",
787 (long)itv.it_interval.tv_sec,
788 itv.it_interval.tv_usec,
789 (long)itv.it_value.tv_sec,
790 itv.it_value.tv_usec);
792 asprintf(&tmp, "0x%lx", args[sc->offset]);
797 struct linux_socketcall_args largs;
798 if (get_struct(pid, (void *)args[sc->offset], (void *)&largs,
799 sizeof(largs)) == -1) {
800 err(1, "get_struct %p", (void *)args[sc->offset]);
805 switch (largs.what) {
807 what = "LINUX_SOCKET";
813 what = "LINUX_CONNECT";
816 what = "LINUX_LISTEN";
819 what = "LINUX_ACCEPT";
821 case LINUX_GETSOCKNAME:
822 what = "LINUX_GETSOCKNAME";
824 case LINUX_GETPEERNAME:
825 what = "LINUX_GETPEERNAME";
827 case LINUX_SOCKETPAIR:
828 what = "LINUX_SOCKETPAIR";
837 what = "LINUX_SENDTO";
840 what = "LINUX_RECVFROM";
843 what = "LINUX_SHUTDOWN";
845 case LINUX_SETSOCKOPT:
846 what = "LINUX_SETSOCKOPT";
848 case LINUX_GETSOCKOPT:
849 what = "LINUX_GETSOCKOPT";
852 what = "LINUX_SENDMSG";
855 what = "LINUX_RECVMSG";
858 sprintf(buf, "%d", largs.what);
862 asprintf(&tmp, "(0x%lx)%s, 0x%lx", args[sc->offset], what, (long unsigned int)largs.args);
867 * XXX: A Pollfd argument expects the /next/ syscall argument
868 * to be the number of fds in the array. This matches the poll
872 int numfds = args[sc->offset+1];
873 int bytes = sizeof(struct pollfd) * numfds;
874 int i, tmpsize, u, used;
875 const int per_fd = 100;
877 if ((pfd = malloc(bytes)) == NULL)
878 err(1, "Cannot malloc %d bytes for pollfd array",
880 if (get_struct(pid, (void *)args[sc->offset], pfd, bytes)
883 tmpsize = 1 + per_fd * numfds + 2;
884 if ((tmp = malloc(tmpsize)) == NULL)
885 err(1, "Cannot alloc %d bytes for poll output",
889 for (i = 0; i < numfds; i++) {
891 u = snprintf(tmp + used, per_fd, "%s%d/%s",
892 i > 0 ? " " : "", pfd[i].fd,
893 xlookup_bits(poll_flags, pfd[i].events));
895 used += u < per_fd ? u : per_fd;
900 asprintf(&tmp, "0x%lx", args[sc->offset]);
907 * XXX: A Fd_set argument expects the /first/ syscall argument
908 * to be the number of fds in the array. This matches the
912 int numfds = args[0];
913 int bytes = _howmany(numfds, _NFDBITS) * _NFDBITS;
914 int i, tmpsize, u, used;
915 const int per_fd = 20;
917 if ((fds = malloc(bytes)) == NULL)
918 err(1, "Cannot malloc %d bytes for fd_set array",
920 if (get_struct(pid, (void *)args[sc->offset], fds, bytes)
923 tmpsize = 1 + numfds * per_fd + 2;
924 if ((tmp = malloc(tmpsize)) == NULL)
925 err(1, "Cannot alloc %d bytes for fd_set "
929 for (i = 0; i < numfds; i++) {
930 if (FD_ISSET(i, fds)) {
931 u = snprintf(tmp + used, per_fd, "%d ",
934 used += u < per_fd ? u : per_fd;
937 if (tmp[used-1] == ' ')
942 asprintf(&tmp, "0x%lx", args[sc->offset]);
947 tmp = strsig2(args[sc->offset]);
955 sig = args[sc->offset];
956 if (get_struct(pid, (void *)args[sc->offset], (void *)&ss,
958 asprintf(&tmp, "0x%lx", args[sc->offset]);
961 tmp = malloc(sys_nsig * 8); /* 7 bytes avg per signal name */
963 for (i = 1; i < sys_nsig; i++) {
964 if (sigismember(&ss, i)) {
966 used += sprintf(tmp + used, "%s|", signame);
977 switch (args[sc->offset]) {
978 #define S(a) case a: tmp = strdup(#a); break;
985 asprintf(&tmp, "0x%lx", args[sc->offset]);
989 /* XXX output depends on the value of the previous argument */
990 switch (args[sc->offset-1]) {
992 tmp = strdup(xlookup_bits(fcntlfd_arg,
996 tmp = strdup(xlookup_bits(fcntlfl_arg,
1005 asprintf(&tmp, "0x%lx", args[sc->offset]);
1011 tmp = strdup(xlookup_bits(open_flags, args[sc->offset]));
1014 tmp = strdup(xlookup(fcntl_arg, args[sc->offset]));
1017 tmp = strdup(xlookup_bits(mprot_flags, args[sc->offset]));
1020 char *base, *alignstr;
1024 * MAP_ALIGNED can't be handled by xlookup_bits(), so
1025 * generate that string manually and prepend it to the
1026 * string from xlookup_bits(). Have to be careful to
1027 * avoid outputting MAP_ALIGNED|0 if MAP_ALIGNED is
1030 flags = args[sc->offset] & ~MAP_ALIGNMENT_MASK;
1031 align = args[sc->offset] & MAP_ALIGNMENT_MASK;
1033 if (align == MAP_ALIGNED_SUPER)
1034 alignstr = strdup("MAP_ALIGNED_SUPER");
1036 asprintf(&alignstr, "MAP_ALIGNED(%d)",
1037 align >> MAP_ALIGNMENT_SHIFT);
1044 base = strdup(xlookup_bits(mmap_flags, flags));
1045 if (alignstr == NULL) {
1049 asprintf(&tmp, "%s|%s", alignstr, base);
1055 tmp = strdup(xlookup(whence_arg, args[sc->offset]));
1058 tmp = strdup(xlookup(sockdomain_arg, args[sc->offset]));
1061 tmp = strdup(xlookup(socktype_arg, args[sc->offset]));
1064 tmp = strdup(xlookup(shutdown_arg, args[sc->offset]));
1067 tmp = strdup(xlookup(resource_arg, args[sc->offset]));
1070 tmp = strdup(xlookup(pathconf_arg, args[sc->offset]));
1073 tmp = strdup(xlookup_bits(rfork_flags, args[sc->offset]));
1076 struct sockaddr_storage ss;
1078 struct sockaddr_in *lsin;
1079 struct sockaddr_in6 *lsin6;
1080 struct sockaddr_un *sun;
1081 struct sockaddr *sa;
1086 if (args[sc->offset] == 0) {
1087 asprintf(&tmp, "NULL");
1091 /* yuck: get ss_len */
1092 if (get_struct(pid, (void *)args[sc->offset], (void *)&ss,
1093 sizeof(ss.ss_len) + sizeof(ss.ss_family)) == -1)
1094 err(1, "get_struct %p", (void *)args[sc->offset]);
1096 * If ss_len is 0, then try to guess from the sockaddr type.
1097 * AF_UNIX may be initialized incorrectly, so always frob
1098 * it by using the "right" size.
1100 if (ss.ss_len == 0 || ss.ss_family == AF_UNIX) {
1101 switch (ss.ss_family) {
1103 ss.ss_len = sizeof(*lsin);
1106 ss.ss_len = sizeof(*sun);
1113 if (get_struct(pid, (void *)args[sc->offset], (void *)&ss,
1115 err(2, "get_struct %p", (void *)args[sc->offset]);
1118 switch (ss.ss_family) {
1120 lsin = (struct sockaddr_in *)&ss;
1121 inet_ntop(AF_INET, &lsin->sin_addr, addr, sizeof addr);
1122 asprintf(&tmp, "{ AF_INET %s:%d }", addr,
1123 htons(lsin->sin_port));
1126 lsin6 = (struct sockaddr_in6 *)&ss;
1127 inet_ntop(AF_INET6, &lsin6->sin6_addr, addr,
1129 asprintf(&tmp, "{ AF_INET6 [%s]:%d }", addr,
1130 htons(lsin6->sin6_port));
1133 sun = (struct sockaddr_un *)&ss;
1134 asprintf(&tmp, "{ AF_UNIX \"%s\" }", sun->sun_path);
1137 sa = (struct sockaddr *)&ss;
1138 asprintf(&tmp, "{ sa_len = %d, sa_family = %d, sa_data "
1139 "= {%n%*s } }", (int)sa->sa_len, (int)sa->sa_family,
1140 &i, 6 * (int)(sa->sa_len - ((char *)&sa->sa_data -
1144 for (q = (u_char *)&sa->sa_data;
1145 q < (u_char *)sa + sa->sa_len; q++)
1146 p += sprintf(p, " %#02x,", *q);
1152 struct sigaction sa;
1156 if (get_struct(pid, (void *)args[sc->offset], &sa, sizeof(sa))
1158 asprintf(&hand, "%p", sa.sa_handler);
1159 if (sa.sa_handler == SIG_DFL)
1161 else if (sa.sa_handler == SIG_IGN)
1166 asprintf(&tmp, "{ %s %s ss_t }", h,
1167 xlookup_bits(sigaction_flags, sa.sa_flags));
1170 asprintf(&tmp, "0x%lx", args[sc->offset]);
1175 * XXX XXX: the size of the array is determined by either the
1176 * next syscall argument, or by the syscall returnvalue,
1177 * depending on which argument number we are. This matches the
1178 * kevent syscall, but luckily that's the only syscall that uses
1184 int i, tmpsize, u, used;
1185 const int per_ke = 100;
1187 if (sc->offset == 1)
1188 numevents = args[sc->offset+1];
1189 else if (sc->offset == 3 && retval != -1)
1193 bytes = sizeof(struct kevent) * numevents;
1194 if ((ke = malloc(bytes)) == NULL)
1195 err(1, "Cannot malloc %d bytes for kevent array",
1197 if (numevents >= 0 && get_struct(pid, (void *)args[sc->offset],
1200 tmpsize = 1 + per_ke * numevents + 2;
1201 if ((tmp = malloc(tmpsize)) == NULL)
1202 err(1, "Cannot alloc %d bytes for kevent "
1206 for (i = 0; i < numevents; i++) {
1207 u = snprintf(tmp + used, per_ke,
1208 "%s%p,%s,%s,%d,%p,%p",
1210 (void *)ke[i].ident,
1211 xlookup(kevent_filters, ke[i].filter),
1212 xlookup_bits(kevent_flags, ke[i].flags),
1215 (void *)ke[i].udata);
1217 used += u < per_ke ? u : per_ke;
1222 asprintf(&tmp, "0x%lx", args[sc->offset]);
1229 if (get_struct(pid, (void *)args[sc->offset], &st, sizeof(st))
1232 strmode(st.st_mode, mode);
1234 "{ mode=%s,inode=%jd,size=%jd,blksize=%ld }", mode,
1235 (intmax_t)st.st_ino, (intmax_t)st.st_size,
1236 (long)st.st_blksize);
1238 asprintf(&tmp, "0x%lx", args[sc->offset]);
1244 if (get_struct(pid, (void *)args[sc->offset], &ru, sizeof(ru))
1247 "{ u=%ld.%06ld,s=%ld.%06ld,in=%ld,out=%ld }",
1248 (long)ru.ru_utime.tv_sec, ru.ru_utime.tv_usec,
1249 (long)ru.ru_stime.tv_sec, ru.ru_stime.tv_usec,
1250 ru.ru_inblock, ru.ru_oublock);
1252 asprintf(&tmp, "0x%lx", args[sc->offset]);
1257 if (get_struct(pid, (void *)args[sc->offset], &rl, sizeof(rl))
1259 asprintf(&tmp, "{ cur=%ju,max=%ju }",
1260 rl.rlim_cur, rl.rlim_max);
1262 asprintf(&tmp, "0x%lx", args[sc->offset]);
1269 if (get_struct(pid, (void *)args[sc->offset], &status,
1270 sizeof(status)) != -1) {
1271 if (WIFCONTINUED(status))
1272 tmp = strdup("{ CONTINUED }");
1273 else if (WIFEXITED(status))
1274 asprintf(&tmp, "{ EXITED,val=%d }",
1275 WEXITSTATUS(status));
1276 else if (WIFSIGNALED(status))
1277 asprintf(&tmp, "{ SIGNALED,sig=%s%s }",
1278 signame = strsig2(WTERMSIG(status)),
1279 WCOREDUMP(status) ? ",cored" : "");
1281 asprintf(&tmp, "{ STOPPED,sig=%s }",
1282 signame = strsig2(WTERMSIG(status)));
1284 asprintf(&tmp, "0x%lx", args[sc->offset]);
1289 tmp = strdup(xlookup_bits(wait_options, args[sc->offset]));
1292 tmp = strdup(xlookup(idtype_arg, args[sc->offset]));
1295 tmp = strdup(xlookup(procctl_arg, args[sc->offset]));
1298 tmp = strdup(xlookup(umtx_ops, args[sc->offset]));
1301 errx(1, "Invalid argument type %d\n", sc->type & ARG_MASK);
1308 * Print (to outfile) the system call and its arguments. Note that
1309 * nargs is the number of arguments (not the number of words; this is
1310 * potentially confusing, I know).
1314 print_syscall(struct trussinfo *trussinfo, const char *name, int nargs,
1317 struct timespec timediff;
1321 if (trussinfo->flags & FOLLOWFORKS)
1322 len += fprintf(trussinfo->outfile, "%5d: ", trussinfo->pid);
1324 if (name != NULL && (strcmp(name, "execve") == 0 ||
1325 strcmp(name, "exit") == 0)) {
1326 clock_gettime(CLOCK_REALTIME, &trussinfo->curthread->after);
1329 if (trussinfo->flags & ABSOLUTETIMESTAMPS) {
1330 timespecsubt(&trussinfo->curthread->after,
1331 &trussinfo->start_time, &timediff);
1332 len += fprintf(trussinfo->outfile, "%ld.%09ld ",
1333 (long)timediff.tv_sec, timediff.tv_nsec);
1336 if (trussinfo->flags & RELATIVETIMESTAMPS) {
1337 timespecsubt(&trussinfo->curthread->after,
1338 &trussinfo->curthread->before, &timediff);
1339 len += fprintf(trussinfo->outfile, "%ld.%09ld ",
1340 (long)timediff.tv_sec, timediff.tv_nsec);
1343 len += fprintf(trussinfo->outfile, "%s(", name);
1345 for (i = 0; i < nargs; i++) {
1347 len += fprintf(trussinfo->outfile, "%s", s_args[i]);
1349 len += fprintf(trussinfo->outfile,
1350 "<missing argument>");
1351 len += fprintf(trussinfo->outfile, "%s", i < (nargs - 1) ?
1354 len += fprintf(trussinfo->outfile, ")");
1355 for (i = 0; i < 6 - (len / 8); i++)
1356 fprintf(trussinfo->outfile, "\t");
1360 print_syscall_ret(struct trussinfo *trussinfo, const char *name, int nargs,
1361 char **s_args, int errorp, long retval, struct syscall *sc)
1363 struct timespec timediff;
1365 if (trussinfo->flags & COUNTONLY) {
1368 clock_gettime(CLOCK_REALTIME, &trussinfo->curthread->after);
1369 timespecsubt(&trussinfo->curthread->after,
1370 &trussinfo->curthread->before, &timediff);
1371 timespecadd(&sc->time, &timediff, &sc->time);
1378 print_syscall(trussinfo, name, nargs, s_args);
1379 fflush(trussinfo->outfile);
1381 fprintf(trussinfo->outfile, " ERR#%ld '%s'\n", retval,
1385 * Because pipe(2) has a special assembly glue to provide the
1386 * libc API, we have to adjust retval.
1388 if (name != NULL && strcmp(name, "pipe") == 0)
1390 fprintf(trussinfo->outfile, " = %ld (0x%lx)\n", retval, retval);
1395 print_summary(struct trussinfo *trussinfo)
1397 struct timespec total = {0, 0};
1401 fprintf(trussinfo->outfile, "%-20s%15s%8s%8s\n",
1402 "syscall", "seconds", "calls", "errors");
1404 for (sc = syscalls; sc->name != NULL; sc++)
1406 fprintf(trussinfo->outfile, "%-20s%5jd.%09ld%8d%8d\n",
1407 sc->name, (intmax_t)sc->time.tv_sec,
1408 sc->time.tv_nsec, sc->ncalls, sc->nerror);
1409 timespecadd(&total, &sc->time, &total);
1410 ncall += sc->ncalls;
1411 nerror += sc->nerror;
1413 fprintf(trussinfo->outfile, "%20s%15s%8s%8s\n",
1414 "", "-------------", "-------", "-------");
1415 fprintf(trussinfo->outfile, "%-20s%5jd.%09ld%8d%8d\n",
1416 "", (intmax_t)total.tv_sec, total.tv_nsec, ncall, nerror);