LLVM 23.0.0git
GsymReader.h
Go to the documentation of this file.
1//===- GsymReader.h ---------------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_DEBUGINFO_GSYM_GSYMREADER_H
10#define LLVM_DEBUGINFO_GSYM_GSYMREADER_H
11
12#include "llvm/ADT/ArrayRef.h"
21#include "llvm/Support/Endian.h"
24#include <inttypes.h>
25#include <map>
26#include <memory>
27#include <stdint.h>
28#include <vector>
29
30namespace llvm {
31class MemoryBuffer;
32class raw_ostream;
33
34namespace gsym {
35
36/// GsymReader is used to read GSYM data from a file or buffer.
37///
38/// This class is optimized for very quick lookups when the endianness matches
39/// the host system. The header and the address table are designed to be mmap'ed
40/// as read only into memory and used without any parsing needed. If the
41/// endianness doesn't match, we swap the byte order of the address table into a
42/// separate buffer for efficient binary search. All the other data are parsed
43/// on demand with the correct endianness.
44///
45/// GsymReader objects must use one of the static functions to create an
46/// instance: GsymReader::openFile(...) and GsymReader::copyBuffer(...).
47
49protected:
50 std::unique_ptr<MemoryBuffer> MemBuffer;
52 /// Parsed GlobalData entries, keyed by type. Populated by
53 /// parseHeaderAndGlobalDataEntries().
54 std::map<GlobalInfoType, GlobalData> GlobalDataSections;
56 std::vector<uint8_t> SwappedAddrOffsets;
60
61 GsymReader(std::unique_ptr<MemoryBuffer> Buffer, llvm::endianness Endian);
62
63public:
65 virtual ~GsymReader() = default;
66
68
69 /// Get the GSYM version for this reader.
70 virtual uint16_t getVersion() const = 0;
71
72 /// Get the base address of this GSYM file.
73 virtual uint64_t getBaseAddress() const = 0;
74
75 /// Get the number of addresses in this GSYM file.
76 virtual uint64_t getNumAddresses() const = 0;
77
78 /// Get the address offset byte size for this GSYM file.
79 virtual uint8_t getAddressOffsetSize() const = 0;
80
81 /// Get the address info offset byte size for this GSYM file.
82 virtual uint8_t getAddressInfoOffsetSize() const = 0;
83
84 /// Get the string offset byte size for this GSYM file.
85 virtual uint8_t getStringOffsetSize() const = 0;
86
87 /// Construct a GsymReader from a file on disk.
88 ///
89 /// \param Path The file path the GSYM file to read.
90 /// \returns An expected GsymReader that contains the object or an error
91 /// object that indicates reason for failing to read the GSYM.
93 openFile(StringRef Path);
94
95 /// Construct a GsymReader from a buffer.
96 ///
97 /// \param Bytes A set of bytes that will be copied and owned by the
98 /// returned object on success.
99 /// \returns An expected GsymReader that contains the object or an error
100 /// object that indicates reason for failing to read the GSYM.
102 copyBuffer(StringRef Bytes);
103
104 /// Get the full function info for an address.
105 ///
106 /// This should be called when a client will store a copy of the complete
107 /// FunctionInfo for a given address. For one off lookups, use the lookup()
108 /// function below.
109 ///
110 /// Symbolication server processes might want to parse the entire function
111 /// info for a given address and cache it if the process stays around to
112 /// service many symbolication addresses, like for parsing profiling
113 /// information.
114 ///
115 /// \param Addr A virtual address from the orignal object file to lookup.
116 ///
117 /// \returns An expected FunctionInfo that contains the function info object
118 /// or an error object that indicates reason for failing to lookup the
119 /// address.
121
122 /// Get the full function info given an address index.
123 ///
124 /// \param AddrIdx A address index for an address in the address table.
125 ///
126 /// \returns An expected FunctionInfo that contains the function info object
127 /// or an error object that indicates reason for failing get the function
128 /// info object.
130 getFunctionInfoAtIndex(uint64_t AddrIdx) const;
131
132 /// Lookup an address in the a GSYM.
133 ///
134 /// Lookup just the information needed for a specific address \a Addr. This
135 /// function is faster that calling getFunctionInfo() as it will only return
136 /// information that pertains to \a Addr and allows the parsing to skip any
137 /// extra information encoded for other addresses. For example the line table
138 /// parsing can stop when a matching LineEntry has been fouhnd, and the
139 /// InlineInfo can stop parsing early once a match has been found and also
140 /// skip information that doesn't match. This avoids memory allocations and
141 /// is much faster for lookups.
142 ///
143 /// \param Addr A virtual address from the orignal object file to lookup.
144 ///
145 /// \param MergedFuncsData A pointer to an optional GsymDataExtractor that, if
146 /// non-null, will be set to the raw data of the MergedFunctionInfo, if
147 /// present.
148 ///
149 /// \returns An expected LookupResult that contains only the information
150 /// needed for the current address, or an error object that indicates reason
151 /// for failing to lookup the address.
153 lookup(uint64_t Addr,
154 std::optional<GsymDataExtractor> *MergedFuncsData = nullptr) const;
155
156 /// Lookup all merged functions for a given address.
157 ///
158 /// This function performs a lookup for the specified address and then
159 /// retrieves additional LookupResults from any merged functions associated
160 /// with the primary LookupResult.
161 ///
162 /// \param Addr The address to lookup.
163 ///
164 /// \returns A vector of LookupResult objects, where the first element is the
165 /// primary result, followed by results for any merged functions
167 lookupAll(uint64_t Addr) const;
168
169 /// Get a string from the string table.
170 ///
171 /// \param Offset The string table offset for the string to retrieve.
172 /// \returns The string from the strin table.
174
175 /// Get the a file entry for the suppplied file index.
176 ///
177 /// Used to convert any file indexes in the FunctionInfo data back into
178 /// files. This function can be used for iteration, but is more commonly used
179 /// for random access when doing lookups.
180 ///
181 /// \param Index An index into the file table.
182 /// \returns An optional FileInfo that will be valid if the file index is
183 /// valid, or std::nullopt if the file index is out of bounds,
184 std::optional<FileEntry> getFile(uint32_t Index) const {
185 uint64_t EntrySize =
186 FileEntry::getEncodedSize(FileEntryData.getStringOffsetSize());
187 uint64_t Offset = Index * EntrySize;
188 if (!FileEntryData.isValidOffsetForDataOfSize(Offset, EntrySize))
189 return std::nullopt;
190 FileEntry FE;
191 FE.Dir = FileEntryData.getStringOffset(&Offset);
192 FE.Base = FileEntryData.getStringOffset(&Offset);
193 return FE;
194 }
195
196 /// Dump the entire Gsym data contained in this object.
197 ///
198 /// \param OS The output stream to dump to.
199 virtual void dump(raw_ostream &OS) = 0;
200
201 /// Dump a FunctionInfo object.
202 ///
203 /// This function will convert any string table indexes and file indexes
204 /// into human readable format.
205 ///
206 /// \param OS The output stream to dump to.
207 ///
208 /// \param FI The object to dump.
209 ///
210 /// \param Indent The indentation as number of spaces. Used when dumping as an
211 /// item within MergedFunctionsInfo.
212 LLVM_ABI void dump(raw_ostream &OS, const FunctionInfo &FI,
213 uint32_t Indent = 0);
214
215 /// Dump a MergedFunctionsInfo object.
216 ///
217 /// This function will dump a MergedFunctionsInfo object - basically by
218 /// dumping the contained FunctionInfo objects with indentation.
219 ///
220 /// \param OS The output stream to dump to.
221 ///
222 /// \param MFI The object to dump.
223 LLVM_ABI void dump(raw_ostream &OS, const MergedFunctionsInfo &MFI);
224
225 /// Dump a CallSiteInfo object.
226 ///
227 /// This function will output the details of a CallSiteInfo object in a
228 /// human-readable format.
229 ///
230 /// \param OS The output stream to dump to.
231 ///
232 /// \param CSI The CallSiteInfo object to dump.
233 LLVM_ABI void dump(raw_ostream &OS, const CallSiteInfo &CSI);
234
235 /// Dump a CallSiteInfoCollection object.
236 ///
237 /// This function will iterate over a collection of CallSiteInfo objects and
238 /// dump each one.
239 ///
240 /// \param OS The output stream to dump to.
241 ///
242 /// \param CSIC The CallSiteInfoCollection object to dump.
243 ///
244 /// \param Indent The indentation as number of spaces. Used when dumping as an
245 /// item from within MergedFunctionsInfo.
246 LLVM_ABI void dump(raw_ostream &OS, const CallSiteInfoCollection &CSIC,
247 uint32_t Indent = 0);
248
249 /// Dump a LineTable object.
250 ///
251 /// This function will convert any string table indexes and file indexes
252 /// into human readable format.
253 ///
254 ///
255 /// \param OS The output stream to dump to.
256 ///
257 /// \param LT The object to dump.
258 ///
259 /// \param Indent The indentation as number of spaces. Used when dumping as an
260 /// item from within MergedFunctionsInfo.
261 LLVM_ABI void dump(raw_ostream &OS, const LineTable &LT, uint32_t Indent = 0);
262
263 /// Dump a InlineInfo object.
264 ///
265 /// This function will convert any string table indexes and file indexes
266 /// into human readable format.
267 ///
268 /// \param OS The output stream to dump to.
269 ///
270 /// \param II The object to dump.
271 ///
272 /// \param Indent The indentation as number of spaces. Used for recurive
273 /// dumping.
274 LLVM_ABI void dump(raw_ostream &OS, const InlineInfo &II,
275 uint32_t Indent = 0);
276
277 /// Dump a FileEntry object.
278 ///
279 /// This function will convert any string table indexes into human readable
280 /// format.
281 ///
282 /// \param OS The output stream to dump to.
283 ///
284 /// \param FE The object to dump.
285 LLVM_ABI void dump(raw_ostream &OS, std::optional<FileEntry> FE);
286
287 /// Gets an address from the address table.
288 ///
289 /// Addresses are stored as offsets frrom the gsym::Header::BaseAddress.
290 ///
291 /// \param Index A index into the address table.
292 /// \returns A resolved virtual address for adddress in the address table
293 /// or std::nullopt if Index is out of bounds.
294 LLVM_ABI std::optional<uint64_t> getAddress(size_t Index) const;
295
296protected:
297 /// Get the GlobalData entry for a section type.
298 ///
299 /// \param Type The section type to retrieve.
300 /// \returns The GlobalData entry, or std::nullopt if the section is not
301 /// present.
302 LLVM_ABI std::optional<GlobalData> getGlobalData(GlobalInfoType Type) const;
303
304 /// Get the raw bytes for a required GlobalData section as a StringRef.
305 ///
306 /// \param Type The section type to retrieve.
307 /// \returns The section data, or an error if the section is not present or
308 /// any bytes are not present in the file.
311
312 /// Get the raw bytes for an optional GlobalData section as a StringRef.
313 ///
314 /// \param Type The section type to retrieve.
315 /// \returns The section data, or std::nullopt if the section is not present
316 /// or any bytes are not present in the file.
317 LLVM_ABI std::optional<StringRef>
319
320 /// Parse the GSYM data from the memory buffer.
321 ///
322 /// \returns Error on failure.
324
325 /// Parse the version-specific header and populate GlobalDataSections.
326 ///
327 /// \returns Error on failure.
329
330 /// Parse and validate the header from the beginning of the memory buffer.
331 ///
332 /// \param OutHdr Output pointer to the parsed header.
333 /// \param OutSwappedHdr Storage for byte-swapped header if needed.
334 /// \returns Error on failure.
335 template <class HeaderT>
336 llvm::Error parseHeader(const HeaderT *&OutHdr,
337 std::unique_ptr<HeaderT> &OutSwappedHdr) {
338 const StringRef Buf = MemBuffer->getBuffer();
339 if (Buf.size() < HeaderT::getEncodedSize())
340 return createStringError(std::errc::invalid_argument,
341 "not enough data for a GSYM header");
343 // Non-swap case. Mmap the header.
344 OutHdr = reinterpret_cast<const HeaderT *>(Buf.data());
345 } else {
346 // Swap case. Decode with a GsymDataExtractor with the correct endianness.
348 OutSwappedHdr = std::make_unique<HeaderT>();
349 auto ExpectedHdr = HeaderT::decode(Data);
350 if (!ExpectedHdr)
351 return ExpectedHdr.takeError();
352 *OutSwappedHdr = *ExpectedHdr;
353 OutHdr = OutSwappedHdr.get();
354 }
355 if (Error Err = OutHdr->checkForError())
356 return Err;
357 return Error::success();
358 }
359
360 /// Parse GlobalData entries starting at \p Offset into GlobalDataSections.
361 ///
362 /// This should only be called by any GSYM version >= 2. If called by V1, an
363 /// error will be returned.
364 ///
365 /// \param Offset The byte offset where GlobalData entries begin.
366 /// \returns Error on failure.
368
369 /// Parse address offsets section bytes into AddrOffsets.
370 ///
371 /// \param Bytes The raw section bytes.
372 /// \returns Error on failure.
374
375 /// Set address info offsets section bytes into AddrInfoOffsetsData.
376 ///
377 /// \param Bytes The raw section bytes.
378 /// \returns Error on failure.
380
381 /// Set string table section bytes into StrTab.
382 ///
383 /// \param Bytes The raw section bytes.
384 /// \returns Error on failure.
386
387 /// Set file table section bytes into FileEntryData.
388 ///
389 /// \param Bytes The raw section bytes.
390 /// \returns Error on failure.
392
393 /// Get an appropriate address info offsets array.
394 ///
395 /// The address table in the GSYM file is stored as array of 1, 2, 4 or 8
396 /// byte offsets from the The gsym::Header::BaseAddress. The table is stored
397 /// internally as a array of bytes that are in the correct endianness. When
398 /// we access this table we must get an array that matches those sizes. This
399 /// templatized helper function is used when accessing address offsets in the
400 /// AddrOffsets member variable.
401 ///
402 /// \returns An ArrayRef of an appropriate address offset size.
403 template <class T> ArrayRef<T>
405 return ArrayRef<T>(reinterpret_cast<const T *>(AddrOffsets.data()),
406 AddrOffsets.size()/sizeof(T));
407 }
408
409 /// Get an appropriate address from the address table.
410 ///
411 /// The address table in the GSYM file is stored as array of 1, 2, 4 or 8
412 /// byte address offsets from the The gsym::Header::BaseAddress. The table is
413 /// stored internally as a array of bytes that are in the correct endianness.
414 /// In order to extract an address from the address table we must access the
415 /// address offset using the correct size and then add it to the BaseAddress
416 /// in the header.
417 ///
418 /// \param Index An index into the AddrOffsets array.
419 /// \returns An virtual address that matches the original object file for the
420 /// address as the specified index, or std::nullopt if Index is out of bounds.
421 template <class T>
422 std::optional<uint64_t> addressForIndex(size_t Index) const {
424 if (Index < AIO.size())
425 return AIO[Index] + getBaseAddress();
426 return std::nullopt;
427 }
428
429 /// Lookup an address offset in the AddrOffsets table.
430 ///
431 /// Given an address offset, look it up using a binary search of the
432 /// AddrOffsets table.
433 ///
434 /// \param AddrOffset An address offset, that has already been computed by
435 /// subtracting the gsym::Header::BaseAddress.
436 /// \returns The matching address offset index. This index will be used to
437 /// extract the FunctionInfo data's offset from the AddrInfoOffsets array.
438 template <class T>
439 std::optional<uint64_t>
440 getAddressOffsetIndex(const uint64_t AddrOffset) const {
442 const auto Begin = AIO.begin();
443 const auto End = AIO.end();
444 auto Iter = std::lower_bound(Begin, End, AddrOffset);
445 // Watch for addresses that fall between the gsym::Header::BaseAddress and
446 // the first address offset.
447 if (Iter == Begin && AddrOffset < *Begin)
448 return std::nullopt;
449 if (Iter == End || AddrOffset < *Iter)
450 --Iter;
451
452 // GSYM files have sorted function infos with the most information (line
453 // table and/or inline info) first in the array of function infos, so
454 // always backup as much as possible as long as the address offset is the
455 // same as the previous entry.
456 while (Iter != Begin) {
457 auto Prev = Iter - 1;
458 if (*Prev == *Iter)
459 Iter = Prev;
460 else
461 break;
462 }
463
464 return std::distance(Begin, Iter);
465 }
466
467 /// Create a GSYM from a memory buffer.
468 ///
469 /// Called by both openFile() and copyBuffer(), this function does all of the
470 /// work of parsing the GSYM file and returning an error.
471 ///
472 /// \param MemBuffer A memory buffer that will transfer ownership into the
473 /// GsymReader.
474 /// \returns An expected GsymReader that contains the object or an error
475 /// object that indicates reason for failing to read the GSYM.
477 create(std::unique_ptr<MemoryBuffer> &MemBuffer);
478
479 /// Given an address, find the address index.
480 ///
481 /// Binary search the address table and find the matching address index.
482 ///
483 /// \param Addr A virtual address that matches the original object file
484 /// to lookup.
485 /// \returns An index into the address table. This index can be used to
486 /// extract the FunctionInfo data's offset from the AddrInfoOffsets array.
487 /// Returns an error if the address isn't in the GSYM with details of why.
489
490 /// Given an address index, get the offset for the FunctionInfo.
491 ///
492 /// Looking up an address is done by finding the corresponding address
493 /// index for the address. This index is then used to get the offset of the
494 /// FunctionInfo data that we will decode using this function.
495 ///
496 /// \param Index An index into the address table.
497 /// \returns An optional GSYM data offset for the offset of the FunctionInfo
498 /// that needs to be decoded.
499 LLVM_ABI std::optional<uint64_t> getAddressInfoOffset(size_t Index) const;
500
501 /// Given an address, find the correct function info data and function
502 /// address.
503 ///
504 /// Binary search the address table and find the matching address info
505 /// and make sure that the function info contains the address. GSYM allows
506 /// functions to overlap, and the most debug info is contained in the first
507 /// entries due to the sorting when GSYM files are created. We can have
508 /// multiple function info that start at the same address only if their
509 /// address range doesn't match. So find the first entry that matches \a Addr
510 /// and iterate forward until we find one that contains the address.
511 ///
512 /// \param[in] Addr A virtual address that matches the original object file
513 /// to lookup.
514 ///
515 /// \param[out] FuncStartAddr A virtual address that is the base address of
516 /// the function that is used for decoding the FunctionInfo.
517 ///
518 /// \returns An valid data extractor on success, or an error if we fail to
519 /// find the address in a function info or corrrectly decode the data
521 getFunctionInfoDataForAddress(uint64_t Addr, uint64_t &FuncStartAddr) const;
522
523 /// Get the function data and address given an address index.
524 ///
525 /// \param AddrIdx A address index from the address table.
526 ///
527 /// \returns An expected FunctionInfo that contains the function info object
528 /// or an error object that indicates reason for failing to lookup the
529 /// address.
531 getFunctionInfoDataAtIndex(uint64_t AddrIdx, uint64_t &FuncStartAddr) const;
532};
533
534} // namespace gsym
535} // namespace llvm
536
537#endif // LLVM_DEBUGINFO_GSYM_GSYMREADER_H
#define LLVM_ABI
Definition Compiler.h:213
Provides ErrorOr<T> smart pointer.
#define T
uint64_t IntrinsicInst * II
Value * RHS
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
iterator end() const
Definition ArrayRef.h:131
size_t size() const
size - Get the array size.
Definition ArrayRef.h:142
iterator begin() const
Definition ArrayRef.h:130
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
static ErrorSuccess success()
Create a success value.
Definition Error.h:336
Tagged union holding either a T or a Error.
Definition Error.h:485
This interface provides simple read-only access to a block of memory, and provides simple methods for...
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
constexpr size_t size() const
size - Get the string size.
Definition StringRef.h:143
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition StringRef.h:137
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
A DataExtractor subclass that adds GSYM-specific string offset support.
StringRef getString(gsym_strp_t Offset) const
Get a string from the string table.
Definition GsymReader.h:173
llvm::Error setAddrInfoOffsetsData(StringRef Bytes)
Set address info offsets section bytes into AddrInfoOffsetsData.
llvm::Error parseGlobalDataEntries(uint64_t Offset)
Parse GlobalData entries starting at Offset into GlobalDataSections.
GsymDataExtractor FileEntryData
Definition GsymReader.h:58
LLVM_ABI llvm::Expected< GsymDataExtractor > getFunctionInfoDataAtIndex(uint64_t AddrIdx, uint64_t &FuncStartAddr) const
Get the function data and address given an address index.
virtual uint8_t getStringOffsetSize() const =0
Get the string offset byte size for this GSYM file.
static LLVM_ABI llvm::Expected< std::unique_ptr< GsymReader > > copyBuffer(StringRef Bytes)
Construct a GsymReader from a buffer.
virtual llvm::Error parseHeaderAndGlobalDataEntries()=0
Parse the version-specific header and populate GlobalDataSections.
std::optional< FileEntry > getFile(uint32_t Index) const
Get the a file entry for the suppplied file index.
Definition GsymReader.h:184
bool isLittleEndian() const
Definition GsymReader.h:67
LLVM_ABI std::optional< GlobalData > getGlobalData(GlobalInfoType Type) const
Get the GlobalData entry for a section type.
llvm::Error parseHeader(const HeaderT *&OutHdr, std::unique_ptr< HeaderT > &OutSwappedHdr)
Parse and validate the header from the beginning of the memory buffer.
Definition GsymReader.h:336
ArrayRef< uint8_t > AddrOffsets
Definition GsymReader.h:55
llvm::Error setFileTableData(StringRef Bytes)
Set file table section bytes into FileEntryData.
GsymDataExtractor AddrInfoOffsetsData
Definition GsymReader.h:57
static LLVM_ABI llvm::Expected< std::unique_ptr< GsymReader > > create(std::unique_ptr< MemoryBuffer > &MemBuffer)
Create a GSYM from a memory buffer.
LLVM_ABI std::optional< uint64_t > getAddress(size_t Index) const
Gets an address from the address table.
LLVM_ABI std::optional< uint64_t > getAddressInfoOffset(size_t Index) const
Given an address index, get the offset for the FunctionInfo.
ArrayRef< T > getAddrOffsets() const
Get an appropriate address info offsets array.
Definition GsymReader.h:404
GsymReader(std::unique_ptr< MemoryBuffer > Buffer, llvm::endianness Endian)
virtual uint16_t getVersion() const =0
Get the GSYM version for this reader.
llvm::Error setStringTableData(StringRef Bytes)
Set string table section bytes into StrTab.
LLVM_ABI llvm::Expected< StringRef > getRequiredGlobalDataBytes(GlobalInfoType Type) const
Get the raw bytes for a required GlobalData section as a StringRef.
LLVM_ABI llvm::Expected< FunctionInfo > getFunctionInfo(uint64_t Addr) const
Get the full function info for an address.
std::optional< uint64_t > addressForIndex(size_t Index) const
Get an appropriate address from the address table.
Definition GsymReader.h:422
LLVM_ABI llvm::Expected< LookupResult > lookup(uint64_t Addr, std::optional< GsymDataExtractor > *MergedFuncsData=nullptr) const
Lookup an address in the a GSYM.
std::vector< uint8_t > SwappedAddrOffsets
Definition GsymReader.h:56
LLVM_ABI GsymReader(GsymReader &&RHS)=default
llvm::Error parseAddrOffsets(StringRef Bytes)
Parse address offsets section bytes into AddrOffsets.
LLVM_ABI llvm::Expected< GsymDataExtractor > getFunctionInfoDataForAddress(uint64_t Addr, uint64_t &FuncStartAddr) const
Given an address, find the correct function info data and function address.
virtual ~GsymReader()=default
LLVM_ABI Expected< uint64_t > getAddressIndex(const uint64_t Addr) const
Given an address, find the address index.
virtual uint64_t getNumAddresses() const =0
Get the number of addresses in this GSYM file.
std::map< GlobalInfoType, GlobalData > GlobalDataSections
Parsed GlobalData entries, keyed by type.
Definition GsymReader.h:54
LLVM_ABI llvm::Error parse()
Parse the GSYM data from the memory buffer.
virtual uint8_t getAddressInfoOffsetSize() const =0
Get the address info offset byte size for this GSYM file.
std::unique_ptr< MemoryBuffer > MemBuffer
Definition GsymReader.h:50
virtual void dump(raw_ostream &OS)=0
Dump the entire Gsym data contained in this object.
static LLVM_ABI llvm::Expected< std::unique_ptr< GsymReader > > openFile(StringRef Path)
Construct a GsymReader from a file on disk.
LLVM_ABI llvm::Expected< FunctionInfo > getFunctionInfoAtIndex(uint64_t AddrIdx) const
Get the full function info given an address index.
virtual uint8_t getAddressOffsetSize() const =0
Get the address offset byte size for this GSYM file.
llvm::endianness Endian
Definition GsymReader.h:51
LLVM_ABI llvm::Expected< std::vector< LookupResult > > lookupAll(uint64_t Addr) const
Lookup all merged functions for a given address.
virtual uint64_t getBaseAddress() const =0
Get the base address of this GSYM file.
std::optional< uint64_t > getAddressOffsetIndex(const uint64_t AddrOffset) const
Lookup an address offset in the AddrOffsets table.
Definition GsymReader.h:440
LLVM_ABI std::optional< StringRef > getOptionalGlobalDataBytes(GlobalInfoType Type) const
Get the raw bytes for an optional GlobalData section as a StringRef.
LineTable class contains deserialized versions of line tables for each function's address ranges.
Definition LineTable.h:119
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
uint64_t gsym_strp_t
The type of string offset used in the code.
Definition GsymTypes.h:21
GlobalInfoType
GlobalInfoType allows GSYM files to encode global information within a GSYM file in a way that is ext...
Definition GlobalData.h:26
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:532
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Definition Error.h:1321
FunctionAddr VTableAddr uintptr_t uintptr_t Data
Definition InstrProf.h:221
endianness
Definition bit.h:71
Files in GSYM are contained in FileEntry structs where we split the directory and basename into two d...
Definition FileEntry.h:25
static constexpr uint64_t getEncodedSize(uint8_t StringOffsetSize)
Returns the on-disk encoded size of a FileEntry for the given string offset size.
Definition FileEntry.h:38
gsym_strp_t Dir
Offsets in the string table.
Definition FileEntry.h:29
Function information in GSYM files encodes information for one contiguous address range.
Inline information stores the name of the inline function along with an array of address ranges.
Definition InlineInfo.h:61
String tables in GSYM files are required to start with an empty string at offset zero.
Definition StringTable.h:22