* [PATCH] Use PT_IO ptrace request if available
@ 2002-11-08 15:58 Mark Kettenis
2002-11-08 16:08 ` Daniel Jacobowitz
0 siblings, 1 reply; 2+ messages in thread
From: Mark Kettenis @ 2002-11-08 15:58 UTC (permalink / raw)
To: gdb-patches
The attached patch makes use of the PT_IO ptrace request that's
available in *BSD for data transfers to/from the inferior. It's a
couple of weeks ago now that my patch that fixes the FreeBSD
5.0-CURRENT kernel went in, and I hope that OpenBSD and NetBSD don't
have any problems. We'll probably find out soon :-). Note that if
you run FreeBSD 5.0-CURRENT from before October 16 and after March 16,
your machine will probably lock up when using GDB. However, since
-CURRENT is a development version, I think it's acceptable to ask
people to upgrade.
It would be great if we could get Linux to support the same interface.
Committed.
Mark
Index: ChangeLog
from Mark Kettenis <kettenis@gnu.org>
* infptrace.c (child_xfer_memory): Make use of the new PT_IO
request that's available in *BSD.
Index: infptrace.c
===================================================================
RCS file: /cvs/src/src/gdb/infptrace.c,v
retrieving revision 1.21
diff -u -p -r1.21 infptrace.c
--- infptrace.c 19 Jan 2002 03:32:36 -0000 1.21
+++ infptrace.c 8 Nov 2002 23:45:18 -0000
@@ -514,6 +514,37 @@ child_xfer_memory (CORE_ADDR memaddr, ch
PTRACE_XFER_TYPE *buffer;
struct cleanup *old_chain = NULL;
+#ifdef PT_IO
+ /* OpenBSD 3.1, NetBSD 1.6 and FreeBSD 5.0 have a new PT_IO request
+ that promises to be much more efficient in reading and writing
+ data in the traced process's address space. */
+
+ {
+ struct ptrace_io_desc piod;
+
+ /* NOTE: We assume that there are no distinct address spaces for
+ instruction and data. */
+ piod.piod_op = write ? PIOD_WRITE_D : PIOD_READ_D;
+ piod.piod_offs = (void *) memaddr;
+ piod.piod_addr = myaddr;
+ piod.piod_len = len;
+
+ if (ptrace (PT_IO, PIDGET (inferior_ptid), (caddr_t) &piod, 0) == -1)
+ {
+ /* If the PT_IO request is somehow not supported, fallback on
+ using PT_WRITE_D/PT_READ_D. Otherwise we will return zero
+ to indicate failure. */
+ if (errno != EINVAL)
+ return 0;
+ }
+ else
+ {
+ /* Return the actual number of bytes read or written. */
+ return piod.piod_len;
+ }
+ }
+#endif
+
/* Allocate buffer of that many longwords. */
if (len < GDB_MAX_ALLOCA)
{
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Use PT_IO ptrace request if available
2002-11-08 15:58 [PATCH] Use PT_IO ptrace request if available Mark Kettenis
@ 2002-11-08 16:08 ` Daniel Jacobowitz
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Jacobowitz @ 2002-11-08 16:08 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
On Sat, Nov 09, 2002 at 12:58:02AM +0100, Mark Kettenis wrote:
> The attached patch makes use of the PT_IO ptrace request that's
> available in *BSD for data transfers to/from the inferior. It's a
> couple of weeks ago now that my patch that fixes the FreeBSD
> 5.0-CURRENT kernel went in, and I hope that OpenBSD and NetBSD don't
> have any problems. We'll probably find out soon :-). Note that if
> you run FreeBSD 5.0-CURRENT from before October 16 and after March 16,
> your machine will probably lock up when using GDB. However, since
> -CURRENT is a development version, I think it's acceptable to ask
> people to upgrade.
>
> It would be great if we could get Linux to support the same interface.
We've got read covered, from /proc/<pid>/mem; I'm going to implement
that when I get a chance.
I suppose I could implement PT_IO the way you did... I was planning on
a Sun-style PTRACE_READDATA (SPARC Linux already has this) but it's not
possible on i386 (syscall with five arguments). I'm not sure it's
worth it; it's generally reading that we do in bulk, not writing.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-11-09 0:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-08 15:58 [PATCH] Use PT_IO ptrace request if available Mark Kettenis
2002-11-08 16:08 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox