Hide unknown registers, which probably don't exist

Change-Id: Iffa8fa5ff4b0a01abd30fa302b7087e2011337bf
This commit is contained in:
Tim Newsome 2017-11-29 13:38:04 -08:00
parent 26a54452d2
commit 8926e66d3a
2 changed files with 21 additions and 13 deletions

View File

@ -1249,6 +1249,12 @@ static int init_registers(struct target *target)
r->name = csr_info[csr_info_index].name; r->name = csr_info[csr_info_index].name;
} else { } else {
sprintf(reg_name, "csr%d", csr_number); 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) { switch (csr_number) {

View File

@ -2742,21 +2742,23 @@ COMMAND_HANDLER(handle_reg_command)
i < cache->num_regs; i < cache->num_regs;
i++, reg++, count++) { i++, reg++, count++) {
/* only print cached values if they are valid */ /* only print cached values if they are valid */
if (reg->valid) { if (reg->exist) {
value = buf_to_str(reg->value, if (reg->valid) {
reg->size, 16); value = buf_to_str(reg->value,
command_print(CMD_CTX, reg->size, 16);
"(%i) %s (/%" PRIu32 "): 0x%s%s", command_print(CMD_CTX,
count, reg->name, "(%i) %s (/%" PRIu32 "): 0x%s%s",
reg->size, value, count, reg->name,
reg->dirty reg->size, value,
reg->dirty
? " (dirty)" ? " (dirty)"
: ""); : "");
free(value); free(value);
} else { } else {
command_print(CMD_CTX, "(%i) %s (/%" PRIu32 ")", command_print(CMD_CTX, "(%i) %s (/%" PRIu32 ")",
count, reg->name, count, reg->name,
reg->size) ; reg->size) ;
}
} }
} }
cache = cache->next; cache = cache->next;