xref: /freebsd/usr.bin/truss/syscall.h (revision 4f29da19bd44f0e99f021510460a81bf754c21d2)
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  * String -- pointers to sensible data.  Note that we treat read() and
9  *	write() arguments as such, even though they may *not* be
10  *	printable data.
11  * Ptr -- pointer to some specific structure.  Just print as hex for now.
12  * Stat -- a pointer to a stat buffer.  Currently unused.
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  * Itimerval -- a pointer to a struct itimerval.  Prints all elements.
21  * Pollfd -- a pointer to an array of struct pollfd.  Prints .fd and .events.
22  * Fd_set -- a pointer to an array of fd_set.  Prints the fds that are set.
23  * Sigaction -- a pointer to a struct sigaction.  Prints all elements.
24  *
25  * In addition, the pointer types (String, Ptr) may have OUT masked in --
26  * this means that the data is set on *return* from the system call -- or
27  * IN (meaning that the data is passed *into* the system call).
28  */
29 /*
30  * $FreeBSD$
31  */
32 
33 enum Argtype { None = 1, Hex, Octal, Int, Name, String, Ptr, Stat, Ioctl, Quad,
34 	Signal, Sockaddr, StringArray, Timespec, Timeval, Itimerval, Pollfd,
35 	Fd_set, Sigaction, Fcntl, Mprot, Mmapflags, Whence, Readlinkres };
36 
37 #define ARG_MASK	0xff
38 #define OUT	0x100
39 #define IN	/*0x20*/0
40 
41 struct syscall_args {
42 	enum Argtype type;
43 	int offset;
44 };
45 
46 struct syscall {
47 	const char *name;
48 	int ret_type;	/* 0, 1, or 2 return values */
49 	int nargs;	/* actual number of meaningful arguments */
50 			/* Hopefully, no syscalls with > 10 args */
51 	struct syscall_args args[10];
52 };
53 
54 struct syscall *get_syscall(const char*);
55 char *get_string(int, void*, int);
56 char *print_arg(int, struct syscall_args *, unsigned long*, long, struct trussinfo *);
57 void print_syscall(struct trussinfo *, const char *, int, char **);
58 void print_syscall_ret(struct trussinfo *, const char *, int, char **, int,
59     long);
60