From 2706df0ec368125d680d4e88f95dfe00af89ad38 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Sun, 13 Aug 2017 14:14:23 -0700 Subject: [PATCH] Fix a corner case in block memory read. --- src/target/riscv/riscv-013.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index 0296ffdd1..284f6a1ba 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -1356,7 +1356,8 @@ static int read_memory(struct target *target, target_addr_t address, bool first = true; bool this_is_last_read = false; LOG_DEBUG("reading until final address 0x%" PRIx64, fin_addr); - while (count > 1 && (cur_addr = riscv_read_debug_buffer_x(target, d_addr)) < fin_addr - size) { + while (count > 1 && !this_is_last_read) { + cur_addr = riscv_read_debug_buffer_x(target, d_addr); LOG_DEBUG("transferring burst starting at address 0x%" TARGET_PRIxADDR " (previous burst was 0x%" TARGET_PRIxADDR ")", cur_addr, prev_addr); @@ -1373,7 +1374,6 @@ static int read_memory(struct target *target, target_addr_t address, size_t reads = 0; size_t rereads = reads; for (riscv_addr_t i = start; i < count; ++i) { - if (i == count - 1) { // don't do actual read in this batch, // we will do it later after we disable autoexec