BlockPrinter.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. #include "llvm/Support/raw_ostream.h"
  16. #include "llvm/XRay/FDRRecords.h"
  17. #include "llvm/XRay/RecordPrinter.h"
  18. namespace llvm {
  19. namespace xray {
  20. class BlockPrinter : public RecordVisitor {
  21. enum class State {
  22. Start,
  23. Preamble,
  24. Metadata,
  25. Function,
  26. Arg,
  27. CustomEvent,
  28. End,
  29. };
  30. raw_ostream &OS;
  31. RecordPrinter &RP;
  32. State CurrentState = State::Start;
  33. public:
  34. explicit BlockPrinter(raw_ostream &O, RecordPrinter &P)
  35. : RecordVisitor(), OS(O), RP(P) {}
  36. Error visit(BufferExtents &) override;
  37. Error visit(WallclockRecord &) override;
  38. Error visit(NewCPUIDRecord &) override;
  39. Error visit(TSCWrapRecord &) override;
  40. Error visit(CustomEventRecord &) override;
  41. Error visit(CallArgRecord &) override;
  42. Error visit(PIDRecord &) override;
  43. Error visit(NewBufferRecord &) override;
  44. Error visit(EndBufferRecord &) override;
  45. Error visit(FunctionRecord &) override;
  46. Error visit(CustomEventRecordV5 &) override;
  47. Error visit(TypedEventRecord &) override;
  48. void reset() { CurrentState = State::Start; }
  49. };
  50. } // namespace xray
  51. } // namespace llvm
  52. #endif // LLVM_XRAY_BLOCKPRINTER_H