blob: 949258085332d58ff51ad285c0c76e1be1510af3 [file] [log] [blame]
Andrew Scull0372a572018-11-16 15:47:06 +00001//===- BlockPrinter.h - FDR Block Pretty Printer -------------------------===//
2//
Andrew Walbran16937d02019-10-22 13:54:20 +01003// 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
Andrew Scull0372a572018-11-16 15:47:06 +00006//
7//===----------------------------------------------------------------------===//
8//
9// An implementation of the RecordVisitor which formats a block of records for
10// easier human consumption.
11//
12//===----------------------------------------------------------------------===//
13#ifndef LLVM_INCLUDE_LLVM_XRAY_BLOCKPRINTER_H_
14#define LLVM_INCLUDE_LLVM_XRAY_BLOCKPRINTER_H_
15
16#include "llvm/Support/raw_ostream.h"
17#include "llvm/XRay/FDRRecords.h"
18#include "llvm/XRay/RecordPrinter.h"
19
20namespace llvm {
21namespace xray {
22
23class BlockPrinter : public RecordVisitor {
24 enum class State {
25 Start,
26 Preamble,
27 Metadata,
28 Function,
29 Arg,
30 CustomEvent,
31 End,
32 };
33
34 raw_ostream &OS;
35 RecordPrinter &RP;
36 State CurrentState = State::Start;
37
38public:
39 explicit BlockPrinter(raw_ostream &O, RecordPrinter &P)
40 : RecordVisitor(), OS(O), RP(P) {}
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;
Andrew Walbran16937d02019-10-22 13:54:20 +010052 Error visit(CustomEventRecordV5 &) override;
53 Error visit(TypedEventRecord &) override;
Andrew Scull0372a572018-11-16 15:47:06 +000054
55 void reset() { CurrentState = State::Start; }
56};
57
58} // namespace xray
59} // namespace llvm
60
61#endif // LLVM_INCLUDE_LLVM_XRAY_BLOCKPRINTER_H_