LLVM 20.0.0git
|
Function information in GSYM files encodes information for one contiguous address range. More...
#include "llvm/DebugInfo/GSYM/FunctionInfo.h"
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::Expected< uint64_t > | encode (FileWriter &O, bool NoPadding=false) const |
Encode this object into FileWriter stream. | |
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 () |
Static Public Member Functions | |
static llvm::Expected< FunctionInfo > | decode (DataExtractor &Data, uint64_t BaseAddr) |
Decode an object from a binary data stream. | |
static llvm::Expected< LookupResult > | lookup (DataExtractor &Data, const GsymReader &GR, uint64_t FuncAddr, uint64_t Addr) |
Lookup an address within a FunctionInfo object's data stream. | |
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 |
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 };
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 89 of file FunctionInfo.h.
|
inline |
Definition at line 100 of file FunctionInfo.h.
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(...).
Definition at line 108 of file FunctionInfo.cpp.
References llvm::SmallVectorImpl< T >::clear(), llvm::consumeError(), encode(), EncodingCache, isValid(), llvm::native, and llvm::SmallVectorBase< Size_T >::size().
|
inline |
Definition at line 198 of file FunctionInfo.h.
References Inline, Name, OptLineTable, and Range.
|
static |
Decode an object from a binary data stream.
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. |
Definition at line 38 of file FunctionInfo.cpp.
References llvm::createStringError(), llvm::Data, llvm::gsym::InlineInfo::decode(), llvm::gsym::LineTable::decode(), llvm::gsym::MergedFunctionsInfo::decode(), llvm::Done, II, Inline, IT, MergedFunctions, MI, Name, llvm::Offset, OptLineTable, and Range.
Referenced by llvm::gsym::MergedFunctionsInfo::decode(), llvm::gsym::GsymReader::getFunctionInfo(), and llvm::gsym::GsymReader::getFunctionInfoAtIndex().
llvm::Expected< uint64_t > FunctionInfo::encode | ( | FileWriter & | O, |
bool | NoPadding = false |
||
) | const |
Encode this object into FileWriter stream.
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. |
Definition at line 123 of file FunctionInfo.cpp.
References llvm::gsym::FileWriter::alignTo(), llvm::createStringError(), llvm::SmallVectorTemplateCommon< T, typename >::data(), llvm::SmallVectorBase< Size_T >::empty(), EncodingCache, llvm::gsym::FileWriter::fixup32(), llvm::gsym::FileWriter::getByteOrder(), Inline, isValid(), llvm::Length, MergedFunctions, Name, llvm::native, OptLineTable, Range, llvm::SmallVectorBase< Size_T >::size(), size(), llvm::AddressRange::start(), llvm::gsym::FileWriter::tell(), llvm::gsym::FileWriter::writeData(), and llvm::gsym::FileWriter::writeU32().
Referenced by cacheEncoding().
|
inline |
Definition at line 195 of file FunctionInfo.h.
References llvm::AddressRange::end(), and Range.
Referenced by convertFunctionLineTable().
|
inline |
Query if a FunctionInfo has rich debug info.
Definition at line 110 of file FunctionInfo.h.
References Inline, and OptLineTable.
Referenced by llvm::gsym::GsymCreator::finalize().
|
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.
Definition at line 121 of file FunctionInfo.h.
References Name.
Referenced by cacheEncoding(), and encode().
|
static |
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.
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. |
Definition at line 209 of file FunctionInfo.cpp.
References Addr, llvm::gsym::SourceLocation::Base, llvm::AddressRange::contains(), llvm::createStringError(), llvm::Data, llvm::gsym::SourceLocation::Dir, llvm::Done, llvm::gsym::LineEntry::File, llvm::gsym::LookupResult::FuncName, llvm::gsym::LookupResult::FuncRange, llvm::gsym::GsymReader::getFile(), llvm::gsym::GsymReader::getString(), IT, llvm::gsym::LineEntry::Line, llvm::gsym::SourceLocation::Line, llvm::gsym::LookupResult::Locations, llvm::gsym::InlineInfo::lookup(), llvm::gsym::LineTable::lookup(), llvm::gsym::LookupResult::LookupAddr, llvm::gsym::SourceLocation::Name, llvm::gsym::SourceLocation::Offset, llvm::Offset, llvm::AddressRange::size(), and llvm::StringRef::size().
Referenced by llvm::gsym::GsymReader::lookup().
|
inline |
Definition at line 196 of file FunctionInfo.h.
References Range, and llvm::AddressRange::size().
Referenced by encode(), and llvm::gsym::DwarfTransformer::verify().
|
inline |
Definition at line 194 of file FunctionInfo.h.
References Range, and llvm::AddressRange::start().
Referenced by convertFunctionLineTable().
SmallString<32> llvm::gsym::FunctionInfo::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.
Definition at line 98 of file FunctionInfo.h.
Referenced by cacheEncoding(), and encode().
std::optional<InlineInfo> llvm::gsym::FunctionInfo::Inline |
Definition at line 93 of file FunctionInfo.h.
Referenced by clear(), decode(), llvm::gsym::GsymReader::dump(), encode(), hasRichInfo(), and llvm::gsym::operator<<().
std::optional<MergedFunctionsInfo> llvm::gsym::FunctionInfo::MergedFunctions |
Definition at line 94 of file FunctionInfo.h.
Referenced by decode(), llvm::gsym::GsymReader::dump(), encode(), and llvm::gsym::GsymCreator::prepareMergedFunctions().
uint32_t llvm::gsym::FunctionInfo::Name |
String table offset in the string table.
Definition at line 91 of file FunctionInfo.h.
Referenced by clear(), decode(), llvm::gsym::GsymReader::dump(), encode(), isValid(), and llvm::gsym::operator<<().
std::optional<LineTable> llvm::gsym::FunctionInfo::OptLineTable |
Definition at line 92 of file FunctionInfo.h.
Referenced by clear(), convertFunctionLineTable(), decode(), llvm::gsym::GsymReader::dump(), encode(), hasRichInfo(), and llvm::gsym::operator<<().
AddressRange llvm::gsym::FunctionInfo::Range |
Definition at line 90 of file FunctionInfo.h.
Referenced by clear(), convertFunctionLineTable(), decode(), llvm::gsym::GsymReader::dump(), encode(), endAddress(), llvm::gsym::GsymCreator::finalize(), llvm::gsym::operator<<(), llvm::gsym::GsymCreator::prepareMergedFunctions(), size(), and startAddress().