2018-09-10 04:35:25 +02:00
|
|
|
//===- BlockVerifier.h - FDR Block Verifier -------------------------------===//
|
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2018-09-10 04:35:25 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// An implementation of the RecordVisitor which verifies a sequence of records
|
|
|
|
// associated with a block, following the FDR mode log format's specifications.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2021-02-06 06:02:06 +01:00
|
|
|
#ifndef LLVM_XRAY_BLOCKVERIFIER_H
|
|
|
|
#define LLVM_XRAY_BLOCKVERIFIER_H
|
2018-09-10 04:35:25 +02:00
|
|
|
|
|
|
|
#include "llvm/XRay/FDRRecords.h"
|
|
|
|
#include <array>
|
|
|
|
#include <bitset>
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
namespace xray {
|
|
|
|
|
|
|
|
class BlockVerifier : public RecordVisitor {
|
|
|
|
public:
|
|
|
|
// We force State elements to be size_t, to be used as indices for containers.
|
|
|
|
enum class State : std::size_t {
|
|
|
|
Unknown,
|
|
|
|
BufferExtents,
|
|
|
|
NewBuffer,
|
|
|
|
WallClockTime,
|
|
|
|
PIDEntry,
|
|
|
|
NewCPUId,
|
|
|
|
TSCWrap,
|
|
|
|
CustomEvent,
|
2018-11-07 05:37:42 +01:00
|
|
|
TypedEvent,
|
2018-09-10 04:35:25 +02:00
|
|
|
Function,
|
|
|
|
CallArg,
|
|
|
|
EndOfBuffer,
|
|
|
|
StateMax,
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
// We keep track of the current record seen by the verifier.
|
|
|
|
State CurrentRecord = State::Unknown;
|
|
|
|
|
|
|
|
// Transitions the current record to the new record, records an error on
|
|
|
|
// invalid transitions.
|
|
|
|
Error transition(State To);
|
|
|
|
|
|
|
|
public:
|
|
|
|
Error visit(BufferExtents &) override;
|
|
|
|
Error visit(WallclockRecord &) override;
|
|
|
|
Error visit(NewCPUIDRecord &) override;
|
|
|
|
Error visit(TSCWrapRecord &) override;
|
|
|
|
Error visit(CustomEventRecord &) override;
|
|
|
|
Error visit(CallArgRecord &) override;
|
|
|
|
Error visit(PIDRecord &) override;
|
|
|
|
Error visit(NewBufferRecord &) override;
|
|
|
|
Error visit(EndBufferRecord &) override;
|
|
|
|
Error visit(FunctionRecord &) override;
|
2018-11-07 05:37:42 +01:00
|
|
|
Error visit(CustomEventRecordV5 &) override;
|
|
|
|
Error visit(TypedEventRecord &) override;
|
2018-09-10 04:35:25 +02:00
|
|
|
|
|
|
|
Error verify();
|
|
|
|
void reset();
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace xray
|
|
|
|
} // namespace llvm
|
|
|
|
|
2021-02-06 06:02:06 +01:00
|
|
|
#endif // LLVM_XRAY_BLOCKVERIFIER_H
|