This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 7/8] Adjust read_value_memory to use to_xfer_partial
- From: Yao Qi <yao at codesourcery dot com>
- To: <gdb-patches at sourceware dot org>
- Date: Wed, 12 Feb 2014 14:05:51 +0800
- Subject: [PATCH 7/8] Adjust read_value_memory to use to_xfer_partial
- Authentication-results: sourceware.org; auth=none
- References: <1392185152-21220-1-git-send-email-yao at codesourcery dot com>
As the new to_xfer_partial implementations are done in ctf and tfile
targets, read_value_memory can be simplified a lot. Call
target_xfer_partial in a loop, check return value, and set bytes
unavailable when necessary.
gdb:
2014-02-11 Yao Qi <yao@codesourcery.com>
* valops.c (read_value_memory): Rewrite it. Call
target_xfer_partial in a loop.
---
gdb/valops.c | 90 ++++++++++++---------------------------------------------
1 files changed, 19 insertions(+), 71 deletions(-)
diff --git a/gdb/valops.c b/gdb/valops.c
index 898401d..ec87409 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -949,81 +949,29 @@ read_value_memory (struct value *val, int embedded_offset,
int stack, CORE_ADDR memaddr,
gdb_byte *buffer, size_t length)
{
- if (length)
- {
- VEC(mem_range_s) *available_memory;
-
- if (!traceframe_available_memory (&available_memory, memaddr, length))
- {
- if (stack)
- read_stack (memaddr, buffer, length);
- else
- read_memory (memaddr, buffer, length);
- }
- else
- {
- struct target_section_table *table;
- struct cleanup *old_chain;
- CORE_ADDR unavail;
- mem_range_s *r;
- int i;
-
- /* Fallback to reading from read-only sections. */
- table = target_get_section_table (&exec_ops);
- available_memory =
- section_table_available_memory (available_memory,
- memaddr, length,
- table->sections,
- table->sections_end);
-
- old_chain = make_cleanup (VEC_cleanup(mem_range_s),
- &available_memory);
+ ULONGEST xfered = 0;
- normalize_mem_ranges (available_memory);
-
- /* Mark which bytes are unavailable, and read those which
- are available. */
-
- unavail = memaddr;
+ while (xfered < length)
+ {
+ enum target_xfer_status status;
+ ULONGEST xfered_len;
- for (i = 0;
- VEC_iterate (mem_range_s, available_memory, i, r);
- i++)
- {
- if (mem_ranges_overlap (r->start, r->length,
- memaddr, length))
- {
- CORE_ADDR lo1, hi1, lo2, hi2;
- CORE_ADDR start, end;
-
- /* Get the intersection window. */
- lo1 = memaddr;
- hi1 = memaddr + length;
- lo2 = r->start;
- hi2 = r->start + r->length;
- start = max (lo1, lo2);
- end = min (hi1, hi2);
-
- gdb_assert (end - memaddr <= length);
-
- if (start > unavail)
- mark_value_bytes_unavailable (val,
- (embedded_offset
- + unavail - memaddr),
- start - unavail);
- unavail = end;
-
- read_memory (start, buffer + start - memaddr, end - start);
- }
- }
+ status = target_xfer_partial (current_target.beneath,
+ TARGET_OBJECT_MEMORY, NULL,
+ buffer + xfered, NULL,
+ memaddr + xfered, length - xfered,
+ &xfered_len);
- if (unavail != memaddr + length)
- mark_value_bytes_unavailable (val,
- embedded_offset + unavail - memaddr,
- (memaddr + length) - unavail);
+ if (status == TARGET_XFER_EOF)
+ memory_error (TARGET_XFER_E_IO, memaddr + xfered);
+ else if (status == TARGET_XFER_E_UNAVAILABLE)
+ mark_value_bytes_unavailable (val, embedded_offset + xfered,
+ xfered_len);
+ else if (TARGET_XFER_STATUS_ERROR_P (status))
+ memory_error (status, memaddr + xfered);
- do_cleanups (old_chain);
- }
+ xfered += xfered_len;
+ QUIT;
}
}
--
1.7.7.6