Duane Ellis: addresses protocol problems with GDB.
[openocd.git] / src / server / gdb_server.c
index 851777a9c4f3a0b937cb43906a8080b34b0c2c62..69e91dbead1bb3ec3629d7f6f6c75bfadebe0f95 100644 (file)
@@ -305,6 +305,13 @@ int gdb_put_packet_inner(connection_t *connection, char *buffer, int len)
                        break;
                if ((retval = gdb_get_char(connection, &reply)) != ERROR_OK)
                        return retval;
+        if( reply == '$' ){
+                       // fix a problem with some IAR tools
+                       gdb_putback_char( connection, reply );
+                       LOG_DEBUG("Unexpected start of new packet");
+                       break;
+               }
+
                LOG_WARNING("Discard unexpected char %c", reply);
        }
 #endif
@@ -369,16 +376,25 @@ int gdb_put_packet_inner(connection_t *connection, char *buffer, int len)
                                log_remove_callback(gdb_log_callback, connection);
                                LOG_WARNING("negative reply, retrying");
                        }
-                       else
-                       {
-                               LOG_ERROR("unknown character 0x%2.2x in reply, dropping connection", reply);
+                       else if( reply == '$' ){
+                               LOG_ERROR("GDB missing ack(1) - assumed good");
+                               gdb_putback_char( connection, reply );
+                               return ERROR_OK;
+                       } else {
+                                       
+                               LOG_ERROR("unknown character(1) 0x%2.2x in reply, dropping connection", reply);
                                gdb_con->closed=1;
                                return ERROR_SERVER_REMOTE_CLOSED;
                        }
-               }
+               } 
+               else if( reply == '$' ){
+                       LOG_ERROR("GDB missing ack(2) - assumed good");
+                       gdb_putback_char( connection, reply );
+                       return ERROR_OK;
+               } 
                else
                {
-                       LOG_ERROR("unknown character 0x%2.2x in reply, dropping connection", reply);
+                       LOG_ERROR("unknown character(2) 0x%2.2x in reply, dropping connection", reply);
                        gdb_con->closed=1;
                        return ERROR_SERVER_REMOTE_CLOSED;
                }
@@ -1942,7 +1958,20 @@ int gdb_input_inner(connection_t *connection)
                /* terminate with zero */
                packet[packet_size] = 0;
 
-               LOG_DEBUG("received packet: '%s'", packet);
+               if( LOG_LEVEL_IS( LOG_LVL_DEBUG ) ){
+                       if( packet[0] == 'X' ){
+                               // binary packets spew junk into the debug log stream 
+                               char buf[ 50 ];
+                               int x;
+                               for( x = 0 ; (x < 49) && (packet[x] != ':') ; x++ ){
+                                       buf[x] = packet[x];
+                               }
+                               buf[x] = 0;
+                               LOG_DEBUG("received packet: '%s:<binary-data>'", buf );
+                       } else {
+                               LOG_DEBUG("received packet: '%s'", packet );
+                       }
+               }
 
                if (packet_size > 0)
                {

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)