NetBSD Problem Report #15945
Received: (qmail 842 invoked from network); 17 Mar 2002 14:30:40 -0000
Message-Id: <200203171429.g2HET3B00582@nutcracker.stacken.kth.se>
Date: Sun, 17 Mar 2002 15:29:03 +0100 (CET)
From: lha@stacken.kth.se
Reply-To: lha@stacken.kth.se
To: gnats-bugs@gnats.netbsd.org
Subject: PT_IO
X-Send-Pr-Version: 3.95
>Number: 15945
>Category: kern
>Synopsis: PT_IO
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: thorpej
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Mar 17 14:31:00 +0000 2002
>Closed-Date: Sun Mar 17 17:03:49 +0000 2002
>Last-Modified: Sun Mar 17 17:03:49 +0000 2002
>Originator: Love
>Release: NetBSD 1.5ZB
>Organization:
Stacken Computer Club
>Environment:
System: NetBSD nutcracker.stacken.kth.se 1.5ZB NetBSD 1.5ZB (NUTCRACKER) #7: Sun Mar 17 15:01:14 CET 2002 lha@nutcracker.stacken.kth.se:/usr/src/sys/arch/i386/compile/NUTCRACKER i386
Architecture: i386
Machine: i386
>Description:
Artur Grabowski <art@blahonga.org>, described a more generic
pthread API for reading/writing to a process on
<bsd-api-discuss@wasabisystems.com>.
>How-To-Repeat:
Try use use pmdb and find PT_IO missing.
>Fix:
I just adapeded the Artur's patch (including the changes
proposed to bsd-api-discuss list) to netbsd.
Index: sys/ptrace.h
===================================================================
RCS file: /sources/netbsd/NetBSD-cvs/syssrc/sys/sys/ptrace.h,v
retrieving revision 1.23
diff -u -r1.23 ptrace.h
--- sys/ptrace.h 2001/12/05 00:58:06 1.23
+++ sys/ptrace.h 2002/03/17 13:55:21
@@ -1,4 +1,4 @@
-/* $NetBSD: ptrace.h,v 1.22 2001/06/13 16:06:27 nathanw Exp $ */
+/* $NetBSD: ptrace.h,v 1.23 2001/12/05 00:58:06 thorpej Exp $ */
/*-
* Copyright (c) 1984, 1993
@@ -47,6 +47,22 @@
#define PT_KILL 8 /* kill the child process */
#define PT_ATTACH 9 /* attach to running process */
#define PT_DETACH 10 /* detach from running process */
+#define PT_IO 11 /* do I/O to/from the stopped process. */
+
+struct ptrace_io_desc {
+ int piod_op; /* I/O operation */
+ void *piod_offs; /* child offset */
+ void *piod_addr; /* parent offset */
+ size_t piod_len; /* request length */
+};
+
+/*
+ * Operations in piod_op.
+ */
+#define PIOD_READ_D 1 /* Read from D space */
+#define PIOD_WRITE_D 2 /* Write to D space */
+#define PIOD_READ_I 3 /* Read from I space */
+#define PIOD_WRITE_I 4 /* Write to I space */
#define PT_FIRSTMACH 32 /* for machine-specific requests */
#include <machine/ptrace.h> /* machine-specific requests, if any */
Index: kern/sys_process.c
===================================================================
RCS file: /sources/netbsd/NetBSD-cvs/syssrc/sys/kern/sys_process.c,v
retrieving revision 1.72
diff -u -r1.72 sys_process.c
--- kern/sys_process.c 2002/01/11 21:16:28 1.72
+++ kern/sys_process.c 2002/03/17 14:00:58
@@ -95,6 +95,7 @@
struct proc *t; /* target process */
struct uio uio;
struct iovec iov;
+ struct ptrace_io_desc piod;
int s, error, write, tmp;
/* "A foolish consistency..." XXX */
@@ -168,6 +169,7 @@
case PT_WRITE_I:
case PT_WRITE_D:
case PT_CONTINUE:
+ case PT_IO:
case PT_KILL:
case PT_DETACH:
#ifdef PT_STEP
@@ -255,6 +257,35 @@
error = procfs_domem(p, t, NULL, &uio);
if (!write)
*retval = tmp;
+ return (error);
+
+ case PT_IO:
+ error = copyin(SCARG(uap, addr), &piod, sizeof(piod));
+ if (error)
+ return (error);
+ iov.iov_base = piod.piod_addr;
+ iov.iov_len = piod.piod_len;
+ uio.uio_iov = &iov;
+ uio.uio_iovcnt = 1;
+ uio.uio_offset = (off_t)(long)piod.piod_offs;
+ uio.uio_resid = piod.piod_len;
+ uio.uio_segflg = UIO_USERSPACE;
+ uio.uio_procp = p;
+ switch (piod.piod_op) {
+ case PIOD_READ_D:
+ case PIOD_READ_I:
+ uio.uio_rw = UIO_READ;
+ break;
+ case PIOD_WRITE_D:
+ case PIOD_WRITE_I:
+ uio.uio_rw = UIO_WRITE;
+ break;
+ default:
+ return (EINVAL);
+ }
+ error = procfs_domem(p, t, NULL, &uio);
+ piod.piod_len -= uio.uio_resid;
+ (void) copyout(&piod, SCARG(uap, addr), sizeof(piod));
return (error);
#ifdef PT_STEP
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: thorpej
State-Changed-When: Sun Mar 17 09:03:02 PST 2002
State-Changed-Why:
Patch applied.
Responsible-Changed-From-To: kern-bug-people->thorpej
Responsible-Changed-By: thorpej
Responsible-Changed-When: Sun Mar 17 09:03:02 PST 2002
Responsible-Changed-Why:
I took care of this on bsd-api-discuss, and will take
responsibility for it in the tree.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.