LLVM  14.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 
15 #include "llvm/Support/Endian.h"
16 #include "llvm/Support/Error.h"
18 #include <cstdint>
19 #include <memory>
20 
21 namespace llvm {
22 
23 class BinaryStreamWriter;
24 
25 namespace codeview {
26 
27 class DebugSubsection;
28 
29 // Corresponds to the `CV_DebugSSubsectionHeader_t` structure.
31  support::ulittle32_t Kind; // codeview::DebugSubsectionKind enum
32  support::ulittle32_t Length; // number of bytes occupied by this record.
33 };
34 
36 public:
39 
41 
42  uint32_t getRecordLength() const;
43  DebugSubsectionKind kind() const;
45 
46 private:
49 };
50 
52 public:
53  DebugSubsectionRecordBuilder(std::shared_ptr<DebugSubsection> Subsection);
54 
55  /// Use this to copy existing subsections directly from source to destination.
56  /// For example, line table subsections in an object file only need to be
57  /// relocated before being copied into the PDB.
59 
61  Error commit(BinaryStreamWriter &Writer, CodeViewContainer Container) const;
62 
63 private:
64  /// The subsection to build. Will be null if Contents is non-empty.
65  std::shared_ptr<DebugSubsection> Subsection;
66 
67  /// The bytes of the subsection. Only non-empty if Subsection is null.
68  /// FIXME: Reduce the size of this.
69  DebugSubsectionRecord Contents;
70 };
71 
72 } // end namespace codeview
73 
74 template <> struct VarStreamArrayExtractor<codeview::DebugSubsectionRecord> {
77  // FIXME: We need to pass the container type through to this function. In
78  // practice this isn't super important since the subsection header describes
79  // its length and we can just skip it. It's more important when writing.
81  return EC;
82  Length = alignTo(Info.getRecordLength(), 4);
83  return Error::success();
84  }
85 };
86 
87 namespace codeview {
88 
90 
91 } // end namespace codeview
92 
93 } // end namespace llvm
94 
95 #endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGSUBSECTIONRECORD_H
llvm::alignTo
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition: Alignment.h:148
MathExtras.h
llvm::codeview::DebugSubsectionHeader
Definition: DebugSubsectionRecord.h:30
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
llvm::codeview::DebugSubsectionHeader::Length
support::ulittle32_t Length
Definition: DebugSubsectionRecord.h:32
llvm::support::detail::packed_endian_specific_integral
Definition: Endian.h:206
llvm::BinaryStreamWriter
Provides write only access to a subclass of WritableBinaryStream.
Definition: BinaryStreamWriter.h:31
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:331
llvm::codeview::DebugSubsectionRecord::initialize
static Error initialize(BinaryStreamRef Stream, DebugSubsectionRecord &Info)
Definition: DebugSubsectionRecord.cpp:29
Error.h
llvm::codeview::DebugSubsectionKind::None
@ None
llvm::codeview::DebugSubsectionRecordBuilder::DebugSubsectionRecordBuilder
DebugSubsectionRecordBuilder(std::shared_ptr< DebugSubsection > Subsection)
Definition: DebugSubsectionRecord.cpp:52
llvm::VarStreamArrayExtractor
VarStreamArrayExtractor is intended to be specialized to provide customized extraction logic.
Definition: BinaryStreamArray.h:47
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
llvm::VarStreamArray< DebugSubsectionRecord >
Info
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
CodeView.h
llvm::codeview::DebugSubsectionHeader::Kind
support::ulittle32_t Kind
Definition: DebugSubsectionRecord.h:31
llvm::VarStreamArrayExtractor< codeview::DebugSubsectionRecord >::operator()
Error operator()(BinaryStreamRef Stream, uint32_t &Length, codeview::DebugSubsectionRecord &Info)
Definition: DebugSubsectionRecord.h:75
llvm::codeview::DebugSubsectionRecord::getRecordLength
uint32_t getRecordLength() const
Definition: DebugSubsectionRecord.cpp:44
BinaryStreamArray.h
llvm::codeview::DebugSubsectionRecord
Definition: DebugSubsectionRecord.h:35
llvm::codeview::DebugSubsectionRecordBuilder::calculateSerializedLength
uint32_t calculateSerializedLength() const
Definition: DebugSubsectionRecord.cpp:60
BinaryStreamRef.h
uint32_t
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::codeview::DebugSubsectionRecord::kind
DebugSubsectionKind kind() const
Definition: DebugSubsectionRecord.cpp:48
llvm::codeview::DebugSubsectionRecord::DebugSubsectionRecord
DebugSubsectionRecord()
llvm::codeview::DebugSubsectionKind
DebugSubsectionKind
Definition: CodeView.h:313
llvm::codeview::DebugSubsectionRecordBuilder::commit
Error commit(BinaryStreamWriter &Writer, CodeViewContainer Container) const
Definition: DebugSubsectionRecord.cpp:68
llvm::codeview::DebugSubsectionRecordBuilder
Definition: DebugSubsectionRecord.h:51
llvm::codeview::DebugSubsectionRecord::getRecordData
BinaryStreamRef getRecordData() const
Definition: DebugSubsectionRecord.cpp:50
llvm::codeview::CodeViewContainer
CodeViewContainer
Definition: CodeView.h:607
Endian.h
llvm::BinaryStreamRef
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
Definition: BinaryStreamRef.h:156