xref: /freebsd/usr.bin/truss/syscall.h (revision 9ecd54f24fe9fa373e07c9fd7c052deb2188f545)
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  * Name -- pointer to a NULL-terminated string.
9  * BinString -- pointer to an array of chars, printed via strvisx().
10  * Ptr -- pointer to some unspecified structure.  Just print as hex for now.
11  * Stat -- a pointer to a stat buffer.  Prints a couple fields.
12  * Ioctl -- an ioctl command.  Woefully limited.
13  * Quad -- a double-word value.  e.g., lseek(int, offset_t, int)
14  * Signal -- a signal number.  Prints the signal name (SIGxxx)
15  * Sockaddr -- a pointer to a struct sockaddr.  Prints symbolic AF, and IP:Port
16  * StringArray -- a pointer to an array of string pointers.
17  * Timespec -- a pointer to a struct timespec.  Prints both elements.
18  * Timeval -- a pointer to a struct timeval.  Prints both elements.
19  * Timeval2 -- a pointer to two struct timevals.  Prints both elements of both.
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  * Sigset -- a pointer to a sigset_t.  Prints the signals that are set.
25  * Sigprocmask -- the first argument to sigprocmask().  Prints the name.
26  * Kevent -- a pointer to an array of struct kevents.  Prints all elements.
27  * Pathconf -- the 2nd argument of pathconf().
28  *
29  * In addition, the pointer types (String, Ptr) may have OUT masked in --
30  * this means that the data is set on *return* from the system call -- or
31  * IN (meaning that the data is passed *into* the system call).
32  */
33 /*
34  * $FreeBSD$
35  */
36 
37 enum Argtype { None = 1, Hex, Octal, Int, Name, Ptr, Stat, Ioctl, Quad,
38 	Signal, Sockaddr, StringArray, Timespec, Timeval, Itimerval, Pollfd,
39 	Fd_set, Sigaction, Fcntl, Mprot, Mmapflags, Whence, Readlinkres,
40 	Sigset, Sigprocmask, Kevent, Sockdomain, Socktype, Open,
41 	Fcntlflag, Rusage, BinString, Shutdown, Resource, Rlimit, Timeval2,
42 	Pathconf, Rforkflags, ExitStatus, Waitoptions, Idtype, Procctl };
43 
44 #define	ARG_MASK	0xff
45 #define	OUT	0x100
46 #define	IN	/*0x20*/0
47 
48 struct syscall_args {
49 	enum Argtype type;
50 	int offset;
51 };
52 
53 struct syscall {
54 	const char *name;
55 	int ret_type;	/* 0, 1, or 2 return values */
56 	int nargs;	/* actual number of meaningful arguments */
57 			/* Hopefully, no syscalls with > 10 args */
58 	struct syscall_args args[10];
59 	struct timespec time; /* Time spent for this call */
60 	int ncalls;	/* Number of calls */
61 	int nerror;	/* Number of calls that returned with error */
62 };
63 
64 struct syscall *get_syscall(const char*);
65 char *print_arg(struct syscall_args *, unsigned long*, long, struct trussinfo *);
66 void print_syscall(struct trussinfo *, const char *, int, char **);
67 void print_syscall_ret(struct trussinfo *, const char *, int, char **, int,
68     long, struct syscall *);
69 void print_summary(struct trussinfo *trussinfo);
70