diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2014-05-29 14:02:06 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2014-05-29 14:02:06 +0000 |
commit | 8113ec81a6732cf42863fb4406dc983fb05ac7b9 (patch) | |
tree | 38699547b8ae2d8843490fcbe6a9e321cf29cedb | |
parent | ef0f7ccc94812900a1426fb04979a7779b75db45 (diff) | |
download | compiler-rt-8113ec81a6732cf42863fb4406dc983fb05ac7b9.tar.gz |
tsan: allow to write memory profile to stdout/stderr
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@209811 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/tsan/rtl/tsan_rtl.cc | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/tsan/rtl/tsan_rtl.cc b/lib/tsan/rtl/tsan_rtl.cc index b4c564f5d..c494bf338 100644 --- a/lib/tsan/rtl/tsan_rtl.cc +++ b/lib/tsan/rtl/tsan_rtl.cc @@ -131,16 +131,21 @@ static void BackgroundThread(void *arg) { fd_t mprof_fd = kInvalidFd; if (flags()->profile_memory && flags()->profile_memory[0]) { - // FIXME(dvyukov): support stdout/stderr - InternalScopedBuffer<char> filename(4096); - internal_snprintf(filename.data(), filename.size(), "%s.%d", - flags()->profile_memory, (int)internal_getpid()); - uptr openrv = OpenFile(filename.data(), true); - if (internal_iserror(openrv)) { - Printf("ThreadSanitizer: failed to open memory profile file '%s'\n", - &filename[0]); + if (internal_strcmp(flags()->profile_memory, "stdout") == 0) { + mprof_fd = 1; + } else if (internal_strcmp(flags()->profile_memory, "stderr") == 0) { + mprof_fd = 2; } else { - mprof_fd = openrv; + InternalScopedBuffer<char> filename(4096); + internal_snprintf(filename.data(), filename.size(), "%s.%d", + flags()->profile_memory, (int)internal_getpid()); + uptr openrv = OpenFile(filename.data(), true); + if (internal_iserror(openrv)) { + Printf("ThreadSanitizer: failed to open memory profile file '%s'\n", + &filename[0]); + } else { + mprof_fd = openrv; + } } } |