Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/truss/syscalls.c
Show First 20 Lines • Show All 919 Lines • ▼ Show 20 Lines | init_syscalls(void) | ||||
for (sc = decoded_syscalls; sc->name != NULL; sc++) | for (sc = decoded_syscalls; sc->name != NULL; sc++) | ||||
STAILQ_INSERT_HEAD(&syscalls, sc, entries); | STAILQ_INSERT_HEAD(&syscalls, sc, entries); | ||||
} | } | ||||
/* | /* | ||||
* If/when the list gets big, it might be desirable to do it | * If/when the list gets big, it might be desirable to do it | ||||
* as a hash table or binary search. | * as a hash table or binary search. | ||||
*/ | */ | ||||
struct syscall * | struct syscall * | ||||
get_syscall(const char *name, int nargs) | get_syscall(const struct threadinfo *t, int nargs) | ||||
{ | { | ||||
struct syscall *sc; | struct syscall *sc; | ||||
int i; | int i; | ||||
if (name == NULL) | if (t->cs.name == NULL) | ||||
return (NULL); | return (NULL); | ||||
bdrewery: This is coming out in the next commit to fix unknown syscalls. | |||||
STAILQ_FOREACH(sc, &syscalls, entries) | STAILQ_FOREACH(sc, &syscalls, entries) | ||||
if (strcmp(name, sc->name) == 0) | if (t->cs.number == sc->number && | ||||
t->proc->abi->abi == sc->abi) | |||||
return (sc); | return (sc); | ||||
/* It is unknown. Add it into the list. */ | /* It is unknown. Add it into the list. */ | ||||
#if DEBUG | #if DEBUG | ||||
fprintf(stderr, "unknown syscall %s -- setting args to %d\n", name, | fprintf(stderr, "unknown syscall %s -- setting args to %d\n", | ||||
nargs); | t->cs.name, nargs); | ||||
#endif | #endif | ||||
sc = calloc(1, sizeof(struct syscall)); | sc = calloc(1, sizeof(struct syscall)); | ||||
sc->name = strdup(name); | sc->abi = t->proc->abi->abi; | ||||
sc->name = strdup(t->cs.name); | |||||
sc->ret_type = 1; | sc->ret_type = 1; | ||||
sc->nargs = nargs; | sc->nargs = nargs; | ||||
sc->number = t->cs.number; | |||||
for (i = 0; i < nargs; i++) { | for (i = 0; i < nargs; i++) { | ||||
sc->args[i].offset = i; | sc->args[i].offset = i; | ||||
/* Treat all unknown arguments as LongHex. */ | /* Treat all unknown arguments as LongHex. */ | ||||
sc->args[i].type = LongHex; | sc->args[i].type = LongHex; | ||||
} | } | ||||
STAILQ_INSERT_HEAD(&syscalls, sc, entries); | STAILQ_INSERT_HEAD(&syscalls, sc, entries); | ||||
return (sc); | return (sc); | ||||
▲ Show 20 Lines • Show All 1,160 Lines • Show Last 20 Lines |
This is coming out in the next commit to fix unknown syscalls.