LLVM 23.0.0git
GsymDataExtractor.h
Go to the documentation of this file.
1//===- GsymDataExtractor.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_GSYMDATAEXTRACTOR_H
10#define LLVM_DEBUGINFO_GSYM_GSYMDATAEXTRACTOR_H
11
13
14namespace llvm {
15namespace gsym {
16
17/// A DataExtractor subclass that adds GSYM-specific string offset support.
18///
19/// GSYM files use variable-width string offsets (1-8 bytes). This subclass
20/// adds getStringOffsetSize() and getStringOffset() methods to support reading
21/// string offsets of the configured size.
23 uint8_t StringOffsetSize;
24
25public:
26 /// Construct from raw bytes.
27 GsymDataExtractor(StringRef Data, bool IsLittleEndian,
28 uint8_t StringOffsetSize = 8)
29 : DataExtractor(Data, IsLittleEndian),
30 StringOffsetSize(StringOffsetSize) {}
31
32 /// Construct a sub-range extractor from a parent, copying its endianness
33 /// and string offset size.
37 Parent.isLittleEndian()),
38 StringOffsetSize(Parent.getStringOffsetSize()) {}
39
40 /// Get the string offset size in bytes.
41 uint8_t getStringOffsetSize() const { return StringOffsetSize; }
42
43 /// Extract a string offset of StringOffsetSize bytes from \a *offset_ptr.
44 uint64_t getStringOffset(uint64_t *offset_ptr) const {
45 return getUnsigned(offset_ptr, StringOffsetSize);
46 }
47
48 /// Extract a string offset of StringOffsetSize bytes from the location given
49 /// by the cursor.
51 return getUnsigned(C, StringOffsetSize);
52 }
53};
54
55} // namespace gsym
56} // namespace llvm
57
58#endif // LLVM_DEBUGINFO_GSYM_GSYMDATAEXTRACTOR_H
static StringRef substr(StringRef Str, uint64_t Len)
A class representing a position in a DataExtractor, as well as any error encountered during extractio...
LLVM_ABI uint64_t getUnsigned(uint64_t *offset_ptr, uint32_t byte_size, Error *Err=nullptr) const
Extract an unsigned integer of size byte_size from *offset_ptr.
DataExtractor(StringRef Data, bool IsLittleEndian)
Construct with a buffer that is owned by the caller.
StringRef getData() const
Get the data pointed to by this extractor.
bool isLittleEndian() const
Get the endianness for this extractor.
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
uint64_t getStringOffset(Cursor &C) const
Extract a string offset of StringOffsetSize bytes from the location given by the cursor.
uint8_t getStringOffsetSize() const
Get the string offset size in bytes.
GsymDataExtractor(StringRef Data, bool IsLittleEndian, uint8_t StringOffsetSize=8)
Construct from raw bytes.
uint64_t getStringOffset(uint64_t *offset_ptr) const
Extract a string offset of StringOffsetSize bytes from *offset_ptr.
GsymDataExtractor(const GsymDataExtractor &Parent, uint64_t Offset, uint64_t Length)
Construct a sub-range extractor from a parent, copying its endianness and string offset size.
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:532
@ Length
Definition DWP.cpp:532