LLVM  10.0.0svn
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
llvm::gsym::FunctionInfo Struct Reference

Function information in GSYM files encodes information for one contiguous address range. More...

#include "llvm/DebugInfo/GSYM/FunctionInfo.h"

Collaboration diagram for llvm::gsym::FunctionInfo:
Collaboration graph
[legend]

Public Member Functions

 FunctionInfo (uint64_t Addr=0, uint64_t Size=0, uint32_t N=0)
 
bool hasRichInfo () const
 Query if a FunctionInfo has rich debug info. More...
 
bool isValid () const
 Query if a FunctionInfo object is valid. More...
 
llvm::Expected< uint64_t > encode (FileWriter &O) const
 Encode this object into FileWriter stream. More...
 
uint64_t startAddress () const
 
uint64_t endAddress () const
 
uint64_t size () const
 
void setStartAddress (uint64_t Addr)
 
void setEndAddress (uint64_t Addr)
 
void setSize (uint64_t Size)
 
void clear ()
 

Static Public Member Functions

static llvm::Expected< FunctionInfodecode (DataExtractor &Data, uint64_t BaseAddr)
 Decode an object from a binary data stream. More...
 

Public Attributes

AddressRange Range
 
uint32_t Name
 String table offset in the string table. More...
 
llvm::Optional< LineTableOptLineTable
 
llvm::Optional< InlineInfoInline
 

Detailed Description

Function information in GSYM files encodes information for one contiguous address range.

If a function has discontiguous address ranges, they will need to be encoded using multiple FunctionInfo objects.

ENCODING

The function information gets the function start address as an argument to the FunctionInfo::decode(...) function. This information is calculated from the GSYM header and an address offset from the GSYM address offsets table. The encoded FunctionInfo information must be alinged to a 4 byte boundary.

The encoded data for a FunctionInfo starts with fixed data that all function info objects have:

ENCODING NAME DESCRIPTION ========= =========== ==================================================== uint32_t Size The size in bytes of this function. uint32_t Name The string table offset of the function name.

The optional data in a FunctionInfo object follows this fixed information and consists of a stream of tuples that consist of:

ENCODING NAME DESCRIPTION ========= =========== ==================================================== uint32_t InfoType An "InfoType" enumeration that describes the type of optional data that is encoded. uint32_t InfoLength The size in bytes of the encoded data that immediately follows this length if this value is greater than zero. uint8_t[] InfoData Encoded bytes that represent the data for the "InfoType". These bytes are only present if "InfoLength" is greater than zero.

The "InfoType" is an enumeration:

enum InfoType { EndOfList = 0u, LineTableInfo = 1u, InlineInfo = 2u };

This stream of tuples is terminated by a "InfoType" whose value is InfoType::EndOfList and a zero for "InfoLength". This signifies the end of the optional information list. This format allows us to add new optional information data to a FunctionInfo object over time and allows older clients to still parse the format and skip over any data that they don't understand or want to parse.

So the function information encoding essientially looks like:

struct { uint32_t Size; uint32_t Name; struct { uint32_t InfoType; uint32_t InfoLength; uint8_t InfoData[InfoLength]; }[N]; }

Where "N" is the number of tuples.

Definition at line 86 of file FunctionInfo.h.

Constructor & Destructor Documentation

◆ FunctionInfo()

llvm::gsym::FunctionInfo::FunctionInfo ( uint64_t  Addr = 0,
uint64_t  Size = 0,
uint32_t  N = 0 
)
inline

Definition at line 92 of file FunctionInfo.h.

Member Function Documentation

◆ clear()

void llvm::gsym::FunctionInfo::clear ( )
inline

Definition at line 150 of file FunctionInfo.h.

References llvm::None.

◆ decode()

llvm::Expected< FunctionInfo > FunctionInfo::decode ( DataExtractor Data,
uint64_t  BaseAddr 
)
static

Decode an object from a binary data stream.

Parameters
DataThe binary stream to read the data from. This object must have the data for the object starting at offset zero. The data can contain more data than needed.
BaseAddrThe FunctionInfo's start address and will be used as the base address when decoding any contained information like the line table and the inline info.
Returns
An FunctionInfo or an error describing the issue that was encountered during decoding.

Definition at line 32 of file FunctionInfo.cpp.

References llvm::createStringError(), llvm::gsym::AddressRange::End, llvm::DataExtractor::getU32(), llvm::DataExtractor::isValidOffsetForDataOfSize(), Name, Range, and llvm::gsym::AddressRange::Start.

Referenced by llvm::gsym::GsymReader::getFunctionInfo(), and isValid().

◆ encode()

llvm::Expected< uint64_t > FunctionInfo::encode ( FileWriter O) const

Encode this object into FileWriter stream.

Parameters
OThe binary stream to write the data to at the current file position.
Returns
An error object that indicates failure or the offset of the function info that was successfully written into the stream.

Definition at line 95 of file FunctionInfo.cpp.

References llvm::gsym::FileWriter::alignTo(), llvm::createStringError(), EndOfList, llvm::gsym::FileWriter::fixup32(), Inline, InlineInfo, isValid(), LineTableInfo, Name, OptLineTable, Range, size(), llvm::gsym::AddressRange::Start, llvm::gsym::FileWriter::tell(), and llvm::gsym::FileWriter::writeU32().

Referenced by isValid().

◆ endAddress()

uint64_t llvm::gsym::FunctionInfo::endAddress ( ) const
inline

Definition at line 144 of file FunctionInfo.h.

References llvm::gsym::AddressRange::End.

◆ hasRichInfo()

bool llvm::gsym::FunctionInfo::hasRichInfo ( ) const
inline

Query if a FunctionInfo has rich debug info.

Returns
A bool that indicates if this object has something else than range and name. When converting information from a symbol table and from debug info, we might end up with multiple FunctionInfo objects for the same range and we need to be able to tell which one is the better object to use.

Definition at line 102 of file FunctionInfo.h.

References llvm::Optional< T >::hasValue().

◆ isValid()

bool llvm::gsym::FunctionInfo::isValid ( ) const
inline

Query if a FunctionInfo object is valid.

Address and size can be zero and there can be no line entries for a symbol so the only indication this entry is valid is if the name is not zero. This can happen when extracting information from symbol tables that do not encode symbol sizes. In that case only the address and name will be filled in.

Returns
A boolean indicating if this FunctionInfo is valid.

Definition at line 115 of file FunctionInfo.h.

References llvm::Data, decode(), encode(), and llvm::RISCVFenceField::O.

Referenced by encode().

◆ setEndAddress()

void llvm::gsym::FunctionInfo::setEndAddress ( uint64_t  Addr)
inline

Definition at line 147 of file FunctionInfo.h.

References llvm::gsym::AddressRange::End.

◆ setSize()

void llvm::gsym::FunctionInfo::setSize ( uint64_t  Size)
inline

◆ setStartAddress()

void llvm::gsym::FunctionInfo::setStartAddress ( uint64_t  Addr)
inline

Definition at line 146 of file FunctionInfo.h.

References llvm::gsym::AddressRange::Start.

◆ size()

uint64_t llvm::gsym::FunctionInfo::size ( ) const
inline

Definition at line 145 of file FunctionInfo.h.

References llvm::gsym::AddressRange::size().

Referenced by encode().

◆ startAddress()

uint64_t llvm::gsym::FunctionInfo::startAddress ( ) const
inline

Definition at line 143 of file FunctionInfo.h.

References llvm::gsym::AddressRange::Start.

Member Data Documentation

◆ Inline

llvm::Optional<InlineInfo> llvm::gsym::FunctionInfo::Inline

◆ Name

uint32_t llvm::gsym::FunctionInfo::Name

String table offset in the string table.

Definition at line 88 of file FunctionInfo.h.

Referenced by decode(), encode(), llvm::gsym::operator<<(), and llvm::gsym::operator==().

◆ OptLineTable

llvm::Optional<LineTable> llvm::gsym::FunctionInfo::OptLineTable

◆ Range

AddressRange llvm::gsym::FunctionInfo::Range

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