From: Josef Weidendorfer Date: Wed, 18 Feb 2015 16:28:58 +0000 (+0000) Subject: Fix Bug #344314 callgrind_annotate ... commands containing newlines X-Git-Tag: svn/VALGRIND_3_11_0~645 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9b43616636fc2845230ae631cf1e56eda76f3c67;p=thirdparty%2Fvalgrind.git Fix Bug #344314 callgrind_annotate ... commands containing newlines Escape newlines in command arguments for "cmd:" header field in dumps We could do unescaping in callgrind_annotate, but a escaped command even seems better there. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14947 --- diff --git a/NEWS b/NEWS index 3e6dbe520d..8c8b7c537e 100644 --- a/NEWS +++ b/NEWS @@ -101,6 +101,7 @@ where XXXXXX is the bug number as listed below. 344279 syscall sendmmsg on arm64 (269) and ppc32/64 (349) unhandled 344295 syscall recvmmsg on arm64 (243) and ppc32/64 (343) unhandled 344307 2 unhandled syscalls on aarch64/arm64: umount2(39), mount (40) +344314 callgrind_annotate ... warnings about commands containing newlines n-i-bz Provide implementations of certain compiler builtins to support compilers who may not provide those n-i-bz Old STABS code is still being compiled, but never used. Remove it. diff --git a/callgrind/dump.c b/callgrind/dump.c index 687561431b..c6d4de11bd 100644 --- a/callgrind/dump.c +++ b/callgrind/dump.c @@ -1508,7 +1508,15 @@ void init_cmdbuf(void) for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) { const HChar *arg = *(HChar**)VG_(indexXA)( VG_(args_for_client), i ); size += 1; // separator ' ' - size += VG_(strlen)(arg); + // escape NL in arguments to not break dump format + for(j=0; arg[j]; j++) + switch(arg[j]) { + case '\n': + case '\\': + size++; // fall through + default: + size++; + } } cmdbuf = CLG_MALLOC("cl.dump.ic.1", size + 1); // +1 for '\0' @@ -1520,7 +1528,19 @@ void init_cmdbuf(void) const HChar *arg = * (HChar**) VG_(indexXA)( VG_(args_for_client), i ); cmdbuf[size++] = ' '; for(j=0; arg[j]; j++) - cmdbuf[size++] = arg[j]; + switch(arg[j]) { + case '\n': + cmdbuf[size++] = '\\'; + cmdbuf[size++] = 'n'; + break; + case '\\': + cmdbuf[size++] = '\\'; + cmdbuf[size++] = '\\'; + break; + default: + cmdbuf[size++] = arg[j]; + break; + } } cmdbuf[size] = '\0'; }