class DwarfStreamer

Declaration

class DwarfStreamer : public DwarfEmitter { /* full declaration omitted */ };

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.

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:45

Inherits from: DwarfEmitter

Member Variables

private std::unique_ptr<MCRegisterInfo> MRI
@ {
private std::unique_ptr<MCAsmInfo> MAI
private std::unique_ptr<MCObjectFileInfo> MOFI
private std::unique_ptr<MCContext> MC
private llvm::MCAsmBackend* MAB
private std::unique_ptr<MCInstrInfo> MII
private std::unique_ptr<MCSubtargetInfo> MSTI
private llvm::MCInstPrinter* MIP
private llvm::MCCodeEmitter* MCE
private llvm::MCStreamer* MS
private std::unique_ptr<TargetMachine> TM
private std::unique_ptr<AsmPrinter> Asm
private llvm::raw_pwrite_stream& OutFile
The output file we stream the linked Dwarf to.
private llvm::OutputFileType OutFileType = OutputFileType::Object
private std::function<StringRef(StringRef)> Translator
private uint64_t RangesSectionSize = 0
private uint64_t LocSectionSize = 0
private uint64_t LineSectionSize = 0
private uint64_t FrameSectionSize = 0
private uint64_t DebugInfoSectionSize = 0
private std::vector<EmittedUnit> EmittedUnits
private llvm::messageHandler ErrorHandler = nullptr
private llvm::messageHandler WarningHandler = nullptr

Method Overview

  • public DwarfStreamer(llvm::OutputFileType OutFileType, llvm::raw_pwrite_stream & OutFile, std::function<StringRef (StringRef)> Translator, llvm::messageHandler Error, llvm::messageHandler Warning)
  • public void emitAbbrevs(const std::vector<std::unique_ptr<DIEAbbrev>> & Abbrevs, unsigned int DwarfVersion)
  • public void emitAppleNames(AccelTable<llvm::AppleAccelTableStaticOffsetData> & Table)
  • public void emitAppleNamespaces(AccelTable<llvm::AppleAccelTableStaticOffsetData> & Table)
  • public void emitAppleObjc(AccelTable<llvm::AppleAccelTableStaticOffsetData> & Table)
  • public void emitAppleTypes(AccelTable<llvm::AppleAccelTableStaticTypeData> & Table)
  • public void emitCIE(llvm::StringRef CIEBytes)
  • public void emitCompileUnitHeader(llvm::CompileUnit & Unit, unsigned int DwarfVersion)
  • public void emitDIE(llvm::DIE & Die)
  • public void emitDebugNames(AccelTable<llvm::DWARF5AccelTableStaticData> & Table)
  • public void emitFDE(uint32_t CIEOffset, uint32_t AddreSize, uint32_t Address, llvm::StringRef Bytes)
  • public void emitLineTableForUnit(llvm::MCDwarfLineTableParams Params, llvm::StringRef PrologueBytes, unsigned int MinInstLength, std::vector<DWARFDebugLine::Row> & Rows, unsigned int AdddressSize)
  • public void emitLocationsForUnit(const llvm::CompileUnit & Unit, llvm::DWARFContext & Dwarf, std::function<void (StringRef, SmallVectorImpl<uint8_t> &)> ProcessExpr)
  • public void emitPaperTrailWarningsDie(llvm::DIE & Die)
  • public void emitPubNamesForUnit(const llvm::CompileUnit & Unit)
  • private void emitPubSectionForUnit(llvm::MCSection * Sec, llvm::StringRef Name, const llvm::CompileUnit & Unit, const std::vector<CompileUnit::AccelInfo> & Names)
  • public void emitPubTypesForUnit(const llvm::CompileUnit & Unit)
  • public void emitRangesEntries(int64_t UnitPcOffset, uint64_t OrigLowPc, Optional<std::pair<AddressRange, int64_t>> FuncRange, const std::vector<DWARFDebugRangeList::RangeListEntry> & Entries, unsigned int AddressSize)
  • public void emitSectionContents(llvm::StringRef SecData, llvm::StringRef SecName)
  • public void emitStrings(const llvm::NonRelocatableStringpool & Pool)
  • public void emitSwiftAST(llvm::StringRef Buffer)
  • public void emitSwiftReflectionSection(llvm::binaryformat::Swift5ReflectionSectionKind ReflSectionKind, llvm::StringRef Buffer, uint32_t Alignment, uint32_t Size)
  • public void emitUnitRangesEntries(llvm::CompileUnit & Unit, bool DoRangesSection)
  • private inline void error(const llvm::Twine & Error, llvm::StringRef Context = "")
  • public void finish()
  • public llvm::AsmPrinter & getAsmPrinter() const
  • public uint64_t getDebugInfoSectionSize() const
  • public uint64_t getFrameSectionSize() const
  • public uint64_t getLineSectionSize() const
  • public uint64_t getRangesSectionSize() const
  • public bool init(llvm::Triple TheTriple, llvm::StringRef Swift5ReflectionSegmentName)
  • public void switchToDebugInfoSection(unsigned int DwarfVersion)
  • public void translateLineTable(llvm::DataExtractor LineData, uint64_t Offset)
  • private inline void warn(const llvm::Twine & Warning, llvm::StringRef Context = "")

Inherited from DwarfEmitter:

Methods

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

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:47

Parameters

llvm::OutputFileType OutFileType
llvm::raw_pwrite_stream& OutFile
std::function<StringRef(StringRef)> Translator
llvm::messageHandler Error
llvm::messageHandler Warning

void emitAbbrevs(
    const std::vector<std::unique_ptr<DIEAbbrev>>&
        Abbrevs,
    unsigned int DwarfVersion)

Description

Emit the abbreviation table \p Abbrevs to the debug_abbrev section.

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:75

Parameters

const std::vector<std::unique_ptr<DIEAbbrev>>& Abbrevs
unsigned int DwarfVersion

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

Description

Emit Apple names accelerator table.

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:152

Parameters

AccelTable<llvm::AppleAccelTableStaticOffsetData>& Table

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

Description

Emit Apple namespaces accelerator table.

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:147

Parameters

AccelTable<llvm::AppleAccelTableStaticOffsetData>& Table

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

Description

Emit Apple Objective-C accelerator table.

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:156

Parameters

AccelTable<llvm::AppleAccelTableStaticOffsetData>& Table

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

Description

Emit Apple type accelerator table.

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:160

Parameters

AccelTable<llvm::AppleAccelTableStaticTypeData>& Table

void emitCIE(llvm::StringRef CIEBytes)

Description

Emit a CIE.

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:137

Parameters

llvm::StringRef CIEBytes

void emitCompileUnitHeader(
    llvm::CompileUnit& Unit,
    unsigned int DwarfVersion)

Description

Emit the compilation unit header for \p 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().

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:69

Parameters

llvm::CompileUnit& Unit
unsigned int DwarfVersion

void emitDIE(llvm::DIE& Die)

Description

Recursively emit the DIE tree rooted at \p Die.

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:72

Parameters

llvm::DIE& Die

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

Description

Emit DWARF debug names.

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:144

Parameters

AccelTable<llvm::DWARF5AccelTableStaticData>& Table

void emitFDE(uint32_t CIEOffset,
             uint32_t AddreSize,
             uint32_t Address,
             llvm::StringRef Bytes)

Description

Emit an FDE with data \p Bytes.

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:140

Parameters

uint32_t CIEOffset
uint32_t AddreSize
uint32_t Address
llvm::StringRef Bytes

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

Description

Emit the line table described in \p Rows into the debug_line section.

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:119

Parameters

llvm::MCDwarfLineTableParams Params
llvm::StringRef PrologueBytes
unsigned int MinInstLength
std::vector<DWARFDebugLine::Row>& Rows
unsigned int AdddressSize

void emitLocationsForUnit(
    const llvm::CompileUnit& Unit,
    llvm::DWARFContext& Dwarf,
    std::function<void(StringRef,
                       SmallVectorImpl<uint8_t>&)>
        ProcessExpr)

Description

Emit the debug_loc contribution for \p Unit by copying the entries from\p Dwarf and offsetting them. Update the location attributes to point to the new entries.

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:113

Parameters

const llvm::CompileUnit& Unit
llvm::DWARFContext& Dwarf
std::function<void(StringRef, SmallVectorImpl<uint8_t>&)> ProcessExpr

void emitPaperTrailWarningsDie(llvm::DIE& Die)

Description

Emit DIE containing warnings.

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:79

Parameters

llvm::DIE& Die

void emitPubNamesForUnit(
    const llvm::CompileUnit& Unit)

Description

Emit the .debug_pubnames contribution for \p Unit.

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:131

Parameters

const llvm::CompileUnit& Unit

void emitPubSectionForUnit(
    llvm::MCSection* Sec,
    llvm::StringRef Name,
    const llvm::CompileUnit& Unit,
    const std::vector<CompileUnit::AccelInfo>&
        Names)

Description

Emit the pubnames or pubtypes section contribution for \p Unit into \p Sec. The data is provided in \p Names.

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:215

Parameters

llvm::MCSection* Sec
llvm::StringRef Name
const llvm::CompileUnit& Unit
const std::vector<CompileUnit::AccelInfo>& Names

void emitPubTypesForUnit(
    const llvm::CompileUnit& Unit)

Description

Emit the .debug_pubtypes contribution for \p Unit.

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:134

Parameters

const llvm::CompileUnit& Unit

void emitRangesEntries(
    int64_t UnitPcOffset,
    uint64_t OrigLowPc,
    Optional<std::pair<AddressRange, int64_t>>
        FuncRange,
    const std::vector<
        DWARFDebugRangeList::RangeListEntry>&
        Entries,
    unsigned int AddressSize)

Description

Emit debug_ranges for \p FuncRange by translating the original \p Entries.

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:97

Parameters

int64_t UnitPcOffset
uint64_t OrigLowPc
Optional<std::pair<AddressRange, int64_t>> FuncRange
const std::vector< DWARFDebugRangeList::RangeListEntry>& Entries
unsigned int AddressSize

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

Description

Emit contents of section SecName From Obj.

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:82

Parameters

llvm::StringRef SecData
llvm::StringRef SecName

void emitStrings(
    const llvm::NonRelocatableStringpool& Pool)

Description

Emit the string table described by \p Pool.

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:85

Parameters

const llvm::NonRelocatableStringpool& Pool

void emitSwiftAST(llvm::StringRef Buffer)

Description

Emit the swift_ast section stored in \p Buffer.

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:88

Parameters

llvm::StringRef Buffer

void emitSwiftReflectionSection(
    llvm::binaryformat::
        Swift5ReflectionSectionKind
            ReflSectionKind,
    llvm::StringRef Buffer,
    uint32_t Alignment,
    uint32_t Size)

Description

Emit the swift reflection section stored in \p Buffer.

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:91

Parameters

llvm::binaryformat::Swift5ReflectionSectionKind ReflSectionKind
llvm::StringRef Buffer
uint32_t Alignment
uint32_t Size

void emitUnitRangesEntries(
    llvm::CompileUnit& Unit,
    bool DoRangesSection)

Description

Emit debug_aranges entries for \p Unit and if \p DoRangesSection is true, also emit the debug_ranges entries for the DW_TAG_compile_unit's DW_AT_ranges attribute.

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:106

Parameters

llvm::CompileUnit& Unit
bool DoRangesSection

inline void error(const llvm::Twine& Error,
                  llvm::StringRef Context = "")

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:169

Parameters

const llvm::Twine& Error
llvm::StringRef Context = ""

void finish()

Description

Dump the file to the disk.

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:56

llvm::AsmPrinter& getAsmPrinter() const

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:58

uint64_t getDebugInfoSectionSize() const

Description

Returns size of generated .debug_info section.

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:164

uint64_t getFrameSectionSize() const

Description

Returns size of generated .debug_frame section.

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:162

uint64_t getLineSectionSize() const

Description

Returns size of generated .debug_line section.

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:128

uint64_t getRangesSectionSize() const

Description

Returns size of generated .debug_ranges section.

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:108

bool init(
    llvm::Triple TheTriple,
    llvm::StringRef Swift5ReflectionSegmentName)

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:53

Parameters

llvm::Triple TheTriple
llvm::StringRef Swift5ReflectionSegmentName

void switchToDebugInfoSection(
    unsigned int DwarfVersion)

Description

Set the current output section to debug_info and change the MC Dwarf version to \p DwarfVersion.

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:62

Parameters

unsigned int DwarfVersion

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

Description

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

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:126

Parameters

llvm::DataExtractor LineData
uint64_t Offset

inline void warn(const llvm::Twine& Warning,
                 llvm::StringRef Context = "")

Declared at: llvm/include/llvm/DWARFLinker/DWARFStreamer.h:174

Parameters

const llvm::Twine& Warning
llvm::StringRef Context = ""