Assertion 'xfered>0' in target.c for remote connection
Commit Message
Thanks for your comments, Sergio.
Sadly, I had to manually put the tabs into my patch here, but it looks correct now.
I also removed the TARGET_XFER_OK/TARGET_XFER_EOF test in remote_read_bytes, for the reasons you noted.
The TARGET_XFER_UNAVAILABLE/TARGET_XFER_EOF test is still necessary in case 0 bytes is returned by remote_read_bytes_1.
Some of the added tests are for writing blocks, rather than reading blocks.
It is possible that these returns are not needed, but it seems safer to just cover all of the returns.
@@ -1,3 +1,10 @@
+2017-11-02 Paul Carroll <pcarroll@codesourcery.com>
+
+ PR gdb/22388
+ * remote.c (remote_write_bytes_aux, remote_read_bytes_1,
+ remote_read_bytes, remote_write_qxfer, remote_xfer_partial):
+ Return TARGET_XFER_EOF if size of returned data is 0.
+
2017-11-02 Yao Qi <yao.qi@linaro.org>
* frame.c (do_frame_register_read): Remove aspace.
@@ -8264,7 +8264,7 @@ remote_write_bytes_aux (const char *head
/* Return UNITS_WRITTEN, not TODO_UNITS, in case escape chars caused us to
send fewer units than we'd planned. */
*xfered_len_units = (ULONGEST) units_written;
- return TARGET_XFER_OK;
+ return (*xfered_len_units != 0) ? TARGET_XFER_OK : TARGET_XFER_EOF;
}
/* Write memory data directly to the remote machine.
@@ -8358,7 +8358,7 @@ remote_read_bytes_1 (CORE_ADDR memaddr,
decoded_bytes = hex2bin (p, myaddr, todo_units * unit_size);
/* Return what we have. Let higher layers handle partial reads. */
*xfered_len_units = (ULONGEST) (decoded_bytes / unit_size);
- return TARGET_XFER_OK;
+ return (*xfered_len_units != 0) ? TARGET_XFER_OK : TARGET_XFER_EOF;
}
/* Using the set of read-only target sections of remote, read live
@@ -8461,7 +8461,8 @@ remote_read_bytes (struct target_ops *op
/* No use trying further, we know some memory starting
at MEMADDR isn't available. */
*xfered_len = len;
- return TARGET_XFER_UNAVAILABLE;
+ return (*xfered_len != 0) ?
+ TARGET_XFER_UNAVAILABLE : TARGET_XFER_EOF;
}
}
@@ -10386,7 +10387,7 @@ remote_write_qxfer (struct target_ops *o
unpack_varlen_hex (rs->buf, &n);
*xfered_len = n;
- return TARGET_XFER_OK;
+ return (*xfered_len != 0) ? TARGET_XFER_OK : TARGET_XFER_EOF;
}
/* Read OBJECT_NAME/ANNEX from the remote target using a qXfer packet.
@@ -10687,7 +10688,7 @@ remote_xfer_partial (struct target_ops *
strcpy ((char *) readbuf, rs->buf);
*xfered_len = strlen ((char *) readbuf);
- return TARGET_XFER_OK;
+ return (*xfered_len != 0) ? TARGET_XFER_OK : TARGET_XFER_EOF;
}
/* Implementation of to_get_memory_xfer_limit. */