summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/xray/tests/unit/buffer_queue_test.cc
diff options
context:
space:
mode:
authorDean Michael Berris <dberris@google.com>2017-01-25 03:50:46 +0000
committerDean Michael Berris <dberris@google.com>2017-01-25 03:50:46 +0000
commite7dbebf182b92b49883649b7ca3408892273598b (patch)
treef1691fbb54f9f0982ab0358bc46ca3c4096d39ff /compiler-rt/lib/xray/tests/unit/buffer_queue_test.cc
parentbc6aaea3364729cbd29a114e9e1f62ebe34defe3 (diff)
downloadbcm5719-llvm-e7dbebf182b92b49883649b7ca3408892273598b.tar.gz
bcm5719-llvm-e7dbebf182b92b49883649b7ca3408892273598b.zip
[XRay][compiler-rt] XRay Flight Data Recorder Mode
Summary: In this change we introduce the notion of a "flight data recorder" mode for XRay logging, where XRay logs in-memory first, and write out data on-demand as required (as opposed to the naive implementation that keeps logging while tracing is "on"). This depends on D26232 where we implement the core data structure for holding the buffers that threads will be using to write out records of operation. This implementation only currently works on x86_64 and depends heavily on the TSC math to write out smaller records to the inmemory buffers. Also, this implementation defines two different kinds of records with different sizes (compared to the current naive implementation): a MetadataRecord (16 bytes) and a FunctionRecord (8 bytes). MetadataRecord entries are meant to write out information like the thread ID for which the metadata record is defined for, whether the execution of a thread moved to a different CPU, etc. while a FunctionRecord represents the different kinds of function call entry/exit records we might encounter in the course of a thread's execution along with a delta from the last time the logging handler was called. While this implementation is not exactly what is described in the original XRay whitepaper, this one gives us an initial implementation that we can iterate and build upon. Reviewers: echristo, rSerge, majnemer Subscribers: mehdi_amini, llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D27038 llvm-svn: 293015
Diffstat (limited to 'compiler-rt/lib/xray/tests/unit/buffer_queue_test.cc')
-rw-r--r--compiler-rt/lib/xray/tests/unit/buffer_queue_test.cc40
1 files changed, 34 insertions, 6 deletions
diff --git a/compiler-rt/lib/xray/tests/unit/buffer_queue_test.cc b/compiler-rt/lib/xray/tests/unit/buffer_queue_test.cc
index d46f19402c2..de855fd8519 100644
--- a/compiler-rt/lib/xray/tests/unit/buffer_queue_test.cc
+++ b/compiler-rt/lib/xray/tests/unit/buffer_queue_test.cc
@@ -21,10 +21,16 @@ namespace __xray {
static constexpr size_t kSize = 4096;
-TEST(BufferQueueTest, API) { BufferQueue Buffers(kSize, 1); }
+TEST(BufferQueueTest, API) {
+ bool Success = false;
+ BufferQueue Buffers(kSize, 1, Success);
+ ASSERT_TRUE(Success);
+}
TEST(BufferQueueTest, GetAndRelease) {
- BufferQueue Buffers(kSize, 1);
+ bool Success = false;
+ BufferQueue Buffers(kSize, 1, Success);
+ ASSERT_TRUE(Success);
BufferQueue::Buffer Buf;
ASSERT_EQ(Buffers.getBuffer(Buf), std::error_code());
ASSERT_NE(nullptr, Buf.Buffer);
@@ -33,7 +39,9 @@ TEST(BufferQueueTest, GetAndRelease) {
}
TEST(BufferQueueTest, GetUntilFailed) {
- BufferQueue Buffers(kSize, 1);
+ bool Success = false;
+ BufferQueue Buffers(kSize, 1, Success);
+ ASSERT_TRUE(Success);
BufferQueue::Buffer Buf0;
EXPECT_EQ(Buffers.getBuffer(Buf0), std::error_code());
BufferQueue::Buffer Buf1;
@@ -42,7 +50,9 @@ TEST(BufferQueueTest, GetUntilFailed) {
}
TEST(BufferQueueTest, ReleaseUnknown) {
- BufferQueue Buffers(kSize, 1);
+ bool Success = false;
+ BufferQueue Buffers(kSize, 1, Success);
+ ASSERT_TRUE(Success);
BufferQueue::Buffer Buf;
Buf.Buffer = reinterpret_cast<void *>(0xdeadbeef);
Buf.Size = kSize;
@@ -50,7 +60,9 @@ TEST(BufferQueueTest, ReleaseUnknown) {
}
TEST(BufferQueueTest, ErrorsWhenFinalising) {
- BufferQueue Buffers(kSize, 2);
+ bool Success = false;
+ BufferQueue Buffers(kSize, 2, Success);
+ ASSERT_TRUE(Success);
BufferQueue::Buffer Buf;
ASSERT_EQ(Buffers.getBuffer(Buf), std::error_code());
ASSERT_NE(nullptr, Buf.Buffer);
@@ -62,7 +74,9 @@ TEST(BufferQueueTest, ErrorsWhenFinalising) {
}
TEST(BufferQueueTest, MultiThreaded) {
- BufferQueue Buffers(kSize, 100);
+ bool Success = false;
+ BufferQueue Buffers(kSize, 100, Success);
+ ASSERT_TRUE(Success);
auto F = [&] {
BufferQueue::Buffer B;
while (!Buffers.getBuffer(B)) {
@@ -78,4 +92,18 @@ TEST(BufferQueueTest, MultiThreaded) {
F();
}
+TEST(BufferQueueTest, Apply) {
+ bool Success = false;
+ BufferQueue Buffers(kSize, 10, Success);
+ ASSERT_TRUE(Success);
+ auto Count = 0;
+ BufferQueue::Buffer B;
+ for (int I = 0; I < 10; ++I) {
+ ASSERT_FALSE(Buffers.getBuffer(B));
+ ASSERT_FALSE(Buffers.releaseBuffer(B));
+ }
+ Buffers.apply([&](const BufferQueue::Buffer &B) { ++Count; });
+ ASSERT_EQ(Count, 10);
+}
+
} // namespace __xray
OpenPOWER on IntegriCloud