LLVM 22.0.0git
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
llvm::DWARFFormValue Class Reference

#include "llvm/DebugInfo/DWARF/DWARFFormValue.h"

Classes

struct  ValueType
 

Public Types

enum  FormClass {
  FC_Unknown , FC_Address , FC_Block , FC_Constant ,
  FC_String , FC_Flag , FC_Reference , FC_Indirect ,
  FC_SectionOffset , FC_Exprloc
}
 

Public Member Functions

 DWARFFormValue (dwarf::Form F=dwarf::Form(0))
 
dwarf::Form getForm () const
 
uint64_t getRawUValue () const
 
LLVM_ABI bool isFormClass (FormClass FC) const
 
const DWARFUnitgetUnit () const
 
LLVM_ABI void dump (raw_ostream &OS, DIDumpOptions DumpOpts=DIDumpOptions()) const
 
LLVM_ABI void dumpSectionedAddress (raw_ostream &OS, DIDumpOptions DumpOpts, object::SectionedAddress SA) const
 
LLVM_ABI void dumpAddress (raw_ostream &OS, uint64_t Address) const
 
LLVM_ABI bool extractValue (const DWARFDataExtractor &Data, uint64_t *OffsetPtr, dwarf::FormParams FormParams, const DWARFContext *Context=nullptr, const DWARFUnit *Unit=nullptr)
 Extracts a value in Data at offset *OffsetPtr.
 
bool extractValue (const DWARFDataExtractor &Data, uint64_t *OffsetPtr, dwarf::FormParams FormParams, const DWARFUnit *U)
 
LLVM_ABI std::optional< uint64_tgetAsRelativeReference () const
 getAsFoo functions below return the extracted value as Foo if only DWARFFormValue has form class is suitable for representing Foo.
 
LLVM_ABI std::optional< uint64_tgetAsDebugInfoReference () const
 
LLVM_ABI std::optional< uint64_tgetAsSignatureReference () const
 
LLVM_ABI std::optional< uint64_tgetAsSupplementaryReference () const
 
LLVM_ABI std::optional< uint64_tgetAsUnsignedConstant () const
 
LLVM_ABI std::optional< int64_t > getAsSignedConstant () const
 
LLVM_ABI Expected< const char * > getAsCString () const
 
LLVM_ABI std::optional< uint64_tgetAsAddress () const
 
LLVM_ABI std::optional< object::SectionedAddressgetAsSectionedAddress () const
 
LLVM_ABI std::optional< uint64_tgetAsSectionOffset () const
 
LLVM_ABI std::optional< ArrayRef< uint8_t > > getAsBlock () const
 
LLVM_ABI std::optional< uint64_tgetAsCStringOffset () const
 
LLVM_ABI std::optional< uint64_tgetAsReferenceUVal () const
 
LLVM_ABI std::optional< std::string > getAsFile (DILineInfoSpecifier::FileLineInfoKind Kind) const
 Correctly extract any file paths from a form value.
 
bool skipValue (DataExtractor DebugInfoData, uint64_t *OffsetPtr, const dwarf::FormParams Params) const
 Skip a form's value in DebugInfoData at the offset specified by OffsetPtr.
 

Static Public Member Functions

static LLVM_ABI DWARFFormValue createFromSValue (dwarf::Form F, int64_t V)
 
static LLVM_ABI DWARFFormValue createFromUValue (dwarf::Form F, uint64_t V)
 
static LLVM_ABI DWARFFormValue createFromPValue (dwarf::Form F, const char *V)
 
static LLVM_ABI DWARFFormValue createFromBlockValue (dwarf::Form F, ArrayRef< uint8_t > D)
 
static LLVM_ABI DWARFFormValue createFromUnit (dwarf::Form F, const DWARFUnit *Unit, uint64_t *OffsetPtr)
 
static LLVM_ABI std::optional< object::SectionedAddressgetAsSectionedAddress (const ValueType &Val, const dwarf::Form Form, const DWARFUnit *U)
 
static LLVM_ABI void dumpAddress (raw_ostream &OS, uint8_t AddressSize, uint64_t Address)
 
static LLVM_ABI void dumpAddressSection (const DWARFObject &Obj, raw_ostream &OS, DIDumpOptions DumpOpts, uint64_t SectionIndex)
 
static LLVM_ABI bool skipValue (dwarf::Form Form, DataExtractor DebugInfoData, uint64_t *OffsetPtr, const dwarf::FormParams FormParams)
 Skip a form's value in DebugInfoData at the offset specified by OffsetPtr.
 

Detailed Description

Definition at line 27 of file DWARFFormValue.h.

Member Enumeration Documentation

◆ FormClass

Enumerator
FC_Unknown 
FC_Address 
FC_Block 
FC_Constant 
FC_String 
FC_Flag 
FC_Reference 
FC_Indirect 
FC_SectionOffset 
FC_Exprloc 

Definition at line 29 of file DWARFFormValue.h.

Constructor & Destructor Documentation

◆ DWARFFormValue()

llvm::DWARFFormValue::DWARFFormValue ( dwarf::Form  F = dwarf::Form(0))
inline

Definition at line 68 of file DWARFFormValue.h.

Member Function Documentation

◆ createFromBlockValue()

DWARFFormValue DWARFFormValue::createFromBlockValue ( dwarf::Form  F,
ArrayRef< uint8_t D 
)
static

Definition at line 94 of file DWARFFormValue.cpp.

References D, and F.

◆ createFromPValue()

DWARFFormValue DWARFFormValue::createFromPValue ( dwarf::Form  F,
const char V 
)
static

Definition at line 90 of file DWARFFormValue.cpp.

References F.

Referenced by llvm::DWARFDebugLine::LineTable::parse(), and parseV2DirFileTables().

◆ createFromSValue()

DWARFFormValue DWARFFormValue::createFromSValue ( dwarf::Form  F,
int64_t  V 
)
static

◆ createFromUnit()

DWARFFormValue DWARFFormValue::createFromUnit ( dwarf::Form  F,
const DWARFUnit Unit,
uint64_t OffsetPtr 
)
static

Definition at line 102 of file DWARFFormValue.cpp.

References extractValue(), and F.

◆ createFromUValue()

DWARFFormValue DWARFFormValue::createFromUValue ( dwarf::Form  F,
uint64_t  V 
)
static

Definition at line 86 of file DWARFFormValue.cpp.

References F.

Referenced by dumpAttribute().

◆ dump()

void DWARFFormValue::dump ( raw_ostream OS,
DIDumpOptions  DumpOpts = DIDumpOptions() 
) const

◆ dumpAddress() [1/2]

LLVM_ABI void llvm::DWARFFormValue::dumpAddress ( raw_ostream OS,
uint64_t  Address 
) const

◆ dumpAddress() [2/2]

void DWARFFormValue::dumpAddress ( raw_ostream OS,
uint8_t  AddressSize,
uint64_t  Address 
)
static

Definition at line 353 of file DWARFFormValue.cpp.

References llvm::Address, llvm::format(), and OS.

◆ dumpAddressSection()

void DWARFFormValue::dumpAddressSection ( const DWARFObject Obj,
raw_ostream OS,
DIDumpOptions  DumpOpts,
uint64_t  SectionIndex 
)
static

◆ dumpSectionedAddress()

void DWARFFormValue::dumpSectionedAddress ( raw_ostream OS,
DIDumpOptions  DumpOpts,
object::SectionedAddress  SA 
) const

◆ extractValue() [1/2]

bool DWARFFormValue::extractValue ( const DWARFDataExtractor Data,
uint64_t OffsetPtr,
dwarf::FormParams  FormParams,
const DWARFContext Context = nullptr,
const DWARFUnit Unit = nullptr 
)

Extracts a value in Data at offset *OffsetPtr.

The information in FormParams is needed to interpret some forms. The optional Context and Unit allows extracting information if the form refers to other sections (e.g., .debug_str).

Definition at line 220 of file DWARFFormValue.cpp.

References llvm::Data, llvm::errorToBool(), FP, llvm_unreachable, Size, and llvm::Error::success().

Referenced by llvm::dwarf_linker::parallel::DIEAttributeCloner::clone(), createFromUnit(), extractValue(), llvm::DWARFAbbreviationDeclaration::getAttributeValueFromOffset(), llvm::dwarf_linker::parallel::DependencyTracker::maybeAddReferencedRoots(), and llvm::AppleAcceleratorTable::readAtoms().

◆ extractValue() [2/2]

bool llvm::DWARFFormValue::extractValue ( const DWARFDataExtractor Data,
uint64_t OffsetPtr,
dwarf::FormParams  FormParams,
const DWARFUnit U 
)
inline

Definition at line 107 of file DWARFFormValue.h.

References llvm::Data, and extractValue().

◆ getAsAddress()

std::optional< uint64_t > DWARFFormValue::getAsAddress ( ) const

Definition at line 634 of file DWARFFormValue.cpp.

References getAsSectionedAddress().

Referenced by dumpAttribute().

◆ getAsBlock()

std::optional< ArrayRef< uint8_t > > DWARFFormValue::getAsBlock ( ) const

◆ getAsCString()

Expected< const char * > DWARFFormValue::getAsCString ( ) const

◆ getAsCStringOffset()

std::optional< uint64_t > DWARFFormValue::getAsCStringOffset ( ) const

Definition at line 745 of file DWARFFormValue.cpp.

References FC_String, and isFormClass().

◆ getAsDebugInfoReference()

std::optional< uint64_t > DWARFFormValue::getAsDebugInfoReference ( ) const

◆ getAsFile()

std::optional< std::string > DWARFFormValue::getAsFile ( DILineInfoSpecifier::FileLineInfoKind  Kind) const

Correctly extract any file paths from a form value.

These attributes can be in the from DW_AT_decl_file or DW_AT_call_file attributes. We need to use the file index in the correct DWARFUnit's line table prologue, and each DWARFFormValue has the DWARFUnit the form value was extracted from.

Parameters
KindThe kind of path to extract.
Returns
A valid string value on success, or std::nullopt if the form class is not FC_Constant, or if the file index is not valid.

Definition at line 758 of file DWARFFormValue.cpp.

References FC_Constant, llvm::DWARFUnit::getCompilationDir(), llvm::DWARFUnit::getContext(), llvm::DWARFContext::getLineTableForUnit(), and isFormClass().

◆ getAsReferenceUVal()

std::optional< uint64_t > DWARFFormValue::getAsReferenceUVal ( ) const

Definition at line 751 of file DWARFFormValue.cpp.

References FC_Reference, and isFormClass().

◆ getAsRelativeReference()

std::optional< uint64_t > DWARFFormValue::getAsRelativeReference ( ) const

getAsFoo functions below return the extracted value as Foo if only DWARFFormValue has form class is suitable for representing Foo.

Definition at line 668 of file DWARFFormValue.cpp.

Referenced by llvm::dwarf_linker::parallel::CompileUnit::resolveDIEReference().

◆ getAsSectionedAddress() [1/2]

std::optional< object::SectionedAddress > DWARFFormValue::getAsSectionedAddress ( ) const

Definition at line 664 of file DWARFFormValue.cpp.

References getAsSectionedAddress().

Referenced by dump(), getAsAddress(), and getAsSectionedAddress().

◆ getAsSectionedAddress() [2/2]

std::optional< object::SectionedAddress > DWARFFormValue::getAsSectionedAddress ( const ValueType Val,
const dwarf::Form  Form,
const DWARFUnit U 
)
static

Definition at line 640 of file DWARFFormValue.cpp.

References llvm::dwarf::doesFormBelongToClass(), FC_Address, and if().

◆ getAsSectionOffset()

std::optional< uint64_t > DWARFFormValue::getAsSectionOffset ( ) const

◆ getAsSignatureReference()

std::optional< uint64_t > DWARFFormValue::getAsSignatureReference ( ) const

Definition at line 689 of file DWARFFormValue.cpp.

◆ getAsSignedConstant()

std::optional< int64_t > DWARFFormValue::getAsSignedConstant ( ) const

◆ getAsSupplementaryReference()

std::optional< uint64_t > DWARFFormValue::getAsSupplementaryReference ( ) const

Definition at line 695 of file DWARFFormValue.cpp.

◆ getAsUnsignedConstant()

std::optional< uint64_t > DWARFFormValue::getAsUnsignedConstant ( ) const

◆ getForm()

dwarf::Form llvm::DWARFFormValue::getForm ( ) const
inline

◆ getRawUValue()

uint64_t llvm::DWARFFormValue::getRawUValue ( ) const
inline

◆ getUnit()

const DWARFUnit * llvm::DWARFFormValue::getUnit ( ) const
inline

◆ isFormClass()

bool DWARFFormValue::isFormClass ( DWARFFormValue::FormClass  FC) const

◆ skipValue() [1/2]

bool llvm::DWARFFormValue::skipValue ( DataExtractor  DebugInfoData,
uint64_t OffsetPtr,
const dwarf::FormParams  Params 
) const
inline

Skip a form's value in DebugInfoData at the offset specified by OffsetPtr.

Skips the bytes for the current form and updates the offset.

Parameters
DebugInfoDataThe data where we want to skip the value.
OffsetPtrA reference to the offset that will be updated.
ParamsDWARF parameters to help interpret forms.
Returns
true on success, false if the form was not skipped.

Definition at line 151 of file DWARFFormValue.h.

References skipValue().

Referenced by llvm::dwarf_linker::parallel::DIEAttributeCloner::clone(), llvm::DWARFDebugInfoEntry::extractFast(), llvm::DWARFAbbreviationDeclaration::getAttributeOffsetFromIndex(), getCUIdentifiers(), llvm::dwarf_linker::parallel::DependencyTracker::maybeAddReferencedRoots(), and skipValue().

◆ skipValue() [2/2]

bool DWARFFormValue::skipValue ( dwarf::Form  Form,
DataExtractor  DebugInfoData,
uint64_t OffsetPtr,
const dwarf::FormParams  FormParams 
)
static

Skip a form's value in DebugInfoData at the offset specified by OffsetPtr.

Skips the bytes for the specified form and updates the offset.

Parameters
FormThe DW_FORM enumeration that indicates the form to skip.
DebugInfoDataThe data where we want to skip the value.
OffsetPtrA reference to the offset that will be updated.
FormParamsDWARF parameters to help interpret forms.
Returns
true on success, false if the form was not skipped.

Definition at line 110 of file DWARFFormValue.cpp.

References llvm::DataExtractor::getCStr(), llvm::dwarf::getFixedFormByteSize(), llvm::DataExtractor::getSLEB128(), llvm::DataExtractor::getU16(), llvm::DataExtractor::getU32(), llvm::DataExtractor::getU8(), llvm::DataExtractor::getULEB128(), and llvm::size().


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