Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/7] remote-mips.c: Don't install a deprecated_xfer_memory method
Date: Wed, 19 Feb 2014 20:29:00 -0000	[thread overview]
Message-ID: <1392841775-19126-2-git-send-email-palves@redhat.com> (raw)
In-Reply-To: <1392841775-19126-1-git-send-email-palves@redhat.com>

This removes another yet instance of a deprecated_xfer_memory user.

Tested by building a --enable-targets=all gdb, on x86-64 Fedora 17.

gdb/
2014-02-19  Pedro Alves  <palves@redhat.com>

	* remote-mips.c (mips_xfer_memory): Adjust as to_xfer_partial
	helper.
	(mips_xfer_partial): New function.
	(_initialize_remote_mips): Don't install a deprecated_xfer_memory
	hook.  Install a to_xfer_partial hook.
---
 gdb/remote-mips.c | 65 +++++++++++++++++++++++++++++++++++--------------------
 1 file changed, 41 insertions(+), 24 deletions(-)

diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c
index 4338ffa..383d31c 100644
--- a/gdb/remote-mips.c
+++ b/gdb/remote-mips.c
@@ -98,10 +98,11 @@ static int mips_fetch_word (CORE_ADDR addr, unsigned int *valp);
 static int mips_store_word (CORE_ADDR addr, unsigned int value,
 			    int *old_contents);
 
-static int mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len,
-			     int write, 
-			     struct mem_attrib *attrib,
-			     struct target_ops *target);
+static enum target_xfer_status mips_xfer_memory (gdb_byte *readbuf,
+						 const gdb_byte *writebuf,
+						 ULONGEST memaddr,
+						 ULONGEST len,
+						 ULONGEST *xfered_len);
 
 static void mips_files_info (struct target_ops *ignore);
 
@@ -2141,18 +2142,17 @@ mips_store_word (CORE_ADDR addr, unsigned int val, int *old_contents)
   return 0;
 }
 
-/* Read or write LEN bytes from inferior memory at MEMADDR,
-   transferring to or from debugger address MYADDR.  Write to inferior
-   if SHOULD_WRITE is nonzero.  Returns length of data written or
-   read; 0 for error.  Note that protocol gives us the correct value
-   for a longword, since it transfers values in ASCII.  We want the
-   byte values, so we have to swap the longword values.  */
+/* Helper for mips_xfer_partial that handles memory transfers.
+   Arguments are like target_xfer_partial.  Note that the protocol
+   gives us the correct value for a longword, since it transfers
+   values in ASCII.  We want the byte values, so we have to swap the
+   longword values.  */
 
 static int mask_address_p = 1;
 
-static int
-mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write,
-		  struct mem_attrib *attrib, struct target_ops *target)
+static enum target_xfer_status
+mips_xfer_memory (gdb_byte *readbuf, const gdb_byte *writebuf,
+		  ULONGEST memaddr, ULONGEST len, ULONGEST *xfered_len)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
   int i;
@@ -2173,7 +2173,7 @@ mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write,
   /* Allocate buffer of that many longwords.  */
   buffer = alloca (count * 4);
 
-  if (write)
+  if (writebuf != NULL)
     {
       /* Fill start and end extra bytes of buffer with existing data.  */
       if (addr != memaddr || len < 4)
@@ -2181,7 +2181,7 @@ mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write,
 	  unsigned int val;
 
 	  if (mips_fetch_word (addr, &val))
-	    return 0;
+	    return TARGET_XFER_E_IO;
 
 	  /* Need part of initial word -- fetch it.  */
 	  store_unsigned_integer (&buffer[0], 4, byte_order, val);
@@ -2194,7 +2194,7 @@ mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write,
 	  /* Need part of last word -- fetch it.  FIXME: we do this even
 	     if we don't need it.  */
 	  if (mips_fetch_word (addr + (count - 1) * 4, &val))
-	    return 0;
+	    return TARGET_XFER_E_IO;
 
 	  store_unsigned_integer (&buffer[(count - 1) * 4],
 				  4, byte_order, val);
@@ -2202,7 +2202,7 @@ mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write,
 
       /* Copy data to be written over corresponding part of buffer.  */
 
-      memcpy ((char *) buffer + (memaddr & 3), myaddr, len);
+      memcpy ((char *) buffer + (memaddr & 3), writebuf, len);
 
       /* Write the entire buffer.  */
 
@@ -2219,10 +2219,7 @@ mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write,
 	      gdb_flush (gdb_stdout);
 	    }
 	  if (status)
-	    {
-	      errno = status;
-	      return 0;
-	    }
+	    return TARGET_XFER_E_IO;
 	  /* FIXME: Do we want a QUIT here?  */
 	}
       if (count >= 256)
@@ -2236,18 +2233,38 @@ mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write,
 	  unsigned int val;
 
 	  if (mips_fetch_word (addr, &val))
-	    return 0;
+	    return TARGET_XFER_E_IO;
 
 	  store_unsigned_integer (&buffer[i * 4], 4, byte_order, val);
 	  QUIT;
 	}
 
       /* Copy appropriate bytes out of the buffer.  */
-      memcpy (myaddr, buffer + (memaddr & 3), len);
+      memcpy (readbuf, buffer + (memaddr & 3), len);
     }
   return len;
 }
 
+/* Target to_xfer_partial implementation.  */
+
+static enum target_xfer_status
+mips_xfer_partial (struct target_ops *ops, enum target_object object,
+		   const char *annex, gdb_byte *readbuf,
+		   const gdb_byte *writebuf, ULONGEST offset, ULONGEST len,
+		   ULONGEST *xfered_len)
+{
+  switch (object)
+    {
+    case TARGET_OBJECT_MEMORY:
+      return mips_xfer_memory (readbuf, writebuf, offset, len, xfered_len);
+
+    default:
+      return ops->beneath->to_xfer_partial (ops->beneath, object, annex,
+					    readbuf, writebuf, offset, len,
+					    xfered_len);
+    }
+}
+
 /* Print info on this target.  */
 
 static void
@@ -3623,7 +3640,7 @@ _initialize_remote_mips (void)
   mips_ops.to_fetch_registers = mips_fetch_registers;
   mips_ops.to_store_registers = mips_store_registers;
   mips_ops.to_prepare_to_store = mips_prepare_to_store;
-  mips_ops.deprecated_xfer_memory = mips_xfer_memory;
+  mips_ops.to_xfer_partial = mips_xfer_partial;
   mips_ops.to_files_info = mips_files_info;
   mips_ops.to_insert_breakpoint = mips_insert_breakpoint;
   mips_ops.to_remove_breakpoint = mips_remove_breakpoint;
-- 
1.7.11.7


  parent reply	other threads:[~2014-02-19 20:29 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-19 20:29 [PATCH 0/7] eliminate deprecated_xfer_memory Pedro Alves
2014-02-19 20:29 ` [PATCH 6/7] eliminate target_ops->deprecated_xfer_memory Pedro Alves
2014-02-19 20:29 ` [PATCH 7/7] bsd-uthread.c: Don't install a to_xfer_partial method Pedro Alves
2014-02-20 13:26   ` Mark Kettenis
2014-02-20 16:42     ` Pedro Alves
2014-02-19 20:29 ` Pedro Alves [this message]
2014-02-19 20:29 ` [PATCH 4/7] nto-procfs.c: Don't install a deprecated_xfer_memory method Pedro Alves
2014-02-19 20:29 ` [PATCH 3/7] procfs.c: " Pedro Alves
2014-02-20 15:48   ` Joel Brobecker
2014-02-20 15:56     ` Joel Brobecker
2014-02-20 16:38       ` Pedro Alves
2014-02-24 17:53         ` Joel Brobecker
2014-02-24 18:21           ` Pedro Alves
2014-02-24 18:37             ` Joel Brobecker
2014-02-19 20:29 ` [PATCH 5/7] go32-nat.c: " Pedro Alves
     [not found]   ` <00c801cf2e59$acae60f0$060b22d0$@muller@ics-cnrs.unistra.fr>
2014-02-20 16:37     ` Pedro Alves
2014-02-19 20:29 ` [PATCH 2/7] remote-m32r-sdi.c: " Pedro Alves
2014-02-20 18:27 ` [PATCH 0/7] eliminate deprecated_xfer_memory Tom Tromey
2014-02-26 14:50   ` Pedro Alves

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=1392841775-19126-2-git-send-email-palves@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /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