[rfa] Fix remote debugging

Daniel Jacobowitz drow@false.org
Mon Oct 4 20:01:00 GMT 2004


Your recent patch made it mandatory for any target which implements
to_xfer_partial to support TARGET_OBJECT_MEMORY, i.e. its
to_xfer_memory will be ignored.  remote.c doesn't meet this new
requirement.  I didn't check all the other targets with _partial
methods.

OK?  Tested on i386-pc-linux-gnu using gdbserver.  Brings test results
from unspeakable back to merely disappointing.

-- 
Daniel Jacobowitz

2004-10-04  Daniel Jacobowitz  <dan@debian.org>

	* remote.c (remote_xfer_partial): Handle TARGET_OBJECT_MEMORY.

Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.148
diff -u -p -r1.148 remote.c
--- remote.c	24 Sep 2004 19:51:18 -0000	1.148
+++ remote.c	4 Oct 2004 19:58:44 -0000
@@ -4864,6 +4864,31 @@ remote_xfer_partial (struct target_ops *
   char *p2 = &buf2[0];
   char query_type;
 
+  /* Handle memory using remote_xfer_memory.  */
+  if (object == TARGET_OBJECT_MEMORY)
+    {
+      int xfered;
+      errno = 0;
+
+      if (writebuf != NULL)
+	{
+	  void *buffer = xmalloc (len);
+	  struct cleanup *cleanup = make_cleanup (xfree, buffer);
+	  memcpy (buffer, writebuf, len);
+	  xfered = remote_xfer_memory (offset, buffer, len, 1, NULL, ops);
+	  do_cleanups (cleanup);
+	}
+      else
+	xfered = remote_xfer_memory (offset, readbuf, len, 0, NULL, ops);
+
+      if (xfered > 0)
+	return xfered;
+      else if (xfered == 0 && errno == 0)
+	return 0;
+      else
+	return -1;
+    }
+
   /* Only handle reads.  */
   if (writebuf != NULL || readbuf == NULL)
     return -1;



More information about the Gdb-patches mailing list