diff options
author | sef <sef@FreeBSD.org> | 2000-03-18 08:49:41 +0000 |
---|---|---|
committer | sef <sef@FreeBSD.org> | 2000-03-18 08:49:41 +0000 |
commit | 855f88c9ee43d878e9dc8c5f4b362bd197d6f68d (patch) | |
tree | bfac07850597fe28d602d656a956a2b037a5262f /usr.bin/truss | |
parent | 1ed162731b0b7073dfba31f1298772cd6947d679 (diff) | |
download | FreeBSD-src-855f88c9ee43d878e9dc8c5f4b362bd197d6f68d.zip FreeBSD-src-855f88c9ee43d878e9dc8c5f4b362bd197d6f68d.tar.gz |
Change the output of truss to more closely resemble SysV's. (Yes, it
really is much nicer looking.)
Submitted by: "Matthew N. Dodd" <winter@jurai.net>
Diffstat (limited to 'usr.bin/truss')
-rw-r--r-- | usr.bin/truss/alpha-fbsd.c | 7 | ||||
-rw-r--r-- | usr.bin/truss/amd64-fbsd32.c | 7 | ||||
-rw-r--r-- | usr.bin/truss/amd64-linux32.c | 5 | ||||
-rw-r--r-- | usr.bin/truss/i386-fbsd.c | 7 | ||||
-rw-r--r-- | usr.bin/truss/i386-linux.c | 5 | ||||
-rw-r--r-- | usr.bin/truss/syscall.h | 1 | ||||
-rw-r--r-- | usr.bin/truss/syscalls.c | 23 |
7 files changed, 24 insertions, 31 deletions
diff --git a/usr.bin/truss/alpha-fbsd.c b/usr.bin/truss/alpha-fbsd.c index 125e126..6b58e22 100644 --- a/usr.bin/truss/alpha-fbsd.c +++ b/usr.bin/truss/alpha-fbsd.c @@ -321,12 +321,7 @@ alpha_syscall_exit(int pid, int syscall) { * but that complicates things considerably. */ - print_syscall(outfile, fsc.name, fsc.nargs, fsc.s_args); - if (errorp) { - fprintf(outfile, "errno %d '%s'\n", retval, strerror(retval)); - } else { - fprintf(outfile, "returns %d (0x%x)\n", retval, retval); - } + print_syscall_ret(outfile, fsc.name, fsc.nargs, fsc.s_args, errorp, retval); clear_fsc(); return; diff --git a/usr.bin/truss/amd64-fbsd32.c b/usr.bin/truss/amd64-fbsd32.c index 463f475..065c90b 100644 --- a/usr.bin/truss/amd64-fbsd32.c +++ b/usr.bin/truss/amd64-fbsd32.c @@ -299,12 +299,7 @@ i386_syscall_exit(int pid, int syscall) { * but that complicates things considerably. */ - print_syscall(outfile, fsc.name, fsc.nargs, fsc.s_args); - if (errorp) { - fprintf(outfile, "errno %d '%s'\n", retval, strerror(retval)); - } else { - fprintf(outfile, "returns %d (0x%x)\n", retval, retval); - } + print_syscall_ret(outfile, fsc.name, fsc.nargs, fsc.s_args, errorp, retval); clear_fsc(); return; diff --git a/usr.bin/truss/amd64-linux32.c b/usr.bin/truss/amd64-linux32.c index ec7632b..d95c644 100644 --- a/usr.bin/truss/amd64-linux32.c +++ b/usr.bin/truss/amd64-linux32.c @@ -238,15 +238,12 @@ i386_linux_syscall_exit(int pid, int syscall) { } } } - print_syscall(outfile, lsc.name, lsc.nargs, lsc.s_args); if (errorp) { for (i = 0; i < sizeof(bsd_to_linux_errno) / sizeof(int); i++) if (retval == bsd_to_linux_errno[i]) break; - fprintf(outfile, "errno %d '%s'\n", retval, strerror(i)); - } else { - fprintf(outfile, "returns %d (0x%x)\n", retval, retval); } + print_syscall_ret(outfile, lsc.name, lsc.nargs, lsc.s_args, errorp, i); clear_lsc(); return; } diff --git a/usr.bin/truss/i386-fbsd.c b/usr.bin/truss/i386-fbsd.c index 463f475..065c90b 100644 --- a/usr.bin/truss/i386-fbsd.c +++ b/usr.bin/truss/i386-fbsd.c @@ -299,12 +299,7 @@ i386_syscall_exit(int pid, int syscall) { * but that complicates things considerably. */ - print_syscall(outfile, fsc.name, fsc.nargs, fsc.s_args); - if (errorp) { - fprintf(outfile, "errno %d '%s'\n", retval, strerror(retval)); - } else { - fprintf(outfile, "returns %d (0x%x)\n", retval, retval); - } + print_syscall_ret(outfile, fsc.name, fsc.nargs, fsc.s_args, errorp, retval); clear_fsc(); return; diff --git a/usr.bin/truss/i386-linux.c b/usr.bin/truss/i386-linux.c index ec7632b..d95c644 100644 --- a/usr.bin/truss/i386-linux.c +++ b/usr.bin/truss/i386-linux.c @@ -238,15 +238,12 @@ i386_linux_syscall_exit(int pid, int syscall) { } } } - print_syscall(outfile, lsc.name, lsc.nargs, lsc.s_args); if (errorp) { for (i = 0; i < sizeof(bsd_to_linux_errno) / sizeof(int); i++) if (retval == bsd_to_linux_errno[i]) break; - fprintf(outfile, "errno %d '%s'\n", retval, strerror(i)); - } else { - fprintf(outfile, "returns %d (0x%x)\n", retval, retval); } + print_syscall_ret(outfile, lsc.name, lsc.nargs, lsc.s_args, errorp, i); clear_lsc(); return; } diff --git a/usr.bin/truss/syscall.h b/usr.bin/truss/syscall.h index 2b3c66b..5e556e1 100644 --- a/usr.bin/truss/syscall.h +++ b/usr.bin/truss/syscall.h @@ -45,3 +45,4 @@ struct syscall *get_syscall(const char*); char *get_string(int, void*, int); char *print_arg(int, struct syscall_args *, unsigned long*); void print_syscall(FILE *, const char *, int, char **); +void print_syscall_ret(FILE *, const char *, int, char **, int, int); diff --git a/usr.bin/truss/syscalls.c b/usr.bin/truss/syscalls.c index 1b98cba..29e8c29 100644 --- a/usr.bin/truss/syscalls.c +++ b/usr.bin/truss/syscalls.c @@ -256,13 +256,26 @@ print_arg(int fd, struct syscall_args *sc, unsigned long *args) { void print_syscall(FILE *outfile, const char *name, int nargs, char **s_args) { int i; - fprintf(outfile, "syscall %s(", name); + int len = 0; + len += fprintf(outfile, "%s(", name); for (i = 0; i < nargs; i++) { if (s_args[i]) - fprintf(outfile, "%s", s_args[i]); + len += fprintf(outfile, "%s", s_args[i]); else - fprintf(outfile, "<missing argument>"); - fprintf(outfile, "%s", i < (nargs - 1) ? "," : ""); + len += fprintf(outfile, "<missing argument>"); + len += fprintf(outfile, "%s", i < (nargs - 1) ? "," : ""); + } + len += fprintf(outfile, ")"); + for (i = 0; i < 6 - (len / 8); i++) + fprintf(outfile, "\t"); +} + +void +print_syscall_ret(FILE *outfile, const char *name, int nargs, char **s_args, int errorp, int retval) { + print_syscall(outfile, name, nargs, s_args); + if (errorp) { + fprintf(outfile, " ERR#%d '%s'\n", retval, strerror(retval)); + } else { + fprintf(outfile, " = %d (0x%x)\n", retval, retval); } - fprintf(outfile, ")\n\t"); } |