1 /* 2 * See i386-fbsd.c for copyright and license terms. 3 * 4 * System call arguments come in several flavours: 5 * Hex -- values that should be printed in hex (addresses) 6 * Octal -- Same as above, but octal 7 * Int -- normal integer values (file descriptors, for example) 8 * LongHex -- long value that should be printed in hex 9 * Name -- pointer to a NULL-terminated string. 10 * BinString -- pointer to an array of chars, printed via strvisx(). 11 * Ptr -- pointer to some unspecified structure. Just print as hex for now. 12 * Stat -- a pointer to a stat buffer. Prints a couple fields. 13 * Ioctl -- an ioctl command. Woefully limited. 14 * Quad -- a double-word value. e.g., lseek(int, offset_t, int) 15 * Signal -- a signal number. Prints the signal name (SIGxxx) 16 * Sockaddr -- a pointer to a struct sockaddr. Prints symbolic AF, and IP:Port 17 * StringArray -- a pointer to an array of string pointers. 18 * Timespec -- a pointer to a struct timespec. Prints both elements. 19 * Timeval -- a pointer to a struct timeval. Prints both elements. 20 * Timeval2 -- a pointer to two struct timevals. Prints both elements of both. 21 * Itimerval -- a pointer to a struct itimerval. Prints all elements. 22 * Pollfd -- a pointer to an array of struct pollfd. Prints .fd and .events. 23 * Fd_set -- a pointer to an array of fd_set. Prints the fds that are set. 24 * Sigaction -- a pointer to a struct sigaction. Prints all elements. 25 * Sigset -- a pointer to a sigset_t. Prints the signals that are set. 26 * Sigprocmask -- the first argument to sigprocmask(). Prints the name. 27 * Kevent -- a pointer to an array of struct kevents. Prints all elements. 28 * Pathconf -- the 2nd argument of pathconf(). 29 * 30 * In addition, the pointer types (String, Ptr) may have OUT masked in -- 31 * this means that the data is set on *return* from the system call -- or 32 * IN (meaning that the data is passed *into* the system call). 33 */ 34 /* 35 * $FreeBSD$ 36 */ 37 38 enum Argtype { None = 1, Hex, Octal, Int, LongHex, Name, Ptr, Stat, Ioctl, Quad, 39 Signal, Sockaddr, StringArray, Timespec, Timeval, Itimerval, Pollfd, 40 Fd_set, Sigaction, Fcntl, Mprot, Mmapflags, Whence, Readlinkres, 41 Sigset, Sigprocmask, Kevent, Sockdomain, Socktype, Open, 42 Fcntlflag, Rusage, BinString, Shutdown, Resource, Rlimit, Timeval2, 43 Pathconf, Rforkflags, ExitStatus, Waitoptions, Idtype, Procctl, 44 LinuxSockArgs, Umtxop }; 45 46 #define ARG_MASK 0xff 47 #define OUT 0x100 48 #define IN /*0x20*/0 49 50 struct syscall_args { 51 enum Argtype type; 52 int offset; 53 }; 54 55 struct syscall { 56 const char *name; 57 int ret_type; /* 0, 1, or 2 return values */ 58 int nargs; /* actual number of meaningful arguments */ 59 /* Hopefully, no syscalls with > 10 args */ 60 struct syscall_args args[10]; 61 struct timespec time; /* Time spent for this call */ 62 int ncalls; /* Number of calls */ 63 int nerror; /* Number of calls that returned with error */ 64 }; 65 66 struct syscall *get_syscall(const char*); 67 char *print_arg(struct syscall_args *, unsigned long*, long, struct trussinfo *); 68 69 /* 70 * Linux Socket defines 71 */ 72 #define LINUX_SOCKET 1 73 #define LINUX_BIND 2 74 #define LINUX_CONNECT 3 75 #define LINUX_LISTEN 4 76 #define LINUX_ACCEPT 5 77 #define LINUX_GETSOCKNAME 6 78 #define LINUX_GETPEERNAME 7 79 #define LINUX_SOCKETPAIR 8 80 #define LINUX_SEND 9 81 #define LINUX_RECV 10 82 #define LINUX_SENDTO 11 83 #define LINUX_RECVFROM 12 84 #define LINUX_SHUTDOWN 13 85 #define LINUX_SETSOCKOPT 14 86 #define LINUX_GETSOCKOPT 15 87 #define LINUX_SENDMSG 16 88 #define LINUX_RECVMSG 17 89 90 #define PAD_(t) (sizeof(register_t) <= sizeof(t) ? \ 91 0 : sizeof(register_t) - sizeof(t)) 92 93 #if BYTE_ORDER == LITTLE_ENDIAN 94 #define PADL_(t) 0 95 #define PADR_(t) PAD_(t) 96 #else 97 #define PADL_(t) PAD_(t) 98 #define PADR_(t) 0 99 #endif 100 101 typedef int l_int; 102 typedef uint32_t l_ulong; 103 104 struct linux_socketcall_args { 105 char what_l_[PADL_(l_int)]; l_int what; char what_r_[PADR_(l_int)]; 106 char args_l_[PADL_(l_ulong)]; l_ulong args; char args_r_[PADR_(l_ulong)]; 107 }; 108 109 void print_syscall(struct trussinfo *, const char *, int, char **); 110 void print_syscall_ret(struct trussinfo *, const char *, int, char **, int, 111 long, struct syscall *); 112 void print_summary(struct trussinfo *trussinfo); 113