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 LLVM_ABI GsymReader(std::unique_ptr<MemoryBuffer> Buffer,
63
64public:
66 virtual ~GsymReader() = default;
67
69
70 /// Get the GSYM version for this reader.
71 virtual uint16_t getVersion() const = 0;
72
73 /// Get the base address of this GSYM file.
74 virtual uint64_t getBaseAddress() const = 0;
75
76 /// Get the number of addresses in this GSYM file.
77 virtual uint64_t getNumAddresses() const = 0;
78
79 /// Get the address offset byte size for this GSYM file.
80 virtual uint8_t getAddressOffsetSize() const = 0;
81
82 /// Get the address info offset byte size for this GSYM file.
83 virtual uint8_t getAddressInfoOffsetSize() const = 0;
84
85 /// Get the string offset byte size for this GSYM file.
86 virtual uint8_t getStringOffsetSize() const = 0;
87
88 /// Construct a GsymReader from a file on disk.
89 ///
90 /// \param Path The file path the GSYM file to read.
91 /// \returns An expected GsymReader that contains the object or an error
92 /// object that indicates reason for failing to read the GSYM.
94 openFile(StringRef Path);
95
96 /// Construct a GsymReader from a buffer.
97 ///
98 /// \param Bytes A set of bytes that will be copied and owned by the
99 /// returned object on success.
100 /// \returns An expected GsymReader that contains the object or an error
101 /// object that indicates reason for failing to read the GSYM.
103 copyBuffer(StringRef Bytes);
104
105 /// Get the full function info for an address.
106 ///
107 /// This should be called when a client will store a copy of the complete
108 /// FunctionInfo for a given address. For one off lookups, use the lookup()
109 /// function below.
110 ///
111 /// Symbolication server processes might want to parse the entire function
112 /// info for a given address and cache it if the process stays around to
113 /// service many symbolication addresses, like for parsing profiling
114 /// information.
115 ///
116 /// \param Addr A virtual address from the orignal object file to lookup.
117 ///
118 /// \returns An expected FunctionInfo that contains the function info object
119 /// or an error object that indicates reason for failing to lookup the
120 /// address.
122
123 /// Get the full function info given an address index.
124 ///
125 /// \param AddrIdx A address index for an address in the address table.
126 ///
127 /// \returns An expected FunctionInfo that contains the function info object
128 /// or an error object that indicates reason for failing get the function
129 /// info object.
131 getFunctionInfoAtIndex(uint64_t AddrIdx) const;
132
133 /// Lookup an address in the a GSYM.
134 ///
135 /// Lookup just the information needed for a specific address \a Addr. This
136 /// function is faster that calling getFunctionInfo() as it will only return
137 /// information that pertains to \a Addr and allows the parsing to skip any
138 /// extra information encoded for other addresses. For example the line table
139 /// parsing can stop when a matching LineEntry has been fouhnd, and the
140 /// InlineInfo can stop parsing early once a match has been found and also
141 /// skip information that doesn't match. This avoids memory allocations and
142 /// is much faster for lookups.
143 ///
144 /// \param Addr A virtual address from the orignal object file to lookup.
145 ///
146 /// \param MergedFuncsData A pointer to an optional GsymDataExtractor that, if
147 /// non-null, will be set to the raw data of the MergedFunctionInfo, if
148 /// present.
149 ///
150 /// \returns An expected LookupResult that contains only the information
151 /// needed for the current address, or an error object that indicates reason
152 /// for failing to lookup the address.
154 lookup(uint64_t Addr,
155 std::optional<GsymDataExtractor> *MergedFuncsData = nullptr) const;
156
157 /// Lookup all merged functions for a given address.
158 ///
159 /// This function performs a lookup for the specified address and then
160 /// retrieves additional LookupResults from any merged functions associated
161 /// with the primary LookupResult.
162 ///
163 /// \param Addr The address to lookup.
164 ///
165 /// \returns A vector of LookupResult objects, where the first element is the
166 /// primary result, followed by results for any merged functions
168 lookupAll(uint64_t Addr) const;
169
170 /// Get a string from the string table.
171 ///
172 /// \param Offset The string table offset for the string to retrieve.
173 /// \returns The string from the strin table.
175
176 /// Get the a file entry for the suppplied file index.
177 ///
178 /// Used to convert any file indexes in the FunctionInfo data back into
179 /// files. This function can be used for iteration, but is more commonly used
180 /// for random access when doing lookups.
181 ///
182 /// \param Index An index into the file table.
183 /// \returns An optional FileInfo that will be valid if the file index is
184 /// valid, or std::nullopt if the file index is out of bounds,
185 std::optional<FileEntry> getFile(uint32_t Index) const {
186 uint64_t EntrySize =
187 FileEntry::getEncodedSize(FileEntryData.getStringOffsetSize());
188 uint64_t Offset = Index * EntrySize;
189 if (!FileEntryData.isValidOffsetForDataOfSize(Offset, EntrySize))
190 return std::nullopt;
191 FileEntry FE;
192 FE.Dir = FileEntryData.getStringOffset(&Offset);
193 FE.Base = FileEntryData.getStringOffset(&Offset);
194 return FE;
195 }
196
197 /// Dump the entire Gsym data contained in this object.
198 ///
199 /// \param OS The output stream to dump to.
200 virtual void dump(raw_ostream &OS) = 0;
201
202 /// Dump a FunctionInfo object.
203 ///
204 /// This function will convert any string table indexes and file indexes
205 /// into human readable format.
206 ///
207 /// \param OS The output stream to dump to.
208 ///
209 /// \param FI The object to dump.
210 ///
211 /// \param Indent The indentation as number of spaces. Used when dumping as an
212 /// item within MergedFunctionsInfo.
213 LLVM_ABI void dump(raw_ostream &OS, const FunctionInfo &FI,
214 uint32_t Indent = 0);
215
216 /// Dump a MergedFunctionsInfo object.
217 ///
218 /// This function will dump a MergedFunctionsInfo object - basically by
219 /// dumping the contained FunctionInfo objects with indentation.
220 ///
221 /// \param OS The output stream to dump to.
222 ///
223 /// \param MFI The object to dump.
224 LLVM_ABI void dump(raw_ostream &OS, const MergedFunctionsInfo &MFI);
225
226 /// Dump a CallSiteInfo object.
227 ///
228 /// This function will output the details of a CallSiteInfo object in a
229 /// human-readable format.
230 ///
231 /// \param OS The output stream to dump to.
232 ///
233 /// \param CSI The CallSiteInfo object to dump.
234 LLVM_ABI void dump(raw_ostream &OS, const CallSiteInfo &CSI);
235
236 /// Dump a CallSiteInfoCollection object.
237 ///
238 /// This function will iterate over a collection of CallSiteInfo objects and
239 /// dump each one.
240 ///
241 /// \param OS The output stream to dump to.
242 ///
243 /// \param CSIC The CallSiteInfoCollection object to dump.
244 ///
245 /// \param Indent The indentation as number of spaces. Used when dumping as an
246 /// item from within MergedFunctionsInfo.
247 LLVM_ABI void dump(raw_ostream &OS, const CallSiteInfoCollection &CSIC,
248 uint32_t Indent = 0);
249
250 /// Dump a LineTable object.
251 ///
252 /// This function will convert any string table indexes and file indexes
253 /// into human readable format.
254 ///
255 ///
256 /// \param OS The output stream to dump to.
257 ///
258 /// \param LT The object to dump.
259 ///
260 /// \param Indent The indentation as number of spaces. Used when dumping as an
261 /// item from within MergedFunctionsInfo.
262 LLVM_ABI void dump(raw_ostream &OS, const LineTable &LT, uint32_t Indent = 0);
263
264 /// Dump a InlineInfo object.
265 ///
266 /// This function will convert any string table indexes and file indexes
267 /// into human readable format.
268 ///
269 /// \param OS The output stream to dump to.
270 ///
271 /// \param II The object to dump.
272 ///
273 /// \param Indent The indentation as number of spaces. Used for recurive
274 /// dumping.
275 LLVM_ABI void dump(raw_ostream &OS, const InlineInfo &II,
276 uint32_t Indent = 0);
277
278 /// Dump a FileEntry object.
279 ///
280 /// This function will convert any string table indexes into human readable
281 /// format.
282 ///
283 /// \param OS The output stream to dump to.
284 ///
285 /// \param FE The object to dump.
286 LLVM_ABI void dump(raw_ostream &OS, std::optional<FileEntry> FE);
287
288 /// Gets an address from the address table.
289 ///
290 /// Addresses are stored as offsets frrom the gsym::Header::BaseAddress.
291 ///
292 /// \param Index A index into the address table.
293 /// \returns A resolved virtual address for adddress in the address table
294 /// or std::nullopt if Index is out of bounds.
295 LLVM_ABI std::optional<uint64_t> getAddress(size_t Index) const;
296
297protected:
298 /// Get the GlobalData entry for a section type.
299 ///
300 /// \param Type The section type to retrieve.
301 /// \returns The GlobalData entry, or std::nullopt if the section is not
302 /// present.
303 LLVM_ABI std::optional<GlobalData> getGlobalData(GlobalInfoType Type) const;
304
305 /// Get the raw bytes for a required GlobalData section as a StringRef.
306 ///
307 /// \param Type The section type to retrieve.
308 /// \returns The section data, or an error if the section is not present or
309 /// any bytes are not present in the file.
312
313 /// Get the raw bytes for an optional GlobalData section as a StringRef.
314 ///
315 /// \param Type The section type to retrieve.
316 /// \returns The section data, or std::nullopt if the section is not present
317 /// or any bytes are not present in the file.
318 LLVM_ABI std::optional<StringRef>
320
321 /// Parse the GSYM data from the memory buffer.
322 ///
323 /// \returns Error on failure.
325
326 /// Parse the version-specific header and populate GlobalDataSections.
327 ///
328 /// \returns Error on failure.
330
331 /// Parse and validate the header from the beginning of the memory buffer.
332 ///
333 /// \param OutHdr Output pointer to the parsed header.
334 /// \param OutSwappedHdr Storage for byte-swapped header if needed.
335 /// \returns Error on failure.
336 template <class HeaderT>
337 llvm::Error parseHeader(const HeaderT *&OutHdr,
338 std::unique_ptr<HeaderT> &OutSwappedHdr) {
339 const StringRef Buf = MemBuffer->getBuffer();
340 if (Buf.size() < HeaderT::getEncodedSize())
341 return createStringError(std::errc::invalid_argument,
342 "not enough data for a GSYM header");
344 // Non-swap case. Mmap the header.
345 OutHdr = reinterpret_cast<const HeaderT *>(Buf.data());
346 } else {
347 // Swap case. Decode with a GsymDataExtractor with the correct endianness.
349 OutSwappedHdr = std::make_unique<HeaderT>();
350 auto ExpectedHdr = HeaderT::decode(Data);
351 if (!ExpectedHdr)
352 return ExpectedHdr.takeError();
353 *OutSwappedHdr = *ExpectedHdr;
354 OutHdr = OutSwappedHdr.get();
355 }
356 if (Error Err = OutHdr->checkForError())
357 return Err;
358 return Error::success();
359 }
360
361 /// Parse GlobalData entries starting at \p Offset into GlobalDataSections.
362 ///
363 /// This should only be called by any GSYM version >= 2. If called by V1, an
364 /// error will be returned.
365 ///
366 /// \param Offset The byte offset where GlobalData entries begin.
367 /// \returns Error on failure.
369
370 /// Parse address offsets section bytes into AddrOffsets.
371 ///
372 /// \param Bytes The raw section bytes.
373 /// \returns Error on failure.
375
376 /// Set address info offsets section bytes into AddrInfoOffsetsData.
377 ///
378 /// \param Bytes The raw section bytes.
379 /// \returns Error on failure.
381
382 /// Set string table section bytes into StrTab.
383 ///
384 /// \param Bytes The raw section bytes.
385 /// \returns Error on failure.
387
388 /// Set file table section bytes into FileEntryData.
389 ///
390 /// \param Bytes The raw section bytes.
391 /// \returns Error on failure.
393
394 /// Get an appropriate address info offsets array.
395 ///
396 /// The address table in the GSYM file is stored as array of 1, 2, 4 or 8
397 /// byte offsets from the The gsym::Header::BaseAddress. The table is stored
398 /// internally as a array of bytes that are in the correct endianness. When
399 /// we access this table we must get an array that matches those sizes. This
400 /// templatized helper function is used when accessing address offsets in the
401 /// AddrOffsets member variable.
402 ///
403 /// \returns An ArrayRef of an appropriate address offset size.
404 template <class T> ArrayRef<T>
406 return ArrayRef<T>(reinterpret_cast<const T *>(AddrOffsets.data()),
407 AddrOffsets.size()/sizeof(T));
408 }
409
410 /// Get an appropriate address from the address table.
411 ///
412 /// The address table in the GSYM file is stored as array of 1, 2, 4 or 8
413 /// byte address offsets from the The gsym::Header::BaseAddress. The table is
414 /// stored internally as a array of bytes that are in the correct endianness.
415 /// In order to extract an address from the address table we must access the
416 /// address offset using the correct size and then add it to the BaseAddress
417 /// in the header.
418 ///
419 /// \param Index An index into the AddrOffsets array.
420 /// \returns An virtual address that matches the original object file for the
421 /// address as the specified index, or std::nullopt if Index is out of bounds.
422 template <class T>
423 std::optional<uint64_t> addressForIndex(size_t Index) const {
425 if (Index < AIO.size())
426 return AIO[Index] + getBaseAddress();
427 return std::nullopt;
428 }
429
430 /// Lookup an address offset in the AddrOffsets table.
431 ///
432 /// Given an address offset, look it up using a binary search of the
433 /// AddrOffsets table.
434 ///
435 /// \param AddrOffset An address offset, that has already been computed by
436 /// subtracting the gsym::Header::BaseAddress.
437 /// \returns The matching address offset index. This index will be used to
438 /// extract the FunctionInfo data's offset from the AddrInfoOffsets array.
439 template <class T>
440 std::optional<uint64_t>
441 getAddressOffsetIndex(const uint64_t AddrOffset) const {
443 const auto Begin = AIO.begin();
444 const auto End = AIO.end();
445 auto Iter = std::lower_bound(Begin, End, AddrOffset);
446 // Watch for addresses that fall between the gsym::Header::BaseAddress and
447 // the first address offset.
448 if (Iter == Begin && AddrOffset < *Begin)
449 return std::nullopt;
450 if (Iter == End || AddrOffset < *Iter)
451 --Iter;
452
453 // GSYM files have sorted function infos with the most information (line
454 // table and/or inline info) first in the array of function infos, so
455 // always backup as much as possible as long as the address offset is the
456 // same as the previous entry.
457 while (Iter != Begin) {
458 auto Prev = Iter - 1;
459 if (*Prev == *Iter)
460 Iter = Prev;
461 else
462 break;
463 }
464
465 return std::distance(Begin, Iter);
466 }
467
468 /// Create a GSYM from a memory buffer.
469 ///
470 /// Called by both openFile() and copyBuffer(), this function does all of the
471 /// work of parsing the GSYM file and returning an error.
472 ///
473 /// \param MemBuffer A memory buffer that will transfer ownership into the
474 /// GsymReader.
475 /// \returns An expected GsymReader that contains the object or an error
476 /// object that indicates reason for failing to read the GSYM.
478 create(std::unique_ptr<MemoryBuffer> &MemBuffer);
479
480 /// Given an address, find the address index.
481 ///
482 /// Binary search the address table and find the matching address index.
483 ///
484 /// \param Addr A virtual address that matches the original object file
485 /// to lookup.
486 /// \returns An index into the address table. This index can be used to
487 /// extract the FunctionInfo data's offset from the AddrInfoOffsets array.
488 /// Returns an error if the address isn't in the GSYM with details of why.
490
491 /// Given an address index, get the offset for the FunctionInfo.
492 ///
493 /// Looking up an address is done by finding the corresponding address
494 /// index for the address. This index is then used to get the offset of the
495 /// FunctionInfo data that we will decode using this function.
496 ///
497 /// \param Index An index into the address table.
498 /// \returns An optional GSYM data offset for the offset of the FunctionInfo
499 /// that needs to be decoded.
500 LLVM_ABI std::optional<uint64_t> getAddressInfoOffset(size_t Index) const;
501
502 /// Given an address, find the correct function info data and function
503 /// address.
504 ///
505 /// Binary search the address table and find the matching address info
506 /// and make sure that the function info contains the address. GSYM allows
507 /// functions to overlap, and the most debug info is contained in the first
508 /// entries due to the sorting when GSYM files are created. We can have
509 /// multiple function info that start at the same address only if their
510 /// address range doesn't match. So find the first entry that matches \a Addr
511 /// and iterate forward until we find one that contains the address.
512 ///
513 /// \param[in] Addr A virtual address that matches the original object file
514 /// to lookup.
515 ///
516 /// \param[out] FuncStartAddr A virtual address that is the base address of
517 /// the function that is used for decoding the FunctionInfo.
518 ///
519 /// \returns An valid data extractor on success, or an error if we fail to
520 /// find the address in a function info or corrrectly decode the data
522 getFunctionInfoDataForAddress(uint64_t Addr, uint64_t &FuncStartAddr) const;
523
524 /// Get the function data and address given an address index.
525 ///
526 /// \param AddrIdx A address index from the address table.
527 ///
528 /// \returns An expected FunctionInfo that contains the function info object
529 /// or an error object that indicates reason for failing to lookup the
530 /// address.
532 getFunctionInfoDataAtIndex(uint64_t AddrIdx, uint64_t &FuncStartAddr) const;
533};
534
535} // namespace gsym
536} // namespace llvm
537
538#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
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
iterator end() const
Definition ArrayRef.h:130
size_t size() const
Get the array size.
Definition ArrayRef.h:141
iterator begin() const
Definition ArrayRef.h:129
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...
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
constexpr size_t size() const
Get the string size.
Definition StringRef.h:144
constexpr const char * data() const
Get a pointer to the start of the string (which may not be null terminated).
Definition StringRef.h:138
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:174
LLVM_ABI llvm::Error setAddrInfoOffsetsData(StringRef Bytes)
Set address info offsets section bytes into AddrInfoOffsetsData.
LLVM_ABI 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:185
bool isLittleEndian() const
Definition GsymReader.h:68
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:337
ArrayRef< uint8_t > AddrOffsets
Definition GsymReader.h:55
LLVM_ABI 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:405
LLVM_ABI GsymReader(std::unique_ptr< MemoryBuffer > Buffer, llvm::endianness Endian)
virtual uint16_t getVersion() const =0
Get the GSYM version for this reader.
LLVM_ABI 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.
GsymReader(GsymReader &&RHS)=default
std::optional< uint64_t > addressForIndex(size_t Index) const
Get an appropriate address from the address table.
Definition GsymReader.h:423
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 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:441
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:558
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