summaryrefslogtreecommitdiffstats
path: root/compiler-rt/include/xray
diff options
context:
space:
mode:
authorDean Michael Berris <dberris@google.com>2017-03-29 05:56:37 +0000
committerDean Michael Berris <dberris@google.com>2017-03-29 05:56:37 +0000
commit9b57ca171dd05043ddca0e3d15fb9fc1a692144f (patch)
treefa9a72d3c835a7f47fc52d03bd11dadd0c6ea773 /compiler-rt/include/xray
parent0676fb5ae65584389f7340d30d1c13148d778b6c (diff)
downloadbcm5719-llvm-9b57ca171dd05043ddca0e3d15fb9fc1a692144f.tar.gz
bcm5719-llvm-9b57ca171dd05043ddca0e3d15fb9fc1a692144f.zip
[XRay] [compiler-rt] Write buffer length to FDR log before writing buffer.
Summary: Currently the FDR log writer, upon flushing, dumps a sequence of buffers from its freelist to disk. A reader can read the first buffer up to an EOB record, but then it is unclear how far ahead to scan to find the next threads traces. There are a few ways to handle this problem. 1. The reader has externalized knowledge of the buffer size. 2. The size of buffers is in the file header or otherwise encoded in the log. 3. Only write out the portion of the buffer with records. When released, the buffers are marked with a size. 4. The reader looks for memory that matches a pattern and synchronizes on it. 2 and 3 seem the most flexible and 2 does not rule 3 out. This is an implementation of 2. In addition, the function handler for fdr more aggressively checks for finalization and makes an attempt to release its buffer. Reviewers: pelikan, dberris Reviewed By: dberris Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31384 llvm-svn: 298982
Diffstat (limited to 'compiler-rt/include/xray')
-rw-r--r--compiler-rt/include/xray/xray_records.h21
1 files changed, 17 insertions, 4 deletions
diff --git a/compiler-rt/include/xray/xray_records.h b/compiler-rt/include/xray/xray_records.h
index 71637d1fe95..feb8d228b2f 100644
--- a/compiler-rt/include/xray/xray_records.h
+++ b/compiler-rt/include/xray/xray_records.h
@@ -24,6 +24,14 @@ enum FileTypes {
FDR_LOG = 1,
};
+// FDR mode use of the union field in the XRayFileHeader.
+struct alignas(16) FdrAdditionalHeaderData {
+ uint64_t ThreadBufferSize;
+};
+
+static_assert(sizeof(FdrAdditionalHeaderData) == 16,
+ "FdrAdditionalHeaderData != 16 bytes");
+
// This data structure is used to describe the contents of the file. We use this
// for versioning the supported XRay file formats.
struct alignas(32) XRayFileHeader {
@@ -42,10 +50,15 @@ struct alignas(32) XRayFileHeader {
// The frequency by which TSC increases per-second.
alignas(8) uint64_t CycleFrequency = 0;
- // The current civiltime timestamp, as retrived from 'clock_gettime'. This
- // allows readers of the file to determine when the file was created or
- // written down.
- struct timespec TS;
+ union {
+ char FreeForm[16];
+ // The current civiltime timestamp, as retrived from 'clock_gettime'. This
+ // allows readers of the file to determine when the file was created or
+ // written down.
+ struct timespec TS;
+
+ struct FdrAdditionalHeaderData FdrData;
+ };
} __attribute__((packed));
static_assert(sizeof(XRayFileHeader) == 32, "XRayFileHeader != 32 bytes");
OpenPOWER on IntegriCloud