BlockPrinter.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- BlockPrinter.h - FDR Block Pretty Printer -------------------------===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // An implementation of the RecordVisitor which formats a block of records for
  15. // easier human consumption.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_XRAY_BLOCKPRINTER_H
  19. #define LLVM_XRAY_BLOCKPRINTER_H
  20. #include "llvm/Support/raw_ostream.h"
  21. #include "llvm/XRay/FDRRecords.h"
  22. #include "llvm/XRay/RecordPrinter.h"
  23. namespace llvm {
  24. namespace xray {
  25. class BlockPrinter : public RecordVisitor {
  26. enum class State {
  27. Start,
  28. Preamble,
  29. Metadata,
  30. Function,
  31. Arg,
  32. CustomEvent,
  33. End,
  34. };
  35. raw_ostream &OS;
  36. RecordPrinter &RP;
  37. State CurrentState = State::Start;
  38. public:
  39. explicit BlockPrinter(raw_ostream &O, RecordPrinter &P) : OS(O), RP(P) {}
  40. Error visit(BufferExtents &) override;
  41. Error visit(WallclockRecord &) override;
  42. Error visit(NewCPUIDRecord &) override;
  43. Error visit(TSCWrapRecord &) override;
  44. Error visit(CustomEventRecord &) override;
  45. Error visit(CallArgRecord &) override;
  46. Error visit(PIDRecord &) override;
  47. Error visit(NewBufferRecord &) override;
  48. Error visit(EndBufferRecord &) override;
  49. Error visit(FunctionRecord &) override;
  50. Error visit(CustomEventRecordV5 &) override;
  51. Error visit(TypedEventRecord &) override;
  52. void reset() { CurrentState = State::Start; }
  53. };
  54. } // namespace xray
  55. } // namespace llvm
  56. #endif // LLVM_XRAY_BLOCKPRINTER_H
  57. #ifdef __GNUC__
  58. #pragma GCC diagnostic pop
  59. #endif