From 509e0e47156636359a3d1c9e977404867293fde3 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Fri, 2 Mar 2018 20:24:58 -0800 Subject: [PATCH] Error instead of asserting on reg access failure Instead of asserting, return error when an abstract register access fails on running target. Fixes #201 Change-Id: I1ab3b31b0a4babf83c44f95ee2eeca92ef906d2f --- src/target/riscv/riscv-013.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index 45d079685..07322e08d 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -1045,8 +1045,8 @@ static int register_write_direct(struct target *target, unsigned number, int result = register_write_abstract(target, number, value, register_size(target, number)); - if (result == ERROR_OK || - info->progbufsize + r->impebreak < 2) + if (result == ERROR_OK || info->progbufsize + r->impebreak < 2 || + !riscv_is_halted(target)) return result; struct riscv_program program; @@ -1109,8 +1109,8 @@ static int register_read_direct(struct target *target, uint64_t *value, uint32_t int result = register_read_abstract(target, value, number, register_size(target, number)); - if (result != ERROR_OK && - info->progbufsize + r->impebreak >= 2) { + if (result != ERROR_OK && info->progbufsize + r->impebreak >= 2 && + riscv_is_halted(target)) { assert(number != GDB_REGNO_S0); struct riscv_program program;