Skip to content

Commit 45f2808

Browse files
authored
Merge pull request #94 from riscv/memread
Fix a corner case in block memory read.
2 parents 1af0c09 + 2706df0 commit 45f2808

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/target/riscv/riscv-013.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,7 +1356,8 @@ static int read_memory(struct target *target, target_addr_t address,
13561356
bool first = true;
13571357
bool this_is_last_read = false;
13581358
LOG_DEBUG("reading until final address 0x%" PRIx64, fin_addr);
1359-
while (count > 1 && (cur_addr = riscv_read_debug_buffer_x(target, d_addr)) < fin_addr - size) {
1359+
while (count > 1 && !this_is_last_read) {
1360+
cur_addr = riscv_read_debug_buffer_x(target, d_addr);
13601361
LOG_DEBUG("transferring burst starting at address 0x%" TARGET_PRIxADDR
13611362
" (previous burst was 0x%" TARGET_PRIxADDR ")", cur_addr,
13621363
prev_addr);
@@ -1373,7 +1374,6 @@ static int read_memory(struct target *target, target_addr_t address,
13731374
size_t reads = 0;
13741375
size_t rereads = reads;
13751376
for (riscv_addr_t i = start; i < count; ++i) {
1376-
13771377
if (i == count - 1) {
13781378
// don't do actual read in this batch,
13791379
// we will do it later after we disable autoexec

0 commit comments

Comments
 (0)