3689d9eede3859b73b65d7413332eb51a64d4bda
[dragonfly.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  * 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  * Quad -- a double-word value.  e.g., lseek(int, offset_t, int)
13  * Stat -- a pointer to a stat buffer.  Currently unused.
14  * Ioctl -- an ioctl command.  Woefully limited.
15  *
16  * In addition, the pointer types (String, Ptr) may have OUT masked in --
17  * this means that the data is set on *return* from the system call -- or
18  * IN (meaning that the data is passed *into* the system call).
19  */
20 /*
21  * $FreeBSD: src/usr.bin/truss/syscall.h,v 1.5.2.3 2002/02/15 11:43:51 des Exp $
22  * $DragonFly: src/usr.bin/truss/syscall.h,v 1.2 2003/06/17 04:29:33 dillon Exp $
23  */
24
25 enum Argtype { None = 1, Hex, Octal, Int, String, Ptr, Stat, Ioctl, Quad,
26         Signal, Sockaddr };
27
28 #define ARG_MASK        0xff
29 #define OUT     0x100
30 #define IN      /*0x20*/0
31
32 struct syscall_args {
33         enum Argtype type;
34         int offset;
35 };
36
37 struct syscall {
38         const char *name;
39         int ret_type;   /* 0, 1, or 2 return values */
40         int nargs;      /* actual number of meaningful arguments */
41                         /* Hopefully, no syscalls with > 10 args */
42         struct syscall_args args[10];
43 };
44
45 struct syscall *get_syscall(const char*);
46 char *get_string(int, void*, int);
47 char *print_arg(int, struct syscall_args *, unsigned long*);
48 void print_syscall(FILE *, const char *, int, char **);
49 void print_syscall_ret(FILE *, const char *, int, char **, int, int);