wait 500ms for target to halt upon connect.
[fw/openocd] / src / server / gdb_server.c
index 8db55df08a59eeb31d227aa98d37020bd9b67e2d..bbcff58c58b381b95ec350cfa08ade2595e05658 100644 (file)
@@ -287,7 +287,6 @@ int gdb_put_packet_inner(connection_t *connection, char *buffer, int len)
         * however sometimes '-' is sent even though we've already received
         * an ACK (+) for everything we've sent off.
         */
-#ifndef _WIN32
        int gotdata;
        for (;;)
        {
@@ -299,7 +298,6 @@ int gdb_put_packet_inner(connection_t *connection, char *buffer, int len)
                        return retval;
                LOG_WARNING("Discard unexpected char %c", reply);
        }
-#endif
 #endif
 
        while (1)
@@ -413,6 +411,8 @@ int gdb_get_packet_inner(connection_t *connection, char *buffer, int *len)
                                case '$':
                                        break;
                                case '+':
+                                       /* gdb sends a dummy ack '+' at every remote connect - see remote_start_remote (remote.c)
+                                        * incase anyone tries to debug why they receive this warning every time */
                                        LOG_WARNING("acknowledgment received, but no packet pending");
                                        break;
                                case '-':
@@ -679,6 +679,12 @@ int gdb_new_connection(connection_t *connection)
         * connect. 
         */
        target_halt(gdb_service->target);
+       /* FIX!!!! could extended-remote work better here?
+        * 
+        *  wait a tiny bit for halted state or we just continue. The
+        * GDB register packet will then contain garbage 
+        */
+       target_wait_state(gdb_service->target, TARGET_HALTED, 500);
        
        /* remove the initial ACK from the incoming buffer */
        if ((retval = gdb_get_char(connection, &initial_ack)) != ERROR_OK)