fix missing thread ID in stop reply when smp-configured hart (but not hart 0) single-stepped (#675)

This commit is contained in:
Greg Savin 2022-02-07 09:28:31 -08:00 committed by GitHub
parent 7d91f639bb
commit f6ffede8b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 7 deletions

View File

@ -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;
}
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))
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)
{
if ((target->rtos) && (target->rtos->type))
target->rtos->type->update_threads(target->rtos);
struct rtos *rtos = rtos_of_target(target);
if (rtos)
rtos->type->update_threads(rtos);
return ERROR_OK;
}

View File

@ -175,5 +175,6 @@ int rtos_write_buffer(struct target *target, target_addr_t address,
uint32_t size, const uint8_t *buffer);
struct target *rtos_swbp_target(struct target *target, target_addr_t address,
uint32_t length, enum breakpoint_type type);
struct rtos *rtos_of_target(struct target *target);
#endif /* OPENOCD_RTOS_RTOS_H */

View File

@ -778,9 +778,12 @@ static void gdb_signal_reply(struct target *target, struct connection *connectio
sig_reply_len = snprintf(sig_reply, sizeof(sig_reply), "W00");
} else {
struct target *ct;
if (target->rtos) {
target->rtos->current_threadid = target->rtos->current_thread;
target->rtos->gdb_target_for_threadid(connection, target->rtos->current_threadid, &ct);
struct rtos *rtos;
rtos = rtos_of_target(target);
if (rtos) {
rtos->current_threadid = rtos->current_thread;
rtos->gdb_target_for_threadid(connection, rtos->current_threadid, &ct);
} else {
ct = target;
}
@ -817,9 +820,9 @@ static void gdb_signal_reply(struct target *target, struct connection *connectio
}
current_thread[0] = '\0';
if (target->rtos)
if (rtos)
snprintf(current_thread, sizeof(current_thread), "thread:%" PRIx64 ";",
target->rtos->current_thread);
rtos->current_thread);
sig_reply_len = snprintf(sig_reply, sizeof(sig_reply), "T%2.2x%s%s",
signal_var, stop_reason, current_thread);