Fetch the current thread and it's syscall state from the trussinfo object

instead of passing some of that state as arguments to print_syscall() and
print_syscallret().  This just makes the calls of these functions shorter
and easier to read.
This commit is contained in:
John Baldwin 2016-02-16 22:00:01 +00:00
parent 1662c2ae80
commit 00ddbdf2ee
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=295677
3 changed files with 27 additions and 24 deletions

View File

@ -422,8 +422,7 @@ exit_syscall(struct trussinfo *info, struct ptrace_lwpinfo *pl)
}
}
print_syscall_ret(info, t->cs.name, t->cs.nargs, t->cs.s_args,
errorp, retval, sc);
print_syscall_ret(info, errorp, retval);
free_syscall(t);
/*

View File

@ -118,7 +118,6 @@ struct linux_socketcall_args {
};
void init_syscalls(void);
void print_syscall(struct trussinfo *, const char *, int, char **);
void print_syscall_ret(struct trussinfo *, const char *, int, char **, int,
long *, struct syscall *);
void print_syscall(struct trussinfo *);
void print_syscall_ret(struct trussinfo *, int, long *);
void print_summary(struct trussinfo *trussinfo);

View File

@ -2000,37 +2000,39 @@ print_arg(struct syscall_args *sc, unsigned long *args, long *retval,
}
/*
* Print (to outfile) the system call and its arguments. Note that
* nargs is the number of arguments (not the number of words; this is
* potentially confusing, I know).
* Print (to outfile) the system call and its arguments.
*/
void
print_syscall(struct trussinfo *trussinfo, const char *name, int nargs,
char **s_args)
print_syscall(struct trussinfo *trussinfo)
{
struct timespec timediff;
int i, len;
struct threadinfo *t;
const char *name;
char **s_args;
int i, len, nargs;
len = 0;
t = trussinfo->curthread;
if (trussinfo->flags & FOLLOWFORKS)
len += fprintf(trussinfo->outfile, "%5d: ",
trussinfo->curthread->proc->pid);
t->proc->pid);
name = t->cs.name;
nargs = t->cs.nargs;
s_args = t->cs.s_args;
if (name != NULL && (strcmp(name, "execve") == 0 ||
strcmp(name, "exit") == 0)) {
clock_gettime(CLOCK_REALTIME, &trussinfo->curthread->after);
clock_gettime(CLOCK_REALTIME, &t->after);
}
if (trussinfo->flags & ABSOLUTETIMESTAMPS) {
timespecsubt(&trussinfo->curthread->after,
&trussinfo->start_time, &timediff);
timespecsubt(&t->after, &trussinfo->start_time, &timediff);
len += fprintf(trussinfo->outfile, "%jd.%09ld ",
(intmax_t)timediff.tv_sec, timediff.tv_nsec);
}
if (trussinfo->flags & RELATIVETIMESTAMPS) {
timespecsubt(&trussinfo->curthread->after,
&trussinfo->curthread->before, &timediff);
timespecsubt(&t->after, &t->before, &timediff);
len += fprintf(trussinfo->outfile, "%jd.%09ld ",
(intmax_t)timediff.tv_sec, timediff.tv_nsec);
}
@ -2038,7 +2040,7 @@ print_syscall(struct trussinfo *trussinfo, const char *name, int nargs,
len += fprintf(trussinfo->outfile, "%s(", name);
for (i = 0; i < nargs; i++) {
if (s_args[i])
if (s_args[i] != NULL)
len += fprintf(trussinfo->outfile, "%s", s_args[i]);
else
len += fprintf(trussinfo->outfile,
@ -2052,15 +2054,18 @@ print_syscall(struct trussinfo *trussinfo, const char *name, int nargs,
}
void
print_syscall_ret(struct trussinfo *trussinfo, const char *name, int nargs,
char **s_args, int errorp, long *retval, struct syscall *sc)
print_syscall_ret(struct trussinfo *trussinfo, int errorp, long *retval)
{
struct timespec timediff;
struct threadinfo *t;
struct syscall *sc;
int error;
t = trussinfo->curthread;
sc = t->cs.sc;
if (trussinfo->flags & COUNTONLY) {
clock_gettime(CLOCK_REALTIME, &trussinfo->curthread->after);
timespecsubt(&trussinfo->curthread->after,
&trussinfo->curthread->before, &timediff);
clock_gettime(CLOCK_REALTIME, &t->after);
timespecsubt(&t->after, &t->before, &timediff);
timespecadd(&sc->time, &timediff, &sc->time);
sc->ncalls++;
if (errorp)
@ -2068,7 +2073,7 @@ print_syscall_ret(struct trussinfo *trussinfo, const char *name, int nargs,
return;
}
print_syscall(trussinfo, name, nargs, s_args);
print_syscall(trussinfo);
fflush(trussinfo->outfile);
if (errorp)
fprintf(trussinfo->outfile, " ERR#%ld '%s'\n", retval[0],