BlockPrinter.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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_INCLUDE_LLVM_XRAY_BLOCKPRINTER_H_
  19. #define LLVM_INCLUDE_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)
  40. : RecordVisitor(), OS(O), RP(P) {}
  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. void reset() { CurrentState = State::Start; }
  54. };
  55. } // namespace xray
  56. } // namespace llvm
  57. #endif // LLVM_INCLUDE_LLVM_XRAY_BLOCKPRINTER_H_
  58. #ifdef __GNUC__
  59. #pragma GCC diagnostic pop
  60. #endif