LLVM 22.0.0git
DebugSubsectionRecord.h
Go to the documentation of this file.
1//===- DebugSubsectionRecord.h ----------------------------------*- 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#ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGSUBSECTIONRECORD_H
10#define LLVM_DEBUGINFO_CODEVIEW_DEBUGSUBSECTIONRECORD_H
11
16#include "llvm/Support/Endian.h"
17#include "llvm/Support/Error.h"
19#include <cstdint>
20#include <memory>
21
22namespace llvm {
23
24class BinaryStreamWriter;
25
26namespace codeview {
27
28class DebugSubsection;
29
30// Corresponds to the `CV_DebugSSubsectionHeader_t` structure.
32 support::ulittle32_t Kind; // codeview::DebugSubsectionKind enum
33 support::ulittle32_t Length; // number of bytes occupied by this record.
34};
35
37public:
40 BinaryStreamRef Data);
41
44
48
49private:
51 BinaryStreamRef Data;
52};
53
55public:
57 DebugSubsectionRecordBuilder(std::shared_ptr<DebugSubsection> Subsection);
58
59 /// Use this to copy existing subsections directly from source to destination.
60 /// For example, line table subsections in an object file only need to be
61 /// relocated before being copied into the PDB.
63
66 CodeViewContainer Container) const;
67
68private:
69 /// The subsection to build. Will be null if Contents is non-empty.
70 std::shared_ptr<DebugSubsection> Subsection;
71
72 /// The bytes of the subsection. Only non-empty if Subsection is null.
73 /// FIXME: Reduce the size of this.
74 DebugSubsectionRecord Contents;
75};
76
77} // end namespace codeview
78
79template <> struct VarStreamArrayExtractor<codeview::DebugSubsectionRecord> {
82 // FIXME: We need to pass the container type through to this function. In
83 // practice this isn't super important since the subsection header describes
84 // its length and we can just skip it. It's more important when writing.
86 return EC;
87 Length = alignTo(Info.getRecordLength(), 4);
88 return Error::success();
89 }
90};
91
92namespace codeview {
93
95
96} // end namespace codeview
97
98} // end namespace llvm
99
100#endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGSUBSECTIONRECORD_H
Lightweight arrays that are backed by an arbitrary BinaryStream.
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
#define LLVM_ABI
Definition: Compiler.h:213
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
Provides write only access to a subclass of WritableBinaryStream.
Lightweight error class with error context and mandatory checking.
Definition: Error.h:159
static ErrorSuccess success()
Create a success value.
Definition: Error.h:336
LLVM_ABI Error commit(BinaryStreamWriter &Writer, CodeViewContainer Container) const
LLVM_ABI BinaryStreamRef getRecordData() const
LLVM_ABI DebugSubsectionKind kind() const
static LLVM_ABI Error initialize(BinaryStreamRef Stream, DebugSubsectionRecord &Info)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Length
Definition: DWP.cpp:477
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition: Alignment.h:155
Error operator()(BinaryStreamRef Stream, uint32_t &Length, codeview::DebugSubsectionRecord &Info)
VarStreamArrayExtractor is intended to be specialized to provide customized extraction logic.