Merge pull request #850 from riscv/cleanup-in-target-c

Minor cleanup in target.c
This commit is contained in:
Tim Newsome 2023-05-16 09:27:57 -07:00 committed by GitHub
commit d78d991191
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 19 deletions

View File

@ -3101,23 +3101,21 @@ COMMAND_HANDLER(handle_reg_command)
if (reg->exist == false || reg->hidden) if (reg->exist == false || reg->hidden)
continue; continue;
/* only print cached values if they are valid */ /* only print cached values if they are valid */
if (reg->exist) { if (reg->valid) {
if (reg->valid) { char *value = buf_to_hex_str(reg->value,
char *value = buf_to_hex_str(reg->value, reg->size);
reg->size); command_print(CMD,
command_print(CMD, "(%i) %s (/%" PRIu32 "): 0x%s%s",
"(%i) %s (/%" PRIu32 "): 0x%s%s", count, reg->name,
count, reg->name, reg->size, value,
reg->size, value, reg->dirty
reg->dirty ? " (dirty)"
? " (dirty)" : "");
: ""); free(value);
free(value); } else {
} else { command_print(CMD, "(%i) %s (/%" PRIu32 ")",
command_print(CMD, "(%i) %s (/%" PRIu32 ")", count, reg->name,
count, reg->name, reg->size);
reg->size) ;
}
} }
} }
cache = cache->next; cache = cache->next;
@ -3173,8 +3171,8 @@ COMMAND_HANDLER(handle_reg_command)
if (reg->valid == 0) { if (reg->valid == 0) {
int retval = reg->type->get(reg); int retval = reg->type->get(reg);
if (retval != ERROR_OK) { if (retval != ERROR_OK) {
LOG_DEBUG("Couldn't get register %s.", reg->name); LOG_ERROR("Could not read register '%s'", reg->name);
return retval; return retval;
} }
} }
char *value = buf_to_hex_str(reg->value, reg->size); char *value = buf_to_hex_str(reg->value, reg->size);