LLVM 17.0.0git
|
The Dwarf streaming logic. More...
#include "llvm/DWARFLinker/DWARFStreamer.h"
Public Member Functions | |
DwarfStreamer (OutputFileType OutFileType, raw_pwrite_stream &OutFile, std::function< StringRef(StringRef Input)> Translator, messageHandler Error, messageHandler Warning) | |
bool | init (Triple TheTriple, StringRef Swift5ReflectionSegmentName) |
void | finish () |
Dump the file to the disk. | |
AsmPrinter & | getAsmPrinter () const |
void | switchToDebugInfoSection (unsigned DwarfVersion) |
Set the current output section to debug_info and change the MC Dwarf version to DwarfVersion . | |
void | emitCompileUnitHeader (CompileUnit &Unit, unsigned DwarfVersion) override |
Emit the compilation unit header for Unit in the debug_info section. | |
void | emitDIE (DIE &Die) override |
Recursively emit the DIE tree rooted at Die . | |
void | emitAbbrevs (const std::vector< std::unique_ptr< DIEAbbrev > > &Abbrevs, unsigned DwarfVersion) override |
Emit the abbreviation table Abbrevs to the debug_abbrev section. | |
void | emitPaperTrailWarningsDie (DIE &Die) override |
Emit DIE containing warnings. | |
void | emitSectionContents (StringRef SecData, StringRef SecName) override |
Emit contents of section SecName From Obj. | |
void | emitStrings (const NonRelocatableStringpool &Pool) override |
Emit the string table described by Pool . | |
void | emitSwiftAST (StringRef Buffer) |
Emit the swift_ast section stored in Buffer . | |
void | emitSwiftReflectionSection (llvm::binaryformat::Swift5ReflectionSectionKind ReflSectionKind, StringRef Buffer, uint32_t Alignment, uint32_t Size) |
Emit the swift reflection section stored in Buffer . | |
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 entries for the DW_TAG_compile_unit's DW_AT_ranges attribute. | |
uint64_t | getRangesSectionSize () const override |
Returns size of generated .debug_ranges section. | |
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 | 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 | translateLineTable (DataExtractor LineData, uint64_t Offset) override |
Copy the debug_line over to the updated binary while unobfuscating the file names and directories. | |
uint64_t | getLineSectionSize () const override |
Returns size of generated .debug_line section. | |
void | emitPubNamesForUnit (const CompileUnit &Unit) override |
Emit the .debug_pubnames contribution for Unit . | |
void | emitPubTypesForUnit (const CompileUnit &Unit) override |
Emit the .debug_pubtypes contribution for Unit . | |
void | emitCIE (StringRef CIEBytes) override |
Emit a CIE. | |
void | emitFDE (uint32_t CIEOffset, uint32_t AddreSize, uint64_t Address, StringRef Bytes) override |
Emit an FDE with data Bytes . | |
void | emitDebugNames (AccelTable< DWARF5AccelTableStaticData > &Table) override |
Emit DWARF debug names. | |
void | emitAppleNamespaces (AccelTable< AppleAccelTableStaticOffsetData > &Table) override |
Emit Apple namespaces accelerator table. | |
void | emitAppleNames (AccelTable< AppleAccelTableStaticOffsetData > &Table) override |
Emit Apple names accelerator table. | |
void | emitAppleObjc (AccelTable< AppleAccelTableStaticOffsetData > &Table) override |
Emit Apple Objective-C accelerator table. | |
void | emitAppleTypes (AccelTable< AppleAccelTableStaticTypeData > &Table) override |
Emit Apple type accelerator table. | |
uint64_t | getFrameSectionSize () const override |
Returns size of generated .debug_frame section. | |
uint64_t | getDebugInfoSectionSize () const override |
Returns size of generated .debug_info section. | |
uint64_t | getDebugMacInfoSectionSize () const override |
Returns size of generated .debug_macinfo section. | |
uint64_t | getDebugMacroSectionSize () const override |
Returns size of generated .debug_macro section. | |
void | emitMacroTables (DWARFContext *Context, const Offset2UnitMap &UnitMacroMap, OffsetsStringPool &StringPool) override |
Emit all available macro tables(DWARFv4 and DWARFv5). | |
![]() | |
virtual | ~DwarfEmitter () |
virtual void | emitPaperTrailWarningsDie (DIE &Die)=0 |
Emit DIE containing warnings. | |
virtual void | emitSectionContents (StringRef SecData, StringRef SecName)=0 |
Emit section named SecName with data SecData. | |
virtual void | emitAbbrevs (const std::vector< std::unique_ptr< DIEAbbrev > > &Abbrevs, unsigned DwarfVersion)=0 |
Emit the abbreviation table Abbrevs to the .debug_abbrev section. | |
virtual void | emitStrings (const NonRelocatableStringpool &Pool)=0 |
Emit the string table described by Pool . | |
virtual void | emitDebugNames (AccelTable< DWARF5AccelTableStaticData > &Table)=0 |
Emit DWARF debug names. | |
virtual void | emitAppleNamespaces (AccelTable< AppleAccelTableStaticOffsetData > &Table)=0 |
Emit Apple namespaces accelerator table. | |
virtual void | emitAppleNames (AccelTable< AppleAccelTableStaticOffsetData > &Table)=0 |
Emit Apple names accelerator table. | |
virtual void | emitAppleObjc (AccelTable< AppleAccelTableStaticOffsetData > &Table)=0 |
Emit Apple Objective-C accelerator table. | |
virtual void | emitAppleTypes (AccelTable< AppleAccelTableStaticTypeData > &Table)=0 |
Emit Apple type accelerator table. | |
virtual void | emitDwarfDebugRangesTableFragment (const CompileUnit &Unit, const AddressRanges &LinkedRanges)=0 |
Emit piece of .debug_ranges for Ranges . | |
virtual void | emitUnitRangesEntries (CompileUnit &Unit, bool DoRangesSection)=0 |
Emit .debug_aranges entries for Unit and if DoRangesSection is true, also emit the .debug_ranges entries for the DW_TAG_compile_unit's DW_AT_ranges attribute. | |
virtual void | translateLineTable (DataExtractor LineData, uint64_t Offset)=0 |
Copy the .debug_line over to the updated binary while unobfuscating the file names and directories. | |
virtual void | emitLineTableForUnit (MCDwarfLineTableParams Params, StringRef PrologueBytes, unsigned MinInstLength, std::vector< DWARFDebugLine::Row > &Rows, unsigned AdddressSize)=0 |
Emit the line table described in Rows into the .debug_line section. | |
virtual void | emitPubNamesForUnit (const CompileUnit &Unit)=0 |
Emit the .debug_pubnames contribution for Unit . | |
virtual void | emitPubTypesForUnit (const CompileUnit &Unit)=0 |
Emit the .debug_pubtypes contribution for Unit . | |
virtual void | emitCIE (StringRef CIEBytes)=0 |
Emit a CIE. | |
virtual void | emitFDE (uint32_t CIEOffset, uint32_t AddreSize, uint64_t Address, StringRef Bytes)=0 |
Emit an FDE with data Bytes . | |
virtual void | emitLocationsForUnit (const CompileUnit &Unit, DWARFContext &Dwarf, std::function< void(StringRef, SmallVectorImpl< uint8_t > &)> ProcessExpr)=0 |
Emit the .debug_loc contribution for Unit by copying the entries from Dwarf and offsetting them. | |
virtual void | emitCompileUnitHeader (CompileUnit &Unit, unsigned DwarfVersion)=0 |
Emit the compilation unit header for Unit in the .debug_info section. | |
virtual void | emitDIE (DIE &Die)=0 |
Recursively emit the DIE tree rooted at Die . | |
virtual void | emitMacroTables (DWARFContext *Context, const Offset2UnitMap &UnitMacroMap, OffsetsStringPool &StringPool)=0 |
Emit all available macro tables(DWARFv4 and DWARFv5). | |
virtual uint64_t | getLineSectionSize () const =0 |
Returns size of generated .debug_line section. | |
virtual uint64_t | getFrameSectionSize () const =0 |
Returns size of generated .debug_frame section. | |
virtual uint64_t | getRangesSectionSize () const =0 |
Returns size of generated .debug_ranges section. | |
virtual uint64_t | getDebugInfoSectionSize () const =0 |
Returns size of generated .debug_info section. | |
virtual uint64_t | getDebugMacInfoSectionSize () const =0 |
Returns size of generated .debug_macinfo section. | |
virtual uint64_t | getDebugMacroSectionSize () const =0 |
Returns size of generated .debug_macro section. | |
The Dwarf streaming logic.
All interactions with the MC layer that is used to build the debug information binary representation are handled in this class.
Definition at line 46 of file DWARFStreamer.h.
|
inline |
Definition at line 48 of file DWARFStreamer.h.
|
overridevirtual |
Emit the abbreviation table Abbrevs
to the debug_abbrev section.
Emit the Abbrevs
array as the shared abbreviation table for the linked Dwarf file.
Implements llvm::DwarfEmitter.
Definition at line 179 of file DWARFStreamer.cpp.
References llvm::MCStreamer::switchSection().
|
overridevirtual |
Emit Apple names accelerator table.
Implements llvm::DwarfEmitter.
Definition at line 279 of file DWARFStreamer.cpp.
References llvm::emitAppleAccelTable().
|
overridevirtual |
Emit Apple namespaces accelerator table.
Implements llvm::DwarfEmitter.
Definition at line 271 of file DWARFStreamer.cpp.
References llvm::emitAppleAccelTable().
|
overridevirtual |
Emit Apple Objective-C accelerator table.
Implements llvm::DwarfEmitter.
Definition at line 287 of file DWARFStreamer.cpp.
References llvm::emitAppleAccelTable().
|
overridevirtual |
Emit Apple type accelerator table.
Implements llvm::DwarfEmitter.
Definition at line 295 of file DWARFStreamer.cpp.
References llvm::emitAppleAccelTable().
|
overridevirtual |
Emit a CIE.
Emit a CIE into the debug_frame section.
Implements llvm::DwarfEmitter.
Definition at line 766 of file DWARFStreamer.cpp.
References llvm::MCStreamer::emitBytes(), llvm::StringRef::size(), and llvm::MCStreamer::switchSection().
|
overridevirtual |
Emit the compilation unit header for Unit
in the debug_info section.
As a side effect, this also switches the current Dwarf version of the MC layer to the one of U.getOrigUnit().
A Dwarf 4 section header is encoded as: uint32_t Unit length (omitting this field) uint16_t Version uint32_t Abbreviation table offset uint8_t Address size Leading to a total of 11 bytes.
A Dwarf 5 section header is encoded as: uint32_t Unit length (omitting this field) uint16_t Version uint8_t Unit type uint8_t Address size uint32_t Abbreviation table offset Leading to a total of 12 bytes.
The start of the unit within its section.
Implements llvm::DwarfEmitter.
Definition at line 144 of file DWARFStreamer.cpp.
References switchToDebugInfoSection().
|
overridevirtual |
Emit DWARF debug names.
Implements llvm::DwarfEmitter.
Definition at line 248 of file DWARFStreamer.cpp.
References llvm::emitDWARF5AccelTable().
|
overridevirtual |
Recursively emit the DIE tree rooted at Die
.
Implements llvm::DwarfEmitter.
Definition at line 188 of file DWARFStreamer.cpp.
References llvm::DIE::getSize(), and llvm::MCStreamer::switchSection().
Referenced by emitPaperTrailWarningsDie().
|
overridevirtual |
Emit piece of .debug_ranges for Ranges
.
Implements llvm::DwarfEmitter.
Definition at line 365 of file DWARFStreamer.cpp.
References llvm::MCStreamer::emitIntValue(), and llvm::MCStreamer::switchSection().
Referenced by emitUnitRangesEntries().
|
overridevirtual |
Emit an FDE with data Bytes
.
Emit a FDE into the debug_frame section.
FDEBytes
contains the FDE data without the length, CIE offset and address which will be replaced with the parameter values.
Implements llvm::DwarfEmitter.
Definition at line 776 of file DWARFStreamer.cpp.
References llvm::Address, llvm::MCStreamer::emitBytes(), llvm::MCStreamer::emitIntValue(), llvm::StringRef::size(), and llvm::MCStreamer::switchSection().
|
overridevirtual |
Emit the line table described in Rows
into the debug_line section.
Implements llvm::DwarfEmitter.
Definition at line 485 of file DWARFStreamer.cpp.
References llvm::Address, llvm::AddressDelta, llvm::MCStreamer::emitBytes(), llvm::MCStreamer::emitIntValue(), llvm::MCStreamer::emitLabel(), llvm::MCStreamer::emitSLEB128IntValue(), llvm::MCStreamer::emitULEB128IntValue(), llvm::MCDwarfLineAddr::Encode(), llvm::getSLEB128Size(), llvm::getULEB128Size(), llvm::SmallVectorImpl< T >::resize(), llvm::SmallVectorBase< Size_T >::size(), llvm::StringRef::size(), llvm::raw_svector_ostream::str(), and llvm::MCStreamer::switchSection().
|
overridevirtual |
Emit the debug_loc contribution for Unit
by copying the entries from Dwarf
and offsetting them.
Emit location lists for Unit
and update attributes to point to the new entries.
Update the location attributes to point to the new entries.
Implements llvm::DwarfEmitter.
Definition at line 418 of file DWARFStreamer.cpp.
References assert(), Attributes, llvm::SmallVectorTemplateCommon< T, typename >::data(), llvm::DWARFSection::Data, llvm::Data, llvm::Dwarf, llvm::DWARFUnit::getUnitDIE(), High, llvm::Length, llvm::Low, llvm::Offset, llvm::SmallVectorImpl< T >::reserve(), llvm::SmallVectorImpl< T >::resize(), llvm::StringRef::substr(), llvm::MCStreamer::switchSection(), and llvm::dwarf::toAddress().
|
overridevirtual |
Emit all available macro tables(DWARFv4 and DWARFv5).
Use UnitMacroMap
to get compilation unit by macro table offset. Side effects: Fill StringPool
with macro strings, update DW_AT_macro_info, DW_AT_macros attributes for corresponding compile units.
Implements llvm::DwarfEmitter.
Definition at line 787 of file DWARFStreamer.cpp.
References assert(), Context, and llvm::MCStreamer::switchSection().
|
overridevirtual |
Emit DIE containing warnings.
Implements llvm::DwarfEmitter.
Definition at line 215 of file DWARFStreamer.cpp.
References emitDIE(), getAsmPrinter(), llvm::DIE::getSize(), and switchToDebugInfoSection().
|
overridevirtual |
Emit the .debug_pubnames contribution for Unit
.
Emit .debug_pubnames for Unit
.
Implements llvm::DwarfEmitter.
Definition at line 754 of file DWARFStreamer.cpp.
|
overridevirtual |
Emit the .debug_pubtypes contribution for Unit
.
Emit .debug_pubtypes for Unit
.
Implements llvm::DwarfEmitter.
Definition at line 760 of file DWARFStreamer.cpp.
|
overridevirtual |
Emit contents of section SecName From Obj.
Implements llvm::DwarfEmitter.
Definition at line 195 of file DWARFStreamer.cpp.
References llvm::StringSwitch< T, R >::Case(), llvm::StringSwitch< T, R >::Default(), llvm::MCStreamer::emitBytes(), and llvm::MCStreamer::switchSection().
|
overridevirtual |
Emit the string table described by Pool
.
Emit the debug_str section stored in Pool
.
Implements llvm::DwarfEmitter.
Definition at line 227 of file DWARFStreamer.cpp.
References llvm::NonRelocatableStringpool::getEntriesForEmission().
void llvm::DwarfStreamer::emitSwiftAST | ( | StringRef | Buffer | ) |
Emit the swift_ast section stored in Buffer
.
Emit the swift_ast section stored in Buffers
.
Definition at line 304 of file DWARFStreamer.cpp.
References llvm::MCStreamer::emitBytes(), llvm::MCSection::setAlignment(), and llvm::MCStreamer::switchSection().
void llvm::DwarfStreamer::emitSwiftReflectionSection | ( | llvm::binaryformat::Swift5ReflectionSectionKind | ReflSectionKind, |
StringRef | Buffer, | ||
uint32_t | Alignment, | ||
uint32_t | Size | ||
) |
Emit the swift reflection section stored in Buffer
.
Definition at line 311 of file DWARFStreamer.cpp.
References llvm::MCStreamer::emitBytes(), llvm::MCSection::setAlignment(), and llvm::MCStreamer::switchSection().
|
overridevirtual |
Emit debug_aranges entries for Unit
and if DoRangesSection
is true, also emit the debug_ranges entries for the DW_TAG_compile_unit's DW_AT_ranges attribute.
Emit the debug_aranges contribution of a unit and if DoDebugRanges
is true the debug_range contents for a compile_unit level DW_AT_ranges attribute (Which are basically the same thing with a different base address).
Just aggregate all the ranges gathered inside that unit.
Implements llvm::DwarfEmitter.
Definition at line 398 of file DWARFStreamer.cpp.
References emitDwarfDebugRangesTableFragment(), llvm::AddressRangesBase< T >::empty(), and llvm::AddressRanges::insert().
void llvm::DwarfStreamer::finish | ( | ) |
Dump the file to the disk.
Definition at line 121 of file DWARFStreamer.cpp.
References llvm::MCStreamer::finish().
|
inline |
Definition at line 59 of file DWARFStreamer.h.
Referenced by emitPaperTrailWarningsDie().
|
inlineoverridevirtual |
Returns size of generated .debug_info section.
Implements llvm::DwarfEmitter.
Definition at line 162 of file DWARFStreamer.h.
|
inlineoverridevirtual |
Returns size of generated .debug_macinfo section.
Implements llvm::DwarfEmitter.
Definition at line 166 of file DWARFStreamer.h.
|
inlineoverridevirtual |
Returns size of generated .debug_macro section.
Implements llvm::DwarfEmitter.
Definition at line 170 of file DWARFStreamer.h.
|
inlineoverridevirtual |
Returns size of generated .debug_frame section.
Implements llvm::DwarfEmitter.
Definition at line 160 of file DWARFStreamer.h.
|
inlineoverridevirtual |
Returns size of generated .debug_line section.
Implements llvm::DwarfEmitter.
Definition at line 126 of file DWARFStreamer.h.
|
inlineoverridevirtual |
Returns size of generated .debug_ranges section.
Implements llvm::DwarfEmitter.
Definition at line 106 of file DWARFStreamer.h.
Definition at line 31 of file DWARFStreamer.cpp.
References llvm::Assembly, Context, llvm::Target::createAsmPrinter(), llvm::Target::createAsmStreamer(), llvm::Target::createMCAsmBackend(), llvm::Target::createMCAsmInfo(), llvm::Target::createMCCodeEmitter(), llvm::Target::createMCInstPrinter(), llvm::Target::createMCInstrInfo(), llvm::Target::createMCObjectFileInfo(), llvm::Target::createMCObjectStreamer(), llvm::Target::createMCRegInfo(), llvm::Target::createMCSubtargetInfo(), llvm::MCAsmBackend::createObjectWriter(), llvm::Target::createTargetMachine(), error, llvm::Triple::getTriple(), llvm::mc::InitMCTargetOptionsFromFlags(), llvm::TargetRegistry::lookupTarget(), llvm::MCTargetOptions::MCIncrementalLinkerCompatible, llvm::MCTargetOptions::MCRelaxAll, and llvm::Object.
void llvm::DwarfStreamer::switchToDebugInfoSection | ( | unsigned | DwarfVersion | ) |
Set the current output section to debug_info and change the MC Dwarf version to DwarfVersion
.
Definition at line 123 of file DWARFStreamer.cpp.
References llvm::MCStreamer::switchSection().
Referenced by emitCompileUnitHeader(), and emitPaperTrailWarningsDie().
|
overridevirtual |
Copy the debug_line over to the updated binary while unobfuscating the file names and directories.
Implements llvm::DwarfEmitter.
Definition at line 631 of file DWARFStreamer.cpp.
References llvm::Data, llvm::Offset, llvm::StringRef::size(), llvm::StringRef::slice(), and llvm::MCStreamer::switchSection().