packet_format[0], 1);
}
-/* Read memory from the live target, even if currently inspecting a
- traceframe. The return is the same as that of target_read. */
+/* Read memory data directly from the remote machine.
+ This does not use the data cache; the data cache uses this.
+ MEMADDR is the address in the remote memory space.
+ MYADDR is the address of the buffer in our space.
+ LEN is the number of bytes.
+
+ Return the transferred status, error or OK (an
+ 'enum target_xfer_status' value). Save the number of bytes
+ transferred in *XFERED_LEN. */
static enum target_xfer_status
-target_read_live_memory (enum target_object object,
- ULONGEST memaddr, gdb_byte *myaddr, ULONGEST len,
- ULONGEST *xfered_len)
+remote_read_bytes_1 (CORE_ADDR memaddr, gdb_byte *myaddr, ULONGEST len,
+ ULONGEST *xfered_len)
{
- enum target_xfer_status ret;
- struct cleanup *cleanup;
+ struct remote_state *rs = get_remote_state ();
+ int max_buf_size; /* Max size of packet output buffer. */
+ char *p;
+ int todo;
+ int i;
- /* Switch momentarily out of tfind mode so to access live memory.
- Note that this must not clear global state, such as the frame
- cache, which must still remain valid for the previous traceframe.
- We may be _building_ the frame cache at this point. */
- cleanup = make_cleanup_restore_traceframe_number ();
- set_traceframe_number (-1);
+ max_buf_size = get_memory_read_packet_size ();
+ /* The packet buffer will be large enough for the payload;
+ get_memory_packet_size ensures this. */
- ret = target_xfer_partial (current_target.beneath, object, NULL,
- myaddr, NULL, memaddr, len, xfered_len);
+ /* Number if bytes that will fit. */
+ todo = min (len, max_buf_size / 2);
- do_cleanups (cleanup);
- return ret;
+ /* 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')
+ return TARGET_XFER_E_IO;
+ /* 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. */
+ *xfered_len = (ULONGEST) i;
+ return TARGET_XFER_OK;
}
-/* Using the set of read-only target sections of OPS, read live
- read-only memory. Note that the actual reads start from the
- top-most target again.
+/* Using the set of read-only target sections of remote, read live
+ read-only memory.
For interface/parameters/return description see target.h,
to_xfer_partial. */
static enum target_xfer_status
-memory_xfer_live_readonly_partial (struct target_ops *ops,
- enum target_object object,
- gdb_byte *readbuf, ULONGEST memaddr,
- ULONGEST len, ULONGEST *xfered_len)
+remote_xfer_live_readonly_partial (struct target_ops *ops, gdb_byte *readbuf,
+ ULONGEST memaddr, ULONGEST len,
+ ULONGEST *xfered_len)
{
struct target_section *secp;
struct target_section_table *table;
if (memend <= p->endaddr)
{
/* Entire transfer is within this section. */
- return target_read_live_memory (object, memaddr,
- readbuf, len, xfered_len);
+ return remote_read_bytes_1 (memaddr, readbuf, len,
+ xfered_len);
}
else if (memaddr >= p->endaddr)
{
{
/* This section overlaps the transfer. Just do half. */
len = p->endaddr - memaddr;
- return target_read_live_memory (object, memaddr,
- readbuf, len, xfered_len);
+ return remote_read_bytes_1 (memaddr, readbuf, len,
+ xfered_len);
}
}
}
return TARGET_XFER_EOF;
}
-/* Read memory data directly from the remote machine.
- This does not use the data cache; the data cache uses this.
- MEMADDR is the address in the remote memory space.
- MYADDR is the address of the buffer in our space.
- LEN is the number of bytes.
-
- Return the transferred status, error or OK (an
- 'enum target_xfer_status' value). Save the number of bytes
- transferred in *XFERED_LEN. */
+/* Similar to remote_read_bytes_1, but it reads from the remote stub
+ first if the requested memory is unavailable in traceframe.
+ Otherwise, fall back to remote_read_bytes_1. */
static enum target_xfer_status
remote_read_bytes (struct target_ops *ops, CORE_ADDR memaddr,
gdb_byte *myaddr, ULONGEST len, ULONGEST *xfered_len)
{
- struct remote_state *rs = get_remote_state ();
- int max_buf_size; /* Max size of packet output buffer. */
- char *p;
- int todo;
- int i;
-
if (len == 0)
return 0;
do_cleanups (old_chain);
/* This goes through the topmost target again. */
- res = memory_xfer_live_readonly_partial (ops,
- TARGET_OBJECT_MEMORY,
- myaddr, memaddr,
+ res = remote_xfer_live_readonly_partial (ops, myaddr, memaddr,
len, xfered_len);
if (res == TARGET_XFER_OK)
return TARGET_XFER_OK;
}
}
- max_buf_size = get_memory_read_packet_size ();
- /* The packet buffer will be large enough for the payload;
- get_memory_packet_size ensures this. */
-
- /* 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')
- return TARGET_XFER_E_IO;
- /* 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. */
- *xfered_len = (ULONGEST) i;
- return TARGET_XFER_OK;
+ return remote_read_bytes_1 (memaddr, myaddr, len, xfered_len);
}
\f