Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:45

0001 //===- BlockVerifier.h - FDR Block Verifier -------------------------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // An implementation of the RecordVisitor which verifies a sequence of records
0010 // associated with a block, following the FDR mode log format's specifications.
0011 //
0012 //===----------------------------------------------------------------------===//
0013 #ifndef LLVM_XRAY_BLOCKVERIFIER_H
0014 #define LLVM_XRAY_BLOCKVERIFIER_H
0015 
0016 #include "llvm/XRay/FDRRecords.h"
0017 
0018 namespace llvm {
0019 namespace xray {
0020 
0021 class BlockVerifier : public RecordVisitor {
0022 public:
0023   // We force State elements to be size_t, to be used as indices for containers.
0024   enum class State : std::size_t {
0025     Unknown,
0026     BufferExtents,
0027     NewBuffer,
0028     WallClockTime,
0029     PIDEntry,
0030     NewCPUId,
0031     TSCWrap,
0032     CustomEvent,
0033     TypedEvent,
0034     Function,
0035     CallArg,
0036     EndOfBuffer,
0037     StateMax,
0038   };
0039 
0040 private:
0041   // We keep track of the current record seen by the verifier.
0042   State CurrentRecord = State::Unknown;
0043 
0044   // Transitions the current record to the new record, records an error on
0045   // invalid transitions.
0046   Error transition(State To);
0047 
0048 public:
0049   Error visit(BufferExtents &) override;
0050   Error visit(WallclockRecord &) override;
0051   Error visit(NewCPUIDRecord &) override;
0052   Error visit(TSCWrapRecord &) override;
0053   Error visit(CustomEventRecord &) override;
0054   Error visit(CallArgRecord &) override;
0055   Error visit(PIDRecord &) override;
0056   Error visit(NewBufferRecord &) override;
0057   Error visit(EndBufferRecord &) override;
0058   Error visit(FunctionRecord &) override;
0059   Error visit(CustomEventRecordV5 &) override;
0060   Error visit(TypedEventRecord &) override;
0061 
0062   Error verify();
0063   void reset();
0064 };
0065 
0066 } // namespace xray
0067 } // namespace llvm
0068 
0069 #endif // LLVM_XRAY_BLOCKVERIFIER_H