LLVM: lib/DebugInfo/LogicalView/Core/LVSymbol.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
18
19using namespace llvm;
21
22#define DEBUG_TYPE "Symbol"
23
24namespace {
25const char *const KindCallSiteParameter = "CallSiteParameter";
26const char *const KindConstant = "Constant";
27const char *const KindInherits = "Inherits";
28const char *const KindMember = "Member";
29const char *const KindParameter = "Parameter";
30const char *const KindUndefined = "Undefined";
31const char *const KindUnspecified = "Unspecified";
32const char *const KindVariable = "Variable";
33}
34
35
37 const char *Kind = KindUndefined;
38 if (getIsCallSiteParameter())
39 Kind = KindCallSiteParameter;
40 else if (getIsConstant())
41 Kind = KindConstant;
42 else if (getIsInheritance())
43 Kind = KindInherits;
44 else if (getIsMember())
45 Kind = KindMember;
46 else if (getIsParameter())
47 Kind = KindParameter;
48 else if (getIsUnspecified())
49 Kind = KindUnspecified;
50 else if (getIsVariable())
51 Kind = KindVariable;
53}
54
63
64
67 uint64_t LocDescOffset, bool CallSiteLocation) {
68 if (!Locations)
69 Locations = std::make_unique();
70
71
72 CurrentLocation = getReader().createLocationSymbol();
75 if (CallSiteLocation)
76 CurrentLocation->setIsCallSite();
77 CurrentLocation->addObject(LowPC, HighPC, SectionOffset, LocDescOffset);
78 Locations->push_back(CurrentLocation);
79
80
81 setHasLocation();
82}
83
84
87 if (CurrentLocation)
89}
90
91
94
96 0, -1,
97 0, LocDescOffset);
98
99
101}
102
106
109 Gap->setAttr(dwarf::DW_AT_location);
111 0,
112 0);
113
115
116
118
119
120 Gap->setIsGapEntry();
121
122 return Iter;
123}
124
126
127 if (!getHasLocation() || !getFillGaps())
128 return;
129
130
133 return;
134
136 LVAddress ParentLowPC = Entry->getLowerAddress();
137 LVAddress ParentHighPC = Entry->getUpperAddress();
138
139
140
145 Iter != Locations->end(); ++Iter) {
147 LowPC = Location->getLowerAddress();
148 if (LowPC != Marker) {
149
150 Iter = addLocationGap(Iter, Marker, LowPC - 1);
151 ++Iter;
152 }
153
154
155 Marker = Location->getUpperAddress() + 1;
156 }
157
158
159 if (Marker < ParentHighPC)
160
161 addLocationGap(Locations->end(), Marker, ParentHighPC);
162 }
163}
164
165
168 if (!Locations)
169 return;
170
172
173 if (!(Location->*ValidLocation)() && RecordInvalid)
175 }
176
177
179}
180
182 if (!Locations)
183 return;
184
187}
188
189
192 CoveragePercentage)) {
194 if (Parent->getIsInlinedFunction()) {
195
196
197
198
199
200
202 Parent->outermostParent(Locations->front()->getLowerAddress());
205 }
207
208
209 CoveragePercentage =
210 CoverageParent
211 ? rint((double(CoverageFactor) / CoverageParent) * 100.0 * 100.0) /
212 100.0
213 : 0;
214
215 if (options().getWarningCoverages() && CoveragePercentage > 100)
217 }
218}
219
221 if (getIsResolvedName())
222 return;
223 setIsResolvedName();
224
226
227
229}
230
232
233
234
235
236
237
238
239
240
241
245
247 }
248
249
251
252
255
256
257 if (Element->getIsTypedefReduced()) {
260 }
261
262
263
265 }
266
267
270}
271
273
274
275 if (getHasReference() && ())
277
279}
280
283 if (!(References && Targets))
284 return;
285
287 dbgs() << "\n[LVSymbol::markMissingParents]\n";
288 for (const LVSymbol *Reference : *References)
289 dbgs() << "References: "
293 dbgs() << "Targets : "
296 });
297
298 for (LVSymbol *Reference : *References) {
300 dbgs() << "Search Reference: Name = "
302 });
303 if (!Reference->findIn(Targets))
305 }
306}
307
309 if (!Targets)
310 return nullptr;
311
313 dbgs() << "\n[LVSymbol::findIn]\n"
314 << "Reference: "
315 << "Level = " << getLevel() << ", "
319 dbgs() << "Target : "
320 << "Level = " << Target->getLevel() << ", "
323 });
324
328
329 return nullptr;
330}
331
332
335 if (!References && !Targets)
336 return true;
337 if (References && Targets) {
343 }
344 return false;
345}
346
347
351 if (Symbol->getIsParameter())
352 Parameters->push_back(Symbol);
353}
354
357 return false;
358
359
361 return false;
362
364 return false;
365
366 return true;
367}
368
370 if (!References && !Targets)
371 return true;
372 if (References && Targets && References->size() == Targets->size()) {
373 for (const LVSymbol *Reference : *References)
374 if (!Reference->findIn(Targets))
375 return false;
376 return true;
377 }
378 return false;
379}
380
383}
384
386 if (Locations)
389}
390
392 if (getIncludeInPrint() && getReader().doPrintSymbol(this)) {
396 }
397}
398
400
402 if (getIsMember() || getIsInheritance())
405
406 const LVSymbol *Symbol = getIsInlined() ? Reference : this;
408 Symbol->getIsCallSiteParameter()
409 ? ""
413
415 if (Symbol->getIsUnspecified())
417 else {
418 if (Symbol->getIsInheritance())
422 else {
424
430 }
431 }
432
433
434 if (ValueIndex)
436 OS << "\n";
437
438 if (Full && options().getPrintFormatting()) {
443
444
446 }
447}
mir Rename Register Operands
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
This is an important base class in LLVM.
Pass interface - Implemented by all 'passes'.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Target - Wrapper for Target specific information.
const char * getName() const
getName - Get the target name.
void printItem(LVElement *Element, LVComparePass Pass)
virtual void resolveName()
StringRef virtualityString(uint32_t Virtuality=dwarf::DW_VIRTUALITY_none) const
StringRef typeAsString() const
StringRef externalString() const
void setName(StringRef ElementName) override
void setGenericType(LVElement *Element)
StringRef getName() const override
LVElement * getType() const
bool referenceMatch(const LVElement *Element) const
void setFile(LVElement *Reference=nullptr)
void setType(LVElement *Element=nullptr)
void printLinkageName(raw_ostream &OS, bool Full, LVElement *Parent, LVScope *Scope) const
StringRef getTypeQualifiedName() const
StringRef accessibilityString(uint32_t Access=dwarf::DW_ACCESS_private) const
bool equals(const LVElement *Element) const
std::string typeOffsetAsString() const
bool isNamed() const override
void printReference(raw_ostream &OS, bool Full, LVElement *Parent) const
static bool calculateCoverage(LVLocations *Locations, unsigned &Factor, float &Percentage)
virtual void addObject(LVAddress LowPC, LVAddress HighPC, LVUnsigned SectionOffset, uint64_t LocDescOffset)
static void print(LVLocations *Locations, raw_ostream &OS, bool Full=true)
LVScope * getParentScope() const
virtual void print(raw_ostream &OS, bool Full=true) const
void setParent(LVScope *Scope)
void setAttr(dwarf::Attribute Attr)
void markBranchAsMissing()
void resolvePatternMatch(LVLine *Line)
void addInvalidCoverage(LVSymbol *Symbol)
void incrementPrintedSymbols()
LVScope * outermostParent(LVAddress Address)
unsigned getCoverageFactor() const
const LVLocations * getRanges() const
void resolveName() override
static void getParameters(const LVSymbols *Symbols, LVSymbols *Parameters)
void report(LVComparePass Pass) override
void printExtra(raw_ostream &OS, bool Full=true) const override
void addLocation(dwarf::Attribute Attr, LVAddress LowPC, LVAddress HighPC, LVUnsigned SectionOffset, uint64_t LocDescOffset, bool CallSiteLocation=false)
void resolveReferences() override
void print(raw_ostream &OS, bool Full=true) const override
void addLocationOperands(LVSmall Opcode, ArrayRef< uint64_t > Operands)
size_t getLinkageNameIndex() const override
void getLocations(LVLocations &LocationList, LVValidLocation ValidLocation, bool RecordInvalid=false)
static void markMissingParents(const LVSymbols *References, const LVSymbols *Targets)
void addLocationConstant(dwarf::Attribute Attr, LVUnsigned Constant, uint64_t LocDescOffset)
StringRef getValue() const override
bool equals(const LVSymbol *Symbol) const
uint32_t getBitSize() const override
const char * kind() const override
void printLocations(raw_ostream &OS, bool Full=true) const
static bool parametersMatch(const LVSymbols *References, const LVSymbols *Targets)
StringRef resolveReferencesChain()
LVSymbol * getReference() const
This class implements an extremely fast bulk output stream that can only output to a stream.
std::string formattedNames(StringRef Name1, StringRef Name2)
std::string formattedKind(StringRef Kind)
LVScopeCompileUnit * getReaderCompileUnit()
bool(LVLocation::*)() LVValidLocation
std::string formattedName(StringRef Name)
std::map< LVSymbolKind, LVSymbolGetFunction > LVSymbolDispatch
const LVSmall LVLocationMemberOffset
std::string formatAttributes(const StringRef First, Args... Others)
LVCompare & getComparator()
This is an optimization pass for GlobalISel generic memory operations.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.