aboutsummaryrefslogtreecommitdiff
path: root/src/rtos/rtos.c
diff options
context:
space:
mode:
authorGreg Savin <greg.savin@sifive.com>2022-02-07 09:28:31 -0800
committerGitHub <noreply@github.com>2022-02-07 09:28:31 -0800
commitf6ffede8b62e7092141d54e75238fde1ee00d0c2 (patch)
tree4768bb39d995fef7f170b90e051b202b7886cdd0 /src/rtos/rtos.c
parent7d91f639bbc18206a48c7ae72580be79cb70c15b (diff)
downloadriscv-openocd-f6ffede8b62e7092141d54e75238fde1ee00d0c2.zip
riscv-openocd-f6ffede8b62e7092141d54e75238fde1ee00d0c2.tar.gz
riscv-openocd-f6ffede8b62e7092141d54e75238fde1ee00d0c2.tar.bz2
fix missing thread ID in stop reply when smp-configured hart (but not hart 0) single-stepped (#675)
Diffstat (limited to 'src/rtos/rtos.c')
-rw-r--r--src/rtos/rtos.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/rtos/rtos.c b/src/rtos/rtos.c
index 8141658..b9adf0a 100644
--- a/src/rtos/rtos.c
+++ b/src/rtos/rtos.c
@@ -22,6 +22,7 @@
#include "rtos.h"
#include "target/target.h"
+#include "target/smp.h"
#include "helper/log.h"
#include "helper/binarybuffer.h"
#include "server/gdb_server.h"
@@ -789,10 +790,29 @@ static int rtos_try_next(struct target *target)
return 1;
}
-int rtos_update_threads(struct target *target)
+struct rtos *rtos_of_target(struct target *target)
{
+ /* Primarily consider the rtos field of the target itself, secondarily consider
+ * rtos field SMP leader target, then consider rtos field of any other target in the SMP group.
+ * Otherwise NULL return means that no associated non-zero rtos field could be found. */
+
+ struct target_list *pos;
+
if ((target->rtos) && (target->rtos->type))
- target->rtos->type->update_threads(target->rtos);
+ return target->rtos;
+
+ foreach_smp_target(pos, target->head)
+ if ((pos->target->rtos) && (pos->target->rtos->type))
+ return pos->target->rtos;
+
+ return NULL;
+}
+
+int rtos_update_threads(struct target *target)
+{
+ struct rtos *rtos = rtos_of_target(target);
+ if (rtos)
+ rtos->type->update_threads(rtos);
return ERROR_OK;
}