Dean Michael Berris | dd24af1 | 2018-09-11 00:22:53 +0000 | [diff] [blame] | 1 | //===- BlockPrinter.cpp - FDR Block Pretty Printer Implementation --------===// |
| 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 | #include "llvm/XRay/BlockPrinter.h" |
| 10 | |
| 11 | namespace llvm { |
| 12 | namespace xray { |
| 13 | |
| 14 | Error BlockPrinter::visit(BufferExtents &R) { |
| 15 | OS << "\n[New Block]\n"; |
| 16 | CurrentState = State::Preamble; |
| 17 | return RP.visit(R); |
| 18 | } |
| 19 | |
| 20 | // Preamble printing. |
| 21 | Error BlockPrinter::visit(NewBufferRecord &R) { |
| 22 | if (CurrentState == State::Start) |
| 23 | OS << "\n[New Block]\n"; |
| 24 | |
| 25 | OS << "Preamble: \n"; |
| 26 | CurrentState = State::Preamble; |
| 27 | return RP.visit(R); |
| 28 | } |
| 29 | |
| 30 | Error BlockPrinter::visit(WallclockRecord &R) { |
| 31 | CurrentState = State::Preamble; |
| 32 | return RP.visit(R); |
| 33 | } |
| 34 | |
| 35 | Error BlockPrinter::visit(PIDRecord &R) { |
| 36 | CurrentState = State::Preamble; |
| 37 | return RP.visit(R); |
| 38 | } |
| 39 | |
| 40 | // Metadata printing. |
| 41 | Error BlockPrinter::visit(NewCPUIDRecord &R) { |
| 42 | if (CurrentState == State::Preamble) |
| 43 | OS << "\nBody:\n"; |
| 44 | if (CurrentState == State::Function) |
| 45 | OS << "\nMetadata: "; |
| 46 | CurrentState = State::Metadata; |
| 47 | OS << " "; |
| 48 | auto E = RP.visit(R); |
| 49 | return E; |
| 50 | } |
| 51 | |
| 52 | Error BlockPrinter::visit(TSCWrapRecord &R) { |
| 53 | if (CurrentState == State::Function) |
| 54 | OS << "\nMetadata:"; |
| 55 | CurrentState = State::Metadata; |
| 56 | OS << " "; |
| 57 | auto E = RP.visit(R); |
| 58 | return E; |
| 59 | } |
| 60 | |
| 61 | // Custom events will be rendered like "function" events. |
| 62 | Error BlockPrinter::visit(CustomEventRecord &R) { |
| 63 | if (CurrentState == State::Metadata) |
| 64 | OS << "\n"; |
| 65 | CurrentState = State::CustomEvent; |
| 66 | OS << "* "; |
| 67 | auto E = RP.visit(R); |
| 68 | return E; |
| 69 | } |
| 70 | |
Dean Michael Berris | 8fa10fd | 2018-11-07 04:37:42 +0000 | [diff] [blame] | 71 | Error BlockPrinter::visit(CustomEventRecordV5 &R) { |
| 72 | if (CurrentState == State::Metadata) |
| 73 | OS << "\n"; |
| 74 | CurrentState = State::CustomEvent; |
| 75 | OS << "* "; |
| 76 | auto E = RP.visit(R); |
| 77 | return E; |
| 78 | } |
| 79 | |
| 80 | Error BlockPrinter::visit(TypedEventRecord &R) { |
| 81 | if (CurrentState == State::Metadata) |
| 82 | OS << "\n"; |
| 83 | CurrentState = State::CustomEvent; |
| 84 | OS << "* "; |
| 85 | auto E = RP.visit(R); |
| 86 | return E; |
| 87 | } |
| 88 | |
Dean Michael Berris | dd24af1 | 2018-09-11 00:22:53 +0000 | [diff] [blame] | 89 | // Function call printing. |
| 90 | Error BlockPrinter::visit(FunctionRecord &R) { |
| 91 | if (CurrentState == State::Metadata) |
| 92 | OS << "\n"; |
| 93 | CurrentState = State::Function; |
| 94 | OS << "- "; |
| 95 | auto E = RP.visit(R); |
| 96 | return E; |
| 97 | } |
| 98 | |
| 99 | Error BlockPrinter::visit(CallArgRecord &R) { |
| 100 | CurrentState = State::Arg; |
| 101 | OS << " : "; |
| 102 | auto E = RP.visit(R); |
| 103 | return E; |
| 104 | } |
| 105 | |
| 106 | Error BlockPrinter::visit(EndBufferRecord &R) { |
| 107 | CurrentState = State::End; |
| 108 | OS << " *** "; |
| 109 | auto E = RP.visit(R); |
| 110 | return E; |
| 111 | } |
| 112 | |
| 113 | } // namespace xray |
| 114 | } // namespace llvm |