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:
parent
1662c2ae80
commit
00ddbdf2ee
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=295677
@ -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,
|
print_syscall_ret(info, errorp, retval);
|
||||||
errorp, retval, sc);
|
|
||||||
free_syscall(t);
|
free_syscall(t);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -118,7 +118,6 @@ struct linux_socketcall_args {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void init_syscalls(void);
|
void init_syscalls(void);
|
||||||
void print_syscall(struct trussinfo *, const char *, int, char **);
|
void print_syscall(struct trussinfo *);
|
||||||
void print_syscall_ret(struct trussinfo *, const char *, int, char **, int,
|
void print_syscall_ret(struct trussinfo *, int, long *);
|
||||||
long *, struct syscall *);
|
|
||||||
void print_summary(struct trussinfo *trussinfo);
|
void print_summary(struct trussinfo *trussinfo);
|
||||||
|
@ -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
|
* Print (to outfile) the system call and its arguments.
|
||||||
* nargs is the number of arguments (not the number of words; this is
|
|
||||||
* potentially confusing, I know).
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
print_syscall(struct trussinfo *trussinfo, const char *name, int nargs,
|
print_syscall(struct trussinfo *trussinfo)
|
||||||
char **s_args)
|
|
||||||
{
|
{
|
||||||
struct timespec timediff;
|
struct timespec timediff;
|
||||||
int i, len;
|
struct threadinfo *t;
|
||||||
|
const char *name;
|
||||||
|
char **s_args;
|
||||||
|
int i, len, nargs;
|
||||||
|
|
||||||
len = 0;
|
len = 0;
|
||||||
|
t = trussinfo->curthread;
|
||||||
if (trussinfo->flags & FOLLOWFORKS)
|
if (trussinfo->flags & FOLLOWFORKS)
|
||||||
len += fprintf(trussinfo->outfile, "%5d: ",
|
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 ||
|
if (name != NULL && (strcmp(name, "execve") == 0 ||
|
||||||
strcmp(name, "exit") == 0)) {
|
strcmp(name, "exit") == 0)) {
|
||||||
clock_gettime(CLOCK_REALTIME, &trussinfo->curthread->after);
|
clock_gettime(CLOCK_REALTIME, &t->after);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trussinfo->flags & ABSOLUTETIMESTAMPS) {
|
if (trussinfo->flags & ABSOLUTETIMESTAMPS) {
|
||||||
timespecsubt(&trussinfo->curthread->after,
|
timespecsubt(&t->after, &trussinfo->start_time, &timediff);
|
||||||
&trussinfo->start_time, &timediff);
|
|
||||||
len += fprintf(trussinfo->outfile, "%jd.%09ld ",
|
len += fprintf(trussinfo->outfile, "%jd.%09ld ",
|
||||||
(intmax_t)timediff.tv_sec, timediff.tv_nsec);
|
(intmax_t)timediff.tv_sec, timediff.tv_nsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trussinfo->flags & RELATIVETIMESTAMPS) {
|
if (trussinfo->flags & RELATIVETIMESTAMPS) {
|
||||||
timespecsubt(&trussinfo->curthread->after,
|
timespecsubt(&t->after, &t->before, &timediff);
|
||||||
&trussinfo->curthread->before, &timediff);
|
|
||||||
len += fprintf(trussinfo->outfile, "%jd.%09ld ",
|
len += fprintf(trussinfo->outfile, "%jd.%09ld ",
|
||||||
(intmax_t)timediff.tv_sec, timediff.tv_nsec);
|
(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);
|
len += fprintf(trussinfo->outfile, "%s(", name);
|
||||||
|
|
||||||
for (i = 0; i < nargs; i++) {
|
for (i = 0; i < nargs; i++) {
|
||||||
if (s_args[i])
|
if (s_args[i] != NULL)
|
||||||
len += fprintf(trussinfo->outfile, "%s", s_args[i]);
|
len += fprintf(trussinfo->outfile, "%s", s_args[i]);
|
||||||
else
|
else
|
||||||
len += fprintf(trussinfo->outfile,
|
len += fprintf(trussinfo->outfile,
|
||||||
@ -2052,15 +2054,18 @@ print_syscall(struct trussinfo *trussinfo, const char *name, int nargs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
print_syscall_ret(struct trussinfo *trussinfo, const char *name, int nargs,
|
print_syscall_ret(struct trussinfo *trussinfo, int errorp, long *retval)
|
||||||
char **s_args, int errorp, long *retval, struct syscall *sc)
|
|
||||||
{
|
{
|
||||||
struct timespec timediff;
|
struct timespec timediff;
|
||||||
|
struct threadinfo *t;
|
||||||
|
struct syscall *sc;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
t = trussinfo->curthread;
|
||||||
|
sc = t->cs.sc;
|
||||||
if (trussinfo->flags & COUNTONLY) {
|
if (trussinfo->flags & COUNTONLY) {
|
||||||
clock_gettime(CLOCK_REALTIME, &trussinfo->curthread->after);
|
clock_gettime(CLOCK_REALTIME, &t->after);
|
||||||
timespecsubt(&trussinfo->curthread->after,
|
timespecsubt(&t->after, &t->before, &timediff);
|
||||||
&trussinfo->curthread->before, &timediff);
|
|
||||||
timespecadd(&sc->time, &timediff, &sc->time);
|
timespecadd(&sc->time, &timediff, &sc->time);
|
||||||
sc->ncalls++;
|
sc->ncalls++;
|
||||||
if (errorp)
|
if (errorp)
|
||||||
@ -2068,7 +2073,7 @@ print_syscall_ret(struct trussinfo *trussinfo, const char *name, int nargs,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
print_syscall(trussinfo, name, nargs, s_args);
|
print_syscall(trussinfo);
|
||||||
fflush(trussinfo->outfile);
|
fflush(trussinfo->outfile);
|
||||||
if (errorp)
|
if (errorp)
|
||||||
fprintf(trussinfo->outfile, " ERR#%ld '%s'\n", retval[0],
|
fprintf(trussinfo->outfile, " ERR#%ld '%s'\n", retval[0],
|
||||||
|
Loading…
Reference in New Issue
Block a user