From c78b4fe426c35f638e5575b59ec89d0e794263af Mon Sep 17 00:00:00 2001 From: oharboe Date: Fri, 7 Mar 2008 21:49:16 +0000 Subject: - Improves error handling upon GDB connect - switch to synchronous halt during connect. This fixes the bug where poll() was not invoked between halt() and servicing the 'g' register packet - halt() no longer returns error code when target is already halted, just logs a warning. Only the halt() implementation can say anything meaningful about why a halt() failed, so error messages are pushed up to halt() - fixed soft_reset_halt infinite loop bug in arm7_9_common.c. The rest of the implementations are still busted. - by using USER() instead of command_print() the log gets the source + line #. Nice. - no longer invoke exit() if soft_reset_halt fails. A reset can often fix the problem. git-svn-id: svn://svn.berlios.de/openocd/trunk@475 b42882b7-edfa-0310-969c-e2dbd0fdcd60 --- src/server/gdb_server.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/server') diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 1fac4697..f01d638f 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -684,13 +684,19 @@ int gdb_new_connection(connection_t *connection) * GDB connection will fail if e.g. register read packets fail, * otherwise resetting/halting the target could have been left to GDB init * scripts + * + * DANGER!!!! + * We need a synchronous halt, lest connect will fail. + * Also there is no guarantee that poll() will be invoked + * between here and serving the first packet, so the halt() + * statement above is *NOT* sufficient */ - if (((retval = gdb_service->target->type->halt(gdb_service->target)) != ERROR_OK) && - (retval != ERROR_TARGET_ALREADY_HALTED)) + if ((retval = gdb_service->target->type->halt(gdb_service->target)) != ERROR_OK) { ERROR("error(%d) when trying to halt target, falling back to \"reset\"", retval); command_run_line(connection->cmd_ctx, "reset"); } + command_run_line(connection->cmd_ctx, "halt"); /* remove the initial ACK from the incoming buffer */ if ((retval = gdb_get_char(connection, &initial_ack)) != ERROR_OK) @@ -1462,6 +1468,7 @@ int gdb_query_packet(connection_t *connection, target_t *target, char *packet, i log_add_callback(gdb_log_callback, connection); target_call_timer_callbacks(); command_run_line(cmd_ctx, cmd); + target_call_timer_callbacks(); log_remove_callback(gdb_log_callback, connection); free(cmd); } -- cgit v1.2.3