Date: Sat, 4 Nov 2006 00:22:43 GMT From: John Birrell <jb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 109173 for review Message-ID: <200611040022.kA40MhlV034021@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=109173 Change 109173 by jb@jb_freebsd8 on 2006/11/04 00:22:20 Reset to match current. I'll ask howardsu to create a //depot/user/howardsu/truss branch to help isolate the truss/ptrace changes for review rather than complicating the DTrace review with them. Affected files ... .. //depot/projects/dtrace/src/usr.bin/truss/powerpc-fbsd.c#6 edit Differences ... ==== //depot/projects/dtrace/src/usr.bin/truss/powerpc-fbsd.c#6 (text+ko) ==== @@ -41,7 +41,8 @@ */ #include <sys/types.h> -#include <sys/ptrace.h> +#include <sys/ioctl.h> +#include <sys/pioctl.h> #include <sys/syscall.h> #include <machine/reg.h> @@ -61,6 +62,7 @@ #include "syscall.h" #include "extern.h" +static int fd = -1; static int cpid = -1; #include "syscalls.h" @@ -110,18 +112,30 @@ void powerpc_syscall_entry(struct trussinfo *trussinfo, int nargs) { + char buf[32]; struct reg regs; void *args; int syscall_num; int i; unsigned int regargs; struct syscall *sc; - struct ptrace_io_desc iorequest; - cpid = trussinfo->tid; + if (fd == -1 || trussinfo->pid != cpid) { + sprintf(buf, "/proc/%d/regs", trussinfo->pid); + fd = open(buf, O_RDWR); + if (fd == -1) { + fprintf(trussinfo->outfile, "-- CANNOT OPEN REGISTERS --\n"); + return; + } + cpid = trussinfo->pid; + } clear_fsc(); - ptrace(PT_GETREGS, cpid, (caddr_t)®s, 0); + lseek(fd, 0L, 0); + if (read(fd, ®s, sizeof(regs)) != sizeof(regs)) { + fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); + return; + } /* * FreeBSD has two special kinds of system call redirctions -- @@ -163,13 +177,8 @@ if (nargs > regargs) { memmove(&fsc.args[0], args, regargs * sizeof(fsc.args[0])); - - iorequest.piod_op = PIOD_READ_D; - iorequest.piod_offs = (void *)(regs.fixreg[1] + 8); - iorequest.piod_addr = &fsc.args[regargs]; - iorequest.piod_len = (nargs - regargs) * sizeof(fsc.args[0]); - ptrace(PT_IO, cpid, (caddr_t)&iorequest, 0); - if (iorequest.piod_len == 0) return; + lseek(Procfd, regs.fixreg[1] + 8, SEEK_SET); + read(Procfd, &fsc.args[regargs], (nargs - regargs) * sizeof(fsc.args[0])); } else { memmove(&fsc.args[0], args, nargs * sizeof(fsc.args[0])); } @@ -211,7 +220,7 @@ i < (fsc.nargs - 1) ? "," : ""); #endif if (sc && !(sc->args[i].type & OUT)) { - fsc.s_args[i] = print_arg(&sc->args[i], fsc.args, 0, trussinfo); + fsc.s_args[i] = print_arg(Procfd, &sc->args[i], fsc.args, 0, trussinfo); } } #if DEBUG @@ -266,15 +275,28 @@ long powerpc_syscall_exit(struct trussinfo *trussinfo, int syscall_num __unused) { + char buf[32]; struct reg regs; long retval; int i; int errorp; struct syscall *sc; - cpid = trussinfo->tid; - ptrace(PT_GETREGS, cpid, (caddr_t)®s, 0); + if (fd == -1 || trussinfo->pid != cpid) { + sprintf(buf, "/proc/%d/regs", trussinfo->pid); + fd = open(buf, O_RDONLY); + if (fd == -1) { + fprintf(trussinfo->outfile, "-- CANNOT OPEN REGISTERS --\n"); + return (-1); + } + cpid = trussinfo->pid; + } + lseek(fd, 0L, 0); + if (read(fd, ®s, sizeof(regs)) != sizeof(regs)) { + fprintf(trussinfo->outfile, "\n"); + return (-1); + } retval = regs.fixreg[3]; errorp = !!(regs.cr & 0x10000000); @@ -310,7 +332,7 @@ if (errorp) asprintf(&temp, "0x%lx", fsc.args[sc->args[i].offset]); else - temp = print_arg(&sc->args[i], fsc.args, retval, trussinfo); + temp = print_arg(Procfd, &sc->args[i], fsc.args, retval, trussinfo); fsc.s_args[i] = temp; } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200611040022.kA40MhlV034021>