Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/truss/syscall.h
Show All 36 Lines | |||||
enum Argtype { None = 1, Hex, Octal, Int, LongHex, Name, Ptr, Stat, Ioctl, Quad, | enum Argtype { None = 1, Hex, Octal, Int, LongHex, Name, Ptr, Stat, Ioctl, Quad, | ||||
Signal, Sockaddr, StringArray, Timespec, Timeval, Itimerval, Pollfd, | Signal, Sockaddr, StringArray, Timespec, Timeval, Itimerval, Pollfd, | ||||
Fd_set, Sigaction, Fcntl, Mprot, Mmapflags, Whence, Readlinkres, | Fd_set, Sigaction, Fcntl, Mprot, Mmapflags, Whence, Readlinkres, | ||||
Sigset, Sigprocmask, Kevent, Sockdomain, Socktype, Open, | Sigset, Sigprocmask, Kevent, Sockdomain, Socktype, Open, | ||||
Fcntlflag, Rusage, BinString, Shutdown, Resource, Rlimit, Timeval2, | Fcntlflag, Rusage, BinString, Shutdown, Resource, Rlimit, Timeval2, | ||||
Pathconf, Rforkflags, ExitStatus, Waitoptions, Idtype, Procctl, | Pathconf, Rforkflags, ExitStatus, Waitoptions, Idtype, Procctl, | ||||
LinuxSockArgs, Umtxop, Atfd, Atflags, Timespec2, Accessmode, Long, | LinuxSockArgs, Umtxop, Atfd, Atflags, Timespec2, Accessmode, Long, | ||||
Sysarch, ExecArgs, ExecEnv }; | Sysarch, ExecArgs, ExecEnv, PipeFds }; | ||||
#define ARG_MASK 0xff | #define ARG_MASK 0xff | ||||
#define OUT 0x100 | #define OUT 0x100 | ||||
#define IN /*0x20*/0 | #define IN /*0x20*/0 | ||||
struct syscall_args { | struct syscall_args { | ||||
enum Argtype type; | enum Argtype type; | ||||
int offset; | int offset; | ||||
}; | }; | ||||
struct syscall { | struct syscall { | ||||
const char *name; | const char *name; | ||||
int ret_type; /* 0, 1, or 2 return values */ | int ret_type; /* 0, 1, or 2 return values */ | ||||
int nargs; /* actual number of meaningful arguments */ | int nargs; /* actual number of meaningful arguments */ | ||||
/* Hopefully, no syscalls with > 10 args */ | /* Hopefully, no syscalls with > 10 args */ | ||||
struct syscall_args args[10]; | struct syscall_args args[10]; | ||||
struct timespec time; /* Time spent for this call */ | struct timespec time; /* Time spent for this call */ | ||||
int ncalls; /* Number of calls */ | int ncalls; /* Number of calls */ | ||||
int nerror; /* Number of calls that returned with error */ | int nerror; /* Number of calls that returned with error */ | ||||
}; | }; | ||||
struct syscall *get_syscall(const char*); | struct syscall *get_syscall(const char*); | ||||
char *print_arg(struct syscall_args *, unsigned long*, long, struct trussinfo *); | char *print_arg(struct syscall_args *, unsigned long*, long *, struct trussinfo *); | ||||
/* | /* | ||||
* Linux Socket defines | * Linux Socket defines | ||||
*/ | */ | ||||
#define LINUX_SOCKET 1 | #define LINUX_SOCKET 1 | ||||
#define LINUX_BIND 2 | #define LINUX_BIND 2 | ||||
#define LINUX_CONNECT 3 | #define LINUX_CONNECT 3 | ||||
#define LINUX_LISTEN 4 | #define LINUX_LISTEN 4 | ||||
#define LINUX_ACCEPT 5 | #define LINUX_ACCEPT 5 | ||||
#define LINUX_GETSOCKNAME 6 | #define LINUX_GETSOCKNAME 6 | ||||
#define LINUX_GETPEERNAME 7 | #define LINUX_GETPEERNAME 7 | ||||
#define LINUX_SOCKETPAIR 8 | #define LINUX_SOCKETPAIR 8 | ||||
#define LINUX_SEND 9 | #define LINUX_SEND 9 | ||||
#define LINUX_RECV 10 | #define LINUX_RECV 10 | ||||
#define LINUX_SENDTO 11 | #define LINUX_SENDTO 11 | ||||
#define LINUX_RECVFROM 12 | #define LINUX_RECVFROM 12 | ||||
#define LINUX_SHUTDOWN 13 | #define LINUX_SHUTDOWN 13 | ||||
#define LINUX_SETSOCKOPT 14 | #define LINUX_SETSOCKOPT 14 | ||||
#define LINUX_GETSOCKOPT 15 | #define LINUX_GETSOCKOPT 15 | ||||
#define LINUX_SENDMSG 16 | #define LINUX_SENDMSG 16 | ||||
#define LINUX_RECVMSG 17 | #define LINUX_RECVMSG 17 | ||||
#define PAD_(t) (sizeof(register_t) <= sizeof(t) ? \ | #define PAD_(t) (sizeof(register_t) <= sizeof(t) ? \ | ||||
0 : sizeof(register_t) - sizeof(t)) | 0 : sizeof(register_t) - sizeof(t)) | ||||
#if BYTE_ORDER == LITTLE_ENDIAN | #if BYTE_ORDER == LITTLE_ENDIAN | ||||
#define PADL_(t) 0 | #define PADL_(t) 0 | ||||
#define PADR_(t) PAD_(t) | #define PADR_(t) PAD_(t) | ||||
#else | #else | ||||
#define PADL_(t) PAD_(t) | #define PADL_(t) PAD_(t) | ||||
#define PADR_(t) 0 | #define PADR_(t) 0 | ||||
#endif | #endif | ||||
typedef int l_int; | typedef int l_int; | ||||
typedef uint32_t l_ulong; | typedef uint32_t l_ulong; | ||||
struct linux_socketcall_args { | struct linux_socketcall_args { | ||||
char what_l_[PADL_(l_int)]; l_int what; char what_r_[PADR_(l_int)]; | char what_l_[PADL_(l_int)]; l_int what; char what_r_[PADR_(l_int)]; | ||||
char args_l_[PADL_(l_ulong)]; l_ulong args; char args_r_[PADR_(l_ulong)]; | char args_l_[PADL_(l_ulong)]; l_ulong args; char args_r_[PADR_(l_ulong)]; | ||||
}; | }; | ||||
void print_syscall(struct trussinfo *, const char *, int, char **); | void print_syscall(struct trussinfo *, const char *, int, char **); | ||||
void print_syscall_ret(struct trussinfo *, const char *, int, char **, int, | void print_syscall_ret(struct trussinfo *, const char *, int, char **, int, | ||||
long, struct syscall *); | long *, struct syscall *); | ||||
void print_summary(struct trussinfo *trussinfo); | void print_summary(struct trussinfo *trussinfo); |