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