LLVM  8.0.1
BlockVerifier.h
Go to the documentation of this file.
1 //===- BlockVerifier.h - FDR Block Verifier -------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // An implementation of the RecordVisitor which verifies a sequence of records
11 // associated with a block, following the FDR mode log format's specifications.
12 //
13 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_INCLUDE_LLVM_XRAY_BLOCKVERIFIER_H_
15 #define LLVM_INCLUDE_LLVM_XRAY_BLOCKVERIFIER_H_
16 
17 #include "llvm/XRay/FDRRecords.h"
18 #include <array>
19 #include <bitset>
20 
21 namespace llvm {
22 namespace xray {
23 
24 class BlockVerifier : public RecordVisitor {
25 public:
26  // We force State elements to be size_t, to be used as indices for containers.
27  enum class State : std::size_t {
28  Unknown,
30  NewBuffer,
32  PIDEntry,
33  NewCPUId,
34  TSCWrap,
36  TypedEvent,
37  Function,
38  CallArg,
40  StateMax,
41  };
42 
43 private:
44  // We keep track of the current record seen by the verifier.
45  State CurrentRecord = State::Unknown;
46 
47  // Transitions the current record to the new record, records an error on
48  // invalid transitions.
49  Error transition(State To);
50 
51 public:
52  Error visit(BufferExtents &) override;
53  Error visit(WallclockRecord &) override;
54  Error visit(NewCPUIDRecord &) override;
55  Error visit(TSCWrapRecord &) override;
56  Error visit(CustomEventRecord &) override;
57  Error visit(CallArgRecord &) override;
58  Error visit(PIDRecord &) override;
59  Error visit(NewBufferRecord &) override;
60  Error visit(EndBufferRecord &) override;
61  Error visit(FunctionRecord &) override;
62  Error visit(CustomEventRecordV5 &) override;
63  Error visit(TypedEventRecord &) override;
64 
65  Error verify();
66  void reset();
67 };
68 
69 } // namespace xray
70 } // namespace llvm
71 
72 #endif // LLVM_INCLUDE_LLVM_XRAY_BLOCKVERIFIER_H_
This class represents lattice values for constants.
Definition: AllocatorList.h:24
Error visit(BufferExtents &) override
Lightweight error class with error context and mandatory checking.
Definition: Error.h:158