aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorphilippe <philippe@a5019735-40e9-0310-863c-91ae7b9d1cf9>2015-05-17 16:34:04 +0000
committerphilippe <philippe@a5019735-40e9-0310-863c-91ae7b9d1cf9>2015-05-17 16:34:04 +0000
commit8568c99d33c6e0ad6738ebb39da9467a71b847dd (patch)
tree9ee8d344f84c0e451ab13109842e560b05542c19
parent9edbf75d3da31c7eb8e5c34fc1386dabcd823997 (diff)
downloadvalgrind-8568c99d33c6e0ad6738ebb39da9467a71b847dd.tar.gz
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 a5019735-40e9-0310-863c-91ae7b9d1cf9
-rw-r--r--coregrind/m_gdbserver/remote-utils.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/coregrind/m_gdbserver/remote-utils.c b/coregrind/m_gdbserver/remote-utils.c
index b71220ce6..f5f31c1e6 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;