Index: lib/xray/tests/CMakeLists.txt =================================================================== --- lib/xray/tests/CMakeLists.txt +++ lib/xray/tests/CMakeLists.txt @@ -42,7 +42,7 @@ list(APPEND TEST_DEPS gtest_main xray) endif() if(NOT APPLE) - add_compiler_rt_test(XRayUnitTests ${testname}-${arch} + add_compiler_rt_test(XRayUnitTests "${testname}-${arch}-Test" OBJECTS ${TEST_OBJECTS} DEPS ${TEST_DEPS} LINK_FLAGS ${TARGET_LINK_FLAGS} Index: lib/xray/tests/unit/buffer_queue_test.cc =================================================================== --- lib/xray/tests/unit/buffer_queue_test.cc +++ lib/xray/tests/unit/buffer_queue_test.cc @@ -68,9 +68,9 @@ ASSERT_NE(nullptr, Buf.Buffer); ASSERT_EQ(Buffers.finalize(), BufferQueue::ErrorCode::Ok); BufferQueue::Buffer OtherBuf; - ASSERT_EQ(BufferQueue::ErrorCode::AlreadyFinalized, + ASSERT_EQ(BufferQueue::ErrorCode::QueueFinalizing, Buffers.getBuffer(OtherBuf)); - ASSERT_EQ(BufferQueue::ErrorCode::AlreadyFinalized, + ASSERT_EQ(BufferQueue::ErrorCode::QueueFinalizing, Buffers.finalize()); ASSERT_EQ(Buffers.releaseBuffer(Buf), BufferQueue::ErrorCode::Ok); } Index: lib/xray/tests/unit/fdr_logging_test.cc =================================================================== --- lib/xray/tests/unit/fdr_logging_test.cc +++ lib/xray/tests/unit/fdr_logging_test.cc @@ -57,7 +57,6 @@ fdrLoggingHandleArg0(1, XRayEntryType::EXIT); ASSERT_EQ(fdrLoggingFinalize(), XRayLogInitStatus::XRAY_LOG_FINALIZED); ASSERT_EQ(fdrLoggingFlush(), XRayLogFlushStatus::XRAY_LOG_FLUSHED); - ASSERT_EQ(fdrLoggingReset(), XRayLogInitStatus::XRAY_LOG_UNINITIALIZED); // To do this properly, we have to close the file descriptor then re-open the // file for reading this time. @@ -98,7 +97,6 @@ } ASSERT_EQ(fdrLoggingFinalize(), XRayLogInitStatus::XRAY_LOG_FINALIZED); ASSERT_EQ(fdrLoggingFlush(), XRayLogFlushStatus::XRAY_LOG_FLUSHED); - ASSERT_EQ(fdrLoggingReset(), XRayLogInitStatus::XRAY_LOG_UNINITIALIZED); // To do this properly, we have to close the file descriptor then re-open the // file for reading this time. Index: lib/xray/xray_buffer_queue.h =================================================================== --- lib/xray/xray_buffer_queue.h +++ lib/xray/xray_buffer_queue.h @@ -82,15 +82,18 @@ /// - BufferQueue is not finalising. /// /// Returns: - /// - std::errc::not_enough_memory on exceeding MaxSize. - /// - no error when we find a Buffer. - /// - std::errc::state_not_recoverable on finalising BufferQueue. + /// - ErrorCode::NotEnoughMemory on exceeding MaxSize. + /// - ErrorCode::Ok when we find a Buffer. + /// - ErrorCode::QueueFinalizing or ErrorCode::AlreadyFinalized on + /// a finalizing/finalized BufferQueue. ErrorCode getBuffer(Buffer &Buf); /// Updates |Buf| to point to nullptr, with size 0. /// /// Returns: - /// - ... + /// - ErrorCode::Ok when we successfully release the buffer. + /// - ErrorCode::UnrecognizedBuffer for when this BufferQueue does not own + /// the buffer being released. ErrorCode releaseBuffer(Buffer &Buf); bool finalizing() const { @@ -107,12 +110,12 @@ /// - All releaseBuffer operations will not fail. /// /// After a call to finalize succeeds, all subsequent calls to finalize will - /// fail with std::errc::state_not_recoverable. + /// fail with ErrorCode::QueueFinalizing. ErrorCode finalize(); /// Applies the provided function F to each Buffer in the queue, only if the /// Buffer is marked 'used' (i.e. has been the result of getBuffer(...) and a - /// releaseBuffer(...) operation. + /// releaseBuffer(...) operation). template void apply(F Fn) { __sanitizer::BlockingMutexLock G(&Mutex); for (const auto &T : Buffers) { Index: lib/xray/xray_init.cc =================================================================== --- lib/xray/xray_init.cc +++ lib/xray/xray_init.cc @@ -49,7 +49,8 @@ void __xray_init() XRAY_NEVER_INSTRUMENT { initializeFlags(); if (__start_xray_instr_map == nullptr) { - Report("XRay instrumentation map missing. Not initializing XRay.\n"); + if (common_flags()->verbosity) + Report("XRay instrumentation map missing. Not initializing XRay.\n"); return; } Index: test/xray/TestCases/Linux/quiet-start.cc =================================================================== --- /dev/null +++ test/xray/TestCases/Linux/quiet-start.cc @@ -0,0 +1,19 @@ +// Ensure that we have a quiet startup when we don't have the XRay +// instrumentation sleds. +// +// RUN: %clangxx -std=c++11 %s -o %t %xraylib +// RUN: XRAY_OPTIONS="patch_premain=true verbosity=1" %run %t 2>&1 | \ +// RUN: FileCheck %s --check-prefix NOISY +// RUN: XRAY_OPTIONS="patch_premain=true verbosity=0" %run %t 2>&1 | \ +// RUN: FileCheck %s --check-prefix QUIET +#include + +using namespace std; + +int main(int, char**) { + // NOISY: {{.*}}XRay instrumentation map missing. Not initializing XRay. + // QUIET-NOT: {{.*}}XRay instrumentation map missing. Not initializing XRay. + cout << "Hello, XRay!" << endl; + // NOISY-NEXT: Hello, XRay! + // QUIET: Hello, XRay! +} Index: test/xray/Unit/lit.site.cfg.in =================================================================== --- test/xray/Unit/lit.site.cfg.in +++ test/xray/Unit/lit.site.cfg.in @@ -13,4 +13,4 @@ # Do not patch the XRay unit tests pre-main, and also make the error logging # verbose to get a more accurate error logging mechanism. -config.environment['XRAY_OPTIONS'] = 'patch_premain=false verbose=1' +config.environment['XRAY_OPTIONS'] = 'patch_premain=false' Index: test/xray/lit.cfg =================================================================== --- test/xray/lit.cfg +++ test/xray/lit.cfg @@ -31,6 +31,11 @@ ('%clangxx_xray', build_invocation(clang_xray_cxxflags))) config.substitutions.append( ('%llvm_xray', llvm_xray)) +config.substitutions.append( + ('%xraylib', + ('-lm -lpthread -ldl -lrt -L%s ' + '-Wl,-whole-archive -lclang_rt.xray-%s -Wl,-no-whole-archive') + % (config.compiler_rt_libdir, config.host_arch))) # Default test suffixes. config.suffixes = ['.c', '.cc', '.cpp'] Index: test/xray/lit.site.cfg.in =================================================================== --- test/xray/lit.site.cfg.in +++ test/xray/lit.site.cfg.in @@ -17,4 +17,4 @@ lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") # Load tool-specific config that would do the real work. -lit_config.load_config(config, "@XRAY_LIT_SOURCE_DIR@/lit.cfg") +lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg")