diff options
Diffstat (limited to 'usr.bin/truss/alpha-fbsd.c')
-rw-r--r-- | usr.bin/truss/alpha-fbsd.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/usr.bin/truss/alpha-fbsd.c b/usr.bin/truss/alpha-fbsd.c index 60c62e1..5d8b5c2 100644 --- a/usr.bin/truss/alpha-fbsd.c +++ b/usr.bin/truss/alpha-fbsd.c @@ -63,6 +63,7 @@ static const char rcsid[] = #include "truss.h" #include "syscall.h" +#include "extern.h" static int fd = -1; static int cpid = -1; @@ -83,7 +84,7 @@ static int nsyscalls = sizeof(syscallnames) / sizeof(syscallnames[0]); */ static struct freebsd_syscall { struct syscall *sc; - char *name; + const char *name; int number; unsigned long *args; int nargs; /* number of arguments -- *not* number of words! */ @@ -92,7 +93,7 @@ static struct freebsd_syscall { /* Clear up and free parts of the fsc structure. */ static __inline void -clear_fsc() { +clear_fsc(void) { if (fsc.args) { free(fsc.args); } @@ -116,8 +117,8 @@ clear_fsc() { void alpha_syscall_entry(struct trussinfo *trussinfo, int nargs) { char buf[32]; - struct reg regs = { { 0 } }; - int syscall; + struct reg regs; + int syscall_num; int i; unsigned int parm_offset; struct syscall *sc; @@ -127,7 +128,7 @@ alpha_syscall_entry(struct trussinfo *trussinfo, int nargs) { sprintf(buf, "/proc/%d/regs", trussinfo->pid); fd = open(buf, O_RDWR); if (fd == -1) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); + fprintf(trussinfo->outfile, "-- CANNOT OPEN REGISTERS --\n"); return; } cpid = trussinfo->pid; @@ -135,7 +136,10 @@ alpha_syscall_entry(struct trussinfo *trussinfo, int nargs) { clear_fsc(); lseek(fd, 0L, 0); - i = read(fd, ®s, sizeof(regs)); + if (read(fd, ®s, sizeof(regs)) != sizeof(regs)) { + fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); + return; + } parm_offset = regs.r_regs[R_SP] + sizeof(int); /* @@ -143,17 +147,17 @@ alpha_syscall_entry(struct trussinfo *trussinfo, int nargs) { * SYS_syscall, and SYS___syscall. The former is the old syscall() * routine, basicly; the latter is for quad-aligned arguments. */ - syscall = regs.r_regs[R_V0]; - if (syscall == SYS_syscall || syscall == SYS___syscall) { + syscall_num = regs.r_regs[R_V0]; + if (syscall_num == SYS_syscall || syscall_num == SYS___syscall) { indir = 1; - syscall = regs.r_regs[R_A0]; + syscall_num = regs.r_regs[R_A0]; } - fsc.number = syscall; + fsc.number = syscall_num; fsc.name = - (syscall < 0 || syscall > nsyscalls) ? NULL : syscallnames[syscall]; + (syscall_num < 0 || syscall_num > nsyscalls) ? NULL : syscallnames[syscall_num]; if (!fsc.name) { - fprintf(trussinfo->outfile, "-- UNKNOWN SYSCALL %d --\n", syscall); + fprintf(trussinfo->outfile, "-- UNKNOWN SYSCALL %d --\n", syscall_num); } if (fsc.name && (trussinfo->flags & FOLLOWFORKS) @@ -288,7 +292,7 @@ alpha_syscall_entry(struct trussinfo *trussinfo, int nargs) { */ int -alpha_syscall_exit(struct trussinfo *trussinfo, int syscall) { +alpha_syscall_exit(struct trussinfo *trussinfo, int syscall_num __unused) { char buf[32]; struct reg regs; int retval; @@ -300,8 +304,8 @@ alpha_syscall_exit(struct trussinfo *trussinfo, int syscall) { sprintf(buf, "/proc/%d/regs", trussinfo->pid); fd = open(buf, O_RDONLY); if (fd == -1) { - fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); - return; + fprintf(trussinfo->outfile, "-- CANNOT OPEN REGISTERS --\n"); + return (-1); } cpid = trussinfo->pid; } @@ -309,7 +313,7 @@ alpha_syscall_exit(struct trussinfo *trussinfo, int syscall) { lseek(fd, 0L, 0); if (read(fd, ®s, sizeof(regs)) != sizeof(regs)) { fprintf(trussinfo->outfile, "\n"); - return; + return (-1); } retval = regs.r_regs[R_V0]; errorp = !!(regs.r_regs[R_A3]); |