This is an automated email from Gerrit.

"Tomas Vanek <van...@fbl.cz>" just uploaded a new patch set to Gerrit, which 
you can find at https://review.openocd.org/c/openocd/+/8914

-- gerrit

commit 30107eb7c9b60c6c3dbc4fc0ccf2fc79900e9076
Author: Tim Newsome <t...@sifive.com>
Date:   Fri Sep 15 09:42:16 2023 -0700

    server/gdb_server: Handle events if first target is unavailable
    
    When a target in an SMP group is unavailable, the gdb layer might get an
    event for a different target in that SMP group, but not one that is the
    primary target for that gdb connection. So propagate events if they're
    for any of the targets in the SMP group, not just if it's for the first
    one in that group.
    
    Imported from
    https://github.com/riscv-collab/riscv-openocd/pull/926
    
    Change-Id: I8d6738762acc7c0aef96f56ce2cb7f2eeb233b33
    Signed-off-by: Tim Newsome <t...@sifive.com>

diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c
index 312c592234..d242dbc3a8 100644
--- a/src/server/gdb_server.c
+++ b/src/server/gdb_server.c
@@ -172,6 +172,24 @@ struct target *get_available_target_from_connection(struct 
connection *connectio
        return target;
 }
 
+/** Return true iff the given connection includes the given target. */
+static bool gdb_connection_includes_target(struct connection *connection, 
struct target *target)
+{
+       struct gdb_service *gdb_service = connection->service->priv;
+       struct target *service_target = gdb_service->target;
+       if (service_target->smp) {
+               struct target_list *tlist;
+               foreach_smp_target(tlist, service_target->smp_targets) {
+                       struct target *t = tlist->target;
+                       if (t == target)
+                               return true;
+               }
+               return false;
+       }
+       /* Non-SMP target. */
+       return service_target == target;
+}
+
 static int gdb_last_signal(struct target *target)
 {
        LOG_TARGET_DEBUG(target, "Debug reason is: %s",
@@ -978,9 +996,9 @@ static int gdb_target_callback_event_handler(struct target 
*target,
                enum target_event event, void *priv)
 {
        struct connection *connection = priv;
-       struct target *gdb_target = 
get_available_target_from_connection(connection);
 
-       if (gdb_target != target)
+       /* Propagate this event if it's for any of the targets on this gdb 
connection. */
+       if (!gdb_connection_includes_target(connection, target))
                return ERROR_OK;
 
        switch (event) {

-- 

Reply via email to