diff options
| author | Martin Pelikan <martin.pelikan@gmail.com> | 2017-10-04 05:12:00 +0000 |
|---|---|---|
| committer | Martin Pelikan <martin.pelikan@gmail.com> | 2017-10-04 05:12:00 +0000 |
| commit | 68ea360ed1cd30baa0d11737f7223d2e429262bd (patch) | |
| tree | 75da9ff29b14a927bb55c0e9a74e0c0884d24d27 /compiler-rt/lib/xray | |
| parent | f31b1f310c7c9d90adbad35dd17732c6683d1c27 (diff) | |
| download | bcm5719-llvm-68ea360ed1cd30baa0d11737f7223d2e429262bd.tar.gz bcm5719-llvm-68ea360ed1cd30baa0d11737f7223d2e429262bd.zip | |
[XRay] [compiler-rt] make sure single threaded programs get traced too
Summary:
When the XRay user calls the API to finish writing the log, the thread
which is calling the API still hasn't finished and therefore won't get
its trace written. Add a test for only the main thread to check this.
Reviewers: dberris
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D38493
llvm-svn: 314875
Diffstat (limited to 'compiler-rt/lib/xray')
| -rw-r--r-- | compiler-rt/lib/xray/xray_fdr_logging.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler-rt/lib/xray/xray_fdr_logging.cc b/compiler-rt/lib/xray/xray_fdr_logging.cc index 7aebcb22466..bd79893f618 100644 --- a/compiler-rt/lib/xray/xray_fdr_logging.cc +++ b/compiler-rt/lib/xray/xray_fdr_logging.cc @@ -116,6 +116,16 @@ XRayLogFlushStatus fdrLoggingFlush() XRAY_NEVER_INSTRUMENT { reinterpret_cast<char *>(B.Buffer) + B.Size); } }); + + // The buffer for this particular thread would have been finalised after + // we've written everything to disk, and we'd lose the thread's trace. + auto &TLD = __xray::__xray_fdr_internal::getThreadLocalData(); + if (TLD.Buffer.Buffer != nullptr) { + __xray::__xray_fdr_internal::writeEOBMetadata(); + auto Start = reinterpret_cast<char *>(TLD.Buffer.Buffer); + retryingWriteAll(Fd, Start, Start + TLD.Buffer.Size); + } + __sanitizer::atomic_store(&LogFlushStatus, XRayLogFlushStatus::XRAY_LOG_FLUSHED, __sanitizer::memory_order_release); |

