From owner-freebsd-hackers Mon Mar 25 11:45:33 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from renown.cnchost.com (renown.concentric.net [207.155.248.7]) by hub.freebsd.org (Postfix) with ESMTP id 8F87B37B404 for ; Mon, 25 Mar 2002 11:45:26 -0800 (PST) Received: from bitblocks.com (adsl-209-204-185-216.sonic.net [209.204.185.216]) by renown.cnchost.com id OAA08115; Mon, 25 Mar 2002 14:45:24 -0500 (EST) [ConcentricHost SMTP Relay 1.14] Message-ID: <200203251945.OAA08115@renown.cnchost.com> To: callum.gibson@db.com Cc: hackers@FreeBSD.ORG, Peter Wemm Subject: Re: Missing PT_READ_U In-reply-to: Your message of "Mon, 25 Mar 2002 13:28:08 +1100." <20020325022808.11749.qmail@merton.aus.deuba.com> Date: Mon, 25 Mar 2002 11:45:23 -0800 From: Bakul Shah Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > }> As the culprit behind PT_READ_U's demise, I'm willing to dive in > }> and help here if needed. > }Thanks but Julian sent me a patch for 4.5 that seems to work > }with no changes in ups. Would be nice if PT_READ_U is put > }back in 4.x. > > As a followup to this old thread (and as the poster of the original > question on the ups mailing list in late Feb) I note there has still > been no change on the RELENG_4 branch to fix this. Could we have the > patch posted here at least so other people can use ups again (with > signals)? I'd just apply a reverse patch from kern/sys_process.c 1.51.2.2 > to 1.51.2.1 except that I don't know if other files (apart from sys/ptrace.h) > have been affected. Julain Elischer's diff as applied to the 4.5-RELEASE included below. With this change ups-3.37-beta4 compiled unchanged. But note that you still can't change any registers. If PT_WRITE_U is added back to the FreeBSD-4.x branch, no change is necessary to ups. So how about it, Peter Wemm? The other alternative is to change ups to understand PT_{SET,GET}{REGS,FPREGS} -- this would be needed for FreeBSD-5 in any case. But this is not a quick change as ups uses PTRACE_{PEEK,POKE}USER for dealing with registers and signals and these need to be replaced something more discriminating. I took a quick look at it but then got distracted. Also, not every arch. has separate FP regs and I didn't look deep enough in ups to figure out how to add machine dependent code like this. -- bakul Index: sys/ptrace.h =================================================================== RCS file: /home/ncvs/src/sys/sys/ptrace.h,v retrieving revision 1.10.2.1 diff -u -r1.10.2.1 ptrace.h --- sys/ptrace.h 3 Oct 2001 06:55:43 -0000 1.10.2.1 +++ sys/ptrace.h 1 Mar 2002 21:52:57 -0000 @@ -40,7 +40,7 @@ #define PT_TRACE_ME 0 /* child declares it's being traced */ #define PT_READ_I 1 /* read word in child's I space */ #define PT_READ_D 2 /* read word in child's D space */ -/* was PT_READ_U 3 * read word in child's user structure */ +#define PT_READ_U 3 /* read word in child's user structure */ #define PT_WRITE_I 4 /* write word in child's I space */ #define PT_WRITE_D 5 /* write word in child's D space */ /* was PT_WRITE_U 6 * write word in child's user structure */ Index: kern/sys_process.c =================================================================== RCS file: /home/ncvs/src/sys/kern/sys_process.c,v retrieving revision 1.51.2.3 diff -u -r1.51.2.3 sys_process.c --- kern/sys_process.c 22 Jan 2002 17:22:59 -0000 1.51.2.3 +++ kern/sys_process.c 1 Mar 2002 23:45:18 -0000 @@ -257,6 +257,7 @@ case PT_READ_I: case PT_READ_D: + case PT_READ_U: case PT_WRITE_I: case PT_WRITE_D: case PT_CONTINUE: @@ -413,6 +417,33 @@ } return (error); + case PT_READ_U: + if ((uintptr_t)uap->addr > UPAGES * PAGE_SIZE - + sizeof(int)) { + return EFAULT; + } + if ((uintptr_t)uap->addr & (sizeof(int) - 1)) { + return EFAULT; + } + if (ptrace_read_u_check(p,(vm_offset_t) uap->addr, + sizeof(int))) { + return EFAULT; + } + error = 0; + PHOLD(p); /* user had damn well better be incore!*/ + if (p->p_flag & P_INMEM) { + p->p_addr->u_kproc.kp_proc = *p; + fill_eproc (p, &p->p_addr->u_kproc.kp_eproc); + curp->p_retval[0] = *(int *) + ((uintptr_t)p->p_addr + + (uintptr_t)uap->addr); + } else { + curp->p_retval[0] = 0; + error = EFAULT; + } + PRELE(p); + return error; + case PT_KILL: uap->data = SIGKILL; goto sendsig; /* in PT_CONTINUE above */ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message