blob: 1a46b7a5717592bd17dbe1cd3232ae3b9ddca631 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#pragma once
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif
//===- FDRRecordProducer.h - XRay FDR Mode Record Producer ----------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_INCLUDE_LLVM_XRAY_FDRRECORDPRODUCER_H_
#define LLVM_INCLUDE_LLVM_XRAY_FDRRECORDPRODUCER_H_
#include "llvm/Support/Error.h"
#include "llvm/XRay/FDRRecords.h"
#include "llvm/XRay/XRayRecord.h"
#include <memory>
namespace llvm {
namespace xray {
class RecordProducer {
public:
/// All producer implementations must yield either an Error or a non-nullptr
/// unique_ptr<Record>.
virtual Expected<std::unique_ptr<Record>> produce() = 0;
virtual ~RecordProducer() = default;
};
class FileBasedRecordProducer : public RecordProducer {
const XRayFileHeader &Header;
DataExtractor &E;
uint64_t &OffsetPtr;
uint32_t CurrentBufferBytes = 0;
// Helper function which gets the next record by speculatively reading through
// the log, finding a buffer extents record.
Expected<std::unique_ptr<Record>> findNextBufferExtent();
public:
FileBasedRecordProducer(const XRayFileHeader &FH, DataExtractor &DE,
uint64_t &OP)
: Header(FH), E(DE), OffsetPtr(OP) {}
/// This producer encapsulates the logic for loading a File-backed
/// RecordProducer hidden behind a DataExtractor.
Expected<std::unique_ptr<Record>> produce() override;
};
} // namespace xray
} // namespace llvm
#endif // LLVM_INCLUDE_LLVM_XRAY_FDRRECORDPRODUCER_H_
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
|