Line data Source code
1 : //===- BlockPrinter.h - FDR Block Pretty Printer -------------------------===//
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 formats a block of records for
11 : // easier human consumption.
12 : //
13 : //===----------------------------------------------------------------------===//
14 : #ifndef LLVM_INCLUDE_LLVM_XRAY_BLOCKPRINTER_H_
15 : #define LLVM_INCLUDE_LLVM_XRAY_BLOCKPRINTER_H_
16 :
17 : #include "llvm/Support/raw_ostream.h"
18 : #include "llvm/XRay/FDRRecords.h"
19 : #include "llvm/XRay/RecordPrinter.h"
20 :
21 : namespace llvm {
22 : namespace xray {
23 :
24 1 : class BlockPrinter : public RecordVisitor {
25 : enum class State {
26 : Start,
27 : Preamble,
28 : Metadata,
29 : Function,
30 : Arg,
31 : CustomEvent,
32 : End,
33 : };
34 :
35 : raw_ostream &OS;
36 : RecordPrinter &RP;
37 : State CurrentState = State::Start;
38 :
39 : public:
40 : explicit BlockPrinter(raw_ostream &O, RecordPrinter &P)
41 1 : : RecordVisitor(), OS(O), RP(P) {}
42 :
43 : Error visit(BufferExtents &) override;
44 : Error visit(WallclockRecord &) override;
45 : Error visit(NewCPUIDRecord &) override;
46 : Error visit(TSCWrapRecord &) override;
47 : Error visit(CustomEventRecord &) override;
48 : Error visit(CallArgRecord &) override;
49 : Error visit(PIDRecord &) override;
50 : Error visit(NewBufferRecord &) override;
51 : Error visit(EndBufferRecord &) override;
52 : Error visit(FunctionRecord &) override;
53 :
54 3 : void reset() { CurrentState = State::Start; }
55 : };
56 :
57 : } // namespace xray
58 : } // namespace llvm
59 :
60 : #endif // LLVM_INCLUDE_LLVM_XRAY_BLOCKPRINTER_H_
|