A target_read_string patch for gdb

H.J. Lu hjl@lucon.org
Thu Nov 19 10:29:00 GMT 1998


target_read_string in gdb 4.17 doesn't handle the partial read right.
Here is a patch.

Thanks.

-- 
H.J. Lu (hjl@gnu.org)
---
Mon May 25 22:18:03 1998  H.J. Lu  <hjl@gnu.org>

	* target.c (target_read_string): Handle partial read.

Index: target.c
===================================================================
RCS file: /home/work/cvs/gnu/gdb/gdb/target.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 target.c
--- target.c	1998/05/29 13:57:38	1.1.1.1
+++ target.c	1998/11/19 18:10:33
@@ -656,11 +656,11 @@ target_read_string (memaddr, string, len
 
   while (len > 0)
     {
-      tlen = MIN (len, 4 - (memaddr & 3));
       offset = memaddr & 3;
 
-      errcode = target_xfer_memory (memaddr & ~3, buf, 4, 0, NULL);
-      if (errcode != 0)
+      tlen = target_read_memory_partial (memaddr & ~3, buf, 4,
+					 &errcode);
+      if (tlen == 0 && errcode != 0)
 	goto done;
 
       if (bufptr - buffer + tlen > buffer_allocated)
@@ -678,6 +678,7 @@ target_read_string (memaddr, string, len
 	  if (buf[i + offset] == '\000')
 	    {
 	      nbytes_read += i + 1;
+	      errcode = 0;
 	      goto done;
 	    }
 	}



More information about the Gdb mailing list