1 //===- FDRRecordProducer.h - XRay FDR Mode Record Producer ----------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_INCLUDE_LLVM_XRAY_FDRRECORDPRODUCER_H_
10 #define LLVM_INCLUDE_LLVM_XRAY_FDRRECORDPRODUCER_H_
12 #include "llvm/Support/Error.h"
13 #include "llvm/XRay/FDRRecords.h"
14 #include "llvm/XRay/XRayRecord.h"
20 class RecordProducer {
22 /// All producer implementations must yield either an Error or a non-nullptr
23 /// unique_ptr<Record>.
24 virtual Expected<std::unique_ptr<Record>> produce() = 0;
25 virtual ~RecordProducer() = default;
28 class FileBasedRecordProducer : public RecordProducer {
29 const XRayFileHeader &Header;
32 uint32_t CurrentBufferBytes = 0;
34 // Helper function which gets the next record by speculatively reading through
35 // the log, finding a buffer extents record.
36 Expected<std::unique_ptr<Record>> findNextBufferExtent();
39 FileBasedRecordProducer(const XRayFileHeader &FH, DataExtractor &DE,
41 : Header(FH), E(DE), OffsetPtr(OP) {}
43 /// This producer encapsulates the logic for loading a File-backed
44 /// RecordProducer hidden behind a DataExtractor.
45 Expected<std::unique_ptr<Record>> produce() override;
51 #endif // LLVM_INCLUDE_LLVM_XRAY_FDRRECORDPRODUCER_H_