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;
118 StringRef PrologueBytes,
unsigned MinInstLength,
119 std::vector<DWARFDebugLine::Row> &Rows,
120 unsigned AdddressSize)
override;
163 return DebugInfoSectionSize;
167 return MacInfoSectionSize;
171 return MacroSectionSize;
181 ErrorHandler(
Error, Context,
nullptr);
184 inline void warn(
const Twine &
Warning, StringRef Context =
"") {
186 WarningHandler(
Warning, Context,
nullptr);
189 void emitMacroTableImpl(
const DWARFDebugMacro *MacroTable,
192 void emitDwarfDebugArangesTable(
const CompileUnit &Unit,
193 const AddressRanges &LinkedRanges);
197 std::unique_ptr<MCRegisterInfo> MRI;
198 std::unique_ptr<MCAsmInfo> MAI;
199 std::unique_ptr<MCObjectFileInfo> MOFI;
200 std::unique_ptr<MCContext> MC;
202 std::unique_ptr<MCInstrInfo> MII;
203 std::unique_ptr<MCSubtargetInfo> MSTI;
207 std::unique_ptr<TargetMachine> TM;
208 std::unique_ptr<AsmPrinter> Asm;
212 raw_pwrite_stream &OutFile;
214 std::function<StringRef(StringRef Input)> Translator;
229 std::vector<EmittedUnit> EmittedUnits;
233 void emitPubSectionForUnit(MCSection *Sec, StringRef
Name,
234 const CompileUnit &Unit,
235 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.
void emitAppleNames(AccelTable< AppleAccelTableStaticOffsetData > &Table) override
Emit Apple names accelerator table.
void emitPaperTrailWarningsDie(DIE &Die) override
Emit DIE containing warnings.
uint64_t getDebugInfoSectionSize() const override
Returns size of generated .debug_info section.
void emitAppleObjc(AccelTable< AppleAccelTableStaticOffsetData > &Table) override
Emit Apple Objective-C accelerator table.
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 translateLineTable(DataExtractor LineData, uint64_t Offset) override
Copy the debug_line over to the updated binary while unobfuscating the file names and directories.
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
uint64_t getLineSectionSize() const override
Returns size of generated .debug_line section.
void emitCompileUnitHeader(CompileUnit &Unit, unsigned DwarfVersion) override
Emit the compilation unit header for Unit in the debug_info section.
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 emitLocationsForUnit(const CompileUnit &Unit, DWARFContext &Dwarf, std::function< void(StringRef, SmallVectorImpl< uint8_t > &)> ProcessExpr) override
Emit the debug_loc contribution for Unit by copying the entries from Dwarf and offsetting them.
void emitAbbrevs(const std::vector< std::unique_ptr< DIEAbbrev > > &Abbrevs, unsigned DwarfVersion) override
Emit the abbreviation table Abbrevs to the debug_abbrev section.
virtual void emitDwarfDebugRangesTableFragment(const CompileUnit &Unit, const AddressRanges &LinkedRanges) override
Emit piece of .debug_ranges for Ranges.
void emitUnitRangesEntries(CompileUnit &Unit, bool DoRangesSection) override
Emit debug_aranges entries for Unit and if DoRangesSection is true, also emit the debug_ranges entrie...
void emitSwiftReflectionSection(llvm::binaryformat::Swift5ReflectionSectionKind ReflSectionKind, StringRef Buffer, uint32_t Alignment, uint32_t Size)
Emit the swift reflection section stored in Buffer.
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 emitLineTableForUnit(MCDwarfLineTableParams Params, StringRef PrologueBytes, unsigned MinInstLength, std::vector< DWARFDebugLine::Row > &Rows, unsigned AdddressSize) override
Emit the line table described in Rows into the debug_line section.
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.
A string table that doesn't need relocations.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
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.
This is an optimization pass for GlobalISel generic memory operations.
std::function< void(const Twine &Warning, StringRef Context, const DWARFDie *DIE)> messageHandler
@ Dwarf
DWARF v5 .debug_names.
StrongType< NonRelocatableStringpool, OffsetsTag > OffsetsStringPool
DenseMap< uint64_t, CompileUnit * > Offset2UnitMap