diff options
author | Tim Newsome <tim@sifive.com> | 2023-10-11 13:00:21 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-11 13:00:21 -0700 |
commit | 6e9514efcd0b5af1f5ffae5d1afa7e7640962ca6 (patch) | |
tree | e31db66d5f9a3feb215c3e511a711d304b82bb4f /src/server/gdb_server.c | |
parent | 6f4b90afb7fea750cfb633922f64c9d95c3ddb8b (diff) | |
parent | 52c9ae0aa1f1413e01e3599fc23b9e98147129b6 (diff) | |
download | riscv-openocd-6e9514efcd0b5af1f5ffae5d1afa7e7640962ca6.zip riscv-openocd-6e9514efcd0b5af1f5ffae5d1afa7e7640962ca6.tar.gz riscv-openocd-6e9514efcd0b5af1f5ffae5d1afa7e7640962ca6.tar.bz2 |
Merge pull request #926 from riscv/unavailable_events
server/gdb_server: Handle events if first target is unavailable
Diffstat (limited to 'src/server/gdb_server.c')
-rw-r--r-- | src/server/gdb_server.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index a0a5e4a..495af29 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -166,6 +166,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) { switch (target->debug_reason) { @@ -988,9 +1006,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) { |