FDRTraceWriter.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- FDRTraceWriter.h - XRay FDR Trace Writer -----------------*- C++ -*-===//
  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. // Test a utility that can write out XRay FDR Mode formatted trace files.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_XRAY_FDRTRACEWRITER_H
  18. #define LLVM_XRAY_FDRTRACEWRITER_H
  19. #include "llvm/Support/raw_ostream.h"
  20. #include "llvm/Support/EndianStream.h"
  21. #include "llvm/XRay/FDRRecords.h"
  22. #include "llvm/XRay/XRayRecord.h"
  23. namespace llvm {
  24. namespace xray {
  25. /// The FDRTraceWriter allows us to hand-craft an XRay Flight Data Recorder
  26. /// (FDR) mode log file. This is used primarily for testing, generating
  27. /// sequences of FDR records that can be read/processed. It can also be used to
  28. /// generate various kinds of execution traces without using the XRay runtime.
  29. /// Note that this writer does not do any validation, but uses the types of
  30. /// records defined in the FDRRecords.h file.
  31. class FDRTraceWriter : public RecordVisitor {
  32. public:
  33. // Construct an FDRTraceWriter associated with an output stream.
  34. explicit FDRTraceWriter(raw_ostream &O, const XRayFileHeader &H);
  35. ~FDRTraceWriter();
  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. private:
  49. support::endian::Writer OS;
  50. };
  51. } // namespace xray
  52. } // namespace llvm
  53. #endif // LLVM_XRAY_FDRTRACEWRITER_H
  54. #ifdef __GNUC__
  55. #pragma GCC diagnostic pop
  56. #endif