struct Header

Declaration

struct Header { /* full declaration omitted */ };

Description

The GSYM header. The GSYM header is found at the start of a stand alone GSYM file, or as the first bytes in a section when GSYM is contained in a section of an executable file (ELF, mach-o, COFF). The structure is encoded exactly as it appears in the structure definition with no gaps between members. Alignment should not change from system to system as the members were laid out so that they shouldn't align differently on different architectures. When endianness of the system loading a GSYM file matches, the file can be mmap'ed in and a pointer to the header can be cast to the first bytes of the file (stand alone GSYM file) or section data (GSYM in a section). When endianness is swapped, the Header::decode() function should be used to decode the header.

Declared at: llvm/include/llvm/DebugInfo/GSYM/Header.h:45

Member Variables

public uint32_t Magic
The magic bytes should be set to GSYM_MAGIC. This helps detect if a file is a GSYM file by scanning the first 4 bytes of a file or section. This value might appear byte swapped
public uint16_t Version
The version can number determines how the header is decoded and how each InfoType in FunctionInfo is encoded/decoded. As version numbers increase, "Magic" and "Version" members should always appear at offset zero and 4 respectively to ensure clients figure out if they can parse the format.
public uint8_t AddrOffSize
The size in bytes of each address offset in the address offsets table.
public uint8_t UUIDSize
The size in bytes of the UUID encoded in the "UUID" member.
public uint64_t BaseAddress
The 64 bit base address that all address offsets in the address offsets table are relative to. Storing a full 64 bit address allows our address offsets table to be smaller on disk.
public uint32_t NumAddresses
The number of addresses stored in the address offsets table.
public uint32_t StrtabOffset
The file relative offset of the start of the string table for strings contained in the GSYM file. If the GSYM in contained in a stand alone file this will be the file offset of the start of the string table. If the GSYM is contained in a section within an executable file, this can be the offset of the first string used in the GSYM file and can possibly span one or more executable string tables. This allows the strings to share string tables in an ELF or mach-o file.
public uint32_t StrtabSize
The size in bytes of the string table. For a stand alone GSYM file, this will be the exact size in bytes of the string table. When the GSYM data is in a section within an executable file, this size can span one or more sections that contains strings. This allows any strings that are already stored in the executable file to be re-used, and any extra strings could be added to another string table and the string table offset and size can be set to span all needed string tables.
public uint8_t[20] UUID
The UUID of the original executable file. This is stored to allow matching a GSYM file to an executable file when symbolication is required. Only the first "UUIDSize" bytes of the UUID are valid. Any bytes in the UUID value that appear after the first UUIDSize bytes should be set to zero.

Method Overview

  • public llvm::Error checkForError() const
  • public static llvm::Expected<Header> decode(llvm::DataExtractor & Data)
  • public llvm::Error encode(llvm::gsym::FileWriter & O) const

Methods

llvm::Error checkForError() const

Description

Check if a header is valid and return an error if anything is wrong. This function can be used prior to encoding a header to ensure it is valid, or after decoding a header to ensure it is valid and supported. Check a correctly byte swapped header for errors: - check magic value - check that version number is supported - check that the address offset size is supported - check that the UUID size is valid

Declared at: llvm/include/llvm/DebugInfo/GSYM/Header.h:101

Returns

An error if anything is wrong in the header, or Error::success() if there are no errors.

static llvm::Expected<Header> decode(
    llvm::DataExtractor& Data)

Description

Decode an object from a binary data stream.

Declared at: llvm/include/llvm/DebugInfo/GSYM/Header.h:111

Parameters

llvm::DataExtractor& 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.

Returns

A Header or an error describing the issue that was encountered during decoding.

llvm::Error encode(
    llvm::gsym::FileWriter& O) const

Description

Encode this object into FileWriter stream.

Declared at: llvm/include/llvm/DebugInfo/GSYM/Header.h:120

Parameters

llvm::gsym::FileWriter& O
The binary stream to write the data to at the current file position.

Returns

An error object that indicates success or failure of the encoding process.