From ed9203f4aaf3b4a28d5e28da2cdb1a52d9f7c408 Mon Sep 17 00:00:00 2001 From: Paul Fertser Date: Thu, 25 Apr 2024 14:33:07 +0300 Subject: [PATCH] gdb_server: do not start multiple instances on "pipe" For configurations which include multiple targets and the "pipe" mode is requested only the first gdb_server instance should be enabled, otherwise GDB gets confusing replies, goes out of sync and the session fails in weird ways. Compile-tested only. Signed-off-by: Paul Fertser Change-Id: If8f13aa7b58e9b0dc6d5ae88cf75538b34cc1218 Reviewed-on: https://review.openocd.org/c/openocd/+/8222 Tested-by: jenkins Reviewed-by: Antonio Borneo --- src/server/gdb_server.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 7c2f41e41..0ded8e440 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -3879,7 +3879,7 @@ static int gdb_target_add_one(struct target *target) return gdb_target_start(target, target->gdb_port_override); } - if (strcmp(gdb_port, "disabled") == 0) { + if (strcmp(gdb_port_next, "disabled") == 0) { LOG_INFO("gdb port disabled"); return ERROR_OK; } @@ -3908,6 +3908,8 @@ static int gdb_target_add_one(struct target *target) gdb_port_next = strdup("0"); } } + } else if (strcmp(gdb_port_next, "pipe") == 0) { + gdb_port_next = "disabled"; } } return retval;