2 * SPDX-License-Identifier: BSD-4-Clause
4 * Copyright 1997 Sean Eric Fagan
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Sean Eric Fagan
17 * 4. Neither the name of the author may be used to endorse or promote
18 * products derived from this software without specific prior written
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * System call arguments come in several flavours:
38 * Hex -- values that should be printed in hex (addresses)
39 * Octal -- Same as above, but octal
40 * Int -- normal integer values (file descriptors, for example)
41 * LongHex -- long value that should be printed in hex
42 * Name -- pointer to a NULL-terminated string.
43 * BinString -- pointer to an array of chars, printed via strvisx().
44 * Ptr -- pointer to some unspecified structure. Just print as hex for now.
45 * Stat -- a pointer to a stat buffer. Prints a couple fields.
46 * StatFs -- a pointer to a statfs buffer. Prints a few fields.
47 * Ioctl -- an ioctl command. Woefully limited.
48 * Quad -- a double-word value. e.g., lseek(int, offset_t, int)
49 * Signal -- a signal number. Prints the signal name (SIGxxx)
50 * Sockaddr -- a pointer to a struct sockaddr. Prints symbolic AF, and IP:Port
51 * StringArray -- a pointer to an array of string pointers.
52 * Timespec -- a pointer to a struct timespec. Prints both elements.
53 * Timeval -- a pointer to a struct timeval. Prints both elements.
54 * Timeval2 -- a pointer to two struct timevals. Prints both elements of both.
55 * Itimerval -- a pointer to a struct itimerval. Prints all elements.
56 * Pollfd -- a pointer to an array of struct pollfd. Prints .fd and .events.
57 * Fd_set -- a pointer to an array of fd_set. Prints the fds that are set.
58 * Sigaction -- a pointer to a struct sigaction. Prints all elements.
59 * Sigset -- a pointer to a sigset_t. Prints the signals that are set.
60 * Sigprocmask -- the first argument to sigprocmask(). Prints the name.
61 * Kevent -- a pointer to an array of struct kevents. Prints all elements.
62 * Pathconf -- the 2nd argument of pathconf().
63 * Utrace -- utrace(2) buffer.
64 * CapRights -- a pointer to a cap_rights_t. Prints all set capabilities.
66 * In addition, the pointer types (String, Ptr) may have OUT masked in --
67 * this means that the data is set on *return* from the system call -- or
68 * IN (meaning that the data is passed *into* the system call).
71 enum Argtype { None = 1, Hex, Octal, Int, UInt, LongHex, Name, Ptr, Stat, Ioctl,
72 Quad, Signal, Sockaddr, StringArray, Timespec, Timeval, Itimerval,
73 Pollfd, Fd_set, Sigaction, Fcntl, Mprot, Mmapflags, Whence, Readlinkres,
74 Sigset, Sigprocmask, StatFs, Kevent, Sockdomain, Socktype, Open,
75 Fcntlflag, Rusage, RusageWho, BinString, Shutdown, Resource, Rlimit,
76 Timeval2, Pathconf, Rforkflags, ExitStatus, Waitoptions, Idtype, Procctl,
77 LinuxSockArgs, Umtxop, Atfd, Atflags, Timespec2, Accessmode, Long,
78 Sysarch, ExecArgs, ExecEnv, PipeFds, QuadHex, Utrace, IntArray, Pipe2,
79 CapFcntlRights, Fadvice, FileFlags, Flockop, Getfsstatmode, Kldsymcmd,
80 Kldunloadflags, Sizet, Madvice, Socklent, Sockprotocol, Sockoptlevel,
81 Sockoptname, Msgflags, CapRights, PUInt, PQuadHex, Acltype,
82 Extattrnamespace, Minherit, Mlockall, Mountflags, Msync, Priowhich,
83 Ptraceop, Quotactlcmd, Reboothowto, Rtpriofunc, Schedpolicy, Schedparam,
84 PSig, Siginfo, Kevent11,
86 CloudABIAdvice, CloudABIClockID, ClouduABIFDSFlags,
87 CloudABIFDStat, CloudABIFileStat, CloudABIFileType,
88 CloudABIFSFlags, CloudABILookup, CloudABIMFlags, CloudABIMProt,
89 CloudABIMSFlags, CloudABIOFlags, CloudABISDFlags,
90 CloudABISignal, CloudABISockStat, CloudABISSFlags,
91 CloudABITimestamp, CloudABIULFlags, CloudABIWhence };
103 STAILQ_ENTRY(syscall) entries;
105 u_int ret_type; /* 0, 1, or 2 return values */
106 u_int nargs; /* actual number of meaningful arguments */
107 /* Hopefully, no syscalls with > 10 args */
108 struct syscall_args args[10];
109 struct timespec time; /* Time spent for this call */
110 int ncalls; /* Number of calls */
111 int nerror; /* Number of calls that returned with error */
112 bool unknown; /* Unknown system call */
115 struct syscall *get_syscall(struct threadinfo *, u_int, u_int);
116 char *print_arg(struct syscall_args *, unsigned long*, long *, struct trussinfo *);
119 * Linux Socket defines
121 #define LINUX_SOCKET 1
123 #define LINUX_CONNECT 3
124 #define LINUX_LISTEN 4
125 #define LINUX_ACCEPT 5
126 #define LINUX_GETSOCKNAME 6
127 #define LINUX_GETPEERNAME 7
128 #define LINUX_SOCKETPAIR 8
130 #define LINUX_RECV 10
131 #define LINUX_SENDTO 11
132 #define LINUX_RECVFROM 12
133 #define LINUX_SHUTDOWN 13
134 #define LINUX_SETSOCKOPT 14
135 #define LINUX_GETSOCKOPT 15
136 #define LINUX_SENDMSG 16
137 #define LINUX_RECVMSG 17
139 #define PAD_(t) (sizeof(register_t) <= sizeof(t) ? \
140 0 : sizeof(register_t) - sizeof(t))
142 #if BYTE_ORDER == LITTLE_ENDIAN
144 #define PADR_(t) PAD_(t)
146 #define PADL_(t) PAD_(t)
151 typedef uint32_t l_ulong;
153 struct linux_socketcall_args {
154 char what_l_[PADL_(l_int)]; l_int what; char what_r_[PADR_(l_int)];
155 char args_l_[PADL_(l_ulong)]; l_ulong args; char args_r_[PADR_(l_ulong)];
158 void init_syscalls(void);
159 void print_syscall(struct trussinfo *);
160 void print_syscall_ret(struct trussinfo *, int, long *);
161 void print_summary(struct trussinfo *trussinfo);