mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-28 18:10:46 +00:00
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.
This commit is contained in:
92
gdb/remote.c
92
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)
|
||||
/* Number if bytes that will fit. */
|
||||
todo = min (len, max_buf_size / 2);
|
||||
|
||||
/* 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')
|
||||
{
|
||||
char *p;
|
||||
int todo;
|
||||
int i;
|
||||
|
||||
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;
|
||||
/* 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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user