]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/truss/syscall.h
Decode arguments to getpriority() and setpriority().
[FreeBSD/FreeBSD.git] / usr.bin / truss / syscall.h
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  * StatFs -- a pointer to a statfs buffer.  Prints a few fields.
14  * Ioctl -- an ioctl command.  Woefully limited.
15  * Quad -- a double-word value.  e.g., lseek(int, offset_t, int)
16  * Signal -- a signal number.  Prints the signal name (SIGxxx)
17  * Sockaddr -- a pointer to a struct sockaddr.  Prints symbolic AF, and IP:Port
18  * StringArray -- a pointer to an array of string pointers.
19  * Timespec -- a pointer to a struct timespec.  Prints both elements.
20  * Timeval -- a pointer to a struct timeval.  Prints both elements.
21  * Timeval2 -- a pointer to two struct timevals.  Prints both elements of both.
22  * Itimerval -- a pointer to a struct itimerval.  Prints all elements.
23  * Pollfd -- a pointer to an array of struct pollfd.  Prints .fd and .events.
24  * Fd_set -- a pointer to an array of fd_set.  Prints the fds that are set.
25  * Sigaction -- a pointer to a struct sigaction.  Prints all elements.
26  * Sigset -- a pointer to a sigset_t.  Prints the signals that are set.
27  * Sigprocmask -- the first argument to sigprocmask().  Prints the name.
28  * Kevent -- a pointer to an array of struct kevents.  Prints all elements.
29  * Pathconf -- the 2nd argument of pathconf().
30  * Utrace -- utrace(2) buffer.
31  * CapRights -- a pointer to a cap_rights_t.  Prints all set capabilities.
32  *
33  * In addition, the pointer types (String, Ptr) may have OUT masked in --
34  * this means that the data is set on *return* from the system call -- or
35  * IN (meaning that the data is passed *into* the system call).
36  */
37 /*
38  * $FreeBSD$
39  */
40
41 enum Argtype { None = 1, Hex, Octal, Int, UInt, LongHex, Name, Ptr, Stat, Ioctl,
42         Quad, Signal, Sockaddr, StringArray, Timespec, Timeval, Itimerval,
43         Pollfd, Fd_set, Sigaction, Fcntl, Mprot, Mmapflags, Whence, Readlinkres,
44         Sigset, Sigprocmask, StatFs, Kevent, Sockdomain, Socktype, Open,
45         Fcntlflag, Rusage, RusageWho, BinString, Shutdown, Resource, Rlimit,
46         Timeval2, Pathconf, Rforkflags, ExitStatus, Waitoptions, Idtype, Procctl,
47         LinuxSockArgs, Umtxop, Atfd, Atflags, Timespec2, Accessmode, Long,
48         Sysarch, ExecArgs, ExecEnv, PipeFds, QuadHex, Utrace, IntArray, Pipe2,
49         CapFcntlRights, Fadvice, FileFlags, Flockop, Getfsstatmode, Kldsymcmd,
50         Kldunloadflags, Sizet, Madvice, Socklent, Sockprotocol, Sockoptlevel,
51         Sockoptname, Msgflags, CapRights, PUInt, PQuadHex, Acltype,
52         Extattrnamespace, Minherit, Mlockall, Mountflags, Msync, Priowhich,
53
54         CloudABIAdvice, CloudABIClockID, ClouduABIFDSFlags,
55         CloudABIFDStat, CloudABIFileStat, CloudABIFileType,
56         CloudABIFSFlags, CloudABILookup, CloudABIMFlags, CloudABIMProt,
57         CloudABIMSFlags, CloudABIOFlags, CloudABISDFlags,
58         CloudABISignal, CloudABISockStat, CloudABISSFlags,
59         CloudABITimestamp, CloudABIULFlags, CloudABIWhence };
60
61 #define ARG_MASK        0xff
62 #define OUT     0x100
63 #define IN      /*0x20*/0
64
65 struct syscall_args {
66         enum Argtype type;
67         int offset;
68 };
69
70 struct syscall {
71         STAILQ_ENTRY(syscall) entries;
72         const char *name;
73         u_int ret_type; /* 0, 1, or 2 return values */
74         u_int nargs;    /* actual number of meaningful arguments */
75                         /* Hopefully, no syscalls with > 10 args */
76         struct syscall_args args[10];
77         struct timespec time; /* Time spent for this call */
78         int ncalls;     /* Number of calls */
79         int nerror;     /* Number of calls that returned with error */
80         bool unknown;   /* Unknown system call */
81 };
82
83 struct syscall *get_syscall(struct threadinfo *, u_int, u_int);
84 char *print_arg(struct syscall_args *, unsigned long*, long *, struct trussinfo *);
85
86 /*
87  * Linux Socket defines
88  */
89 #define LINUX_SOCKET            1
90 #define LINUX_BIND              2
91 #define LINUX_CONNECT           3
92 #define LINUX_LISTEN            4
93 #define LINUX_ACCEPT            5
94 #define LINUX_GETSOCKNAME       6
95 #define LINUX_GETPEERNAME       7
96 #define LINUX_SOCKETPAIR        8
97 #define LINUX_SEND              9
98 #define LINUX_RECV              10
99 #define LINUX_SENDTO            11
100 #define LINUX_RECVFROM          12
101 #define LINUX_SHUTDOWN          13
102 #define LINUX_SETSOCKOPT        14
103 #define LINUX_GETSOCKOPT        15
104 #define LINUX_SENDMSG           16
105 #define LINUX_RECVMSG           17
106
107 #define PAD_(t) (sizeof(register_t) <= sizeof(t) ? \
108     0 : sizeof(register_t) - sizeof(t))
109
110 #if BYTE_ORDER == LITTLE_ENDIAN
111 #define PADL_(t)        0
112 #define PADR_(t)        PAD_(t)
113 #else
114 #define PADL_(t)        PAD_(t)
115 #define PADR_(t)        0
116 #endif
117
118 typedef int     l_int;
119 typedef uint32_t    l_ulong;
120
121 struct linux_socketcall_args {
122     char what_l_[PADL_(l_int)]; l_int what; char what_r_[PADR_(l_int)];
123     char args_l_[PADL_(l_ulong)]; l_ulong args; char args_r_[PADR_(l_ulong)];
124 };
125
126 void init_syscalls(void);
127 void print_syscall(struct trussinfo *);
128 void print_syscall_ret(struct trussinfo *, int, long *);
129 void print_summary(struct trussinfo *trussinfo);