Skip to content

Commit 3109da7

Browse files
committed
Force actual read from prog buffer for the last transaction in read_memory()
1 parent e676d3d commit 3109da7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/target/riscv/riscv-013.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,7 +1374,7 @@ static int read_memory(struct target *target, target_addr_t address,
13741374
size_t rereads = reads;
13751375
for (riscv_addr_t i = start; i < count; ++i) {
13761376

1377-
if (i == count) {
1377+
if (i == count - 1) {
13781378
// don't do actual read in this batch,
13791379
// we will do it later after we disable autoexec
13801380
//
@@ -1436,7 +1436,10 @@ static int read_memory(struct target *target, target_addr_t address,
14361436

14371437
if (this_is_last_read && i == start + reads - 1) {
14381438
riscv013_set_autoexec(target, d_data, 0);
1439-
value = riscv_program_read_ram(&program, r_data);
1439+
1440+
// access debug buffer without executing a program - this address logic was taken from program.c
1441+
int const off = (r_data - riscv_debug_buffer_addr(program.target)) / sizeof(program.debug_buffer[0]);
1442+
value = riscv_read_debug_buffer(target, off);
14401443
} else {
14411444
uint64_t dmi_out = riscv_batch_get_dmi_read(batch, rereads);
14421445
value = get_field(dmi_out, DTM_DMI_DATA);

0 commit comments

Comments
 (0)