summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/xray/xray_fdr_logging_impl.h
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/xray_fdr_logging_impl.h
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/xray_fdr_logging_impl.h')
-rw-r--r--compiler-rt/lib/xray/xray_fdr_logging_impl.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/compiler-rt/lib/xray/xray_fdr_logging_impl.h b/compiler-rt/lib/xray/xray_fdr_logging_impl.h
index d1cbda96288..ed0b5ca9022 100644
--- a/compiler-rt/lib/xray/xray_fdr_logging_impl.h
+++ b/compiler-rt/lib/xray/xray_fdr_logging_impl.h
@@ -54,7 +54,7 @@ namespace __xray_fdr_internal {
/// Writes the new buffer record and wallclock time that begin a buffer for the
/// current thread.
-static void writeNewBufferPreamble(pid_t Tid, timespec TS);
+static void writeNewBufferPreamble(tid_t Tid, timespec TS);
/// Writes a Function Record to the buffer associated with the current thread.
static void writeFunctionRecord(int FuncId, uint32_t TSCDelta,
@@ -185,7 +185,7 @@ public:
} // namespace
-static void writeNewBufferPreamble(pid_t Tid,
+static void writeNewBufferPreamble(tid_t Tid,
timespec TS) XRAY_NEVER_INSTRUMENT {
static constexpr int InitRecordsCount = 2;
auto &TLD = getThreadLocalData();
@@ -195,11 +195,12 @@ static void writeNewBufferPreamble(pid_t Tid,
// buffer, associated with a particular thread, with a new CPU. For the
// data, we have 15 bytes to squeeze as much information as we can. At this
// point we only write down the following bytes:
- // - Thread ID (pid_t, 4 bytes)
+ // - Thread ID (tid_t, cast to 4 bytes type due to Darwin being 8 bytes)
auto &NewBuffer = Metadata[0];
NewBuffer.Type = uint8_t(RecordType::Metadata);
NewBuffer.RecordKind = uint8_t(MetadataRecord::RecordKinds::NewBuffer);
- std::memcpy(&NewBuffer.Data, &Tid, sizeof(pid_t));
+ int32_t tid = static_cast<int32_t>(Tid);
+ std::memcpy(&NewBuffer.Data, &tid, sizeof(tid));
}
// Also write the WalltimeMarker record.
@@ -236,7 +237,7 @@ inline void setupNewBuffer(int (*wall_clock_reader)(
auto &TLD = getThreadLocalData();
auto &B = TLD.Buffer;
TLD.RecordPtr = static_cast<char *>(B.Data);
- pid_t Tid = syscall(SYS_gettid);
+ tid_t Tid = __sanitizer::GetTid();
timespec TS{0, 0};
// This is typically clock_gettime, but callers have injection ability.
wall_clock_reader(CLOCK_MONOTONIC, &TS);
OpenPOWER on IntegriCloud