From owner-p4-projects@FreeBSD.ORG Sat Nov 4 00:22:57 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id BBBAF16A415; Sat, 4 Nov 2006 00:22:57 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7E78B16A40F for ; Sat, 4 Nov 2006 00:22:57 +0000 (UTC) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0914543D99 for ; Sat, 4 Nov 2006 00:22:43 +0000 (GMT) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id kA40MhTD034024 for ; Sat, 4 Nov 2006 00:22:43 GMT (envelope-from jb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id kA40MhlV034021 for perforce@freebsd.org; Sat, 4 Nov 2006 00:22:43 GMT (envelope-from jb@freebsd.org) Date: Sat, 4 Nov 2006 00:22:43 GMT Message-Id: <200611040022.kA40MhlV034021@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jb@freebsd.org using -f From: John Birrell To: Perforce Change Reviews Cc: Subject: PERFORCE change 109173 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Nov 2006 00:22:58 -0000 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 -#include +#include +#include #include #include @@ -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; } }