LLVM: lib/DWARFLinker/Parallel/DWARFLinkerUnit.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
12
13using namespace llvm;
16
18
21 void *InsertToken;
22
24
25 if (InSet) {
26
28 } else {
29
31 std::make_unique(Abbrev.getTag(), Abbrev.hasChildren()));
32 for (const auto &Attr : Abbrev.getData())
35
38 }
39}
40
42 const std::vector<std::unique_ptr> &Abbrevs = getAbbreviations();
43 if (Abbrevs.empty())
45
48
49
50 for (const auto &Abbrev : Abbrevs)
52
53
55
57}
58
61
63
64
65
67
68
70
71
74
76
77
79
80
81 if (AttrData.getForm() == dwarf::DW_FORM_implicit_const)
83 }
84
85
88}
89
94
95
96
97
101 if (Error Err = Emitter.init(TargetTriple, "__DWARF"))
102 return Err;
103
104
105 Emitter.emitCompileUnitHeader(*this);
106 size_t OffsetToAbbreviationTableOffset =
109 OffsetToAbbreviationTableOffset,
111
112
115
116
119}
120
124
125 return DebugLineEmitter.emit(OutLineTable);
126}
127
131
134
137
138
139
140
142 uint64_t OffsetAfterSectionLength = OutDebugStrOffsetsSection.OS.tell();
143
144
145 OutDebugStrOffsetsSection.emitIntVal(5, 2);
146
147
148 OutDebugStrOffsetsSection.emitIntVal(0, 2);
149
150
152
153 OutDebugStrOffsetsSection.notePatch(
155
156
157 OutDebugStrOffsetsSection.emitOffset(0xBADDEF);
158 }
159
160
161 OutDebugStrOffsetsSection.apply(
162 OffsetAfterSectionLength -
164 dwarf::DW_FORM_sec_offset,
165 OutDebugStrOffsetsSection.OS.tell() - OffsetAfterSectionLength);
166
168}
169
170
171
172std::optional<uint64_t>
175 std::optional<uint64_t> LengthOffset) {
176 if (!LengthOffset) {
177
179 getFormParams().getDwarfOffsetByteSize());
180 LengthOffset = OutSection.OS.tell();
181
183
187 OutSection.emitOffset(0xBADDEF);
188
190 }
191 OutSection.emitOffset(Info.OutOffset);
192
193
195
196 return LengthOffset;
197}
198
199
201 std::optional<uint64_t> NamesLengthOffset;
202 std::optional<uint64_t> TypesLengthOffset;
203
205 if (Info.AvoidForPubSections)
206 return;
207
208 switch (Info.Type) {
212 NamesLengthOffset);
213 } break;
217 TypesLengthOffset);
218 } break;
219 default: {
220
221 } break;
222 }
223 });
224
225 if (NamesLengthOffset) {
228 OutSection.emitIntVal(0, 4);
229
230 OutSection.apply(*NamesLengthOffset -
232 dwarf::DW_FORM_sec_offset,
233 OutSection.OS.tell() - *NamesLengthOffset);
234 }
235
236 if (TypesLengthOffset) {
239 OutSection.emitIntVal(0, 4);
240
241 OutSection.apply(*TypesLengthOffset -
243 dwarf::DW_FORM_sec_offset,
244 OutSection.OS.tell() - *TypesLengthOffset);
245 }
246}
dxil DXContainer Global Emitter
Dwarf abbreviation data, describes one attribute of a Dwarf abbreviation.
Dwarf abbreviation, describes the organization of a debug information object.
unsigned getNumber() const
const SmallVectorImpl< DIEAbbrevData > & getData() const
dwarf::Tag getTag() const
Accessors.
void setNumber(unsigned N)
LLVM_ABI void Profile(FoldingSetNodeID &ID) const
Used to gather unique data for the abbreviation folding set.
A structured debug information entry.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Triple - Helper class for working with autoconf configuration names.
This class emits specified line table into the .debug_line section.
Error emit(const DWARFDebugLine::LineTable &LineTable)
This class emits DWARF data to the output stream.
std::vector< std::unique_ptr< DIEAbbrev > > Abbreviations
Storage for the unique Abbreviations.
DIE * OutUnitDIE
Output unit DIE.
uint64_t getUnitSize() const
Returns size of this(newly generated) compile unit.
void assignAbbrev(DIEAbbrev &Abbrev)
Adds Abbrev into unit`s abbreviation table.
Definition DWARFLinkerUnit.cpp:17
IndexedValuesMap< const StringEntry * > DebugStringIndexMap
Maps a string into the index inside .debug_str_offsets section.
std::optional< uint64_t > emitPubAcceleratorEntry(SectionDescriptor &OutSection, const AccelInfo &Info, std::optional< uint64_t > LengthOffset)
Emit single pubnames/pubtypes accelerator entry.
Definition DWARFLinkerUnit.cpp:173
unsigned ID
Unique ID for the unit.
const std::vector< std::unique_ptr< DIEAbbrev > > & getAbbreviations() const
Returns abbreviations for this compile unit.
void emitDwarfAbbrevEntry(const DIEAbbrev &Abbrev, SectionDescriptor &AbbrevSection)
Emit single abbreviation entry.
Definition DWARFLinkerUnit.cpp:59
FoldingSet< DIEAbbrev > AbbreviationsSet
FoldingSet that uniques the abbreviations.
DIE * getOutUnitDIE()
Returns output unit DIE.
const dwarf::FormParams & getFormParams() const
Return size of address.
uint16_t getVersion() const
Return DWARF version.
SectionDescriptor & getOrCreateSectionDescriptor(DebugSectionKind SectionKind)
Returns descriptor for the specified section of SectionKind.
uint64_t tell() const
tell - Return the current offset with the file.
Error emitDebugInfo(const Triple &TargetTriple)
Emit .debug_info section for unit DIEs.
Definition DWARFLinkerUnit.cpp:90
Error emitDebugStringOffsetSection()
Emit the .debug_str_offsets section for current unit.
Definition DWARFLinkerUnit.cpp:128
virtual void forEachAcceleratorRecord(function_ref< void(AccelInfo &)> Handler)=0
Enumerates accelerator data.
void emitPubAccelerators()
Emit .debug_pubnames and .debug_pubtypes for Unit.
Definition DWARFLinkerUnit.cpp:200
Error emitAbbreviations()
Definition DWARFLinkerUnit.cpp:41
Error emitDebugLine(const Triple &TargetTriple, const DWARFDebugLine::LineTable &OutLineTable)
Emit .debug_line section.
Definition DWARFLinkerUnit.cpp:121
StringMapEntry< EmptyStringSetTag > StringEntry
StringEntry keeps data of the string: the length, external offset and a string body which is placed r...
@ DW_PUBNAMES_VERSION
Section version number for .debug_pubnames.
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
unsigned encodeSLEB128(int64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a SLEB128 value to an output stream.
unsigned encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a ULEB128 value to an output stream.
uint8_t getDwarfOffsetByteSize() const
The size of a reference is determined by the DWARF 32/64-bit format.
This structure is used to update strings offsets into .debug_str.
This structure keeps fields which would be used for creating accelerator table.
dwarf::FormParams getFormParams() const
Returns FormParams used by section.
This structure is used to keep data of the concrete section.
raw_svector_ostream OS
Stream which stores data to the Contents.
void setSizesForSectionCreatedByAsmPrinter()
Some sections are emitted using AsmPrinter.
void emitUnitLength(uint64_t Length)
Emit unit length into the current section contents.
void emitOffset(uint64_t Val)
Emit specified offset value into the current section contents.
void emitIntVal(uint64_t Val, unsigned Size)
Emit specified integer value into the current section contents.
void apply(uint64_t PatchOffset, dwarf::Form AttrForm, uint64_t Val)
Write specified Value of AttrForm to the PatchOffset.
void emitInplaceString(StringRef String)
Emit specified inplace string value into the current section contents.