Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Cagney <cagney@gnu.org>
To: gdb-patches@sources.redhat.com
Subject: Re: [commit] Prefer xfer_partial for memory xfers
Date: Thu, 30 Sep 2004 16:48:00 -0000	[thread overview]
Message-ID: <415C38B5.6010603@gnu.org> (raw)
In-Reply-To: <415C3406.30801@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 115 bytes --]

> 	(inf_ptrace_xfer_memory): Delete.

Oops, this was lost from the patch / commit, it's now really there.

Andrew


[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 4860 bytes --]

Index: inf-ptrace.c
===================================================================
RCS file: /cvs/src/src/gdb/inf-ptrace.c,v
retrieving revision 1.8
diff -p -u -r1.8 inf-ptrace.c
--- inf-ptrace.c	30 Sep 2004 16:18:57 -0000	1.8
+++ inf-ptrace.c	30 Sep 2004 16:46:10 -0000
@@ -95,145 +95,6 @@ inf_ptrace_resume (ptid_t ptid, int step
     perror_with_name ("ptrace");
 }
 
-/* Set an upper limit on alloca.  */
-#define GDB_MAX_ALLOCA 0x1000
-
-/* NOTE! I tried using PTRACE_READDATA, etc., to read and write memory
-   in the NEW_SUN_PTRACE case.  It ought to be straightforward.  But
-   it appears that writing did not write the data that I specified.  I
-   cannot understand where it got the data that it actually did
-   write.  */
-
-/* Copy LEN bytes to or from inferior's memory starting at MEMADDR to
-   debugger memory starting at MYADDR.  Copy to inferior if WRITE is
-   nonzero.  TARGET is ignored.
-
-   Returns the length copied, which is either the LEN argument or
-   zero.  This xfer function does not do partial moves, since
-   ptrace_ops_hack doesn't allow memory operations to cross below us in the
-   target stack anyway.  */
-
-int
-inf_ptrace_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
-			struct mem_attrib *attrib, struct target_ops *target)
-{
-  int i;
-  /* Round starting address down to longword boundary.  */
-  CORE_ADDR addr = memaddr & -(CORE_ADDR) sizeof (PTRACE_TYPE_RET);
-  /* Round ending address up; get number of longwords that makes.  */
-  int count = ((((memaddr + len) - addr) + sizeof (PTRACE_TYPE_RET) - 1)
-	       / sizeof (PTRACE_TYPE_RET));
-  int alloc = count * sizeof (PTRACE_TYPE_RET);
-  PTRACE_TYPE_RET *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)
-    {
-      buffer = (PTRACE_TYPE_RET *) alloca (alloc);
-    }
-  else
-    {
-      buffer = (PTRACE_TYPE_RET *) xmalloc (alloc);
-      old_chain = make_cleanup (xfree, buffer);
-    }
-
-  if (write)
-    {
-      /* Fill start and end extra bytes of buffer with existing memory
-         data.  */
-      if (addr != memaddr || len < (int) sizeof (PTRACE_TYPE_RET))
-	{
-	  /* Need part of initial word -- fetch it.  */
-	  buffer[0] = ptrace (PT_READ_I, PIDGET (inferior_ptid),
-			      (PTRACE_TYPE_ARG3) addr, 0);
-	}
-
-      if (count > 1)		/* FIXME, avoid if even boundary.  */
-	{
-	  buffer[count - 1] =
-	    ptrace (PT_READ_I, PIDGET (inferior_ptid),
-		    ((PTRACE_TYPE_ARG3)
-		     (addr + (count - 1) * sizeof (PTRACE_TYPE_RET))), 0);
-	}
-
-      /* Copy data to be written over corresponding part of buffer.  */
-      memcpy ((char *) buffer + (memaddr & (sizeof (PTRACE_TYPE_RET) - 1)),
-	      myaddr, len);
-
-      /* Write the entire buffer.  */
-      for (i = 0; i < count; i++, addr += sizeof (PTRACE_TYPE_RET))
-	{
-	  errno = 0;
-	  ptrace (PT_WRITE_D, PIDGET (inferior_ptid),
-		  (PTRACE_TYPE_ARG3) addr, buffer[i]);
-	  if (errno)
-	    {
-	      /* Using the appropriate one (I or D) is necessary for
-	         Gould NP1, at least.  */
-	      errno = 0;
-	      ptrace (PT_WRITE_I, PIDGET (inferior_ptid),
-		      (PTRACE_TYPE_ARG3) addr, buffer[i]);
-	    }
-	  if (errno)
-	    return 0;
-	}
-    }
-  else
-    {
-      /* Read all the longwords.  */
-      for (i = 0; i < count; i++, addr += sizeof (PTRACE_TYPE_RET))
-	{
-	  errno = 0;
-	  buffer[i] = ptrace (PT_READ_I, PIDGET (inferior_ptid),
-			      (PTRACE_TYPE_ARG3) addr, 0);
-	  if (errno)
-	    return 0;
-	  QUIT;
-	}
-
-      /* Copy appropriate bytes out of the buffer.  */
-      memcpy (myaddr,
-	      (char *) buffer + (memaddr & (sizeof (PTRACE_TYPE_RET) - 1)),
-	      len);
-    }
-
-  if (old_chain != NULL)
-    do_cleanups (old_chain);
-  return len;
-}
-
 /* Wait for child to do something.  Return pid of child, or -1 in case
    of error; store status through argument pointer OURSTATUS.  */
 

  reply	other threads:[~2004-09-30 16:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-30 16:28 Andrew Cagney
2004-09-30 16:48 ` Andrew Cagney [this message]
2004-10-04  3:35 ` Daniel Jacobowitz
2004-10-04 14:53   ` Andrew Cagney

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=415C38B5.6010603@gnu.org \
    --to=cagney@gnu.org \
    --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