LLVM: llvm::gsym::FunctionInfo Struct Reference (original) (raw)
Function information in GSYM files encodes information for one contiguous address range. More...
#include "[llvm/DebugInfo/GSYM/FunctionInfo.h](FunctionInfo%5F8h%5Fsource.html)"
| 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. | |
| bool | isValid () const |
| Query if a FunctionInfo object is valid. | |
| LLVM_ABI llvm::Expected< uint64_t > | encode (FileWriter &O, bool NoPadding=false) const |
| Encode this object into FileWriter stream. | |
| LLVM_ABI uint64_t | cacheEncoding () |
| Encode this function info into the internal byte cache and return the size in bytes. | |
| uint64_t | startAddress () const |
| uint64_t | endAddress () const |
| uint64_t | size () const |
| void | clear () |
| Public Attributes | |
|---|---|
| AddressRange | Range |
| uint32_t | Name |
| String table offset in the string table. | |
| std::optional< LineTable > | OptLineTable |
| std::optional< InlineInfo > | Inline |
| std::optional< MergedFunctionsInfo > | MergedFunctions |
| std::optional< CallSiteInfoCollection > | CallSites |
| SmallString< 32 > | EncodingCache |
| If we encode a FunctionInfo during segmenting so we know its size, we can cache that encoding here so we don't need to re-encode it when saving the GSYM file. |
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 aligned 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, MergedFunctionsInfo = 3u, CallSiteInfo = 4u };
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 essentially 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 93 of file FunctionInfo.h.
◆ cacheEncoding()
| uint64_t FunctionInfo::cacheEncoding | ( | ) |
|---|
Encode this function info into the internal byte cache and return the size in bytes.
When segmenting GSYM files we need to know how big each FunctionInfo will encode into so we can generate segments of the right size. We don't want to have to encode a FunctionInfo twice, so we can cache the encoded bytes and re-use then when calling FunctionInfo::encode(...).
Returns
The size in bytes of the FunctionInfo if it were to be encoded into a byte stream.
Definition at line 119 of file FunctionInfo.cpp.
References llvm::consumeError(), encode(), EncodingCache, isValid(), and llvm::native.
◆ clear()
| void llvm::gsym::FunctionInfo::clear ( ) | inline |
|---|
◆ decode()
Decode an object from a binary data stream.
Parameters
| Data | The 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. |
|---|---|
| BaseAddr | The 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 41 of file FunctionInfo.cpp.
References CallSiteInfo, CallSites, llvm::createStringError(), llvm::Data, llvm::gsym::CallSiteInfoCollection::decode(), decode(), llvm::gsym::InlineInfo::decode(), llvm::gsym::LineTable::decode(), llvm::gsym::MergedFunctionsInfo::decode(), llvm::Done, EndOfList, FunctionInfo(), II, Inline, InlineInfo, IT, LineTableInfo, MergedFunctions, MergedFunctionsInfo, MI, Name, llvm::Offset, OptLineTable, and Range.
Referenced by decode(), llvm::gsym::MergedFunctionsInfo::decode(), llvm::gsym::GsymReader::getFunctionInfo(), and llvm::gsym::GsymReader::getFunctionInfoAtIndex().
◆ encode()
Encode this object into FileWriter stream.
Parameters
| O | The binary stream to write the data to at the current file position. |
|---|---|
| NoPadding | Directly write the FunctionInfo data, without any padding By default, FunctionInfo will be 4-byte aligned by padding with 0's at the start. This is OK since the function will return the offset of actual data in the stream. However when writing FunctionInfo's as a stream, the padding will break the decoding of the data - since the offset where the FunctionInfo starts is not kept in this scenario. |
Returns
An error object that indicates failure or the offset of the function info that was successfully written into the stream.
Definition at line 134 of file FunctionInfo.cpp.
References llvm::gsym::FileWriter::alignTo(), CallSiteInfo, CallSites, llvm::createStringError(), EncodingCache, EndOfList, llvm::gsym::FileWriter::fixup32(), llvm::gsym::FileWriter::getByteOrder(), Inline, InlineInfo, isValid(), llvm::Length, LineTableInfo, MergedFunctions, MergedFunctionsInfo, Name, llvm::native, OptLineTable, Range, size(), llvm::gsym::FileWriter::tell(), llvm::gsym::FileWriter::writeData(), and llvm::gsym::FileWriter::writeU32().
Referenced by cacheEncoding().
◆ endAddress()
| uint64_t llvm::gsym::FunctionInfo::endAddress ( ) const | inline |
|---|
◆ hasRichInfo()
| bool llvm::gsym::FunctionInfo::hasRichInfo ( ) const | inline |
|---|
◆ 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 126 of file FunctionInfo.h.
References Name.
Referenced by cacheEncoding(), and encode().
◆ lookup()
Lookup an address within a FunctionInfo object's data stream.
Instead of decoding an entire FunctionInfo object when doing lookups, we can decode only the information we need from the FunctionInfo's data for the specific address. The lookup result information is returned as a LookupResult.
Parameters
| Data | The 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. |
|---|---|
| GR | The GSYM reader that contains the string and file table that will be used to fill in information in the returned result. |
| FuncAddr | The function start address decoded from the GsymReader. |
| Addr | The address to lookup. |
| MergedFuncsData | A pointer to an optional DataExtractor that, if non-null, will be set to the raw data of the MergedFunctionInfo, if present. |
Returns
An LookupResult or an error describing the issue that was encountered during decoding. An error should only be returned if the address is not contained in the FunctionInfo or if the data is corrupted.
Definition at line 239 of file FunctionInfo.cpp.
References llvm::gsym::SourceLocation::Base, llvm::gsym::LookupResult::CallSiteFuncRegex, CallSiteInfo, llvm::AddressRange::contains(), llvm::createStringError(), llvm::Data, llvm::gsym::CallSiteInfoCollection::decode(), llvm::gsym::SourceLocation::Dir, llvm::Done, EndOfList, llvm::gsym::LineEntry::File, llvm::gsym::LookupResult::FuncName, llvm::gsym::LookupResult::FuncRange, llvm::gsym::GsymReader::getFile(), llvm::gsym::GsymReader::getString(), InlineInfo, IT, llvm::gsym::LineEntry::Line, llvm::gsym::SourceLocation::Line, LineTableInfo, llvm::gsym::LookupResult::Locations, llvm::gsym::InlineInfo::lookup(), llvm::gsym::LineTable::lookup(), llvm::gsym::LookupResult::LookupAddr, MergedFunctionsInfo, llvm::gsym::SourceLocation::Name, llvm::gsym::SourceLocation::Offset, llvm::Offset, llvm::AddressRange::size(), and llvm::StringRef::size().
Referenced by llvm::gsym::GsymReader::lookup(), and llvm::gsym::GsymReader::lookupAll().
◆ size()
| uint64_t llvm::gsym::FunctionInfo::size ( ) const | inline |
|---|
◆ startAddress()
| uint64_t llvm::gsym::FunctionInfo::startAddress ( ) const | inline |
|---|
◆ CallSites
◆ EncodingCache
SmallString<32> llvm::gsym::FunctionInfo::EncodingCache
◆ Inline
std::optional<InlineInfo> llvm::gsym::FunctionInfo::Inline
◆ MergedFunctions
◆ Name
◆ OptLineTable
std::optional<LineTable> llvm::gsym::FunctionInfo::OptLineTable
◆ Range
Definition at line 94 of file FunctionInfo.h.
Referenced by clear(), convertFunctionLineTable(), decode(), llvm::gsym::GsymReader::dump(), encode(), endAddress(), llvm::gsym::GsymCreator::finalize(), FunctionInfo(), llvm::gsym::operator<<(), llvm::gsym::GsymCreator::prepareMergedFunctions(), size(), and startAddress().
The documentation for this struct was generated from the following files:
- include/llvm/DebugInfo/GSYM/FunctionInfo.h
- lib/DebugInfo/GSYM/FunctionInfo.cpp