Changeset View
Standalone View
usr.bin/truss/syscall.h
Show First 20 Lines • Show All 210 Lines • ▼ Show 20 Lines | |||||
#define ARG_MASK 0xff | #define ARG_MASK 0xff | ||||
#define OUT 0x100 | #define OUT 0x100 | ||||
#define IN /*0x20*/0 | #define IN /*0x20*/0 | ||||
_Static_assert(ARG_MASK > MAX_ARG_TYPE, | _Static_assert(ARG_MASK > MAX_ARG_TYPE, | ||||
"ARG_MASK overlaps with Argtype values"); | "ARG_MASK overlaps with Argtype values"); | ||||
struct syscall_args { | struct syscall_arg { | ||||
enum Argtype type; | enum Argtype type; | ||||
int offset; | int offset; | ||||
}; | }; | ||||
struct syscall_decode { | |||||
jrtc27: Personally not a huge fan of syscall_cconv as a name, maybe syscall_decode to match the fact… | |||||
Done Inline Actionssyscall_decode sounds good to me. arichardson: syscall_decode sounds good to me. | |||||
const char *name; /* Name for calling convention lookup */ | |||||
Done Inline ActionsI don't think this really belongs in here. You only need it for lookups, so why not make the table an array of struct { char *; struct syscall_cconv; }? jrtc27: I don't think this really belongs in here. You only need it for lookups, so why not make the… | |||||
Done Inline ActionsI wanted to avoid having to change all entries in the table. arichardson: I wanted to avoid having to change all entries in the table. | |||||
Not Done Inline ActionsHm. The reason I don't like it is that it's not a useful field to have for syscalls that don't have special decoding, since it's the ABI-prefixed name (with D27625), not the unprefixed name like some like you'll get for known freebsd32 syscalls, and so if we can instead limit it to only where it's needed (the lookup) then it's consistent and there's no risk of being confused and using the wrong thing. Which also means you can rename syscall's kernel_name back to name, as that's not the best name for it either currently. jrtc27: Hm. The reason I don't like it is that it's not a useful field to have for syscalls that don't… | |||||
Done Inline ActionsI agree it's not useful, but I don't want to edit the entire table. I think changing the table should probably be a separate commit that sorts it to allow use of bsearch. arichardson: I agree it's not useful, but I don't want to edit the entire table. I think changing the table… | |||||
Done Inline ActionsIt'd probably be best to decouple sorting from restructuring, that way it's clear they're NFCs (well, at least git will tell you the sorting was just moving lines). Also neither are really dependent on the other except for the fact that they conflict if done independently. Would you consider leaving kernel_name as name so that a follow-up doesn't need to revert that once the restructuring has happened? jrtc27: It'd probably be best to decouple sorting from restructuring, that way it's clear they're NFCs… | |||||
u_int ret_type; /* 0, 1, or 2 return values */ | |||||
jhbUnsubmitted Done Inline ActionsIt's not the number of return values, but the types. 0 means "doesn't return" (for exit()), 1 means "long" (or int), and 2 means off_t. It could possibly stand to be an enum instead of an int, but not in this commit. jhb: It's not the number of return values, but the types. 0 means "doesn't return" (for exit()), 1… | |||||
arichardsonAuthorUnsubmitted Done Inline ActionsI just moved this line from below, should I fix the comment too? arichardson: I just moved this line from below, should I fix the comment too? | |||||
jhbUnsubmitted Done Inline Actions
Oh cute. Might as well update the comment, yes. jhb: > I just moved this line from below, should I fix the comment too?
Oh cute. Might as well… | |||||
u_int nargs; /* number of meaningful arguments */ | |||||
struct syscall_arg args[10]; /* Hopefully no syscalls with > 10 args */ | |||||
}; | |||||
Done Inline ActionsThis belongs in struct syscall IMO (and I don't think you need it here). jrtc27: This belongs in struct syscall IMO (and I don't think you need it here). | |||||
struct syscall { | struct syscall { | ||||
STAILQ_ENTRY(syscall) entries; | STAILQ_ENTRY(syscall) entries; | ||||
const char *name; | char *name; /* Name to be displayed, must be malloc()'d */ | ||||
u_int ret_type; /* 0, 1, or 2 return values */ | struct syscall_decode decode; | ||||
Done Inline ActionsMaybe call this decode instead? jrtc27: Maybe call this decode instead? | |||||
u_int nargs; /* actual number of meaningful arguments */ | |||||
/* Hopefully, no syscalls with > 10 args */ | |||||
struct syscall_args args[10]; | |||||
struct timespec time; /* Time spent for this call */ | struct timespec time; /* Time spent for this call */ | ||||
int ncalls; /* Number of calls */ | int ncalls; /* Number of calls */ | ||||
int nerror; /* Number of calls that returned with error */ | int nerror; /* Number of calls that returned with error */ | ||||
bool unknown; /* Unknown system call */ | bool unknown; /* Unknown system call */ | ||||
}; | }; | ||||
struct syscall *get_syscall(struct threadinfo *, u_int, u_int); | struct syscall *get_syscall(struct threadinfo *, u_int, u_int); | ||||
char *print_arg(struct syscall_args *, unsigned long*, register_t *, | char *print_arg(struct syscall_arg *, unsigned long *, register_t *, | ||||
struct trussinfo *); | struct trussinfo *); | ||||
/* | /* | ||||
* Linux Socket defines | * Linux Socket defines | ||||
*/ | */ | ||||
#define LINUX_SOCKET 1 | #define LINUX_SOCKET 1 | ||||
#define LINUX_BIND 2 | #define LINUX_BIND 2 | ||||
#define LINUX_CONNECT 3 | #define LINUX_CONNECT 3 | ||||
Show All 26 Lines | |||||
typedef int l_int; | typedef int l_int; | ||||
typedef uint32_t l_ulong; | typedef uint32_t l_ulong; | ||||
struct linux_socketcall_args { | struct linux_socketcall_args { | ||||
char what_l_[PADL_(l_int)]; l_int what; char what_r_[PADR_(l_int)]; | char what_l_[PADL_(l_int)]; l_int what; char what_r_[PADR_(l_int)]; | ||||
char args_l_[PADL_(l_ulong)]; l_ulong args; char args_r_[PADR_(l_ulong)]; | char args_l_[PADL_(l_ulong)]; l_ulong args; char args_r_[PADR_(l_ulong)]; | ||||
}; | }; | ||||
void init_syscalls(void); | |||||
void print_syscall(struct trussinfo *); | void print_syscall(struct trussinfo *); | ||||
void print_syscall_ret(struct trussinfo *, int, register_t *); | void print_syscall_ret(struct trussinfo *, int, register_t *); | ||||
void print_summary(struct trussinfo *trussinfo); | void print_summary(struct trussinfo *trussinfo); |
Personally not a huge fan of syscall_cconv as a name, maybe syscall_decode to match the fact that these come from the decoded_syscalls array?