diff options
author | Dean Michael Berris <dberris@google.com> | 2018-11-02 08:07:38 +0000 |
---|---|---|
committer | Dean Michael Berris <dberris@google.com> | 2018-11-02 08:07:38 +0000 |
commit | 0c96ae3d6e24eaf2612a95bb396a77b419051318 (patch) | |
tree | 1864e728355f1911f9f98fba11dfd554ec5497b4 /compiler-rt/lib/xray/tests | |
parent | 12e4ee79391f982114d1462fe26e63a077897db7 (diff) | |
download | bcm5719-llvm-0c96ae3d6e24eaf2612a95bb396a77b419051318.tar.gz bcm5719-llvm-0c96ae3d6e24eaf2612a95bb396a77b419051318.zip |
[XRay] Update delta computations in runtime
Summary:
Fix some issues discovered from mostly manual inspection of outputs from
the `llvm-xray fdr-dump` tool.
It turns out we haven't been writing the deltas properly, and have been
writing down zeros for deltas of some records. This change fixes this
oversight born by the recent refactoring.
Reviewers: mboerger
Subscribers: llvm-commits, hiraditya
Differential Revision: https://reviews.llvm.org/D54022
llvm-svn: 345954
Diffstat (limited to 'compiler-rt/lib/xray/tests')
-rw-r--r-- | compiler-rt/lib/xray/tests/unit/fdr_controller_test.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/compiler-rt/lib/xray/tests/unit/fdr_controller_test.cc b/compiler-rt/lib/xray/tests/unit/fdr_controller_test.cc index 84850c182ff..7199c5c97fa 100644 --- a/compiler-rt/lib/xray/tests/unit/fdr_controller_test.cc +++ b/compiler-rt/lib/xray/tests/unit/fdr_controller_test.cc @@ -137,6 +137,30 @@ TEST_F(FunctionSequenceTest, PreservedCallsHaveCorrectTSC) { TSCIs(Gt(1000uL)))))); } +TEST_F(FunctionSequenceTest, PreservedCallsSupportLargeDeltas) { + C = llvm::make_unique<FDRController<>>(BQ.get(), B, *W, clock_gettime, 1000); + uint64_t TSC = 1; + uint16_t CPU = 0; + const auto LargeDelta = uint64_t{std::numeric_limits<int32_t>::max()}; + ASSERT_TRUE(C->functionEnter(1, TSC++, CPU)); + ASSERT_TRUE(C->functionExit(1, TSC += LargeDelta, CPU)); + ASSERT_TRUE(C->flush()); + ASSERT_EQ(BQ->finalize(), BufferQueue::ErrorCode::Ok); + + // Serialize the buffer then test to see if we find the right TSC with a large + // delta. + std::string Serialized = serialize(*BQ, 3); + llvm::DataExtractor DE(Serialized, true, 8); + auto TraceOrErr = llvm::xray::loadTrace(DE); + EXPECT_THAT_EXPECTED( + TraceOrErr, + HasValue(ElementsAre( + AllOf(FuncId(1), RecordType(llvm::xray::RecordTypes::ENTER), + TSCIs(Eq(1uL))), + AllOf(FuncId(1), RecordType(llvm::xray::RecordTypes::EXIT), + TSCIs(Gt(LargeDelta)))))); +} + TEST_F(FunctionSequenceTest, RewindingMultipleCalls) { C = llvm::make_unique<FDRController<>>(BQ.get(), B, *W, clock_gettime, 1000); |