1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

[XRay] Use correct type for PID records

Previously we've been reading and writing the wrong types which only
worked in little endian implementations. This time we're writing the
same typed values the runtime is using, and reading them appropriately
as well.

llvm-svn: 341241
This commit is contained in:
Dean Michael Berris 2018-08-31 19:32:46 +00:00
parent 60046ba5b9
commit 5bd013d85b
3 changed files with 17 additions and 18 deletions

View File

@ -185,16 +185,16 @@ public:
};
class PIDRecord : public MetadataRecord {
uint64_t PID = 0;
int32_t PID = 0;
friend class RecordInitializer;
public:
PIDRecord() = default;
explicit PIDRecord(uint64_t P) : MetadataRecord(), PID(P) {}
explicit PIDRecord(int32_t P) : MetadataRecord(), PID(P) {}
MetadataType metadataType() const override { return MetadataType::PIDEntry; }
uint64_t pid() const { return PID; }
int32_t pid() const { return PID; }
Error apply(RecordVisitor &V) override;
};

View File

@ -396,7 +396,7 @@ Error processFDRPidRecord(FDRState &State, DataExtractor &RecordExtractor,
fdrStateToTwine(State.Expects),
std::make_error_code(std::errc::executable_format_error));
auto PreReadOffset = OffsetPtr;
State.ProcessId = RecordExtractor.getU32(&OffsetPtr);
State.ProcessId = RecordExtractor.getSigned(&OffsetPtr, 4);
if (OffsetPtr == PreReadOffset)
return createStringError(
std::make_error_code(std::errc::executable_format_error),

View File

@ -63,15 +63,15 @@ TEST(FDRTraceWriterTest, WriteToStringBufferVersion3) {
auto &Trace = TraceOrErr.get();
ASSERT_THAT(Trace, Not(IsEmpty()));
ASSERT_THAT(Trace, ElementsAre(Field(&XRayRecord::FuncId, Eq(1)),
EXPECT_THAT(Trace, ElementsAre(Field(&XRayRecord::FuncId, Eq(1)),
Field(&XRayRecord::FuncId, Eq(1))));
ASSERT_THAT(Trace, ElementsAre(Field(&XRayRecord::TId, Eq(1u)),
EXPECT_THAT(Trace, ElementsAre(Field(&XRayRecord::TId, Eq(1u)),
Field(&XRayRecord::TId, Eq(1u))));
ASSERT_THAT(Trace, ElementsAre(Field(&XRayRecord::PId, Eq(1u)),
EXPECT_THAT(Trace, ElementsAre(Field(&XRayRecord::PId, Eq(1u)),
Field(&XRayRecord::PId, Eq(1u))));
ASSERT_THAT(Trace, ElementsAre(Field(&XRayRecord::CPU, Eq(1u)),
EXPECT_THAT(Trace, ElementsAre(Field(&XRayRecord::CPU, Eq(1u)),
Field(&XRayRecord::CPU, Eq(1u))));
ASSERT_THAT(Trace,
EXPECT_THAT(Trace,
ElementsAre(Field(&XRayRecord::Type, Eq(RecordTypes::ENTER)),
Field(&XRayRecord::Type, Eq(RecordTypes::EXIT))));
}
@ -108,13 +108,13 @@ TEST(FDRTraceWriterTest, WriteToStringBufferVersion2) {
auto &Trace = TraceOrErr.get();
ASSERT_THAT(Trace, Not(IsEmpty()));
ASSERT_THAT(Trace, ElementsAre(Field(&XRayRecord::FuncId, Eq(1)),
EXPECT_THAT(Trace, ElementsAre(Field(&XRayRecord::FuncId, Eq(1)),
Field(&XRayRecord::FuncId, Eq(1))));
ASSERT_THAT(Trace, ElementsAre(Field(&XRayRecord::TId, Eq(1u)),
EXPECT_THAT(Trace, ElementsAre(Field(&XRayRecord::TId, Eq(1u)),
Field(&XRayRecord::TId, Eq(1u))));
ASSERT_THAT(Trace, ElementsAre(Field(&XRayRecord::CPU, Eq(1u)),
EXPECT_THAT(Trace, ElementsAre(Field(&XRayRecord::CPU, Eq(1u)),
Field(&XRayRecord::CPU, Eq(1u))));
ASSERT_THAT(Trace,
EXPECT_THAT(Trace,
ElementsAre(Field(&XRayRecord::Type, Eq(RecordTypes::ENTER)),
Field(&XRayRecord::Type, Eq(RecordTypes::EXIT))));
}
@ -167,14 +167,13 @@ TEST(FDRTraceWriterTest, WriteToStringBufferVersion1) {
auto &Trace = TraceOrErr.get();
ASSERT_THAT(Trace, Not(IsEmpty()));
ASSERT_THAT(Trace, Not(IsEmpty()));
ASSERT_THAT(Trace, ElementsAre(Field(&XRayRecord::FuncId, Eq(1)),
EXPECT_THAT(Trace, ElementsAre(Field(&XRayRecord::FuncId, Eq(1)),
Field(&XRayRecord::FuncId, Eq(1))));
ASSERT_THAT(Trace, ElementsAre(Field(&XRayRecord::TId, Eq(1u)),
EXPECT_THAT(Trace, ElementsAre(Field(&XRayRecord::TId, Eq(1u)),
Field(&XRayRecord::TId, Eq(1u))));
ASSERT_THAT(Trace, ElementsAre(Field(&XRayRecord::CPU, Eq(1u)),
EXPECT_THAT(Trace, ElementsAre(Field(&XRayRecord::CPU, Eq(1u)),
Field(&XRayRecord::CPU, Eq(1u))));
ASSERT_THAT(Trace,
EXPECT_THAT(Trace,
ElementsAre(Field(&XRayRecord::Type, Eq(RecordTypes::ENTER)),
Field(&XRayRecord::Type, Eq(RecordTypes::EXIT))));
}