Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/truss/setup.c
Show First 20 Lines • Show All 453 Lines • ▼ Show 20 Lines | enter_syscall(struct trussinfo *info, struct threadinfo *t, | ||||
narg = MIN(pl->pl_syscall_narg, nitems(t->cs.args)); | narg = MIN(pl->pl_syscall_narg, nitems(t->cs.args)); | ||||
if (narg != 0 && ptrace(PT_GET_SC_ARGS, t->tid, (caddr_t)t->cs.args, | if (narg != 0 && ptrace(PT_GET_SC_ARGS, t->tid, (caddr_t)t->cs.args, | ||||
sizeof(t->cs.args)) != 0) { | sizeof(t->cs.args)) != 0) { | ||||
free_syscall(t); | free_syscall(t); | ||||
return; | return; | ||||
} | } | ||||
sc = get_syscall(t, t->cs.number, narg); | sc = get_syscall(t, t->cs.number, narg); | ||||
if (sc->unknown) | if (sc->info.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); | ||||
t->cs.nargs = sc->nargs; | t->cs.nargs = sc->info.nargs; | ||||
assert(sc->nargs <= nitems(t->cs.s_args)); | assert(sc->info.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 DEBUG | #if DEBUG | ||||
fprintf(stderr, "syscall %s(", sc->name); | fprintf(stderr, "syscall %d %s(", t->cs.number, sc->kernel_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", t->cs.args[sc->args[i].offset], | fprintf(stderr, "%p%s", | ||||
(void *)t->cs.args[sc->info.args[i].offset], | |||||
jrtc27: I don't understand this change | |||||
Done Inline ActionsYeah I guess that doesn't need to be upstreamed and only makes sense if args is not a long... arichardson: Yeah I guess that doesn't need to be upstreamed and only makes sense if args is not a long... | |||||
i < (t->cs.nargs - 1) ? "," : ""); | i < (t->cs.nargs - 1) ? "," : ""); | ||||
#endif | #endif | ||||
if (!(sc->args[i].type & OUT)) { | if (!(sc->info.args[i].type & OUT)) { | ||||
t->cs.s_args[i] = print_arg(&sc->args[i], | t->cs.s_args[i] = print_arg(&sc->info.args[i], | ||||
t->cs.args, NULL, info); | t->cs.args, NULL, 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); | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | if (ptrace(PT_GET_SC_RET, t->tid, (caddr_t)&psr, sizeof(psr)) != 0) { | ||||
return; | return; | ||||
} | } | ||||
sc = t->cs.sc; | sc = t->cs.sc; | ||||
/* | /* | ||||
* Here, we only look for arguments that have OUT masked in -- | * Here, we only look for arguments that have OUT masked in -- | ||||
* otherwise, they were handled in enter_syscall(). | * otherwise, they were handled in enter_syscall(). | ||||
*/ | */ | ||||
for (i = 0; i < sc->nargs; i++) { | for (i = 0; i < sc->info.nargs; i++) { | ||||
char *temp; | char *temp; | ||||
if (sc->args[i].type & OUT) { | if (sc->info.args[i].type & OUT) { | ||||
/* | /* | ||||
* If an error occurred, then don't bother | * If an error occurred, then don't bother | ||||
* getting the data; it may not be valid. | * getting the data; it may not be valid. | ||||
*/ | */ | ||||
if (psr.sr_error != 0) { | if (psr.sr_error != 0) { | ||||
asprintf(&temp, "0x%lx", | asprintf(&temp, "0x%lx", | ||||
t->cs.args[sc->args[i].offset]); | t->cs.args[sc->info.args[i].offset]); | ||||
} else { | } else { | ||||
temp = print_arg(&sc->args[i], | temp = print_arg(&sc->info.args[i], | ||||
t->cs.args, psr.sr_retval, info); | t->cs.args, psr.sr_retval, info); | ||||
} | } | ||||
t->cs.s_args[i] = temp; | t->cs.s_args[i] = temp; | ||||
} | } | ||||
} | } | ||||
print_syscall_ret(info, psr.sr_error, psr.sr_retval); | print_syscall_ret(info, psr.sr_error, psr.sr_retval); | ||||
free_syscall(t); | free_syscall(t); | ||||
▲ Show 20 Lines • Show All 260 Lines • Show Last 20 Lines |
I don't understand this change