diff options
| author | Dean Michael Berris <dberris@google.com> | 2017-10-17 10:33:24 +0000 |
|---|---|---|
| committer | Dean Michael Berris <dberris@google.com> | 2017-10-17 10:33:24 +0000 |
| commit | 1d2f9e2bdd243e1f9ad1efe1e9053fcca0ed054c (patch) | |
| tree | afc74448e9fccd898d21ef3909589d1f2a3d018d /compiler-rt/lib/xray/xray_fdr_logging_impl.h | |
| parent | d17f12a35d8dab9399f22630fe6c9297f0841963 (diff) | |
| download | bcm5719-llvm-1d2f9e2bdd243e1f9ad1efe1e9053fcca0ed054c.tar.gz bcm5719-llvm-1d2f9e2bdd243e1f9ad1efe1e9053fcca0ed054c.zip | |
[XRay][compiler-rt] Always place the CPU record first for every buffer
Summary:
In FDR Mode, when we set up a new buffer for a thread that's just
overflowed, we must place the CPU identifier with the TSC record as the
first record. This is so that we can reconstruct all the function
entry/exit with deltas rooted on a TSC record for the CPU at the
beginning of the buffer.
Without doing this, the tools are rejecting the log for cases when we've
overflown and have different buffers that don't have the CPU and TSC
records as the first entry in the buffers.
Reviewers: pelikan
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D38995
llvm-svn: 315987
Diffstat (limited to 'compiler-rt/lib/xray/xray_fdr_logging_impl.h')
| -rw-r--r-- | compiler-rt/lib/xray/xray_fdr_logging_impl.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/compiler-rt/lib/xray/xray_fdr_logging_impl.h b/compiler-rt/lib/xray/xray_fdr_logging_impl.h index aec205e8a34..f7c77c6c2e4 100644 --- a/compiler-rt/lib/xray/xray_fdr_logging_impl.h +++ b/compiler-rt/lib/xray/xray_fdr_logging_impl.h @@ -532,7 +532,8 @@ inline bool releaseThreadLocalBuffer(BufferQueue &BQArg) { return true; } -inline bool prepareBuffer(int (*wall_clock_reader)(clockid_t, +inline bool prepareBuffer(uint64_t TSC, unsigned char CPU, + int (*wall_clock_reader)(clockid_t, struct timespec *), size_t MaxSize) XRAY_NEVER_INSTRUMENT { auto &TLD = getThreadLocalData(); @@ -549,6 +550,9 @@ inline bool prepareBuffer(int (*wall_clock_reader)(clockid_t, return false; } setupNewBuffer(wall_clock_reader); + + // Always write the CPU metadata as the first record in the buffer. + writeNewCPUIdMetadata(CPU, TSC); } return true; } @@ -599,6 +603,9 @@ inline bool isLogInitializedAndReady( } setupNewBuffer(wall_clock_reader); + + // Always write the CPU metadata as the first record in the buffer. + writeNewCPUIdMetadata(CPU, TSC); } if (TLD.CurrentCPU == std::numeric_limits<uint16_t>::max()) { @@ -728,7 +735,7 @@ inline void processFunctionHook( // bytes in the end of the buffer, we need to write out the EOB, get a new // Buffer, set it up properly before doing any further writing. size_t MaxSize = FunctionRecSize + 2 * MetadataRecSize; - if (!prepareBuffer(wall_clock_reader, MaxSize)) { + if (!prepareBuffer(TSC, CPU, wall_clock_reader, MaxSize)) { TLD.LocalBQ = nullptr; return; } |

