Fix reading of non-general registers for hwthread

Previously the code made the assumption (which is valid for conventional
RTOSs) that special registers (e.g. CSRs) are the same across threads.

26/45 tests pass.

Change-Id: Ibb3398790d7354a995d506772375d869f608f1f0
This commit is contained in:
Tim Newsome
2019-01-17 12:46:20 -08:00
parent c84d56debc
commit c1ef5f61c3
8 changed files with 102 additions and 12 deletions
+23
View File
@@ -36,6 +36,29 @@
* may be separate registers associated with debug or trace modules.
*/
struct reg *register_get_by_number(struct reg_cache *first,
uint32_t reg_num, bool search_all)
{
unsigned i;
struct reg_cache *cache = first;
while (cache) {
for (i = 0; i < cache->num_regs; i++) {
if (cache->reg_list[i].exist == false)
continue;
if (cache->reg_list[i].number == reg_num)
return &(cache->reg_list[i]);
}
if (search_all)
cache = cache->next;
else
break;
}
return NULL;
}
struct reg *register_get_by_name(struct reg_cache *first,
const char *name, bool search_all)
{
+2
View File
@@ -159,6 +159,8 @@ struct reg_arch_type {
int (*set)(struct reg *reg, uint8_t *buf);
};
struct reg *register_get_by_number(struct reg_cache *first,
uint32_t reg_num, bool search_all);
struct reg *register_get_by_name(struct reg_cache *first,
const char *name, bool search_all);
struct reg_cache **register_get_last_cache_p(struct reg_cache **first);
+17 -1
View File
@@ -931,7 +931,7 @@ static int riscv_get_gdb_reg_list(struct target *target,
switch (reg_class) {
case REG_CLASS_GENERAL:
*reg_list_size = 32;
*reg_list_size = 33;
break;
case REG_CLASS_ALL:
*reg_list_size = target->reg_cache->num_regs;
@@ -1218,6 +1218,22 @@ int riscv_openocd_poll(struct target *target)
target->state = TARGET_HALTED;
if (target->smp) {
LOG_DEBUG("Halt other targets in this SMP group.");
struct target_list *targets = target->head;
int result = ERROR_OK;
while (targets) {
struct target *t = targets->target;
targets = targets->next;
if (t->state != TARGET_HALTED) {
if (old_or_new_riscv_halt(t) != ERROR_OK)
result = ERROR_FAIL;
}
}
if (result != ERROR_OK)
return result;
}
if (target->debug_reason == DBG_REASON_BREAKPOINT) {
int retval;
if (riscv_semihosting(target, &retval) != 0)
+3 -2
View File
@@ -1575,8 +1575,9 @@ int target_call_event_callbacks(struct target *target, enum target_event event)
target_call_event_callbacks(target, TARGET_EVENT_GDB_HALT);
}
LOG_DEBUG("target event %i (%s)", event,
Jim_Nvp_value2name_simple(nvp_target_event, event)->name);
LOG_DEBUG("target event %i (%s) for core %d", event,
Jim_Nvp_value2name_simple(nvp_target_event, event)->name,
target->coreid);
target_handle_event(target, event);