summaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorØyvind Harboe <oyvind.harboe@zylin.com>2010-11-13 13:03:29 +0100
committerØyvind Harboe <oyvind.harboe@zylin.com>2010-11-15 09:14:05 +0100
commit6287c23b326cdebf20283b5c4eb8da4fae3eb821 (patch)
tree736c1e53987769d85dd068d8ee06069b6f630d87 /src/server
parentc62fb3fa81efa46f073db46a7eb7f2a91b16909a (diff)
downloadopenocd+libswd-6287c23b326cdebf20283b5c4eb8da4fae3eb821.tar.gz
openocd+libswd-6287c23b326cdebf20283b5c4eb8da4fae3eb821.tar.bz2
openocd+libswd-6287c23b326cdebf20283b5c4eb8da4fae3eb821.tar.xz
openocd+libswd-6287c23b326cdebf20283b5c4eb8da4fae3eb821.zip
gdb: fix occasional crash when flash probe failed
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Diffstat (limited to 'src/server')
-rw-r--r--src/server/gdb_server.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c
index 9503a130..77142dfa 100644
--- a/src/server/gdb_server.c
+++ b/src/server/gdb_server.c
@@ -833,9 +833,6 @@ static int gdb_new_connection(struct connection *connection)
breakpoint_clear_target(gdb_service->target);
watchpoint_clear_target(gdb_service->target);
- /* register callback to be informed about target events */
- target_register_event_callback(gdb_target_callback_event_handler, connection);
-
/* remove the initial ACK from the incoming buffer */
if ((retval = gdb_get_char(connection, &initial_ack)) != ERROR_OK)
return retval;
@@ -873,6 +870,13 @@ static int gdb_new_connection(struct connection *connection)
target_name(gdb_service->target),
target_state_name(gdb_service->target));
+ /* DANGER! If we fail subsequently, we must remove this handler,
+ * otherwise we occasionally see crashes as the timer can invoke the
+ * callback fn.
+ *
+ * register callback to be informed about target events */
+ target_register_event_callback(gdb_target_callback_event_handler, connection);
+
return ERROR_OK;
}