gdb_server: Log both incoming and outgoing GDB packets
- Made sure that also outgoing GDB packets are logged, not only the incoming ones. - Improved the treatment of non-printable characters in the packets to make it more robust. Prior to this change: - Outgoing packets were not printed unless OpenOCD was re-compiled with _DEBUG_GDB_IO_. - Non-prinable characters were only treated in incoming 'X' packets. After this change: - Both incoming and outgoing GDB packets are logged on debug_level >= 3, so that both directions of the GDB channel are visible. - Non-printable characters are checked for in every packet so that hey do not interfere with the terminal. Change-Id: I0613e57ae5059b3279b0abcb71276cf5719a8699 Signed-off-by: Jan Matyas <matyas@codasip.com> Reviewed-on: http://openocd.zylin.com/6269 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
committed by
Antonio Borneo
parent
a8d3f60113
commit
49820b8afd
@@ -518,3 +518,16 @@ void log_socket_error(const char *socket_desc)
|
||||
LOG_ERROR("Error on socket '%s': errno==%d, message: %s.", socket_desc, error_code, strerror(error_code));
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the first non-printable character in the char buffer, return a pointer to it.
|
||||
* If no such character exists, return NULL.
|
||||
*/
|
||||
char *find_nonprint_char(char *buf, unsigned buf_len)
|
||||
{
|
||||
for (unsigned int i = 0; i < buf_len; i++) {
|
||||
if (!isprint(buf[i]))
|
||||
return buf + i;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -100,6 +100,8 @@ char *alloc_vprintf(const char *fmt, va_list ap);
|
||||
char *alloc_printf(const char *fmt, ...)
|
||||
__attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 1, 2)));
|
||||
|
||||
char *find_nonprint_char(char *buf, unsigned buf_len);
|
||||
|
||||
extern int debug_level;
|
||||
|
||||
/* Avoid fn call and building parameter list if we're not outputting the information.
|
||||
|
||||
Reference in New Issue
Block a user