diff options
author | mdodd <mdodd@FreeBSD.org> | 2002-08-04 01:27:31 +0000 |
---|---|---|
committer | mdodd <mdodd@FreeBSD.org> | 2002-08-04 01:27:31 +0000 |
commit | 3cb287247d5c599cde0f7839b27320c6ae3b907c (patch) | |
tree | 1ea381bca59453aef6677708cd85d541a2dc4c3e /usr.bin/truss/main.c | |
parent | e327abdb5fe6f6022bec2eac7491975d34fa77d2 (diff) | |
download | FreeBSD-src-3cb287247d5c599cde0f7839b27320c6ae3b907c.zip FreeBSD-src-3cb287247d5c599cde0f7839b27320c6ae3b907c.tar.gz |
Add options to print absolute and relative timestamps.
PR: bin/25587 (in part)
MFC after: 3 weeks
Diffstat (limited to 'usr.bin/truss/main.c')
-rw-r--r-- | usr.bin/truss/main.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/usr.bin/truss/main.c b/usr.bin/truss/main.c index d1a236a..0a31993 100644 --- a/usr.bin/truss/main.c +++ b/usr.bin/truss/main.c @@ -67,8 +67,8 @@ static __inline void usage(void) { fprintf(stderr, "%s\n%s\n", - "usage: truss [-fS] [-o file] -p pid", - " truss [-fS] [-o file] command [args]"); + "usage: truss [-fdDS] [-o file] -p pid", + " truss [-fdDS] [-o file] command [args]"); exit(1); } @@ -145,7 +145,7 @@ main(int ac, char **av) { bzero(trussinfo, sizeof(struct trussinfo)); trussinfo->outfile = stderr; - while ((c = getopt(ac, av, "p:o:fS")) != -1) { + while ((c = getopt(ac, av, "p:o:fdDS")) != -1) { switch (c) { case 'p': /* specified pid */ trussinfo->pid = atoi(optarg); @@ -153,6 +153,12 @@ main(int ac, char **av) { case 'f': /* Follow fork()'s */ trussinfo->flags |= FOLLOWFORKS; break; + case 'd': /* Absolute timestamps */ + trussinfo->flags |= ABSOLUTETIMESTAMPS; + break; + case 'D': /* Relative timestamps */ + trussinfo->flags |= RELATIVETIMESTAMPS; + break; case 'o': /* Specified output file */ fname = optarg; break; @@ -215,6 +221,8 @@ START_TRACE: * All of the grunt work is done in the support routines. */ + gettimeofday(&trussinfo->start_time, (struct timezone *)NULL); + do { int val = 0; @@ -224,8 +232,10 @@ START_TRACE: switch(i = pfs.why) { case S_SCE: funcs->enter_syscall(trussinfo, pfs.val); + gettimeofday(&trussinfo->before, (struct timezone *)NULL); break; case S_SCX: + gettimeofday(&trussinfo->after, (struct timezone *)NULL); /* * This is so we don't get two messages for an exec -- one * for the S_EXEC, and one for the syscall exit. It also, |