aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/target/riscv/riscv-013.c6
-rw-r--r--src/target/target.c28
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;