From: Philippe Waroquiers Date: Sun, 17 May 2015 16:34:04 +0000 (+0000) Subject: Improve trace of pkt send by V gdbsrv: X-Git-Tag: svn/VALGRIND_3_11_0~374 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=248e483e7b44938bb7c45b197b252ebe15720c88;p=thirdparty%2Fvalgrind.git Improve trace of pkt send by V gdbsrv: * show the len * print binary date using \octal notation (like printf, when given non printable chars) git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15250 --- diff --git a/coregrind/m_gdbserver/remote-utils.c b/coregrind/m_gdbserver/remote-utils.c index b71220ce6a..f5f31c1e65 100644 --- a/coregrind/m_gdbserver/remote-utils.c +++ b/coregrind/m_gdbserver/remote-utils.c @@ -851,10 +851,27 @@ int putpkt_binary (char *buf, int cnt) return -1; } - if (noack_mode) - dlog(3, "putpkt (\"%s\"); [no ack]\n", buf2); - else - dlog(3,"putpkt (\"%s\"); [looking for ack]\n", buf2); + if (VG_(debugLog_getLevel)() >= 3) { + char *tracebuf = malloc(4 * (p - buf2) + 1); // worst case + char *tr = tracebuf; + + for (UInt npr = 0; npr < p - buf2; npr++) { + UChar uc = (unsigned char)buf2[npr]; + if (uc > 31 && uc < 127) { + *tr++ = uc; + } else { + *tr++ = '\\'; + VG_(sprintf)(tr, "%03o", uc); + tr += 3; + } + } + *tr++ = 0; + dlog(3, "putpkt (\"%s\"); (%slen %d) %s\n", tracebuf, + strlen(tracebuf) == p - buf2 ? "binary " : "", + p - buf2, + noack_mode ? "[no ack]" : "[looking for ack]"); + free (tracebuf); + } if (noack_mode) break;