LLVM  8.0.1
FDRTraceExpander.h
Go to the documentation of this file.
1 //===- FDRTraceExpander.h - XRay FDR Mode Log Expander --------------------===//
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 // We define an FDR record visitor which can re-constitute XRayRecord instances
11 // from a sequence of FDR mode records in arrival order into a collection.
12 //
13 //===----------------------------------------------------------------------===//
14 #ifndef INCLUDE_LLVM_XRAY_FDRTRACEEXPANDER_H_
15 #define INCLUDE_LLVM_XRAY_FDRTRACEEXPANDER_H_
16 
17 #include "llvm/ADT/STLExtras.h"
18 #include "llvm/XRay/FDRRecords.h"
19 #include "llvm/XRay/XRayRecord.h"
20 
21 namespace llvm {
22 namespace xray {
23 
24 class TraceExpander : public RecordVisitor {
25  // Type-erased callback for handling individual XRayRecord instances.
27  int32_t PID = 0;
28  int32_t TID = 0;
29  uint64_t BaseTSC = 0;
30  XRayRecord CurrentRecord{0, 0, RecordTypes::ENTER, 0, 0, 0, 0, {}, {}};
31  uint16_t CPUId = 0;
32  uint16_t LogVersion = 0;
33  bool BuildingRecord = false;
34  bool IgnoringRecords = false;
35 
36  void resetCurrentRecord();
37 
38 public:
39  explicit TraceExpander(function_ref<void(const XRayRecord &)> F, uint16_t L)
40  : RecordVisitor(), C(std::move(F)), LogVersion(L) {}
41 
42  Error visit(BufferExtents &) override;
43  Error visit(WallclockRecord &) override;
44  Error visit(NewCPUIDRecord &) override;
45  Error visit(TSCWrapRecord &) override;
46  Error visit(CustomEventRecord &) override;
47  Error visit(CallArgRecord &) override;
48  Error visit(PIDRecord &) override;
49  Error visit(NewBufferRecord &) override;
50  Error visit(EndBufferRecord &) override;
51  Error visit(FunctionRecord &) override;
52  Error visit(CustomEventRecordV5 &) override;
53  Error visit(TypedEventRecord &) override;
54 
55  // Must be called after all the records have been processed, to handle the
56  // most recent record generated.
57  Error flush();
58 };
59 
60 } // namespace xray
61 } // namespace llvm
62 
63 #endif // INCLUDE_LLVM_XRAY_FDRTRACEEXPANDER_H_
This class represents lattice values for constants.
Definition: AllocatorList.h:24
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:117
F(f)
TraceExpander(function_ref< void(const XRayRecord &)> F, uint16_t L)
Definition: BitVector.h:938
Error visit(BufferExtents &) override
An XRayRecord is the denormalized view of data associated in a trace.
Definition: XRayRecord.h:70
Lightweight error class with error context and mandatory checking.
Definition: Error.h:158