9#ifndef LLVM_DWARFLINKER_DWARFSTREAMER_H
10#define LLVM_DWARFLINKER_DWARFSTREAMER_H
24template <
typename DataT>
class AccelTable;
51 : OutFile(OutFile), OutFileType(OutFileType), Translator(Translator),
76 void emitAbbrevs(
const std::vector<std::unique_ptr<DIEAbbrev>> &Abbrevs,
77 unsigned DwarfVersion)
override;
131 return RngListsSectionSize;
177 return DebugInfoSectionSize;
181 return MacInfoSectionSize;
185 return MacroSectionSize;
189 return LocListsSectionSize;
199 ErrorHandler(
Error, Context,
nullptr);
202 inline void warn(
const Twine &
Warning, StringRef Context =
"") {
204 WarningHandler(
Warning, Context,
nullptr);
207 void emitMacroTableImpl(
const DWARFDebugMacro *MacroTable,
212 void emitDwarfDebugRangesTableFragment(
const CompileUnit &Unit,
213 const AddressRanges &LinkedRanges,
214 PatchLocation Patch);
217 void emitDwarfDebugRngListsTableFragment(
const CompileUnit &Unit,
218 const AddressRanges &LinkedRanges,
219 PatchLocation Patch);
222 void emitDwarfDebugLocTableFragment(
223 const CompileUnit &Unit,
225 PatchLocation Patch);
228 void emitDwarfDebugLocListsTableFragment(
229 const CompileUnit &Unit,
231 PatchLocation Patch);
235 void emitLineTablePrologue(
const DWARFDebugLine::Prologue &
P,
238 void emitLineTableString(
const DWARFDebugLine::Prologue &
P,
239 const DWARFFormValue &
String,
242 void emitLineTableProloguePayload(
const DWARFDebugLine::Prologue &
P,
245 void emitLineTablePrologueV2IncludeAndFileTable(
248 void emitLineTablePrologueV5IncludeAndFileTable(
251 void emitLineTableRows(
const DWARFDebugLine::LineTable &LineTable,
252 MCSymbol *LineEndSym,
unsigned AddressByteSize);
255 void emitLabelDifference(
const MCSymbol *
Hi,
const MCSymbol *
Lo,
261 std::unique_ptr<MCRegisterInfo> MRI;
262 std::unique_ptr<MCAsmInfo> MAI;
263 std::unique_ptr<MCObjectFileInfo> MOFI;
264 std::unique_ptr<MCContext> MC;
266 std::unique_ptr<MCInstrInfo> MII;
267 std::unique_ptr<MCSubtargetInfo> MSTI;
271 std::unique_ptr<TargetMachine> TM;
272 std::unique_ptr<AsmPrinter> Asm;
276 raw_pwrite_stream &OutFile;
278 std::function<StringRef(StringRef Input)> Translator;
295 std::vector<EmittedUnit> EmittedUnits;
299 void emitPubSectionForUnit(MCSection *Sec, StringRef
Name,
300 const CompileUnit &Unit,
301 const std::vector<CompileUnit::AccelInfo> &
Names);
This class holds an abstract representation of an Accelerator Table, consisting of a sequence of buck...
The AddressRanges class helps normalize address range collections.
This class is intended to be used as a driving class for all asm writers.
Stores all information relating to a compile unit, be it in its original instance in the object file ...
A structured debug information entry.
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
DwarfEmitter presents interface to generate all debug info tables.
The Dwarf streaming logic.
void emitMacroTables(DWARFContext *Context, const Offset2UnitMap &UnitMacroMap, OffsetsStringPool &StringPool) override
Emit all available macro tables(DWARFv4 and DWARFv5).
uint64_t getDebugMacroSectionSize() const override
Returns size of generated .debug_macro section.
uint64_t getFrameSectionSize() const override
Returns size of generated .debug_frame section.
void emitAppleNamespaces(AccelTable< AppleAccelTableStaticOffsetData > &Table) override
Emit Apple namespaces accelerator table.
void emitStrings(const NonRelocatableStringpool &Pool) override
Emit the string table described by Pool into .debug_str table.
void emitAppleNames(AccelTable< AppleAccelTableStaticOffsetData > &Table) override
Emit Apple names accelerator table.
void emitDwarfDebugArangesTable(const CompileUnit &Unit, const AddressRanges &LinkedRanges) override
Emit .debug_aranges entries for Unit.
void emitPaperTrailWarningsDie(DIE &Die) override
Emit DIE containing warnings.
uint64_t getDebugInfoSectionSize() const override
Returns size of generated .debug_info section.
uint64_t getLocListsSectionSize() const override
Returns size of generated .debug_loclists section.
void emitDwarfDebugRangeListFragment(const CompileUnit &Unit, const AddressRanges &LinkedRanges, PatchLocation Patch) override
Emit debug ranges(.debug_ranges, .debug_rnglists) fragment.
void emitAppleObjc(AccelTable< AppleAccelTableStaticOffsetData > &Table) override
Emit Apple Objective-C accelerator table.
void emitDwarfDebugRangeListFooter(const CompileUnit &Unit, MCSymbol *EndLabel) override
Emit debug ranges(.debug_ranges, .debug_rnglists) footer.
void emitAppleTypes(AccelTable< AppleAccelTableStaticTypeData > &Table) override
Emit Apple type accelerator table.
void emitSectionContents(StringRef SecData, StringRef SecName) override
Emit contents of section SecName From Obj.
void finish()
Dump the file to the disk.
void emitPubNamesForUnit(const CompileUnit &Unit) override
Emit the .debug_pubnames contribution for Unit.
void emitDwarfDebugLocListFragment(const CompileUnit &Unit, const DWARFLocationExpressionsVector &LinkedLocationExpression, PatchLocation Patch) override
Emit debug ranges(.debug_loc, .debug_loclists) fragment.
void emitCIE(StringRef CIEBytes) override
Emit a CIE.
DwarfStreamer(OutputFileType OutFileType, raw_pwrite_stream &OutFile, std::function< StringRef(StringRef Input)> Translator, messageHandler Error, messageHandler Warning)
void emitDIE(DIE &Die) override
Recursively emit the DIE tree rooted at Die.
AsmPrinter & getAsmPrinter() const
void emitDwarfDebugLocListFooter(const CompileUnit &Unit, MCSymbol *EndLabel) override
Emit debug ranges(.debug_loc, .debug_loclists) footer.
uint64_t getLineSectionSize() const override
Returns size of generated .debug_line section.
void emitLineStrings(const NonRelocatableStringpool &Pool) override
Emit the string table described by Pool into .debug_line_str table.
void emitCompileUnitHeader(CompileUnit &Unit, unsigned DwarfVersion) override
Emit the compilation unit header for Unit in the debug_info section.
MCSymbol * emitDwarfDebugLocListHeader(const CompileUnit &Unit) override
Emit debug locations(.debug_loc, .debug_loclists) header.
uint64_t getDebugMacInfoSectionSize() const override
Returns size of generated .debug_macinfo section.
void emitPubTypesForUnit(const CompileUnit &Unit) override
Emit the .debug_pubtypes contribution for Unit.
void emitLineTableForUnit(const DWARFDebugLine::LineTable &LineTable, const CompileUnit &Unit, OffsetsStringPool &DebugStrPool, OffsetsStringPool &DebugLineStrPool) override
Emit .debug_line table entry for specified LineTable.
uint64_t getRngListsSectionSize() const override
Returns size of generated .debug_rnglists section.
void emitAbbrevs(const std::vector< std::unique_ptr< DIEAbbrev > > &Abbrevs, unsigned DwarfVersion) override
Emit the abbreviation table Abbrevs to the debug_abbrev section.
void emitSwiftReflectionSection(llvm::binaryformat::Swift5ReflectionSectionKind ReflSectionKind, StringRef Buffer, uint32_t Alignment, uint32_t Size)
Emit the swift reflection section stored in Buffer.
MCSymbol * emitDwarfDebugRangeListHeader(const CompileUnit &Unit) override
Emit debug ranges(.debug_ranges, .debug_rnglists) header.
uint64_t getRangesSectionSize() const override
Returns size of generated .debug_ranges section.
void emitSwiftAST(StringRef Buffer)
Emit the swift_ast section stored in Buffer.
bool init(Triple TheTriple, StringRef Swift5ReflectionSegmentName)
void switchToDebugInfoSection(unsigned DwarfVersion)
Set the current output section to debug_info and change the MC Dwarf version to DwarfVersion.
void emitDebugNames(AccelTable< DWARF5AccelTableStaticData > &Table) override
Emit DWARF debug names.
void emitFDE(uint32_t CIEOffset, uint32_t AddreSize, uint64_t Address, StringRef Bytes) override
Emit an FDE with data Bytes.
Lightweight error class with error context and mandatory checking.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
A string table that doesn't need relocations.
StringRef - Represent a constant reference to a string, i.e.
Helper for making strong types.
Triple - Helper class for working with autoconf configuration names.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
An abstract base class for streams implementations that also support a pwrite operation.
DwarfFormat
Constants that define the DWARF format as 32 or 64 bit.
This is an optimization pass for GlobalISel generic memory operations.
std::function< void(const Twine &Warning, StringRef Context, const DWARFDie *DIE)> messageHandler
std::vector< DWARFLocationExpression > DWARFLocationExpressionsVector
Represents a set of absolute location expressions.
StrongType< NonRelocatableStringpool, OffsetsTag > OffsetsStringPool
DenseMap< uint64_t, CompileUnit * > Offset2UnitMap