Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:45

0001 //===- FDRRecordProducer.h - XRay FDR Mode Record Producer ----------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 #ifndef LLVM_XRAY_FDRRECORDPRODUCER_H
0009 #define LLVM_XRAY_FDRRECORDPRODUCER_H
0010 
0011 #include "llvm/Support/Error.h"
0012 #include "llvm/XRay/FDRRecords.h"
0013 #include "llvm/XRay/XRayRecord.h"
0014 #include <memory>
0015 
0016 namespace llvm {
0017 namespace xray {
0018 
0019 class RecordProducer {
0020 public:
0021   /// All producer implementations must yield either an Error or a non-nullptr
0022   /// unique_ptr<Record>.
0023   virtual Expected<std::unique_ptr<Record>> produce() = 0;
0024   virtual ~RecordProducer() = default;
0025 };
0026 
0027 class FileBasedRecordProducer : public RecordProducer {
0028   const XRayFileHeader &Header;
0029   DataExtractor &E;
0030   uint64_t &OffsetPtr;
0031   uint32_t CurrentBufferBytes = 0;
0032 
0033   // Helper function which gets the next record by speculatively reading through
0034   // the log, finding a buffer extents record.
0035   Expected<std::unique_ptr<Record>> findNextBufferExtent();
0036 
0037 public:
0038   FileBasedRecordProducer(const XRayFileHeader &FH, DataExtractor &DE,
0039                           uint64_t &OP)
0040       : Header(FH), E(DE), OffsetPtr(OP) {}
0041 
0042   /// This producer encapsulates the logic for loading a File-backed
0043   /// RecordProducer hidden behind a DataExtractor.
0044   Expected<std::unique_ptr<Record>> produce() override;
0045 };
0046 
0047 } // namespace xray
0048 } // namespace llvm
0049 
0050 #endif // LLVM_XRAY_FDRRECORDPRODUCER_H