LLVM  14.0.0git
FDRTraceExpander.h
Go to the documentation of this file.
1 //===- FDRTraceExpander.h - XRay FDR Mode Log Expander --------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // We define an FDR record visitor which can re-constitute XRayRecord instances
10 // from a sequence of FDR mode records in arrival order into a collection.
11 //
12 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_XRAY_FDRTRACEEXPANDER_H
14 #define LLVM_XRAY_FDRTRACEEXPANDER_H
15 
16 #include "llvm/ADT/STLExtras.h"
17 #include "llvm/XRay/FDRRecords.h"
18 #include "llvm/XRay/XRayRecord.h"
19 
20 namespace llvm {
21 namespace xray {
22 
23 class TraceExpander : public RecordVisitor {
24  // Type-erased callback for handling individual XRayRecord instances.
25  function_ref<void(const XRayRecord &)> C;
26  int32_t PID = 0;
27  int32_t TID = 0;
28  uint64_t BaseTSC = 0;
29  XRayRecord CurrentRecord{0, 0, RecordTypes::ENTER, 0, 0, 0, 0, {}, {}};
30  uint16_t CPUId = 0;
31  uint16_t LogVersion = 0;
32  bool BuildingRecord = false;
33  bool IgnoringRecords = false;
34 
35  void resetCurrentRecord();
36 
37 public:
38  explicit TraceExpander(function_ref<void(const XRayRecord &)> F, uint16_t L)
39  : RecordVisitor(), C(std::move(F)), LogVersion(L) {}
40 
41  Error visit(BufferExtents &) override;
42  Error visit(WallclockRecord &) override;
43  Error visit(NewCPUIDRecord &) override;
44  Error visit(TSCWrapRecord &) override;
45  Error visit(CustomEventRecord &) override;
46  Error visit(CallArgRecord &) override;
47  Error visit(PIDRecord &) override;
48  Error visit(NewBufferRecord &) override;
49  Error visit(EndBufferRecord &) override;
50  Error visit(FunctionRecord &) override;
51  Error visit(CustomEventRecordV5 &) override;
52  Error visit(TypedEventRecord &) override;
53 
54  // Must be called after all the records have been processed, to handle the
55  // most recent record generated.
56  Error flush();
57 };
58 
59 } // namespace xray
60 } // namespace llvm
61 
62 #endif // LLVM_XRAY_FDRTRACEEXPANDER_H
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::xray::RecordVisitor
Definition: FDRRecords.h:399
llvm::xray::FunctionRecord
Definition: FDRRecords.h:372
llvm::xray::PIDRecord
Definition: FDRRecords.h:313
STLExtras.h
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::xray::XRayRecord
An XRayRecord is the denormalized view of data associated in a trace.
Definition: XRayRecord.h:69
llvm::xray::BufferExtents
Definition: FDRRecords.h:110
llvm::xray::NewCPUIDRecord
Definition: FDRRecords.h:158
llvm::xray::TraceExpander
Definition: FDRTraceExpander.h:23
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::xray::NewBufferRecord
Definition: FDRRecords.h:336
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:168
llvm::xray::TraceExpander::flush
Error flush()
Definition: FDRTraceExpander.cpp:125
uint64_t
llvm::xray::TraceExpander::visit
Error visit(BufferExtents &) override
Definition: FDRTraceExpander.cpp:21
llvm::xray::EndBufferRecord
Definition: FDRRecords.h:359
llvm::xray::WallclockRecord
Definition: FDRRecords.h:133
llvm::xray::CallArgRecord
Definition: FDRRecords.h:291
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1609
llvm::xray::TypedEventRecord
Definition: FDRRecords.h:262
llvm::xray::RecordTypes::ENTER
@ ENTER
llvm::xray::TSCWrapRecord
Definition: FDRRecords.h:184
std
Definition: BitVector.h:838
llvm::xray::TraceExpander::TraceExpander
TraceExpander(function_ref< void(const XRayRecord &)> F, uint16_t L)
Definition: FDRTraceExpander.h:38
uint16_t
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::xray::CustomEventRecord
Definition: FDRRecords.h:206
llvm::xray::CustomEventRecordV5
Definition: FDRRecords.h:235
FDRRecords.h
XRayRecord.h