summaryrefslogtreecommitdiff
path: root/lib/xray/xray_inmemory_log.cc
diff options
context:
space:
mode:
authorDean Michael Berris <dberris@google.com>2016-11-16 01:01:13 +0000
committerDean Michael Berris <dberris@google.com>2016-11-16 01:01:13 +0000
commita1df33d42314dc8c52e3eb5254f0f216397e60fc (patch)
tree3170b1ed69ea95bca55af2ddfebef5da3fdf08a2 /lib/xray/xray_inmemory_log.cc
parentec301129e76d82fbdf59168f7478b343cff71294 (diff)
[XRay][compiler-rt] Disable XRay instrumentation of the XRay runtime.
Summary: Adds a CMake check for whether the compiler used to build the XRay library supports XRay-instrumentation. If the compiler we're using does support the `-fxray-instrument` flag (i.e. recently-built Clang), we define the XRAY_NEVER_INSTRUMENT macro that then makes sure that the XRay runtime functions never get XRay-instrumented. This prevents potential weirdness involved with building the XRay library with a Clang that supports XRay-instrumentation, and is attempting to XRay-instrument the build of compiler-rt. Reviewers: majnemer, rSerge, echristo Subscribers: mehdi_amini, llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D26597 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@287068 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/xray/xray_inmemory_log.cc')
-rw-r--r--lib/xray/xray_inmemory_log.cc30
1 files changed, 20 insertions, 10 deletions
diff --git a/lib/xray/xray_inmemory_log.cc b/lib/xray/xray_inmemory_log.cc
index 84958928e..17275ccf9 100644
--- a/lib/xray/xray_inmemory_log.cc
+++ b/lib/xray/xray_inmemory_log.cc
@@ -35,6 +35,7 @@ static const int64_t NanosecondsPerSecond = 1000LL * 1000 * 1000;
#include "sanitizer_common/sanitizer_libc.h"
#include "xray/xray_records.h"
+#include "xray_defs.h"
#include "xray_flags.h"
#include "xray_interface_internal.h"
@@ -43,14 +44,16 @@ static const int64_t NanosecondsPerSecond = 1000LL * 1000 * 1000;
// events. We store simple fixed-sized entries in the log for external analysis.
extern "C" {
-void __xray_InMemoryRawLog(int32_t FuncId, XRayEntryType Type);
+void __xray_InMemoryRawLog(int32_t FuncId,
+ XRayEntryType Type) XRAY_NEVER_INSTRUMENT;
}
namespace __xray {
std::mutex LogMutex;
-static void retryingWriteAll(int Fd, char *Begin, char *End) {
+static void retryingWriteAll(int Fd, char *Begin,
+ char *End) XRAY_NEVER_INSTRUMENT {
if (Begin == End)
return;
auto TotalBytes = std::distance(Begin, End);
@@ -69,8 +72,8 @@ static void retryingWriteAll(int Fd, char *Begin, char *End) {
}
#if defined(__x86_64__)
-static std::pair<ssize_t, bool> retryingReadSome(int Fd, char *Begin,
- char *End) {
+static std::pair<ssize_t, bool>
+retryingReadSome(int Fd, char *Begin, char *End) XRAY_NEVER_INSTRUMENT {
auto BytesToRead = std::distance(Begin, End);
ssize_t BytesRead;
ssize_t TotalBytesRead = 0;
@@ -89,7 +92,8 @@ static std::pair<ssize_t, bool> retryingReadSome(int Fd, char *Begin,
return std::make_pair(TotalBytesRead, true);
}
-static bool readValueFromFile(const char *Filename, long long *Value) {
+static bool readValueFromFile(const char *Filename,
+ long long *Value) XRAY_NEVER_INSTRUMENT {
int Fd = open(Filename, O_RDONLY | O_CLOEXEC);
if (Fd == -1)
return false;
@@ -119,10 +123,13 @@ class ThreadExitFlusher {
size_t &Offset;
public:
- explicit ThreadExitFlusher(int Fd, XRayRecord *Start, size_t &Offset)
- : Fd(Fd), Start(Start), Offset(Offset) {}
+ explicit ThreadExitFlusher(int Fd, XRayRecord *Start,
+ size_t &Offset) XRAY_NEVER_INSTRUMENT
+ : Fd(Fd),
+ Start(Start),
+ Offset(Offset) {}
- ~ThreadExitFlusher() {
+ ~ThreadExitFlusher() XRAY_NEVER_INSTRUMENT {
std::lock_guard<std::mutex> L(LogMutex);
if (Fd > 0 && Start != nullptr) {
retryingWriteAll(Fd, reinterpret_cast<char *>(Start),
@@ -140,9 +147,12 @@ public:
using namespace __xray;
-void PrintToStdErr(const char *Buffer) { fprintf(stderr, "%s", Buffer); }
+void PrintToStdErr(const char *Buffer) XRAY_NEVER_INSTRUMENT {
+ fprintf(stderr, "%s", Buffer);
+}
-void __xray_InMemoryRawLog(int32_t FuncId, XRayEntryType Type) {
+void __xray_InMemoryRawLog(int32_t FuncId,
+ XRayEntryType Type) XRAY_NEVER_INSTRUMENT {
using Buffer =
std::aligned_storage<sizeof(XRayRecord), alignof(XRayRecord)>::type;
static constexpr size_t BuffLen = 1024;