LLVM: lib/DebugInfo/GSYM/InlineInfo.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
14#include <inttypes.h>
15
16using namespace llvm;
17using namespace gsym;
18
19
21 if (.isValid())
22 return OS;
23 bool First = true;
24 for (auto Range : II.Ranges) {
27 else
28 OS << ' ';
30 }
31 OS << " Name = " << HEX32(II.Name) << ", CallFile = " << II.CallFile
32 << ", CallLine = " << II.CallFile << '\n';
33 for (const auto &Child : II.Children)
34 OS << Child;
35 return OS;
36}
37
39 std::vector<const InlineInfo *> &InlineStack) {
40 if (II.Ranges.contains(Addr)) {
41
42
43
44 if (II.Name != 0)
45 InlineStack.insert(InlineStack.begin(), &II);
46 for (const auto &Child : II.Children) {
48 break;
49 }
50 return !InlineStack.empty();
51 }
52 return false;
53}
54
55std::optionalInlineInfo::InlineArray
59 return Result;
60 return std::nullopt;
61}
62
63
64
65
66
67
68
69
70
71
72
73
74
75
77 if (!SkippedRanges) {
79 return false;
80 }
81 bool HasChildren = Data.getU8(&Offset) != 0;
85 if (HasChildren) {
87 ;
88 }
89
90 return true;
91}
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
113 if (Inline.Ranges.empty())
114 return true;
115
116
117 if (!Inline.Ranges.contains(Addr)) {
119 return false;
120 }
121
122
123
124 bool HasChildren = Data.getU8(&Offset) != 0;
128 if (HasChildren) {
129
130
131 const auto ChildBaseAddr = Inline.Ranges[0].start();
132 bool Done = false;
133 while ()
135 }
136
137 std::optional CallFile = GR.getFile(Inline.CallFile);
138 if (!CallFile) {
140 "failed to extract file[%" PRIu32 "]",
141 Inline.CallFile);
142 return false;
143 }
144
145 if (CallFile->Dir || CallFile->Base) {
147 SrcLoc.Name = SrcLocs.back().Name;
148 SrcLoc.Offset = SrcLocs.back().Offset;
151 SrcLoc.Line = Inline.CallLine;
152 SrcLocs.back().Name = GR.getString(Inline.Name);
153 SrcLocs.back().Offset = Addr - Inline.Ranges[0].start();
154 SrcLocs.push_back(SrcLoc);
155 }
156 return true;
157}
158
168
169
170
171
172
173
174
175
176
177
178
184 "0x%8.8" PRIx64 ": missing InlineInfo address ranges data", Offset);
186 if (Inline.Ranges.empty())
187 return Inline;
188 if (.isValidOffsetForDataOfSize(Offset, 1))
190 "0x%8.8" PRIx64 ": missing InlineInfo uint8_t indicating children",
192 bool HasChildren = Data.getU8(&Offset) != 0;
193 if (.isValidOffsetForDataOfSize(Offset, 4))
195 "0x%8.8" PRIx64 ": missing InlineInfo uint32_t for name", Offset);
199 "0x%8.8" PRIx64 ": missing ULEB128 for InlineInfo call file", Offset);
203 "0x%8.8" PRIx64 ": missing ULEB128 for InlineInfo call line", Offset);
205 if (HasChildren) {
206
207
208 const auto ChildBaseAddr = Inline.Ranges[0].start();
209 while (true) {
211 if (!Child)
213
214 if (Child.get().Ranges.empty())
215 break;
216 Inline.Children.emplace_back(std::move(*Child));
217 }
218 }
219 return Inline;
220}
221
227
229
230
231
234 "attempted to encode invalid InlineInfo object");
236 bool HasChildren = .empty();
237 O.writeU8(HasChildren);
238 O.writeU32(Name);
241 if (HasChildren) {
242
243
244
246 for (const auto &Child : Children) {
247
248
249 for (const auto &ChildRange: Child.Ranges) {
250 if (.contains(ChildRange))
252 "child range not contained in parent");
253 }
254 llvm::Error Err = Child.encode(O, ChildBaseAddr);
255 if (Err)
256 return Err;
257 }
258
259
260
261
262 O.writeULEB(0);
263 }
265}
266
268 uint64_t NumChildren = II.Children.size();
269 for (const auto &Child : II.Children)
271 return NumChildren;
272}
273
static bool lookup(const GsymReader &GR, DataExtractor &Data, uint64_t &Offset, uint64_t BaseAddr, uint64_t Addr, SourceLocations &SrcLocs, llvm::Error &Err)
A Lookup helper functions.
Definition InlineInfo.cpp:108
static bool getInlineStackHelper(const InlineInfo &II, uint64_t Addr, std::vector< const InlineInfo * > &InlineStack)
Definition InlineInfo.cpp:38
static bool skip(DataExtractor &Data, uint64_t &Offset, bool SkippedRanges)
Skip an InlineInfo object in the specified data at the specified offset.
Definition InlineInfo.cpp:76
static uint64_t GetTotalNumChildren(const InlineInfo &II)
Definition InlineInfo.cpp:267
static llvm::Expected< InlineInfo > decode(DataExtractor &Data, uint64_t &Offset, uint64_t BaseAddr)
Decode an InlineInfo in Data at the specified offset.
Definition InlineInfo.cpp:179
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
uint64_t IntrinsicInst * II
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
reference get()
Returns a reference to the stored T value.
A simplified binary data writer class that doesn't require targets, target definitions,...
GsymReader is used to read GSYM data from a file or buffer.
std::optional< FileEntry > getFile(uint32_t Index) const
Get the a file entry for the suppplied file index.
StringRef getString(uint32_t Offset) const
Get a string from the string table.
This class implements an extremely fast bulk output stream that can only output to a stream.
LLVM_ABI void encodeRanges(const AddressRanges &Ranges, FileWriter &O, uint64_t BaseAddr)
LLVM_ABI raw_ostream & operator<<(raw_ostream &OS, const CallSiteInfo &CSI)
LLVM_ABI void decodeRanges(AddressRanges &Ranges, DataExtractor &Data, uint64_t BaseAddr, uint64_t &Offset)
Address ranges are decoded and encoded to be relative to a base address.
LLVM_ABI uint64_t skipRanges(DataExtractor &Data, uint64_t &Offset)
Skip an address range object in the specified data a the specified offset.
std::vector< SourceLocation > SourceLocations
This is an optimization pass for GlobalISel generic memory operations.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
Inline information stores the name of the inline function along with an array of address ranges.
LLVM_ABI bool operator<(const InlineInfo &RHS) const
Compare InlineInfo objects.
Definition InlineInfo.cpp:274
std::vector< InlineInfo > Children
std::vector< const InlineInfo * > InlineArray
LLVM_ABI std::optional< InlineArray > getInlineStack(uint64_t Addr) const
Lookup an address in the InlineInfo object.
Definition InlineInfo.cpp:56
static LLVM_ABI llvm::Error lookup(const GsymReader &GR, DataExtractor &Data, uint64_t BaseAddr, uint64_t Addr, SourceLocations &SrcLocs)
Lookup a single address within the inline info data.
Definition InlineInfo.cpp:159
uint32_t CallFile
1 based file index in the file table.
LLVM_ABI llvm::Error encode(FileWriter &O, uint64_t BaseAddr) const
Encode this InlineInfo object into FileWriter stream.
Definition InlineInfo.cpp:228
uint32_t CallLine
Source line number.
static LLVM_ABI llvm::Expected< InlineInfo > decode(DataExtractor &Data, uint64_t BaseAddr)
Decode an InlineInfo object from a binary data stream.
Definition InlineInfo.cpp:222
uint32_t Name
String table offset in the string table.
StringRef Base
Line entry source file basename.
uint32_t Line
Source file line number.
uint32_t Offset
Byte size offset within the named function.
StringRef Dir
Line entry source file directory path.
StringRef Name
Function or symbol name.