Line data Source code
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 7 : class TraceExpander : public RecordVisitor {
25 : // Type-erased callback for handling individual XRayRecord instances.
26 : function_ref<void(const XRayRecord &)> C;
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 BuildingFunction = 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 14 : : 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 :
53 : // Must be called after all the records have been processed, to handle the
54 : // most recent record generated.
55 : Error flush();
56 : };
57 :
58 : } // namespace xray
59 : } // namespace llvm
60 :
61 : #endif // INCLUDE_LLVM_XRAY_FDRTRACEEXPANDER_H_
|