summaryrefslogtreecommitdiffstats
path: root/usr.bin/truss/amd64-fbsd32.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/truss/amd64-fbsd32.c')
-rw-r--r--usr.bin/truss/amd64-fbsd32.c40
1 files changed, 22 insertions, 18 deletions
diff --git a/usr.bin/truss/amd64-fbsd32.c b/usr.bin/truss/amd64-fbsd32.c
index 8a3537b..95e0dfb 100644
--- a/usr.bin/truss/amd64-fbsd32.c
+++ b/usr.bin/truss/amd64-fbsd32.c
@@ -61,6 +61,7 @@ static const char rcsid[] =
#include "truss.h"
#include "syscall.h"
+#include "extern.h"
static int fd = -1;
static int cpid = -1;
@@ -81,7 +82,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! */
@@ -90,7 +91,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);
}
@@ -114,8 +115,8 @@ clear_fsc() {
void
i386_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;
@@ -124,7 +125,7 @@ i386_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;
@@ -132,7 +133,10 @@ i386_syscall_entry(struct trussinfo *trussinfo, int nargs) {
clear_fsc();
lseek(fd, 0L, 0);
- i = read(fd, &regs, sizeof(regs));
+ if (read(fd, &regs, sizeof(regs)) != sizeof(regs)) {
+ fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n");
+ return;
+ }
parm_offset = regs.r_esp + sizeof(int);
/*
@@ -140,25 +144,25 @@ i386_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_eax;
- switch (syscall) {
+ syscall_num = regs.r_eax;
+ switch (syscall_num) {
case SYS_syscall:
lseek(Procfd, parm_offset, SEEK_SET);
- read(Procfd, &syscall, sizeof(int));
+ read(Procfd, &syscall_num, sizeof(int));
parm_offset += sizeof(int);
break;
case SYS___syscall:
lseek(Procfd, parm_offset, SEEK_SET);
- read(Procfd, &syscall, sizeof(int));
+ read(Procfd, &syscall_num, sizeof(int));
parm_offset += sizeof(quad_t);
break;
}
- 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)
@@ -267,7 +271,7 @@ i386_syscall_entry(struct trussinfo *trussinfo, int nargs) {
*/
int
-i386_syscall_exit(struct trussinfo *trussinfo, int syscall) {
+i386_syscall_exit(struct trussinfo *trussinfo, int syscall_num __unused) {
char buf[32];
struct reg regs;
int retval;
@@ -279,16 +283,16 @@ i386_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;
}
lseek(fd, 0L, 0);
if (read(fd, &regs, sizeof(regs)) != sizeof(regs)) {
- fprintf(trussinfo->outfile, "\n");
- return;
+ fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n");
+ return (-1);
}
retval = regs.r_eax;
errorp = !!(regs.r_eflags & PSL_C);
OpenPOWER on IntegriCloud