xref: /dflybsd-src/usr.bin/truss/syscall.h (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
1*86d7f5d3SJohn Marino /*
2*86d7f5d3SJohn Marino  * See i386-fbsd.c for copyright and license terms.
3*86d7f5d3SJohn Marino  *
4*86d7f5d3SJohn Marino  * System call arguments come in several flavours:
5*86d7f5d3SJohn Marino  * Hex -- values that should be printed in hex (addresses)
6*86d7f5d3SJohn Marino  * Octal -- Same as above, but octal
7*86d7f5d3SJohn Marino  * Int -- normal integer values (file descriptors, for example)
8*86d7f5d3SJohn Marino  * String -- pointers to sensible data.  Note that we treat read() and
9*86d7f5d3SJohn Marino  *	write() arguments as such, even though they may *not* be
10*86d7f5d3SJohn Marino  *	printable data.
11*86d7f5d3SJohn Marino  * Ptr -- pointer to some specific structure.  Just print as hex for now.
12*86d7f5d3SJohn Marino  * Quad -- a double-word value.  e.g., lseek(int, offset_t, int)
13*86d7f5d3SJohn Marino  * Stat -- a pointer to a stat buffer.  Currently unused.
14*86d7f5d3SJohn Marino  * Ioctl -- an ioctl command.  Woefully limited.
15*86d7f5d3SJohn Marino  *
16*86d7f5d3SJohn Marino  * In addition, the pointer types (String, Ptr) may have OUT masked in --
17*86d7f5d3SJohn Marino  * this means that the data is set on *return* from the system call -- or
18*86d7f5d3SJohn Marino  * IN (meaning that the data is passed *into* the system call).
19*86d7f5d3SJohn Marino  */
20*86d7f5d3SJohn Marino /*
21*86d7f5d3SJohn Marino  * $FreeBSD: src/usr.bin/truss/syscall.h,v 1.5.2.3 2002/02/15 11:43:51 des Exp $
22*86d7f5d3SJohn Marino  * $DragonFly: src/usr.bin/truss/syscall.h,v 1.2 2003/06/17 04:29:33 dillon Exp $
23*86d7f5d3SJohn Marino  */
24*86d7f5d3SJohn Marino 
25*86d7f5d3SJohn Marino enum Argtype { None = 1, Hex, Octal, Int, String, Ptr, Stat, Ioctl, Quad,
26*86d7f5d3SJohn Marino 	Signal, Sockaddr };
27*86d7f5d3SJohn Marino 
28*86d7f5d3SJohn Marino #define ARG_MASK	0xff
29*86d7f5d3SJohn Marino #define OUT	0x100
30*86d7f5d3SJohn Marino #define IN	/*0x20*/0
31*86d7f5d3SJohn Marino 
32*86d7f5d3SJohn Marino struct syscall_args {
33*86d7f5d3SJohn Marino 	enum Argtype type;
34*86d7f5d3SJohn Marino 	int offset;
35*86d7f5d3SJohn Marino };
36*86d7f5d3SJohn Marino 
37*86d7f5d3SJohn Marino struct syscall {
38*86d7f5d3SJohn Marino 	const char *name;
39*86d7f5d3SJohn Marino 	int ret_type;	/* 0, 1, or 2 return values */
40*86d7f5d3SJohn Marino 	int nargs;	/* actual number of meaningful arguments */
41*86d7f5d3SJohn Marino 			/* Hopefully, no syscalls with > 10 args */
42*86d7f5d3SJohn Marino 	struct syscall_args args[10];
43*86d7f5d3SJohn Marino };
44*86d7f5d3SJohn Marino 
45*86d7f5d3SJohn Marino struct syscall *get_syscall(const char*);
46*86d7f5d3SJohn Marino char *get_string(int, void*, int);
47*86d7f5d3SJohn Marino char *print_arg(int, struct syscall_args *, unsigned long*);
48*86d7f5d3SJohn Marino void print_syscall(struct trussinfo *, const char *, int, char **);
49*86d7f5d3SJohn Marino void print_syscall_ret(struct trussinfo *, const char *, int, char **, int, int);
50