LLVM  12.0.0git
Public Member Functions | List of all members
llvm::DWARFDataExtractor Class Reference

A DataExtractor (typically for an in-memory copy of an object-file section) plus a relocation map for that section, if there is one. More...

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

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

Public Member Functions

 DWARFDataExtractor (const DWARFObject &Obj, const DWARFSection &Section, bool IsLittleEndian, uint8_t AddressSize)
 Constructor for the normal case of extracting data from a DWARF section. More...
 
 DWARFDataExtractor (StringRef Data, bool IsLittleEndian, uint8_t AddressSize)
 Constructor for cases when there are no relocations. More...
 
 DWARFDataExtractor (ArrayRef< uint8_t > Data, bool IsLittleEndian, uint8_t AddressSize)
 
 DWARFDataExtractor (const DWARFDataExtractor &Other, size_t Length)
 Truncating constructor. More...
 
std::pair< uint64_t, dwarf::DwarfFormatgetInitialLength (uint64_t *Off, Error *Err=nullptr) const
 Extracts the DWARF "initial length" field, which can either be a 32-bit value smaller than 0xfffffff0, or the value 0xffffffff followed by a 64-bit length. More...
 
std::pair< uint64_t, dwarf::DwarfFormatgetInitialLength (Cursor &C) const
 
uint64_t getRelocatedValue (uint32_t Size, uint64_t *Off, uint64_t *SectionIndex=nullptr, Error *Err=nullptr) const
 Extracts a value and applies a relocation to the result if one exists for the given offset. More...
 
uint64_t getRelocatedValue (Cursor &C, uint32_t Size, uint64_t *SectionIndex=nullptr) const
 
uint64_t getRelocatedAddress (uint64_t *Off, uint64_t *SecIx=nullptr) const
 Extracts an address-sized value and applies a relocation to the result if one exists for the given offset. More...
 
uint64_t getRelocatedAddress (Cursor &C, uint64_t *SecIx=nullptr) const
 
Optional< uint64_t > getEncodedPointer (uint64_t *Offset, uint8_t Encoding, uint64_t AbsPosOffset=0) const
 Extracts a DWARF-encoded pointer in Offset using Encoding. More...
 
- Public Member Functions inherited from llvm::DataExtractor
 DataExtractor (StringRef Data, bool IsLittleEndian, uint8_t AddressSize)
 Construct with a buffer that is owned by the caller. More...
 
 DataExtractor (ArrayRef< uint8_t > Data, bool IsLittleEndian, uint8_t AddressSize)
 
StringRef getData () const
 Get the data pointed to by this extractor. More...
 
bool isLittleEndian () const
 Get the endianness for this extractor. More...
 
uint8_t getAddressSize () const
 Get the address size for this extractor. More...
 
void setAddressSize (uint8_t Size)
 Set the address size for this extractor. More...
 
const chargetCStr (uint64_t *OffsetPtr, Error *Err=nullptr) const
 Extract a C string from *offset_ptr. More...
 
const chargetCStr (Cursor &C) const
 Extract a C string from the location given by the cursor. More...
 
StringRef getCStrRef (uint64_t *OffsetPtr, Error *Err=nullptr) const
 Extract a C string from *offset_ptr. More...
 
StringRef getCStrRef (Cursor &C) const
 Extract a C string (as a StringRef) from the location given by the cursor. More...
 
StringRef getFixedLengthString (uint64_t *OffsetPtr, uint64_t Length, StringRef TrimChars={"\, 1}) const
 Extract a fixed length string from *OffsetPtr and consume Length bytes. More...
 
StringRef getBytes (uint64_t *OffsetPtr, uint64_t Length, Error *Err=nullptr) const
 Extract a fixed number of bytes from the specified offset. More...
 
StringRef getBytes (Cursor &C, uint64_t Length)
 Extract a fixed number of bytes from the location given by the cursor. More...
 
uint64_t getUnsigned (uint64_t *offset_ptr, uint32_t byte_size, Error *Err=nullptr) const
 Extract an unsigned integer of size byte_size from *offset_ptr. More...
 
uint64_t getUnsigned (Cursor &C, uint32_t Size) const
 Extract an unsigned integer of the given size from the location given by the cursor. More...
 
int64_t getSigned (uint64_t *offset_ptr, uint32_t size) const
 Extract an signed integer of size byte_size from *offset_ptr. More...
 
uint64_t getAddress (uint64_t *offset_ptr) const
 Extract an pointer from *offset_ptr. More...
 
uint64_t getAddress (Cursor &C) const
 Extract a pointer-sized unsigned integer from the location given by the cursor. More...
 
uint8_t getU8 (uint64_t *offset_ptr, Error *Err=nullptr) const
 Extract a uint8_t value from *offset_ptr. More...
 
uint8_t getU8 (Cursor &C) const
 Extract a single uint8_t value from the location given by the cursor. More...
 
uint8_t * getU8 (uint64_t *offset_ptr, uint8_t *dst, uint32_t count) const
 Extract count uint8_t values from *offset_ptr. More...
 
uint8_t * getU8 (Cursor &C, uint8_t *Dst, uint32_t Count) const
 Extract Count uint8_t values from the location given by the cursor and store them into the destination buffer. More...
 
void getU8 (Cursor &C, SmallVectorImpl< uint8_t > &Dst, uint32_t Count) const
 Extract Count uint8_t values from the location given by the cursor and store them into the destination vector. More...
 
uint16_t getU16 (uint64_t *offset_ptr, Error *Err=nullptr) const
 Extract a uint16_t value from *offset_ptr. More...
 
uint16_t getU16 (Cursor &C) const
 Extract a single uint16_t value from the location given by the cursor. More...
 
uint16_tgetU16 (uint64_t *offset_ptr, uint16_t *dst, uint32_t count) const
 Extract count uint16_t values from *offset_ptr. More...
 
uint32_t getU24 (uint64_t *OffsetPtr, Error *Err=nullptr) const
 Extract a 24-bit unsigned value from *offset_ptr and return it in a uint32_t. More...
 
uint32_t getU24 (Cursor &C) const
 Extract a single 24-bit unsigned value from the location given by the cursor. More...
 
uint32_t getU32 (uint64_t *offset_ptr, Error *Err=nullptr) const
 Extract a uint32_t value from *offset_ptr. More...
 
uint32_t getU32 (Cursor &C) const
 Extract a single uint32_t value from the location given by the cursor. More...
 
uint32_tgetU32 (uint64_t *offset_ptr, uint32_t *dst, uint32_t count) const
 Extract count uint32_t values from *offset_ptr. More...
 
uint64_t getU64 (uint64_t *offset_ptr, Error *Err=nullptr) const
 Extract a uint64_t value from *offset_ptr. More...
 
uint64_t getU64 (Cursor &C) const
 Extract a single uint64_t value from the location given by the cursor. More...
 
uint64_t * getU64 (uint64_t *offset_ptr, uint64_t *dst, uint32_t count) const
 Extract count uint64_t values from *offset_ptr. More...
 
int64_t getSLEB128 (uint64_t *OffsetPtr, Error *Err=nullptr) const
 Extract a signed LEB128 value from *offset_ptr. More...
 
int64_t getSLEB128 (Cursor &C) const
 Extract an signed LEB128 value from the location given by the cursor. More...
 
uint64_t getULEB128 (uint64_t *offset_ptr, llvm::Error *Err=nullptr) const
 Extract a unsigned LEB128 value from *offset_ptr. More...
 
uint64_t getULEB128 (Cursor &C) const
 Extract an unsigned LEB128 value from the location given by the cursor. More...
 
void skip (Cursor &C, uint64_t Length) const
 Advance the Cursor position by the given number of bytes. More...
 
bool eof (const Cursor &C) const
 Return true iff the cursor is at the end of the buffer, regardless of the error state of the cursor. More...
 
bool isValidOffset (uint64_t offset) const
 Test the validity of offset. More...
 
bool isValidOffsetForDataOfSize (uint64_t offset, uint64_t length) const
 Test the availability of length bytes of data from offset. More...
 
bool isValidOffsetForAddress (uint64_t offset) const
 Test the availability of enough bytes of data for a pointer from offset. More...
 
size_t size () const
 Return the number of bytes in the underlying buffer. More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from llvm::DataExtractor
static uint64_t & getOffset (Cursor &C)
 
static ErrorgetError (Cursor &C)
 

Detailed Description

A DataExtractor (typically for an in-memory copy of an object-file section) plus a relocation map for that section, if there is one.

Definition at line 21 of file DWARFDataExtractor.h.

Constructor & Destructor Documentation

◆ DWARFDataExtractor() [1/4]

llvm::DWARFDataExtractor::DWARFDataExtractor ( const DWARFObject Obj,
const DWARFSection Section,
bool  IsLittleEndian,
uint8_t  AddressSize 
)
inline

Constructor for the normal case of extracting data from a DWARF section.

The DWARFSection's lifetime must be at least as long as the extractor's.

Definition at line 28 of file DWARFDataExtractor.h.

References llvm::Data.

◆ DWARFDataExtractor() [2/4]

llvm::DWARFDataExtractor::DWARFDataExtractor ( StringRef  Data,
bool  IsLittleEndian,
uint8_t  AddressSize 
)
inline

Constructor for cases when there are no relocations.

Definition at line 34 of file DWARFDataExtractor.h.

◆ DWARFDataExtractor() [3/4]

llvm::DWARFDataExtractor::DWARFDataExtractor ( ArrayRef< uint8_t >  Data,
bool  IsLittleEndian,
uint8_t  AddressSize 
)
inline

Definition at line 36 of file DWARFDataExtractor.h.

◆ DWARFDataExtractor() [4/4]

llvm::DWARFDataExtractor::DWARFDataExtractor ( const DWARFDataExtractor Other,
size_t  Length 
)
inline

Truncating constructor.

Definition at line 43 of file DWARFDataExtractor.h.

References getInitialLength().

Member Function Documentation

◆ getEncodedPointer()

Optional< uint64_t > DWARFDataExtractor::getEncodedPointer ( uint64_t *  Offset,
uint8_t  Encoding,
uint64_t  AbsPosOffset = 0 
) const

◆ getInitialLength() [1/2]

std::pair< uint64_t, dwarf::DwarfFormat > DWARFDataExtractor::getInitialLength ( uint64_t *  Off,
Error Err = nullptr 
) const

Extracts the DWARF "initial length" field, which can either be a 32-bit value smaller than 0xfffffff0, or the value 0xffffffff followed by a 64-bit length.

Returns the actual length, and the DWARF format which is encoded in the field. In case of errors, it returns {0, DWARF32} and leaves the offset unchanged.

Definition at line 15 of file DWARFDataExtractor.cpp.

Referenced by DWARFDataExtractor(), llvm::DWARFDebugPubTable::extract(), llvm::DWARFDebugNames::Header::extract(), getInitialLength(), llvm::DWARFVerifier::DieRangeInfo::intersects(), llvm::DWARFDebugLine::Prologue::parse(), and llvm::DWARFDebugFrame::parse().

◆ getInitialLength() [2/2]

std::pair<uint64_t, dwarf::DwarfFormat> llvm::DWARFDataExtractor::getInitialLength ( Cursor C) const
inline

◆ getRelocatedAddress() [1/2]

uint64_t llvm::DWARFDataExtractor::getRelocatedAddress ( uint64_t *  Off,
uint64_t *  SecIx = nullptr 
) const
inline

Extracts an address-sized value and applies a relocation to the result if one exists for the given offset.

Definition at line 72 of file DWARFDataExtractor.h.

References llvm::DataExtractor::getAddressSize(), and getRelocatedValue().

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

◆ getRelocatedAddress() [2/2]

uint64_t llvm::DWARFDataExtractor::getRelocatedAddress ( Cursor C,
uint64_t *  SecIx = nullptr 
) const
inline

◆ getRelocatedValue() [1/2]

uint64_t DWARFDataExtractor::getRelocatedValue ( uint32_t  Size,
uint64_t *  Off,
uint64_t *  SectionIndex = nullptr,
Error Err = nullptr 
) const

◆ getRelocatedValue() [2/2]

uint64_t llvm::DWARFDataExtractor::getRelocatedValue ( Cursor C,
uint32_t  Size,
uint64_t *  SectionIndex = nullptr 
) const
inline

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