[compiler-rt] r299042 - [XRay][compiler-rt] Use llvm-xray in FDR mode tests

Dean Michael Berris via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 29 17:35:58 PDT 2017


Author: dberris
Date: Wed Mar 29 19:35:58 2017
New Revision: 299042

URL: http://llvm.org/viewvc/llvm-project?rev=299042&view=rev
Log:
[XRay][compiler-rt] Use llvm-xray in FDR mode tests

Summary:
This change allows us to do an end-to-end test of the FDR mode
implementation that uses the llvm-xray tooling to verify that what we
are both writing and reading the data in a consistent manner.

Reviewers: kpw, pelikan

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D31454

Added:
    compiler-rt/trunk/test/xray/TestCases/Linux/fdr-thread-order.cc
Modified:
    compiler-rt/trunk/test/xray/TestCases/Linux/fdr-mode.cc

Modified: compiler-rt/trunk/test/xray/TestCases/Linux/fdr-mode.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/xray/TestCases/Linux/fdr-mode.cc?rev=299042&r1=299041&r2=299042&view=diff
==============================================================================
--- compiler-rt/trunk/test/xray/TestCases/Linux/fdr-mode.cc (original)
+++ compiler-rt/trunk/test/xray/TestCases/Linux/fdr-mode.cc Wed Mar 29 19:35:58 2017
@@ -1,6 +1,6 @@
-// RUN: %clangxx_xray -std=c++11 %s -o %t
+// RUN: %clangxx_xray -g -std=c++11 %s -o %t
 // RUN: XRAY_OPTIONS="patch_premain=false xray_naive_log=false xray_logfile_base=fdr-logging-test- xray_fdr_log=true verbosity=1" %run %t 2>&1 | FileCheck %s
-// FIXME: %llvm_xray convert -instr_map=%t "`ls fdr-logging-test-* | head -1`" | FileCheck %s --check-prefix TRACE
+// RUN: %llvm_xray convert --symbolize --output-format=yaml -instr_map=%t "`ls fdr-logging-test-* | head -1`" | FileCheck %s --check-prefix TRACE
 // RUN: rm fdr-logging-test-*
 
 #include "xray/xray_log_interface.h"
@@ -59,4 +59,22 @@ int main(int argc, char *argv[]) {
   return 0;
 }
 
-// TRACE: { function }
+
+
+// Check that we're able to see two threads, each entering and exiting fA().
+// TRACE-DAG: - { type: 0, func-id: [[FIDA:[0-9]+]], function: {{.*fA.*}}, cpu: {{.*}}, thread: [[THREAD1:[0-9]+]], kind: function-enter, tsc: {{[0-9]+}} }
+// TRACE:     - { type: 0, func-id: [[FIDA]], function: {{.*fA.*}}, cpu: {{.*}}, thread: [[THREAD1]], kind: function-exit, tsc: {{[0-9]+}} }
+// TRACE-DAG: - { type: 0, func-id: [[FIDA]], function: {{.*fA.*}}, cpu: {{.*}}, thread: [[THREAD2:[0-9]+]], kind: function-enter, tsc: {{[0-9]+}} }
+// TRACE:     - { type: 0, func-id: [[FIDA]], function: {{.*fA.*}}, cpu: {{.*}}, thread: [[THREAD2]], kind: function-exit, tsc: {{[0-9]+}} }
+//
+// Do the same as above for fC()
+// TRACE-DAG: - { type: 0, func-id: [[FIDC:[0-9]+]], function: {{.*fC.*}}, cpu: {{.*}}, thread: [[THREAD1:[0-9]+]], kind: function-enter, tsc: {{[0-9]+}} }
+// TRACE:     - { type: 0, func-id: [[FIDC]], function: {{.*fC.*}}, cpu: {{.*}}, thread: [[THREAD1]], kind: function-exit, tsc: {{[0-9]+}} }
+// TRACE-DAG: - { type: 0, func-id: [[FIDC]], function: {{.*fC.*}}, cpu: {{.*}}, thread: [[THREAD2:[0-9]+]], kind: function-enter, tsc: {{[0-9]+}} }
+// TRACE:     - { type: 0, func-id: [[FIDC]], function: {{.*fC.*}}, cpu: {{.*}}, thread: [[THREAD2]], kind: function-exit, tsc: {{[0-9]+}} }
+
+// Do the same as above for fB()
+// TRACE-DAG: - { type: 0, func-id: [[FIDB:[0-9]+]], function: {{.*fB.*}}, cpu: {{.*}}, thread: [[THREAD1:[0-9]+]], kind: function-enter, tsc: {{[0-9]+}} }
+// TRACE:     - { type: 0, func-id: [[FIDB]], function: {{.*fB.*}}, cpu: {{.*}}, thread: [[THREAD1]], kind: function-exit, tsc: {{[0-9]+}} }
+// TRACE-DAG: - { type: 0, func-id: [[FIDB]], function: {{.*fB.*}}, cpu: {{.*}}, thread: [[THREAD2:[0-9]+]], kind: function-enter, tsc: {{[0-9]+}} }
+// TRACE:     - { type: 0, func-id: [[FIDB]], function: {{.*fB.*}}, cpu: {{.*}}, thread: [[THREAD2]], kind: function-exit, tsc: {{[0-9]+}} }

Added: compiler-rt/trunk/test/xray/TestCases/Linux/fdr-thread-order.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/xray/TestCases/Linux/fdr-thread-order.cc?rev=299042&view=auto
==============================================================================
--- compiler-rt/trunk/test/xray/TestCases/Linux/fdr-thread-order.cc (added)
+++ compiler-rt/trunk/test/xray/TestCases/Linux/fdr-thread-order.cc Wed Mar 29 19:35:58 2017
@@ -0,0 +1,36 @@
+// RUN: %clangxx_xray -g -std=c++11 %s -o %t
+// RUN: XRAY_OPTIONS="patch_premain=false xray_naive_log=false xray_logfile_base=fdr-thread-order. xray_fdr_log=true verbosity=1" %run %t 2>&1 | FileCheck %s
+// RUN: %llvm_xray convert --symbolize --output-format=yaml -instr_map=%t "`ls fdr-thread-order.* | head -1`" | FileCheck %s --check-prefix TRACE
+// RUN: rm fdr-thread-order.*
+#include "xray/xray_log_interface.h"
+#include <thread>
+#include <cassert>
+
+constexpr auto kBufferSize = 16384;
+constexpr auto kBufferMax = 10;
+
+thread_local uint64_t var = 0;
+[[clang::xray_always_instrument]] void __attribute__((noinline)) f1() { ++var; }
+[[clang::xray_always_instrument]] void __attribute__((noinline)) f2() { ++var; }
+
+int main(int argc, char *argv[]) {
+  using namespace __xray;
+  FDRLoggingOptions Options;
+  assert(__xray_log_init(kBufferSize, kBufferMax, &Options,
+                         sizeof(FDRLoggingOptions)) ==
+         XRayLogInitStatus::XRAY_LOG_INITIALIZED);
+  __xray_patch();
+  std::thread t1([] { f1(); });
+  std::thread t2([] { f2(); });
+  t1.join();
+  t2.join();
+  __xray_log_finalize();
+  __xray_log_flushLog();
+  // CHECK: =={{[0-9]+}}==XRay: Log file in '{{.*}}'
+}
+
+// We want to make sure that the order of the function log doesn't matter.
+// TRACE-DAG: - { type: 0, func-id: [[FID1:[0-9]+]], function: {{.*f1.*}}, cpu: {{.*}}, thread: [[THREAD1:[0-9]+]], kind: function-enter, tsc: {{[0-9]+}} }
+// TRACE-DAG: - { type: 0, func-id: [[FID2:[0-9]+]], function: {{.*f2.*}}, cpu: {{.*}}, thread: [[THREAD2:[0-9]+]], kind: function-enter, tsc: {{[0-9]+}} }
+// TRACE-DAG: - { type: 0, func-id: [[FID1]], function: {{.*f1.*}}, cpu: {{.*}}, thread: [[THREAD1]], kind: function-exit, tsc: {{[0-9]+}} }
+// TRACE-DAG: - { type: 0, func-id: [[FID2]], function: {{.*f2.*}}, cpu: {{.*}}, thread: [[THREAD2]], kind: function-exit, tsc: {{[0-9]+}} }




More information about the llvm-commits mailing list