From 397d5be64b1c8e1a2e5bd2b38572c1ff096570f4 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Tue, 21 Apr 2020 10:48:03 -0700 Subject: [PATCH] Don't read registers that we know don't exist. Change-Id: Ie5c6226b3d4ecb6cf8f0d8954a52fda88e6e5bdd --- src/target/riscv/riscv.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/target/riscv/riscv.c b/src/target/riscv/riscv.c index 2d04e9ffb..1345078f7 100644 --- a/src/target/riscv/riscv.c +++ b/src/target/riscv/riscv.c @@ -3096,6 +3096,11 @@ int riscv_get_register_on_hart(struct target *target, riscv_reg_t *value, RISCV_INFO(r); struct reg *reg = &target->reg_cache->reg_list[regid]; + if (!reg->exist) { + LOG_DEBUG("[%s]{%d} %s does not exist.", + target_name(target), hartid, gdb_regno_name(regid)); + return ERROR_FAIL; + } if (reg && reg->valid && hartid == riscv_current_hartid(target)) { *value = buf_get_u64(reg->value, 0, reg->size);