1 //===- FDRRecordProducer.h - XRay FDR Mode Record Producer ----------------===//
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
7 //===----------------------------------------------------------------------===//
8 #ifndef LLVM_INCLUDE_LLVM_XRAY_FDRRECORDPRODUCER_H_
9 #define LLVM_INCLUDE_LLVM_XRAY_FDRRECORDPRODUCER_H_
11 #include "llvm/Support/Error.h"
12 #include "llvm/XRay/FDRRecords.h"
13 #include "llvm/XRay/XRayRecord.h"
19 class RecordProducer
{
21 /// All producer implementations must yield either an Error or a non-nullptr
22 /// unique_ptr<Record>.
23 virtual Expected
<std::unique_ptr
<Record
>> produce() = 0;
24 virtual ~RecordProducer() = default;
27 class FileBasedRecordProducer
: public RecordProducer
{
28 const XRayFileHeader
&Header
;
31 uint32_t CurrentBufferBytes
= 0;
33 // Helper function which gets the next record by speculatively reading through
34 // the log, finding a buffer extents record.
35 Expected
<std::unique_ptr
<Record
>> findNextBufferExtent();
38 FileBasedRecordProducer(const XRayFileHeader
&FH
, DataExtractor
&DE
,
40 : Header(FH
), E(DE
), OffsetPtr(OP
) {}
42 /// This producer encapsulates the logic for loading a File-backed
43 /// RecordProducer hidden behind a DataExtractor.
44 Expected
<std::unique_ptr
<Record
>> produce() override
;
50 #endif // LLVM_INCLUDE_LLVM_XRAY_FDRRECORDPRODUCER_H_