From 0256a6ac4b25d56da14cbbe3cda9977f9c7c13eb Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Wed, 21 May 2014 13:58:16 +0100 Subject: Make the dcache (code/stack cache) handle line reading errors better The dcache (code/stack cache) is supposed to be transparent, but it's actually not in one case. dcache tries to read chunks (cache lines) at a time off of the target. This may end up trying to read unaccessible or unavailable memory. Currently the caller gets an xfer error in this case. But if the specific bits of memory the caller actually wanted are available and accessible, then the caller should get the memory it wanted, not an error. gdb/ 2014-05-21 Pedro Alves * dcache.c (dcache_read_memory_partial): If reading the cache line fails, fallback to reading just the memory the caller wanted. gdb/testsuite/ 2014-05-21 Pedro Alves * gdb.base/dcache-line-read-error.c: New. * gdb.base/dcache-line-read-error.exp: New. --- gdb/dcache.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'gdb/dcache.c') diff --git a/gdb/dcache.c b/gdb/dcache.c index d3b546b..9780f4d 100644 --- a/gdb/dcache.c +++ b/gdb/dcache.c @@ -497,8 +497,11 @@ dcache_read_memory_partial (struct target_ops *ops, DCACHE *dcache, if (i == 0) { - /* FIXME: We lose the real error status. */ - return TARGET_XFER_E_IO; + /* Even though reading the whole line failed, we may be able to + read a piece starting where the caller wanted. */ + return ops->to_xfer_partial (ops, TARGET_OBJECT_MEMORY, NULL, + myaddr, NULL, memaddr, len, + xfered_len); } else { -- cgit v1.1