Commit 06898157 authored by oharboe's avatar oharboe
Browse files

Duane Ellis: addresses protocol problems with GDB.

https://lists.berlios.de/pipermail/openocd-development/2008-October/003326.html

git-svn-id: svn://svn.berlios.de/openocd/trunk@1039 b42882b7-edfa-0310-969c-e2dbd0fdcd60
parent 28f7fb41
...@@ -88,6 +88,7 @@ extern int debug_level; ...@@ -88,6 +88,7 @@ extern int debug_level;
/* Avoid fn call and building parameter list if we're not outputting the information. /* Avoid fn call and building parameter list if we're not outputting the information.
* Matters on feeble CPUs for DEBUG/INFO statements that are involved frequently */ * Matters on feeble CPUs for DEBUG/INFO statements that are involved frequently */
#define LOG_LEVEL_IS( FOO ) ((debug_level) >= (FOO))
#define LOG_DEBUG(expr ...) \ #define LOG_DEBUG(expr ...) \
((debug_level >= LOG_LVL_DEBUG) ? log_printf_lf (LOG_LVL_DEBUG, __FILE__, __LINE__, __FUNCTION__, expr) , 0 : 0) ((debug_level >= LOG_LVL_DEBUG) ? log_printf_lf (LOG_LVL_DEBUG, __FILE__, __LINE__, __FUNCTION__, expr) , 0 : 0)
......
...@@ -305,6 +305,13 @@ int gdb_put_packet_inner(connection_t *connection, char *buffer, int len) ...@@ -305,6 +305,13 @@ int gdb_put_packet_inner(connection_t *connection, char *buffer, int len)
break; break;
if ((retval = gdb_get_char(connection, &reply)) != ERROR_OK) if ((retval = gdb_get_char(connection, &reply)) != ERROR_OK)
return retval; 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); LOG_WARNING("Discard unexpected char %c", reply);
} }
#endif #endif
...@@ -369,16 +376,25 @@ int gdb_put_packet_inner(connection_t *connection, char *buffer, int len) ...@@ -369,16 +376,25 @@ int gdb_put_packet_inner(connection_t *connection, char *buffer, int len)
log_remove_callback(gdb_log_callback, connection); log_remove_callback(gdb_log_callback, connection);
LOG_WARNING("negative reply, retrying"); LOG_WARNING("negative reply, retrying");
} }
else else if( reply == '$' ){
{ LOG_ERROR("GDB missing ack(1) - assumed good");
LOG_ERROR("unknown character 0x%2.2x in reply, dropping connection", reply); 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; gdb_con->closed=1;
return ERROR_SERVER_REMOTE_CLOSED; 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 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; gdb_con->closed=1;
return ERROR_SERVER_REMOTE_CLOSED; return ERROR_SERVER_REMOTE_CLOSED;
} }
...@@ -1942,7 +1958,20 @@ int gdb_input_inner(connection_t *connection) ...@@ -1942,7 +1958,20 @@ int gdb_input_inner(connection_t *connection)
/* terminate with zero */ /* terminate with zero */
packet[packet_size] = 0; 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) if (packet_size > 0)
{ {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment