From: Hsiangkai Wang Date: Thu, 11 Jul 2013 02:44:59 +0000 (+0800) Subject: gdb_server: check target before executing event callback X-Git-Tag: v0.8.0-rc1~324 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0961987a1916a498e65240cded359ab3c9b73f95;p=openocd gdb_server: check target before executing event callback As debugging multi-targets, every target has its own gdb connection. If there are two connections, gdb_target_callback_event_handler will be registered twice. Everytime event occurs, the registered callback will be executed twice. If both targets are running, as user issues ctrl-c in one gdb client, both connections will send "stop reply" to GDB clients even TARGET_EVENT_GDB_HALT is caused by one of them. The commit fix above problem as debugging multi-targets. Change-Id: I1e12d4846927d7dcf1e3bb9aeb1affabc80df813 Signed-off-by: Hsiangkai Wang Reviewed-on: http://openocd.zylin.com/1501 Tested-by: jenkins Reviewed-by: Sergey Borshch Reviewed-by: Spencer Oliver --- diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index c4ad91cf..48015abc 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -864,6 +864,10 @@ static int gdb_target_callback_event_handler(struct target *target, { int retval; struct connection *connection = priv; + struct gdb_service *gdb_service = connection->service->priv; + + if (gdb_service->target != target) + return ERROR_OK; switch (event) { case TARGET_EVENT_GDB_HALT: