class DWARFVerifier

Declaration

class DWARFVerifier { /* full declaration omitted */ };

Description

A class that verifies DWARF debug information given a DWARF Context.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:35

Member Variables

private llvm::raw_ostream& OS
private llvm::DWARFContext& DCtx
private llvm::DIDumpOptions DumpOpts
private uint32_t NumDebugLineErrors = 0
private bool IsObjectFile
private bool IsMachOObject

Method Overview

  • public DWARFVerifier(llvm::raw_ostream & S, llvm::DWARFContext & D, llvm::DIDumpOptions DumpOpts = DIDumpOptions::getForSingleDIE())
  • private llvm::raw_ostream & dump(const llvm::DWARFDie & Die, unsigned int indent = 0) const
  • private llvm::raw_ostream & error() const
  • public bool handleAccelTables()
  • public bool handleDebugAbbrev()
  • public bool handleDebugCUIndex()
  • public bool handleDebugInfo()
  • public bool handleDebugLine()
  • public bool handleDebugTUIndex()
  • private llvm::raw_ostream & note() const
  • private unsigned int verifyAbbrevSection(const llvm::DWARFDebugAbbrev * Abbrev)
  • private unsigned int verifyAppleAccelTable(const llvm::DWARFSection * AccelSection, llvm::DataExtractor * StrData, const char * SectionName)
  • private unsigned int verifyDebugInfoAttribute(const llvm::DWARFDie & Die, llvm::DWARFAttribute & AttrValue)
  • private unsigned int verifyDebugInfoCallSite(const llvm::DWARFDie & Die)
  • private unsigned int verifyDebugInfoForm(const llvm::DWARFDie & Die, llvm::DWARFAttribute & AttrValue, llvm::DWARFVerifier::ReferenceMap & UnitLocalReferences, llvm::DWARFVerifier::ReferenceMap & CrossUnitReferences)
  • private unsigned int verifyDebugInfoReferences(const llvm::DWARFVerifier::ReferenceMap &, llvm::function_ref<DWARFUnit *(uint64_t)> GetUnitForDieOffset)
  • private void verifyDebugLineRows()
  • private void verifyDebugLineStmtOffsets()
  • private unsigned int verifyDebugNames(const llvm::DWARFSection & AccelSection, const llvm::DataExtractor & StrData)
  • private unsigned int verifyDebugNamesCULists(const llvm::DWARFDebugNames & AccelTable)
  • private unsigned int verifyDieRanges(const llvm::DWARFDie & Die, llvm::DWARFVerifier::DieRangeInfo & ParentRI)
  • private unsigned int verifyIndex(llvm::StringRef Name, llvm::DWARFSectionKind SectionKind, llvm::StringRef Index)
  • private unsigned int verifyIndexes(const llvm::DWARFObject & DObj)
  • private bool verifyName(const llvm::DWARFDie & Die)
  • private unsigned int verifyNameIndexAbbrevs(const DWARFDebugNames::NameIndex & NI)
  • private unsigned int verifyNameIndexAttribute(const DWARFDebugNames::NameIndex & NI, const DWARFDebugNames::Abbrev & Abbr, DWARFDebugNames::AttributeEncoding AttrEnc)
  • private unsigned int verifyNameIndexBuckets(const DWARFDebugNames::NameIndex & NI, const llvm::DataExtractor & StrData)
  • private unsigned int verifyNameIndexCompleteness(const llvm::DWARFDie & Die, const DWARFDebugNames::NameIndex & NI)
  • private unsigned int verifyNameIndexEntries(const DWARFDebugNames::NameIndex & NI, const DWARFDebugNames::NameTableEntry & NTE)
  • private unsigned int verifyUnitContents(llvm::DWARFUnit & Unit, llvm::DWARFVerifier::ReferenceMap & UnitLocalReferences, llvm::DWARFVerifier::ReferenceMap & CrossUnitReferences)
  • private bool verifyUnitHeader(const llvm::DWARFDataExtractor DebugInfoData, uint64_t * Offset, unsigned int UnitIndex, uint8_t & UnitType, bool & isUnitDWARF64)
  • private unsigned int verifyUnitSection(const llvm::DWARFSection & S)
  • private unsigned int verifyUnits(const llvm::DWARFUnitVector & Units)
  • private llvm::raw_ostream & warn() const

Methods

DWARFVerifier(
    llvm::raw_ostream& S,
    llvm::DWARFContext& D,
    llvm::DIDumpOptions DumpOpts =
        DIDumpOptions::getForSingleDIE())

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:287

Parameters

llvm::raw_ostream& S
llvm::DWARFContext& D
llvm::DIDumpOptions DumpOpts = DIDumpOptions::getForSingleDIE()

llvm::raw_ostream& dump(
    const llvm::DWARFDie& Die,
    unsigned int indent = 0) const

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:93

Parameters

const llvm::DWARFDie& Die
unsigned int indent = 0

llvm::raw_ostream& error() const

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:90

bool handleAccelTables()

Description

Verify the information in accelerator tables, if they exist. Any errors are reported to the stream that was this object was constructed with.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:341

Returns

true if the existing Apple-style accelerator tables verify successfully, false otherwise.

bool handleDebugAbbrev()

Description

Verify the information in any of the following sections, if available: .debug_abbrev, debug_abbrev.dwo Any errors are reported to the stream that was this object was constructed with.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:298

Returns

true if .debug_abbrev and .debug_abbrev.dwo verify successfully, false otherwise.

bool handleDebugCUIndex()

Description

Verify the information in the .debug_cu_index section. Any errors are reported to the stream that was this object was constructed with.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:315

Returns

true if the .debug_cu_index verifies successfully, false otherwise.

bool handleDebugInfo()

Description

Verify the information in the .debug_info and .debug_types sections. Any errors are reported to the stream that this object was constructed with.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:306

Returns

true if all sections verify successfully, false otherwise.

bool handleDebugLine()

Description

Verify the information in the .debug_line section. Any errors are reported to the stream that was this object was constructed with.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:332

Returns

true if the .debug_line verifies successfully, false otherwise.

bool handleDebugTUIndex()

Description

Verify the information in the .debug_tu_index section. Any errors are reported to the stream that was this object was constructed with.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:324

Returns

true if the .debug_tu_index verifies successfully, false otherwise.

llvm::raw_ostream& note() const

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:92

unsigned int verifyAbbrevSection(
    const llvm::DWARFDebugAbbrev* Abbrev)

Description

Verifies the abbreviations section. This function currently checks that: --No abbreviation declaration has more than one attributes with the same name.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:105

Parameters

const llvm::DWARFDebugAbbrev* Abbrev
Pointer to the abbreviations section we are verifying Abbrev can be a pointer to either .debug_abbrev or debug_abbrev.dwo.

Returns

The number of errors that occurred during verification.

unsigned int verifyAppleAccelTable(
    const llvm::DWARFSection* AccelSection,
    llvm::DataExtractor* StrData,
    const char* SectionName)

Description

Verify that an Apple-style accelerator table is valid. This function currently checks that: - The fixed part of the header fits in the section - The size of the section is as large as what the header describes - There is at least one atom - The form for each atom is valid - The tag for each DIE in the table is valid - The buckets have a valid index, or they are empty - Each hashdata offset is valid - Each DIE is valid

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:250

Parameters

const llvm::DWARFSection* AccelSection
pointer to the section containing the acceleration table
llvm::DataExtractor* StrData
pointer to the string section
const char* SectionName
the name of the table we're verifying

Returns

The number of errors occurred during verification

unsigned int verifyDebugInfoAttribute(
    const llvm::DWARFDie& Die,
    llvm::DWARFAttribute& AttrValue)

Description

Verifies the attribute's DWARF attribute and its value. This function currently checks for: - DW_AT_ranges values is a valid .debug_ranges offset - DW_AT_stmt_list is a valid .debug_line offset

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:189

Parameters

const llvm::DWARFDie& Die
The DWARF DIE that owns the attribute value
llvm::DWARFAttribute& AttrValue
The DWARF attribute value to check

Returns

NumErrors The number of errors occurred during verification of attributes' values in a unit

unsigned int verifyDebugInfoCallSite(
    const llvm::DWARFDie& Die)

Description

Verifies that a call site entry is nested within a subprogram with a DW_AT_call attribute.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:168

Parameters

const llvm::DWARFDie& Die

Returns

Number of errors that occurred during verification.

unsigned int verifyDebugInfoForm(
    const llvm::DWARFDie& Die,
    llvm::DWARFAttribute& AttrValue,
    llvm::DWARFVerifier::ReferenceMap&
        UnitLocalReferences,
    llvm::DWARFVerifier::ReferenceMap&
        CrossUnitReferences)

Description

Verifies the attribute's DWARF form. This function currently checks for: - All DW_FORM_ref values that are CU relative have valid CU offsets - All DW_FORM_ref_addr values have valid section offsets - All DW_FORM_strp values have valid .debug_str offsets

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:204

Parameters

const llvm::DWARFDie& Die
The DWARF DIE that owns the attribute value
llvm::DWARFAttribute& AttrValue
The DWARF attribute value to check
llvm::DWARFVerifier::ReferenceMap& UnitLocalReferences
llvm::DWARFVerifier::ReferenceMap& CrossUnitReferences

Returns

NumErrors The number of errors occurred during verification of attributes' forms in a unit

unsigned int verifyDebugInfoReferences(
    const llvm::DWARFVerifier::ReferenceMap&,
    llvm::function_ref<DWARFUnit*(uint64_t)>
        GetUnitForDieOffset)

Description

Verifies the all valid references that were found when iterating through all of the DIE attributes. This function will verify that all references point to DIEs whose DIE offset matches. This helps to ensure if a DWARF link phase moved things around, that it doesn't create invalid references by failing to relocate CU relative and absolute references.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:218

Parameters

const llvm::DWARFVerifier::ReferenceMap&
llvm::function_ref<DWARFUnit*(uint64_t)> GetUnitForDieOffset

Returns

NumErrors The number of errors occurred during verification of references for the .debug_info and .debug_types sections

void verifyDebugLineRows()

Description

Verify that all of the rows in the line table are valid. This function currently checks for: - addresses within a sequence that decrease in value - invalid file indexes

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:231

void verifyDebugLineStmtOffsets()

Description

Verify the DW_AT_stmt_list encoding and value and ensure that no compile units that have the same DW_AT_stmt_list value.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:224

unsigned int verifyDebugNames(
    const llvm::DWARFSection& AccelSection,
    const llvm::DataExtractor& StrData)

Description

Verify that the DWARF v5 accelerator table is valid. This function currently checks that: - Headers individual Name Indices fit into the section and can be parsed. - Abbreviation tables can be parsed and contain valid index attributes with correct form encodings. - The CU lists reference existing compile units. - The buckets have a valid index, or they are empty. - All names are reachable via the hash table (they have the correct hash, and the hash is in the correct bucket). - Information in the index entries is complete (all required entries are present) and consistent with the debug_info section DIEs.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:283

Parameters

const llvm::DWARFSection& AccelSection
section containing the acceleration table
const llvm::DataExtractor& StrData
string section

Returns

The number of errors occurred during verification

unsigned int verifyDebugNamesCULists(
    const llvm::DWARFDebugNames& AccelTable)

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:254

Parameters

const llvm::DWARFDebugNames& AccelTable

unsigned int verifyDieRanges(
    const llvm::DWARFDie& Die,
    llvm::DWARFVerifier::DieRangeInfo& ParentRI)

Description

Verify that all Die ranges are valid. This function currently checks for: - cases in which lowPC >= highPC

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:176

Parameters

const llvm::DWARFDie& Die
llvm::DWARFVerifier::DieRangeInfo& ParentRI

Returns

Number of errors that occurred during verification.

unsigned int verifyIndex(
    llvm::StringRef Name,
    llvm::DWARFSectionKind SectionKind,
    llvm::StringRef Index)

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:161

Parameters

llvm::StringRef Name
llvm::DWARFSectionKind SectionKind
llvm::StringRef Index

unsigned int verifyIndexes(
    const llvm::DWARFObject& DObj)

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:160

Parameters

const llvm::DWARFObject& DObj

bool verifyName(const llvm::DWARFDie& Die)

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:130

Parameters

const llvm::DWARFDie& Die

unsigned int verifyNameIndexAbbrevs(
    const DWARFDebugNames::NameIndex& NI)

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:257

Parameters

const DWARFDebugNames::NameIndex& NI

unsigned int verifyNameIndexAttribute(
    const DWARFDebugNames::NameIndex& NI,
    const DWARFDebugNames::Abbrev& Abbr,
    DWARFDebugNames::AttributeEncoding AttrEnc)

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:258

Parameters

const DWARFDebugNames::NameIndex& NI
const DWARFDebugNames::Abbrev& Abbr
DWARFDebugNames::AttributeEncoding AttrEnc

unsigned int verifyNameIndexBuckets(
    const DWARFDebugNames::NameIndex& NI,
    const llvm::DataExtractor& StrData)

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:255

Parameters

const DWARFDebugNames::NameIndex& NI
const llvm::DataExtractor& StrData

unsigned int verifyNameIndexCompleteness(
    const llvm::DWARFDie& Die,
    const DWARFDebugNames::NameIndex& NI)

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:263

Parameters

const llvm::DWARFDie& Die
const DWARFDebugNames::NameIndex& NI

unsigned int verifyNameIndexEntries(
    const DWARFDebugNames::NameIndex& NI,
    const DWARFDebugNames::NameTableEntry& NTE)

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:261

Parameters

const DWARFDebugNames::NameIndex& NI
const DWARFDebugNames::NameTableEntry& NTE

unsigned int verifyUnitContents(
    llvm::DWARFUnit& Unit,
    llvm::DWARFVerifier::ReferenceMap&
        UnitLocalReferences,
    llvm::DWARFVerifier::ReferenceMap&
        CrossUnitReferences)

Description

Verifies the header of a unit in a .debug_info or .debug_types section. This function currently verifies: - The debug info attributes. - The debug info form=s. - The presence of a root DIE. - That the root DIE is a unit DIE. - If a unit type is provided, that the unit DIE matches the unit type. - The DIE ranges. - That call site entries are only nested within subprograms with a DW_AT_call attribute.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:147

Parameters

llvm::DWARFUnit& Unit
The DWARF Unit to verify.
llvm::DWARFVerifier::ReferenceMap& UnitLocalReferences
llvm::DWARFVerifier::ReferenceMap& CrossUnitReferences

Returns

The number of errors that occurred during verification.

bool verifyUnitHeader(
    const llvm::DWARFDataExtractor DebugInfoData,
    uint64_t* Offset,
    unsigned int UnitIndex,
    uint8_t& UnitType,
    bool& isUnitDWARF64)

Description

Verifies the header of a unit in a .debug_info or .debug_types section. This function currently checks for: - Unit is in 32-bit DWARF format. The function can be modified to support 64-bit format. - The DWARF version is valid - The unit type is valid (if unit is in version >=5) - The unit doesn't extend beyond the containing section - The address size is valid - The offset in the .debug_abbrev section is valid

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:127

Parameters

const llvm::DWARFDataExtractor DebugInfoData
The section data
uint64_t* Offset
A reference to the offset start of the unit. The offset will be updated to point to the next unit in the section
unsigned int UnitIndex
The index of the unit to be verified
uint8_t& UnitType
A reference to the type of the unit
bool& isUnitDWARF64
A reference to a flag that shows whether the unit is in 64-bit format.

Returns

true if the header is verified successfully, false otherwise.

unsigned int verifyUnitSection(
    const llvm::DWARFSection& S)

Description

Verifies the unit headers and contents in a .debug_info or .debug_types section.

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:157

Parameters

const llvm::DWARFSection& S
The DWARF Section to verify.

Returns

The number of errors that occurred during verification.

unsigned int verifyUnits(
    const llvm::DWARFUnitVector& Units)

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:158

Parameters

const llvm::DWARFUnitVector& Units

llvm::raw_ostream& warn() const

Declared at: llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h:91