Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/truss/setup.c
Show First 20 Lines • Show All 338 Lines • ▼ Show 20 Lines | |||||
static void | static void | ||||
alloc_syscall(struct threadinfo *t, struct ptrace_lwpinfo *pl) | alloc_syscall(struct threadinfo *t, struct ptrace_lwpinfo *pl) | ||||
{ | { | ||||
u_int i; | u_int i; | ||||
assert(t->in_syscall == 0); | assert(t->in_syscall == 0); | ||||
assert(t->cs.number == 0); | assert(t->cs.number == 0); | ||||
assert(t->cs.name == NULL); | assert(t->cs.sc == NULL); | ||||
assert(t->cs.nargs == 0); | assert(t->cs.nargs == 0); | ||||
for (i = 0; i < nitems(t->cs.s_args); i++) | for (i = 0; i < nitems(t->cs.s_args); i++) | ||||
assert(t->cs.s_args[i] == NULL); | assert(t->cs.s_args[i] == NULL); | ||||
memset(t->cs.args, 0, sizeof(t->cs.args)); | memset(t->cs.args, 0, sizeof(t->cs.args)); | ||||
t->cs.number = pl->pl_syscall_code; | t->cs.number = pl->pl_syscall_code; | ||||
t->in_syscall = 1; | t->in_syscall = 1; | ||||
} | } | ||||
Show All 17 Lines | enter_syscall(struct trussinfo *info, struct threadinfo *t, | ||||
alloc_syscall(t, pl); | alloc_syscall(t, pl); | ||||
narg = MIN(pl->pl_syscall_narg, nitems(t->cs.args)); | narg = MIN(pl->pl_syscall_narg, nitems(t->cs.args)); | ||||
if (narg != 0 && t->proc->abi->fetch_args(info, narg) != 0) { | if (narg != 0 && t->proc->abi->fetch_args(info, narg) != 0) { | ||||
free_syscall(t); | free_syscall(t); | ||||
return; | return; | ||||
} | } | ||||
t->cs.name = sysdecode_syscallname(t->proc->abi->abi, t->cs.number); | sc = get_syscall(t, t->cs.number, narg); | ||||
if (t->cs.name == NULL) | if (sc->unknown) | ||||
fprintf(info->outfile, "-- UNKNOWN %s SYSCALL %d --\n", | fprintf(info->outfile, "-- UNKNOWN %s SYSCALL %d --\n", | ||||
t->proc->abi->type, t->cs.number); | t->proc->abi->type, t->cs.number); | ||||
sc = get_syscall(t->cs.name, narg); | |||||
t->cs.nargs = sc->nargs; | t->cs.nargs = sc->nargs; | ||||
assert(sc->nargs <= nitems(t->cs.s_args)); | assert(sc->nargs <= nitems(t->cs.s_args)); | ||||
t->cs.sc = sc; | t->cs.sc = sc; | ||||
/* | /* | ||||
* At this point, we set up the system call arguments. | * At this point, we set up the system call arguments. | ||||
* We ignore any OUT ones, however -- those are arguments that | * We ignore any OUT ones, however -- those are arguments that | ||||
* are set by the system call, and so are probably meaningless | * are set by the system call, and so are probably meaningless | ||||
* now. This doesn't currently support arguments that are | * now. This doesn't currently support arguments that are | ||||
* passed in *and* out, however. | * passed in *and* out, however. | ||||
*/ | */ | ||||
if (t->cs.name != NULL) { | |||||
#if DEBUG | #if DEBUG | ||||
fprintf(stderr, "syscall %s(", t->cs.name); | fprintf(stderr, "syscall %s(", sc->name); | ||||
#endif | #endif | ||||
for (i = 0; i < t->cs.nargs; i++) { | for (i = 0; i < t->cs.nargs; i++) { | ||||
#if DEBUG | #if DEBUG | ||||
fprintf(stderr, "0x%lx%s", sc ? | fprintf(stderr, "0x%lx%s", t->cs.args[sc->args[i].offset], | ||||
t->cs.args[sc->args[i].offset] : t->cs.args[i], | |||||
i < (t->cs.nargs - 1) ? "," : ""); | i < (t->cs.nargs - 1) ? "," : ""); | ||||
#endif | #endif | ||||
if (!(sc->args[i].type & OUT)) { | if (!(sc->args[i].type & OUT)) { | ||||
t->cs.s_args[i] = print_arg(&sc->args[i], | t->cs.s_args[i] = print_arg(&sc->args[i], | ||||
t->cs.args, 0, info); | t->cs.args, 0, info); | ||||
} | } | ||||
} | } | ||||
#if DEBUG | #if DEBUG | ||||
fprintf(stderr, ")\n"); | fprintf(stderr, ")\n"); | ||||
#endif | #endif | ||||
} | |||||
clock_gettime(CLOCK_REALTIME, &t->before); | clock_gettime(CLOCK_REALTIME, &t->before); | ||||
} | } | ||||
/* | /* | ||||
* When a thread exits voluntarily (including when a thread calls | * When a thread exits voluntarily (including when a thread calls | ||||
* exit() to trigger a process exit), the thread's internal state | * exit() to trigger a process exit), the thread's internal state | ||||
* holds the arguments passed to the exit system call. When the | * holds the arguments passed to the exit system call. When the | ||||
▲ Show 20 Lines • Show All 267 Lines • Show Last 20 Lines |