summaryrefslogtreecommitdiff
path: root/gdb/infptrace.c
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@gnu.org>2002-11-08 23:48:38 +0000
committerMark Kettenis <kettenis@gnu.org>2002-11-08 23:48:38 +0000
commit4c3b76ec8dd869f5f721ec1d0727d0ef285fe117 (patch)
tree4513cfcd3f848c70421ca705d21bdc6f83fbccb4 /gdb/infptrace.c
parent55c2979a4d3def9d59c3e2010c7a689c63f5f8d0 (diff)
downloadgdb-4c3b76ec8dd869f5f721ec1d0727d0ef285fe117.tar.gz
* infptrace.c (child_xfer_memory): Make use of the new PT_IO
request that's available in *BSD.
Diffstat (limited to 'gdb/infptrace.c')
-rw-r--r--gdb/infptrace.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/gdb/infptrace.c b/gdb/infptrace.c
index 777a5b491ed..601e157c8ef 100644
--- a/gdb/infptrace.c
+++ b/gdb/infptrace.c
@@ -514,6 +514,37 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
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)
{