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();
73 CurrentLocation->setParent(this);
74 CurrentLocation->setAttr(Attr);
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)
88 CurrentLocation->addObject(Opcode, Operands);
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
186}
187
188
191 CoveragePercentage)) {
193 if (Parent->getIsInlinedFunction()) {
194
195
196
197
198
199
201 Parent->outermostParent(Locations->front()->getLowerAddress());
204 }
205 unsigned CoverageParent = Parent->getCoverageFactor();
206
207
208 CoveragePercentage =
209 CoverageParent
210 ? rint((double(CoverageFactor) / CoverageParent) * 100.0 * 100.0) /
211 100.0
212 : 0;
213
214 if (options().getWarningCoverages() && CoveragePercentage > 100)
216 }
217}
218
220 if (getIsResolvedName())
221 return;
222 setIsResolvedName();
223
225
226
228}
229
231
232
233
234
235
236
237
238
239
240
242 if (Reference) {
243 Reference->resolve();
244
246 }
247
248
250
251
254
255
256 if (Element->getIsTypedefReduced()) {
259 }
260
261
262
264 }
265
266
267 if (() && Reference)
268 setType(Reference->getType());
269}
270
272
273
274 if (getHasReference() && ())
276
278}
279
282 if (!(References && Targets))
283 return;
284
286 dbgs() << "\n[LVSymbol::markMissingParents]\n";
287 for (const LVSymbol *Reference : *References)
288 dbgs() << "References: "
289 << "Kind = " << formattedKind(Reference->kind()) << ", "
290 << "Name = " << formattedName(Reference->getName()) << "\n";
292 dbgs() << "Targets : "
295 });
296
297 for (LVSymbol *Reference : *References) {
299 dbgs() << "Search Reference: Name = "
301 });
302 if (!Reference->findIn(Targets))
303 Reference->markBranchAsMissing();
304 }
305}
306
308 if (!Targets)
309 return nullptr;
310
312 dbgs() << "\n[LVSymbol::findIn]\n"
313 << "Reference: "
314 << "Level = " << getLevel() << ", "
318 dbgs() << "Target : "
319 << "Level = " << Target->getLevel() << ", "
322 });
323
327
328 return nullptr;
329}
330
331
334 if (!References && !Targets)
335 return true;
336 if (References && Targets) {
342 }
343 return false;
344}
345
346
350 if (Symbol->getIsParameter())
351 Parameters->push_back(Symbol);
352}
353
356 return false;
357
358
360 return false;
361
363 return false;
364
365 return true;
366}
367
369 if (!References && !Targets)
370 return true;
371 if (References && Targets && References->size() == Targets->size()) {
372 for (const LVSymbol *Reference : *References)
373 if (!Reference->findIn(Targets))
374 return false;
375 return true;
376 }
377 return false;
378}
379
383
389
391 if (getIncludeInPrint() && getReader().doPrintSymbol(this)) {
395 }
396}
397
399
401 if (getIsMember() || getIsInheritance())
404
405 const LVSymbol *Symbol = getIsInlined() ? Reference : this;
406 std::string Attributes =
407 Symbol->getIsCallSiteParameter()
408 ? ""
410 Symbol->accessibilityString(AccessCode),
412
414 if (Symbol->getIsUnspecified())
416 else {
417 if (Symbol->getIsInheritance())
418 OS << Symbol->typeOffsetAsString()
420 Symbol->typeAsString());
421 else {
423
425 OS << ":" << Size;
426 OS << " -> " << Symbol->typeOffsetAsString()
428 Symbol->typeAsString());
429 }
430 }
431
432
433 if (ValueIndex)
435 OS << "\n";
436
437 if (Full && options().getPrintFormatting()) {
441 Reference->printReference(OS, Full, const_cast<LVSymbol *>(this));
442
443
445 }
446}
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)
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.
LLVM_ABI void printItem(LVElement *Element, LVComparePass Pass)
LVElement(LVSubclassID ID)
virtual void resolveName()
StringRef virtualityString(uint32_t Virtuality=dwarf::DW_VIRTUALITY_none) 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
bool equals(const LVElement *Element) const
bool isNamed() const override
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 resolvePatternMatch(LVLine *Line)
void addInvalidCoverage(LVSymbol *Symbol)
void incrementPrintedSymbols()
const LVLocations * getRanges() const
void resolveName() override
Definition LVSymbol.cpp:219
static void getParameters(const LVSymbols *Symbols, LVSymbols *Parameters)
Definition LVSymbol.cpp:347
void report(LVComparePass Pass) override
Definition LVSymbol.cpp:380
void printExtra(raw_ostream &OS, bool Full=true) const override
Definition LVSymbol.cpp:398
void addLocation(dwarf::Attribute Attr, LVAddress LowPC, LVAddress HighPC, LVUnsigned SectionOffset, uint64_t LocDescOffset, bool CallSiteLocation=false)
Definition LVSymbol.cpp:65
void resolveReferences() override
Definition LVSymbol.cpp:230
void print(raw_ostream &OS, bool Full=true) const override
Definition LVSymbol.cpp:390
void addLocationOperands(LVSmall Opcode, ArrayRef< uint64_t > Operands)
Definition LVSymbol.cpp:85
size_t getLinkageNameIndex() const override
void getLocations(LVLocations &LocationList, LVValidLocation ValidLocation, bool RecordInvalid=false)
Definition LVSymbol.cpp:166
void calculateCoverage()
Definition LVSymbol.cpp:189
static void markMissingParents(const LVSymbols *References, const LVSymbols *Targets)
Definition LVSymbol.cpp:280
void addLocationConstant(dwarf::Attribute Attr, LVUnsigned Constant, uint64_t LocDescOffset)
Definition LVSymbol.cpp:92
StringRef getValue() const override
bool equals(const LVSymbol *Symbol) const
Definition LVSymbol.cpp:354
uint32_t getBitSize() const override
void fillLocationGaps()
Definition LVSymbol.cpp:125
const char * kind() const override
Definition LVSymbol.cpp:36
void printLocations(raw_ostream &OS, bool Full=true) const
Definition LVSymbol.cpp:384
static bool parametersMatch(const LVSymbols *References, const LVSymbols *Targets)
Definition LVSymbol.cpp:332
StringRef resolveReferencesChain()
Definition LVSymbol.cpp:271
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::map< LVSymbolKind, LVSymbolGetFunction > LVSymbolDispatch
std::string formattedKind(StringRef Kind)
LVScopeCompileUnit * getReaderCompileUnit()
bool(LVLocation::*)() LVValidLocation
SmallVector< LVSymbol *, 8 > LVSymbols
std::string formattedName(StringRef Name)
const LVSmall LVLocationMemberOffset
std::string formatAttributes(const StringRef First, Args... Others)
LVCompare & getComparator()
SmallVector< LVLocation *, 8 > LVLocations
This is an optimization pass for GlobalISel generic memory operations.
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.