summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/xray/tests
diff options
context:
space:
mode:
authorKamil Rytarowski <n54@gmx.com>2018-02-15 14:17:15 +0000
committerKamil Rytarowski <n54@gmx.com>2018-02-15 14:17:15 +0000
commit4d4ed0e288bf1f3a90fba6e5b56bc25e2fe961c3 (patch)
tree38cfef3a29d3d35c7914db81f5800af7f6629cb1 /compiler-rt/lib/xray/tests
parent892ea68a825dac2938b937d54ba926d833f01b13 (diff)
downloadbcm5719-llvm-4d4ed0e288bf1f3a90fba6e5b56bc25e2fe961c3.tar.gz
bcm5719-llvm-4d4ed0e288bf1f3a90fba6e5b56bc25e2fe961c3.zip
Add Xray instrumentation support to FreeBSD
Summary: - Enabling the build. - Using assembly for the cpuid parts. - Using thr_self FreeBSD call to get the thread id Patch by: David CARLIER Reviewers: dberris, rnk, krytarowski Reviewed By: dberris, krytarowski Subscribers: emaste, stevecheckoway, nglevin, srhines, kubamracek, dberris, mgorny, krytarowski, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D43278 llvm-svn: 325240
Diffstat (limited to 'compiler-rt/lib/xray/tests')
-rw-r--r--compiler-rt/lib/xray/tests/CMakeLists.txt7
-rw-r--r--compiler-rt/lib/xray/tests/unit/fdr_logging_test.cc11
2 files changed, 11 insertions, 7 deletions
diff --git a/compiler-rt/lib/xray/tests/CMakeLists.txt b/compiler-rt/lib/xray/tests/CMakeLists.txt
index e54e63f2789..b5c7d8fa7e5 100644
--- a/compiler-rt/lib/xray/tests/CMakeLists.txt
+++ b/compiler-rt/lib/xray/tests/CMakeLists.txt
@@ -15,6 +15,10 @@ set(XRAY_TEST_ARCH ${XRAY_SUPPORTED_ARCH})
macro(add_xray_unittest testname)
cmake_parse_arguments(TEST "" "" "SOURCES;HEADERS" ${ARGN})
if(UNIX AND NOT APPLE)
+ set(CMAKE_DL_LIBS_INIT "")
+ foreach(lib ${CMAKE_DL_LIBS})
+ list(APPEND CMAKE_DL_LIBS_INIT -l${lib})
+ endforeach()
foreach(arch ${XRAY_TEST_ARCH})
set(TEST_OBJECTS)
generate_compiler_rt_tests(TEST_OBJECTS
@@ -25,8 +29,7 @@ macro(add_xray_unittest testname)
LINK_FLAGS -fxray-instrument
${TARGET_LINK_FLAGS}
-lstdc++ -lm ${CMAKE_THREAD_LIBS_INIT}
- -lpthread
- -ldl -lrt)
+ ${CMAKE_DL_LIBS_INIT} -lrt)
set_target_properties(XRayUnitTests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endforeach()
endif()
diff --git a/compiler-rt/lib/xray/tests/unit/fdr_logging_test.cc b/compiler-rt/lib/xray/tests/unit/fdr_logging_test.cc
index 76738ea4dff..98802e0a107 100644
--- a/compiler-rt/lib/xray/tests/unit/fdr_logging_test.cc
+++ b/compiler-rt/lib/xray/tests/unit/fdr_logging_test.cc
@@ -10,6 +10,7 @@
// This file is a part of XRay, a function call tracing system.
//
//===----------------------------------------------------------------------===//
+#include "sanitizer_common/sanitizer_common.h"
#include "xray_fdr_logging.h"
#include "gtest/gtest.h"
@@ -154,12 +155,12 @@ TEST(FDRLoggingTest, MultiThreadedCycling) {
// Now we want to create one thread, do some logging, then create another one,
// in succession and making sure that we're able to get thread records from
// the latest thread (effectively being able to recycle buffers).
- std::array<pid_t, 2> Threads;
+ std::array<tid_t, 2> Threads;
for (uint64_t I = 0; I < 2; ++I) {
std::thread t{[I, &Threads] {
fdrLoggingHandleArg0(I + 1, XRayEntryType::ENTRY);
fdrLoggingHandleArg0(I + 1, XRayEntryType::EXIT);
- Threads[I] = syscall(SYS_gettid);
+ Threads[I] = __sanitizer::GetTid();
}};
t.join();
}
@@ -192,9 +193,9 @@ TEST(FDRLoggingTest, MultiThreadedCycling) {
ASSERT_EQ(MDR0.RecordKind,
uint8_t(MetadataRecord::RecordKinds::BufferExtents));
ASSERT_EQ(MDR1.RecordKind, uint8_t(MetadataRecord::RecordKinds::NewBuffer));
- pid_t Latest = 0;
- memcpy(&Latest, MDR1.Data, sizeof(pid_t));
- ASSERT_EQ(Latest, Threads[1]);
+ int32_t Latest = 0;
+ memcpy(&Latest, MDR1.Data, sizeof(int32_t));
+ ASSERT_EQ(Latest, static_cast<int32_t>(Threads[1]));
}
} // namespace
OpenPOWER on IntegriCloud