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
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.
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'
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';
}