aboutsummaryrefslogtreecommitdiff
path: root/gdb/remote.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2011-01-25 11:54:00 +0000
committerPedro Alves <palves@redhat.com>2011-01-25 11:54:00 +0000
commitf7605bc29f0c6454f73819850dd114cdba30d9fb (patch)
treea4d2bc38047e1a5117ae9dbf59b2bb5b843dbed7 /gdb/remote.c
parentd08aafeffe7dcdff4c4f876c6b8f730ce0270847 (diff)
downloadgdb-f7605bc29f0c6454f73819850dd114cdba30d9fb.zip
gdb-f7605bc29f0c6454f73819850dd114cdba30d9fb.tar.gz
gdb-f7605bc29f0c6454f73819850dd114cdba30d9fb.tar.bz2
Stop remote_read_bytes from handling partial reads itself.
* remote-fileio.c: Include target.h. (remote_fileio_write_bytes): Delete. (remote_fileio_func_open, remote_fileio_func_write) (remote_fileio_func_rename, remote_fileio_func_unlink): Use target_read_memory. (remote_fileio_func_stat): Use target_read_memory and target_write_memory. (remote_fileio_func_gettimeofday): Use target_write_memory. (remote_fileio_func_system): Use target_read_memory. * remote.c (remote_write_bytes): Make it static. (remote_read_bytes): Don't handle partial reads here. * remote.h (remote_read_bytes): Delete declaration.
Diffstat (limited to 'gdb/remote.c')
-rw-r--r--gdb/remote.c92
1 files changed, 34 insertions, 58 deletions
diff --git a/gdb/remote.c b/gdb/remote.c
index 48d9d55..b440e9e 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -6356,7 +6356,7 @@ remote_write_bytes_aux (const char *header, CORE_ADDR memaddr,
Returns number of bytes transferred, or 0 (setting errno) for
error. Only transfer a single packet. */
-int
+static int
remote_write_bytes (CORE_ADDR memaddr, const gdb_byte *myaddr, int len)
{
char *packet_format = 0;
@@ -6391,19 +6391,14 @@ remote_write_bytes (CORE_ADDR memaddr, const gdb_byte *myaddr, int len)
Returns number of bytes transferred, or 0 for error. */
-/* NOTE: cagney/1999-10-18: This function (and its siblings in other
- remote targets) shouldn't attempt to read the entire buffer.
- Instead it should read a single packet worth of data and then
- return the byte size of that packet to the caller. The caller (its
- caller and its callers caller ;-) already contains code for
- handling partial reads. */
-
-int
+static int
remote_read_bytes (CORE_ADDR memaddr, gdb_byte *myaddr, int len)
{
struct remote_state *rs = get_remote_state ();
int max_buf_size; /* Max size of packet output buffer. */
- int origlen;
+ char *p;
+ int todo;
+ int i;
if (len <= 0)
return 0;
@@ -6412,56 +6407,37 @@ remote_read_bytes (CORE_ADDR memaddr, gdb_byte *myaddr, int len)
/* The packet buffer will be large enough for the payload;
get_memory_packet_size ensures this. */
- origlen = len;
- while (len > 0)
- {
- char *p;
- int todo;
- int i;
+ /* Number if bytes that will fit. */
+ todo = min (len, max_buf_size / 2);
- todo = min (len, max_buf_size / 2); /* num bytes that will fit. */
-
- /* construct "m"<memaddr>","<len>" */
- /* sprintf (rs->buf, "m%lx,%x", (unsigned long) memaddr, todo); */
- memaddr = remote_address_masked (memaddr);
- p = rs->buf;
- *p++ = 'm';
- p += hexnumstr (p, (ULONGEST) memaddr);
- *p++ = ',';
- p += hexnumstr (p, (ULONGEST) todo);
- *p = '\0';
-
- putpkt (rs->buf);
- getpkt (&rs->buf, &rs->buf_size, 0);
-
- if (rs->buf[0] == 'E'
- && isxdigit (rs->buf[1]) && isxdigit (rs->buf[2])
- && rs->buf[3] == '\0')
- {
- /* There is no correspondance between what the remote
- protocol uses for errors and errno codes. We would like
- a cleaner way of representing errors (big enough to
- include errno codes, bfd_error codes, and others). But
- for now just return EIO. */
- errno = EIO;
- return 0;
- }
-
- /* Reply describes memory byte by byte,
- each byte encoded as two hex characters. */
-
- p = rs->buf;
- if ((i = hex2bin (p, myaddr, todo)) < todo)
- {
- /* Reply is short. This means that we were able to read
- only part of what we wanted to. */
- return i + (origlen - len);
- }
- myaddr += todo;
- memaddr += todo;
- len -= todo;
+ /* Construct "m"<memaddr>","<len>". */
+ memaddr = remote_address_masked (memaddr);
+ p = rs->buf;
+ *p++ = 'm';
+ p += hexnumstr (p, (ULONGEST) memaddr);
+ *p++ = ',';
+ p += hexnumstr (p, (ULONGEST) todo);
+ *p = '\0';
+ putpkt (rs->buf);
+ getpkt (&rs->buf, &rs->buf_size, 0);
+ if (rs->buf[0] == 'E'
+ && isxdigit (rs->buf[1]) && isxdigit (rs->buf[2])
+ && rs->buf[3] == '\0')
+ {
+ /* There is no correspondance between what the remote protocol
+ uses for errors and errno codes. We would like a cleaner way
+ of representing errors (big enough to include errno codes,
+ bfd_error codes, and others). But for now just return
+ EIO. */
+ errno = EIO;
+ return 0;
}
- return origlen;
+ /* Reply describes memory byte by byte, each byte encoded as two hex
+ characters. */
+ p = rs->buf;
+ i = hex2bin (p, myaddr, todo);
+ /* Return what we have. Let higher layers handle partial reads. */
+ return i;
}