Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server/gdb_server: Handle events if first target is unavailable #926

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/server/gdb_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
Loading