diff options
author | Tim Newsome <tim@sifive.com> | 2019-01-18 11:34:26 -0800 |
---|---|---|
committer | Tim Newsome <tim@sifive.com> | 2019-01-18 11:34:26 -0800 |
commit | 348f15315e7670fccdc152545399f3d44a24bf7d (patch) | |
tree | 228186be15762f241400ccee68a60d7f2b9e497e | |
parent | c1ef5f61c3b9b59e1a410badb90e485a98cdedb4 (diff) | |
download | riscv-openocd-348f15315e7670fccdc152545399f3d44a24bf7d.zip riscv-openocd-348f15315e7670fccdc152545399f3d44a24bf7d.tar.gz riscv-openocd-348f15315e7670fccdc152545399f3d44a24bf7d.tar.bz2 |
Don't reset current thread id on single step.
Now passing 36/45 tests.
Change-Id: I244b045f84397b058cf526e3bff238cb05d8ad06
-rw-r--r-- | src/rtos/hwthread.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/rtos/hwthread.c b/src/rtos/hwthread.c index da5d2eb..bfd299a 100644 --- a/src/rtos/hwthread.c +++ b/src/rtos/hwthread.c @@ -96,9 +96,6 @@ static int hwthread_update_threads(struct rtos *rtos) target = rtos->target; - /* wipe out previous thread details if any */ - rtos_free_threadlist(rtos); - /* determine the number of "threads" */ if (target->smp) { for (head = target->head; head != NULL; head = head->next) { @@ -112,6 +109,23 @@ static int hwthread_update_threads(struct rtos *rtos) } else thread_list_size = 1; + if (thread_list_size == rtos->thread_count) { + /* Nothing changed. Exit early. + * This is important because if we do recreate the data, we potentially + * change what the current thread is, which can lead to trouble because + * this function is sometimes called when single stepping + * (gdb_handle_vcont_packet), and the current thread should not be + * changed as part of that. */ + /* TODO: Do we need to confirm that all the "threads" are really the + * same? Is it even possible to change the number of configured + * targets and SMP groups after this function is called the first time? + */ + return ERROR_OK; + } + + /* wipe out previous thread details if any */ + rtos_free_threadlist(rtos); + /* create space for new thread details */ rtos->thread_details = malloc(sizeof(struct thread_detail) * thread_list_size); @@ -303,18 +317,11 @@ int hwthread_set_reg(struct rtos *rtos, int reg_num, uint8_t *reg_value) if (curr == NULL) return ERROR_FAIL; - struct reg **reg_list; - int reg_list_size; - if (target_get_gdb_reg_list(curr, ®_list, ®_list_size, - REG_CLASS_GENERAL) != ERROR_OK) + struct reg *reg = register_get_by_number(curr->reg_cache, reg_num, true); + if (!reg) return ERROR_FAIL; - if (reg_list_size <= reg_num) { - LOG_ERROR("Register %d requested, but only %d registers exist.", - reg_num, reg_list_size); - return ERROR_FAIL; - } - return reg_list[reg_num]->type->set(reg_list[reg_num], reg_value); + return reg->type->set(reg, reg_value); } static int hwthread_get_symbol_list_to_lookup(symbol_table_elem_t *symbol_list[]) |