LLVM  14.0.0git
Classes | Public Member Functions | List of all members
llvm::DwarfStreamer Class Reference

The Dwarf streaming logic. More...

#include "llvm/DWARFLinker/DWARFStreamer.h"

Inheritance diagram for llvm::DwarfStreamer:
Inheritance graph
[legend]
Collaboration diagram for llvm::DwarfStreamer:
Collaboration graph
[legend]

Public Member Functions

 DwarfStreamer (OutputFileType OutFileType, raw_pwrite_stream &OutFile, std::function< StringRef(StringRef Input)> Translator, messageHandler Error, messageHandler Warning)
 
bool init (Triple TheTriple)
 
void finish ()
 Dump the file to the disk. More...
 
AsmPrintergetAsmPrinter () const
 
void switchToDebugInfoSection (unsigned DwarfVersion)
 Set the current output section to debug_info and change the MC Dwarf version to DwarfVersion. More...
 
void emitCompileUnitHeader (CompileUnit &Unit, unsigned DwarfVersion) override
 Emit the compilation unit header for Unit in the debug_info section. More...
 
void emitDIE (DIE &Die) override
 Recursively emit the DIE tree rooted at Die. More...
 
void emitAbbrevs (const std::vector< std::unique_ptr< DIEAbbrev >> &Abbrevs, unsigned DwarfVersion) override
 Emit the abbreviation table Abbrevs to the debug_abbrev section. More...
 
void emitPaperTrailWarningsDie (DIE &Die) override
 Emit DIE containing warnings. More...
 
void emitSectionContents (StringRef SecData, StringRef SecName) override
 Emit contents of section SecName From Obj. More...
 
void emitStrings (const NonRelocatableStringpool &Pool) override
 Emit the string table described by Pool. More...
 
void emitSwiftAST (StringRef Buffer)
 Emit the swift_ast section stored in Buffer. More...
 
void emitRangesEntries (int64_t UnitPcOffset, uint64_t OrigLowPc, const FunctionIntervals::const_iterator &FuncRange, const std::vector< DWARFDebugRangeList::RangeListEntry > &Entries, unsigned AddressSize) override
 Emit debug_ranges for FuncRange by translating the original Entries. More...
 
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. More...
 
uint64_t getRangesSectionSize () const override
 Returns size of generated .debug_ranges section. More...
 
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. More...
 
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. More...
 
void translateLineTable (DataExtractor LineData, uint64_t Offset) override
 Copy the debug_line over to the updated binary while unobfuscating the file names and directories. More...
 
uint64_t getLineSectionSize () const override
 Returns size of generated .debug_line section. More...
 
void emitPubNamesForUnit (const CompileUnit &Unit) override
 Emit the .debug_pubnames contribution for Unit. More...
 
void emitPubTypesForUnit (const CompileUnit &Unit) override
 Emit the .debug_pubtypes contribution for Unit. More...
 
void emitCIE (StringRef CIEBytes) override
 Emit a CIE. More...
 
void emitFDE (uint32_t CIEOffset, uint32_t AddreSize, uint32_t Address, StringRef Bytes) override
 Emit an FDE with data Bytes. More...
 
void emitDebugNames (AccelTable< DWARF5AccelTableStaticData > &Table) override
 Emit DWARF debug names. More...
 
void emitAppleNamespaces (AccelTable< AppleAccelTableStaticOffsetData > &Table) override
 Emit Apple namespaces accelerator table. More...
 
void emitAppleNames (AccelTable< AppleAccelTableStaticOffsetData > &Table) override
 Emit Apple names accelerator table. More...
 
void emitAppleObjc (AccelTable< AppleAccelTableStaticOffsetData > &Table) override
 Emit Apple Objective-C accelerator table. More...
 
void emitAppleTypes (AccelTable< AppleAccelTableStaticTypeData > &Table) override
 Emit Apple type accelerator table. More...
 
uint64_t getFrameSectionSize () const override
 Returns size of generated .debug_frame section. More...
 
uint64_t getDebugInfoSectionSize () const override
 Returns size of generated .debug_info section. More...
 
- Public Member Functions inherited from llvm::DwarfEmitter
virtual ~DwarfEmitter ()
 

Detailed Description

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 43 of file DWARFStreamer.h.

Constructor & Destructor Documentation

◆ DwarfStreamer()

llvm::DwarfStreamer::DwarfStreamer ( OutputFileType  OutFileType,
raw_pwrite_stream OutFile,
std::function< StringRef(StringRef Input)>  Translator,
messageHandler  Error,
messageHandler  Warning 
)
inline

Definition at line 45 of file DWARFStreamer.h.

References llvm::Warning.

Member Function Documentation

◆ emitAbbrevs()

void llvm::DwarfStreamer::emitAbbrevs ( const std::vector< std::unique_ptr< DIEAbbrev >> &  Abbrevs,
unsigned  DwarfVersion 
)
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 173 of file DWARFStreamer.cpp.

References llvm::MCStreamer::SwitchSection().

◆ emitAppleNames()

void llvm::DwarfStreamer::emitAppleNames ( AccelTable< AppleAccelTableStaticOffsetData > &  Table)
overridevirtual

Emit Apple names accelerator table.

Implements llvm::DwarfEmitter.

Definition at line 273 of file DWARFStreamer.cpp.

References llvm::emitAppleAccelTable().

◆ emitAppleNamespaces()

void llvm::DwarfStreamer::emitAppleNamespaces ( AccelTable< AppleAccelTableStaticOffsetData > &  Table)
overridevirtual

Emit Apple namespaces accelerator table.

Implements llvm::DwarfEmitter.

Definition at line 265 of file DWARFStreamer.cpp.

References llvm::emitAppleAccelTable().

◆ emitAppleObjc()

void llvm::DwarfStreamer::emitAppleObjc ( AccelTable< AppleAccelTableStaticOffsetData > &  Table)
overridevirtual

Emit Apple Objective-C accelerator table.

Implements llvm::DwarfEmitter.

Definition at line 281 of file DWARFStreamer.cpp.

References llvm::emitAppleAccelTable().

◆ emitAppleTypes()

void llvm::DwarfStreamer::emitAppleTypes ( AccelTable< AppleAccelTableStaticTypeData > &  Table)
overridevirtual

Emit Apple type accelerator table.

Implements llvm::DwarfEmitter.

Definition at line 289 of file DWARFStreamer.cpp.

References llvm::emitAppleAccelTable().

◆ emitCIE()

void llvm::DwarfStreamer::emitCIE ( StringRef  CIEBytes)
overridevirtual

Emit a CIE.

Emit a CIE into the debug_frame section.

Implements llvm::DwarfEmitter.

Definition at line 775 of file DWARFStreamer.cpp.

References llvm::MCStreamer::emitBytes(), llvm::StringRef::size(), and llvm::MCStreamer::SwitchSection().

◆ emitCompileUnitHeader()

void llvm::DwarfStreamer::emitCompileUnitHeader ( CompileUnit Unit,
unsigned  DwarfVersion 
)
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 138 of file DWARFStreamer.cpp.

References switchToDebugInfoSection().

◆ emitDebugNames()

void llvm::DwarfStreamer::emitDebugNames ( AccelTable< DWARF5AccelTableStaticData > &  Table)
overridevirtual

Emit DWARF debug names.

Implements llvm::DwarfEmitter.

Definition at line 242 of file DWARFStreamer.cpp.

References llvm::emitDWARF5AccelTable().

◆ emitDIE()

void llvm::DwarfStreamer::emitDIE ( DIE Die)
overridevirtual

Recursively emit the DIE tree rooted at Die.

Implements llvm::DwarfEmitter.

Definition at line 182 of file DWARFStreamer.cpp.

References llvm::DIE::getSize(), and llvm::MCStreamer::SwitchSection().

Referenced by emitPaperTrailWarningsDie().

◆ emitFDE()

void llvm::DwarfStreamer::emitFDE ( uint32_t  CIEOffset,
uint32_t  AddrSize,
uint32_t  Address,
StringRef  FDEBytes 
)
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 785 of file DWARFStreamer.cpp.

References llvm::Address, llvm::MCStreamer::emitBytes(), llvm::MCStreamer::emitIntValue(), llvm::StringRef::size(), and llvm::MCStreamer::SwitchSection().

◆ emitLineTableForUnit()

void llvm::DwarfStreamer::emitLineTableForUnit ( MCDwarfLineTableParams  Params,
StringRef  PrologueBytes,
unsigned  MinInstLength,
std::vector< DWARFDebugLine::Row > &  Rows,
unsigned  AdddressSize 
)
overridevirtual

◆ emitLocationsForUnit()

void llvm::DwarfStreamer::emitLocationsForUnit ( const CompileUnit Unit,
DWARFContext Dwarf,
std::function< void(StringRef, SmallVectorImpl< uint8_t > &)>  ProcessExpr 
)
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 428 of file DWARFStreamer.cpp.

References Attributes, llvm::DWARFSection::Data, llvm::Data, llvm::Dwarf, llvm::DWARFUnit::getUnitDIE(), High, llvm::max(), Offset, llvm::SmallVectorImpl< T >::reserve(), llvm::SmallVectorImpl< T >::resize(), llvm::StringRef::substr(), llvm::MCStreamer::SwitchSection(), and llvm::dwarf::toAddress().

◆ emitPaperTrailWarningsDie()

void llvm::DwarfStreamer::emitPaperTrailWarningsDie ( DIE Die)
overridevirtual

Emit DIE containing warnings.

Implements llvm::DwarfEmitter.

Definition at line 209 of file DWARFStreamer.cpp.

References emitDIE(), getAsmPrinter(), llvm::DIE::getSize(), and switchToDebugInfoSection().

◆ emitPubNamesForUnit()

void llvm::DwarfStreamer::emitPubNamesForUnit ( const CompileUnit Unit)
overridevirtual

Emit the .debug_pubnames contribution for Unit.

Emit .debug_pubnames for Unit.

Implements llvm::DwarfEmitter.

Definition at line 763 of file DWARFStreamer.cpp.

◆ emitPubTypesForUnit()

void llvm::DwarfStreamer::emitPubTypesForUnit ( const CompileUnit Unit)
overridevirtual

Emit the .debug_pubtypes contribution for Unit.

Emit .debug_pubtypes for Unit.

Implements llvm::DwarfEmitter.

Definition at line 769 of file DWARFStreamer.cpp.

◆ emitRangesEntries()

void llvm::DwarfStreamer::emitRangesEntries ( int64_t  UnitPcOffset,
uint64_t  OrigLowPc,
const FunctionIntervals::const_iterator FuncRange,
const std::vector< DWARFDebugRangeList::RangeListEntry > &  Entries,
unsigned  AddressSize 
)
overridevirtual

Emit debug_ranges for FuncRange by translating the original Entries.

Emit the debug_range section contents for FuncRange by translating the original Entries.

The debug_range section format is totally trivial, consisting just of pairs of address sized addresses describing the ranges.

Implements llvm::DwarfEmitter.

Definition at line 309 of file DWARFStreamer.cpp.

◆ emitSectionContents()

void llvm::DwarfStreamer::emitSectionContents ( StringRef  SecData,
StringRef  SecName 
)
overridevirtual

◆ emitStrings()

void llvm::DwarfStreamer::emitStrings ( const NonRelocatableStringpool Pool)
overridevirtual

Emit the string table described by Pool.

Emit the debug_str section stored in Pool.

Implements llvm::DwarfEmitter.

Definition at line 221 of file DWARFStreamer.cpp.

◆ emitSwiftAST()

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 298 of file DWARFStreamer.cpp.

References Align, llvm::MCStreamer::emitBytes(), llvm::MCSection::setAlignment(), and llvm::MCStreamer::SwitchSection().

◆ emitUnitRangesEntries()

void llvm::DwarfStreamer::emitUnitRangesEntries ( CompileUnit Unit,
bool  DoDebugRanges 
)
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 348 of file DWARFStreamer.cpp.

◆ finish()

void llvm::DwarfStreamer::finish ( )

Dump the file to the disk.

Definition at line 115 of file DWARFStreamer.cpp.

References llvm::MCStreamer::Finish().

◆ getAsmPrinter()

AsmPrinter& llvm::DwarfStreamer::getAsmPrinter ( ) const
inline

Definition at line 56 of file DWARFStreamer.h.

Referenced by emitPaperTrailWarningsDie().

◆ getDebugInfoSectionSize()

uint64_t llvm::DwarfStreamer::getDebugInfoSectionSize ( ) const
inlineoverridevirtual

Returns size of generated .debug_info section.

Implements llvm::DwarfEmitter.

Definition at line 157 of file DWARFStreamer.h.

◆ getFrameSectionSize()

uint64_t llvm::DwarfStreamer::getFrameSectionSize ( ) const
inlineoverridevirtual

Returns size of generated .debug_frame section.

Implements llvm::DwarfEmitter.

Definition at line 155 of file DWARFStreamer.h.

◆ getLineSectionSize()

uint64_t llvm::DwarfStreamer::getLineSectionSize ( ) const
inlineoverridevirtual

Returns size of generated .debug_line section.

Implements llvm::DwarfEmitter.

Definition at line 121 of file DWARFStreamer.h.

◆ getRangesSectionSize()

uint64_t llvm::DwarfStreamer::getRangesSectionSize ( ) const
inlineoverridevirtual

Returns size of generated .debug_ranges section.

Implements llvm::DwarfEmitter.

Definition at line 101 of file DWARFStreamer.h.

◆ init()

bool llvm::DwarfStreamer::init ( Triple  TheTriple)

◆ switchToDebugInfoSection()

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 117 of file DWARFStreamer.cpp.

References llvm::MCStreamer::SwitchSection().

Referenced by emitCompileUnitHeader(), and emitPaperTrailWarningsDie().

◆ translateLineTable()

void llvm::DwarfStreamer::translateLineTable ( DataExtractor  LineData,
uint64_t  Offset 
)
overridevirtual

Copy the debug_line over to the updated binary while unobfuscating the file names and directories.

Implements llvm::DwarfEmitter.

Definition at line 640 of file DWARFStreamer.cpp.

References llvm::Data, File, Offset, llvm::StringRef::size(), llvm::StringRef::slice(), llvm::MCStreamer::SwitchSection(), and Version.


The documentation for this class was generated from the following files: