131567Ssef/* 231899Ssef * See i386-fbsd.c for copyright and license terms. 331899Ssef * 431567Ssef * System call arguments come in several flavours: 531567Ssef * Hex -- values that should be printed in hex (addresses) 631567Ssef * Octal -- Same as above, but octal 731567Ssef * Int -- normal integer values (file descriptors, for example) 8158630Spav * Name -- pointer to a NULL-terminated string. 9158630Spav * BinString -- pointer to an array of chars, printed via strvisx(). 10158630Spav * Ptr -- pointer to some unspecified structure. Just print as hex for now. 11158630Spav * Stat -- a pointer to a stat buffer. Prints a couple fields. 1231571Ssef * Ioctl -- an ioctl command. Woefully limited. 13127332Sdwmalone * Quad -- a double-word value. e.g., lseek(int, offset_t, int) 14127332Sdwmalone * Signal -- a signal number. Prints the signal name (SIGxxx) 15127332Sdwmalone * Sockaddr -- a pointer to a struct sockaddr. Prints symbolic AF, and IP:Port 16127332Sdwmalone * StringArray -- a pointer to an array of string pointers. 17127332Sdwmalone * Timespec -- a pointer to a struct timespec. Prints both elements. 18127332Sdwmalone * Timeval -- a pointer to a struct timeval. Prints both elements. 19158630Spav * Timeval2 -- a pointer to two struct timevals. Prints both elements of both. 20127332Sdwmalone * Itimerval -- a pointer to a struct itimerval. Prints all elements. 21127332Sdwmalone * Pollfd -- a pointer to an array of struct pollfd. Prints .fd and .events. 22127332Sdwmalone * Fd_set -- a pointer to an array of fd_set. Prints the fds that are set. 23127332Sdwmalone * Sigaction -- a pointer to a struct sigaction. Prints all elements. 24158630Spav * Umtx -- a pointer to a struct umtx. Prints the value of owner. 25158630Spav * Sigset -- a pointer to a sigset_t. Prints the signals that are set. 26158630Spav * Sigprocmask -- the first argument to sigprocmask(). Prints the name. 27158630Spav * Kevent -- a pointer to an array of struct kevents. Prints all elements. 28181061Sdes * Pathconf -- the 2nd argument of pathconf(). 2931567Ssef * 3031567Ssef * In addition, the pointer types (String, Ptr) may have OUT masked in -- 3131567Ssef * this means that the data is set on *return* from the system call -- or 3231567Ssef * IN (meaning that the data is passed *into* the system call). 3331567Ssef */ 3431567Ssef/* 3550477Speter * $FreeBSD$ 3631567Ssef */ 3731567Ssef 38158630Spavenum Argtype { None = 1, Hex, Octal, Int, Name, Ptr, Stat, Ioctl, Quad, 39158630Spav Signal, Sockaddr, StringArray, Timespec, Timeval, Itimerval, Pollfd, 40158630Spav Fd_set, Sigaction, Fcntl, Mprot, Mmapflags, Whence, Readlinkres, 41158630Spav Umtx, Sigset, Sigprocmask, Kevent, Sockdomain, Socktype, Open, 42158630Spav Fcntlflag, Rusage, BinString, Shutdown, Resource, Rlimit, Timeval2, 43266719Ssmh Pathconf, Rforkflags, ExitStatus, Waitoptions, Idtype, Procctl, 44266719Ssmh LinuxSockArgs }; 4531567Ssef 46240005Szont#define ARG_MASK 0xff 47240005Szont#define OUT 0x100 48240005Szont#define IN /*0x20*/0 4931567Ssef 5031567Ssefstruct syscall_args { 5131567Ssef enum Argtype type; 5231567Ssef int offset; 5331567Ssef}; 5431567Ssef 5531567Ssefstruct syscall { 5687703Smarkm const char *name; 5731567Ssef int ret_type; /* 0, 1, or 2 return values */ 5831567Ssef int nargs; /* actual number of meaningful arguments */ 5931567Ssef /* Hopefully, no syscalls with > 10 args */ 6031567Ssef struct syscall_args args[10]; 61192025Sdds struct timespec time; /* Time spent for this call */ 62192025Sdds int ncalls; /* Number of calls */ 63192025Sdds int nerror; /* Number of calls that returned with error */ 6431567Ssef}; 6531567Ssef 6631567Ssefstruct syscall *get_syscall(const char*); 67168569Sdelphijchar *print_arg(struct syscall_args *, unsigned long*, long, struct trussinfo *); 68266719Ssmh 69266719Ssmh/* 70266719Ssmh * Linux Socket defines 71266719Ssmh */ 72266719Ssmh#define LINUX_SOCKET 1 73266719Ssmh#define LINUX_BIND 2 74266719Ssmh#define LINUX_CONNECT 3 75266719Ssmh#define LINUX_LISTEN 4 76266719Ssmh#define LINUX_ACCEPT 5 77266719Ssmh#define LINUX_GETSOCKNAME 6 78266719Ssmh#define LINUX_GETPEERNAME 7 79266719Ssmh#define LINUX_SOCKETPAIR 8 80266719Ssmh#define LINUX_SEND 9 81266719Ssmh#define LINUX_RECV 10 82266719Ssmh#define LINUX_SENDTO 11 83266719Ssmh#define LINUX_RECVFROM 12 84266719Ssmh#define LINUX_SHUTDOWN 13 85266719Ssmh#define LINUX_SETSOCKOPT 14 86266719Ssmh#define LINUX_GETSOCKOPT 15 87266719Ssmh#define LINUX_SENDMSG 16 88266719Ssmh#define LINUX_RECVMSG 17 89266719Ssmh 90266719Ssmh#define PAD_(t) (sizeof(register_t) <= sizeof(t) ? \ 91266719Ssmh 0 : sizeof(register_t) - sizeof(t)) 92266719Ssmh 93266719Ssmh#if BYTE_ORDER == LITTLE_ENDIAN 94266719Ssmh#define PADL_(t) 0 95266719Ssmh#define PADR_(t) PAD_(t) 96266719Ssmh#else 97266719Ssmh#define PADL_(t) PAD_(t) 98266719Ssmh#define PADR_(t) 0 99266719Ssmh#endif 100266719Ssmh 101266719Ssmhtypedef int l_int; 102266719Ssmhtypedef uint32_t l_ulong; 103266719Ssmh 104266719Ssmhstruct linux_socketcall_args { 105266719Ssmh char what_l_[PADL_(l_int)]; l_int what; char what_r_[PADR_(l_int)]; 106266719Ssmh char args_l_[PADL_(l_ulong)]; l_ulong args; char args_r_[PADR_(l_ulong)]; 107266719Ssmh}; 108266719Ssmh 109101282Smdoddvoid print_syscall(struct trussinfo *, const char *, int, char **); 110122348Smarcelvoid print_syscall_ret(struct trussinfo *, const char *, int, char **, int, 111192025Sdds long, struct syscall *); 112192025Sddsvoid print_summary(struct trussinfo *trussinfo); 113