diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2017-02-23 12:49:41 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2017-02-23 12:49:41 +0000 |
commit | 809532d28b35e977ffdbd428e9b7ebf115a2eea9 (patch) | |
tree | 08f66827f08a1d918005d006aadc5a3a0acbe1bc | |
parent | e257e18436359d8a0636752e25e6db0f898b468a (diff) |
[Xray] fix building the runtime with GCC.
GCC has a warning about enum bitfields that cannot be disabled. Do the
ugly thing and go through uint8_t for all the values.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@295967 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/xray/xray_fdr_logging.cc | 30 | ||||
-rw-r--r-- | lib/xray/xray_fdr_logging.h | 9 |
2 files changed, 21 insertions, 18 deletions
diff --git a/lib/xray/xray_fdr_logging.cc b/lib/xray/xray_fdr_logging.cc index e111dbfe3..44ec8fe4b 100644 --- a/lib/xray/xray_fdr_logging.cc +++ b/lib/xray/xray_fdr_logging.cc @@ -190,8 +190,8 @@ void setupNewBuffer(const BufferQueue::Buffer &Buffer) XRAY_NEVER_INSTRUMENT { // point we only write down the following bytes: // - Thread ID (pid_t, 4 bytes) auto &NewBuffer = *reinterpret_cast<MetadataRecord *>(&Records[0]); - NewBuffer.Type = RecordType::Metadata; - NewBuffer.RecordKind = MetadataRecord::RecordKinds::NewBuffer; + NewBuffer.Type = uint8_t(RecordType::Metadata); + NewBuffer.RecordKind = uint8_t(MetadataRecord::RecordKinds::NewBuffer); pid_t Tid = syscall(SYS_gettid); std::memcpy(&NewBuffer.Data, &Tid, sizeof(pid_t)); } @@ -200,8 +200,9 @@ void setupNewBuffer(const BufferQueue::Buffer &Buffer) XRAY_NEVER_INSTRUMENT { { static_assert(sizeof(time_t) <= 8, "time_t needs to be at most 8 bytes"); auto &WalltimeMarker = *reinterpret_cast<MetadataRecord *>(&Records[1]); - WalltimeMarker.Type = RecordType::Metadata; - WalltimeMarker.RecordKind = MetadataRecord::RecordKinds::WalltimeMarker; + WalltimeMarker.Type = uint8_t(RecordType::Metadata); + WalltimeMarker.RecordKind = + uint8_t(MetadataRecord::RecordKinds::WalltimeMarker); timespec TS{0, 0}; clock_gettime(CLOCK_MONOTONIC, &TS); @@ -219,8 +220,8 @@ void setupNewBuffer(const BufferQueue::Buffer &Buffer) XRAY_NEVER_INSTRUMENT { void writeNewCPUIdMetadata(uint16_t CPU, uint64_t TSC) XRAY_NEVER_INSTRUMENT { MetadataRecord NewCPUId; - NewCPUId.Type = RecordType::Metadata; - NewCPUId.RecordKind = MetadataRecord::RecordKinds::NewCPUId; + NewCPUId.Type = uint8_t(RecordType::Metadata); + NewCPUId.RecordKind = uint8_t(MetadataRecord::RecordKinds::NewCPUId); // The data for the New CPU will contain the following bytes: // - CPU ID (uint16_t, 2 bytes) @@ -234,8 +235,8 @@ void writeNewCPUIdMetadata(uint16_t CPU, uint64_t TSC) XRAY_NEVER_INSTRUMENT { void writeEOBMetadata() XRAY_NEVER_INSTRUMENT { MetadataRecord EOBMeta; - EOBMeta.Type = RecordType::Metadata; - EOBMeta.RecordKind = MetadataRecord::RecordKinds::EndOfBuffer; + EOBMeta.Type = uint8_t(RecordType::Metadata); + EOBMeta.RecordKind = uint8_t(MetadataRecord::RecordKinds::EndOfBuffer); // For now we don't write any bytes into the Data field. std::memcpy(RecordPtr, &EOBMeta, sizeof(MetadataRecord)); RecordPtr += sizeof(MetadataRecord); @@ -243,8 +244,8 @@ void writeEOBMetadata() XRAY_NEVER_INSTRUMENT { void writeTSCWrapMetadata(uint64_t TSC) XRAY_NEVER_INSTRUMENT { MetadataRecord TSCWrap; - TSCWrap.Type = RecordType::Metadata; - TSCWrap.RecordKind = MetadataRecord::RecordKinds::TSCWrap; + TSCWrap.Type = uint8_t(RecordType::Metadata); + TSCWrap.RecordKind = uint8_t(MetadataRecord::RecordKinds::TSCWrap); // The data for the TSCWrap record contains the following bytes: // - Full TSC (uint64_t, 8 bytes) @@ -447,7 +448,7 @@ void fdrLoggingHandleArg0(int32_t FuncId, AlignedFuncRecordBuffer; auto &FuncRecord = *reinterpret_cast<FunctionRecord *>(&AlignedFuncRecordBuffer); - FuncRecord.Type = RecordType::Function; + FuncRecord.Type = uint8_t(RecordType::Function); // Only get the lower 28 bits of the function id. FuncRecord.FuncId = FuncId & ~(0x0F << 28); @@ -493,13 +494,14 @@ void fdrLoggingHandleArg0(int32_t FuncId, switch (Entry) { case XRayEntryType::ENTRY: - FuncRecord.RecordKind = FunctionRecord::RecordKinds::FunctionEnter; + FuncRecord.RecordKind = uint8_t(FunctionRecord::RecordKinds::FunctionEnter); break; case XRayEntryType::EXIT: - FuncRecord.RecordKind = FunctionRecord::RecordKinds::FunctionExit; + FuncRecord.RecordKind = uint8_t(FunctionRecord::RecordKinds::FunctionExit); break; case XRayEntryType::TAIL: - FuncRecord.RecordKind = FunctionRecord::RecordKinds::FunctionTailExit; + FuncRecord.RecordKind = + uint8_t(FunctionRecord::RecordKinds::FunctionTailExit); break; } diff --git a/lib/xray/xray_fdr_logging.h b/lib/xray/xray_fdr_logging.h index cade135e3..28c829625 100644 --- a/lib/xray/xray_fdr_logging.h +++ b/lib/xray/xray_fdr_logging.h @@ -34,7 +34,7 @@ enum class RecordType : uint8_t { // additional bytes in the end to hold free-form data. struct alignas(16) MetadataRecord { // A MetadataRecord must always have a type of 1. - RecordType Type : 1; + /* RecordType */ uint8_t Type : 1; // Each kind of record is represented as a 7-bit value (even though we use an // unsigned 8-bit enum class to do so). @@ -45,7 +45,8 @@ struct alignas(16) MetadataRecord { TSCWrap, WalltimeMarker, }; - RecordKinds RecordKind : 7; // Use 7 bits to identify this record type. + // Use 7 bits to identify this record type. + /* RecordKinds */ uint8_t RecordKind : 7; char Data[15]; } __attribute__((packed)); @@ -53,13 +54,13 @@ static_assert(sizeof(MetadataRecord) == 16, "Wrong size for MetadataRecord."); struct alignas(8) FunctionRecord { // A FunctionRecord must always have a type of 0. - RecordType Type : 1; + /* RecordType */ uint8_t Type : 1; enum class RecordKinds { FunctionEnter = 0x00, FunctionExit = 0x01, FunctionTailExit = 0x02, }; - RecordKinds RecordKind : 3; + /* RecordKinds */ uint8_t RecordKind : 3; // We only use 28 bits of the function ID, so that we can use as few bytes as // possible. This means we only support 2^28 (268,435,456) unique function ids |