1 //===- BlockPrinter.h - FDR Block Pretty Printer -------------------------===// 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 // An implementation of the RecordVisitor which formats a block of records for 10 // easier human consumption. 11 // 12 //===----------------------------------------------------------------------===// 13 #ifndef LLVM_XRAY_BLOCKPRINTER_H 14 #define 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 20 namespace llvm { 21 namespace xray { 22 23 class 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 38 public: BlockPrinter(raw_ostream & O,RecordPrinter & P)39 explicit BlockPrinter(raw_ostream &O, RecordPrinter &P) : OS(O), RP(P) {} 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 reset()54 void reset() { CurrentState = State::Start; } 55 }; 56 57 } // namespace xray 58 } // namespace llvm 59 60 #endif // LLVM_XRAY_BLOCKPRINTER_H 61