Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Mark Kettenis <kettenis@chello.nl>
To: gdb-patches@sources.redhat.com
Subject: [PATCH] Use PT_IO ptrace request if available
Date: Fri, 08 Nov 2002 15:58:00 -0000	[thread overview]
Message-ID: <200211082358.gA8Nw2Dj017053@elgar.kettenis.dyndns.org> (raw)

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)
     {


             reply	other threads:[~2002-11-08 23:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-08 15:58 Mark Kettenis [this message]
2002-11-08 16:08 ` Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200211082358.gA8Nw2Dj017053@elgar.kettenis.dyndns.org \
    --to=kettenis@chello.nl \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox