From 8926e66d3a36304af8244dfa177bd8e45a09010d Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Wed, 29 Nov 2017 13:38:04 -0800 Subject: Hide unknown registers, which probably don't exist Change-Id: Iffa8fa5ff4b0a01abd30fa302b7087e2011337bf --- src/target/riscv/riscv-013.c | 6 ++++++ src/target/target.c | 28 +++++++++++++++------------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index 4238273..1c48e55 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -1249,6 +1249,12 @@ static int init_registers(struct target *target) r->name = csr_info[csr_info_index].name; } else { sprintf(reg_name, "csr%d", csr_number); + // Assume unnamed registers don't exist, unless we have some + // configuration that tells us otherwise. That's important + // because eg. Eclipse crashes if a target has too many + // registers, and apparently has no way of only showing a + // subset of registers in any case. + r->exist = false; } switch (csr_number) { diff --git a/src/target/target.c b/src/target/target.c index adedd47..3278444 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -2742,21 +2742,23 @@ COMMAND_HANDLER(handle_reg_command) i < cache->num_regs; i++, reg++, count++) { /* only print cached values if they are valid */ - if (reg->valid) { - value = buf_to_str(reg->value, - reg->size, 16); - command_print(CMD_CTX, - "(%i) %s (/%" PRIu32 "): 0x%s%s", - count, reg->name, - reg->size, value, - reg->dirty + if (reg->exist) { + if (reg->valid) { + value = buf_to_str(reg->value, + reg->size, 16); + command_print(CMD_CTX, + "(%i) %s (/%" PRIu32 "): 0x%s%s", + count, reg->name, + reg->size, value, + reg->dirty ? " (dirty)" : ""); - free(value); - } else { - command_print(CMD_CTX, "(%i) %s (/%" PRIu32 ")", - count, reg->name, - reg->size) ; + free(value); + } else { + command_print(CMD_CTX, "(%i) %s (/%" PRIu32 ")", + count, reg->name, + reg->size) ; + } } } cache = cache->next; -- cgit v1.1