File indexing completed on 2026-05-10 08:43:43
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVSYMBOL_H
0015 #define LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVSYMBOL_H
0016
0017 #include "llvm/DebugInfo/LogicalView/Core/LVElement.h"
0018
0019 namespace llvm {
0020 namespace logicalview {
0021
0022 enum class LVSymbolKind {
0023 IsCallSiteParameter,
0024 IsConstant,
0025 IsInheritance,
0026 IsMember,
0027 IsParameter,
0028 IsUnspecified,
0029 IsVariable,
0030 LastEntry
0031 };
0032 using LVSymbolKindSet = std::set<LVSymbolKind>;
0033 using LVSymbolDispatch = std::map<LVSymbolKind, LVSymbolGetFunction>;
0034 using LVSymbolRequest = std::vector<LVSymbolGetFunction>;
0035
0036 class LVSymbol final : public LVElement {
0037 enum class Property { HasLocation, FillGaps, LastEntry };
0038
0039
0040 LVProperties<LVSymbolKind> Kinds;
0041 LVProperties<Property> Properties;
0042 static LVSymbolDispatch Dispatch;
0043
0044
0045 size_t LinkageNameIndex = 0;
0046
0047
0048 LVSymbol *Reference = nullptr;
0049 std::unique_ptr<LVLocations> Locations;
0050 LVLocation *CurrentLocation = nullptr;
0051
0052
0053 uint32_t BitSize = 0;
0054
0055
0056 size_t ValueIndex = 0;
0057
0058
0059 unsigned CoverageFactor = 0;
0060 float CoveragePercentage = 0;
0061
0062
0063 LVLocations::iterator addLocationGap(LVLocations::iterator Pos,
0064 LVAddress LowPC, LVAddress HighPC);
0065
0066
0067 LVSymbol *findIn(const LVSymbols *Targets) const;
0068
0069 public:
0070 LVSymbol() : LVElement(LVSubclassID::LV_SYMBOL) {
0071 setIsSymbol();
0072 setIncludeInPrint();
0073 }
0074 LVSymbol(const LVSymbol &) = delete;
0075 LVSymbol &operator=(const LVSymbol &) = delete;
0076 ~LVSymbol() = default;
0077
0078 static bool classof(const LVElement *Element) {
0079 return Element->getSubclassID() == LVSubclassID::LV_SYMBOL;
0080 }
0081
0082 KIND(LVSymbolKind, IsCallSiteParameter);
0083 KIND(LVSymbolKind, IsConstant);
0084 KIND(LVSymbolKind, IsInheritance);
0085 KIND(LVSymbolKind, IsMember);
0086 KIND(LVSymbolKind, IsParameter);
0087 KIND(LVSymbolKind, IsUnspecified);
0088 KIND(LVSymbolKind, IsVariable);
0089
0090 PROPERTY(Property, HasLocation);
0091 PROPERTY(Property, FillGaps);
0092
0093 const char *kind() const override;
0094
0095
0096 LVSymbol *getReference() const { return Reference; }
0097 void setReference(LVSymbol *Symbol) override {
0098 Reference = Symbol;
0099 setHasReference();
0100 }
0101 void setReference(LVElement *Element) override {
0102 assert((!Element || isa<LVSymbol>(Element)) && "Invalid element");
0103 setReference(static_cast<LVSymbol *>(Element));
0104 }
0105
0106 void setLinkageName(StringRef LinkageName) override {
0107 LinkageNameIndex = getStringPool().getIndex(LinkageName);
0108 }
0109 StringRef getLinkageName() const override {
0110 return getStringPool().getString(LinkageNameIndex);
0111 }
0112 size_t getLinkageNameIndex() const override { return LinkageNameIndex; }
0113
0114 uint32_t getBitSize() const override { return BitSize; }
0115 void setBitSize(uint32_t Size) override { BitSize = Size; }
0116
0117
0118 StringRef getValue() const override {
0119 return getStringPool().getString(ValueIndex);
0120 }
0121 void setValue(StringRef Value) override {
0122 ValueIndex = getStringPool().getIndex(Value);
0123 }
0124 size_t getValueIndex() const override { return ValueIndex; }
0125
0126
0127 void addLocationConstant(dwarf::Attribute Attr, LVUnsigned Constant,
0128 uint64_t LocDescOffset);
0129 void addLocationOperands(LVSmall Opcode, ArrayRef<uint64_t> Operands);
0130 void addLocation(dwarf::Attribute Attr, LVAddress LowPC, LVAddress HighPC,
0131 LVUnsigned SectionOffset, uint64_t LocDescOffset,
0132 bool CallSiteLocation = false);
0133
0134
0135 void fillLocationGaps();
0136
0137
0138 void getLocations(LVLocations &LocationList, LVValidLocation ValidLocation,
0139 bool RecordInvalid = false);
0140 void getLocations(LVLocations &LocationList) const;
0141
0142
0143 void calculateCoverage();
0144
0145 unsigned getCoverageFactor() const { return CoverageFactor; }
0146 void setCoverageFactor(unsigned Value) { CoverageFactor = Value; }
0147 float getCoveragePercentage() const { return CoveragePercentage; }
0148 void setCoveragePercentage(float Value) { CoveragePercentage = Value; }
0149
0150
0151 void printLocations(raw_ostream &OS, bool Full = true) const;
0152
0153
0154
0155 StringRef resolveReferencesChain();
0156
0157 void resolveName() override;
0158 void resolveReferences() override;
0159
0160 static LVSymbolDispatch &getDispatch() { return Dispatch; }
0161
0162 static bool parametersMatch(const LVSymbols *References,
0163 const LVSymbols *Targets);
0164
0165 static void getParameters(const LVSymbols *Symbols, LVSymbols *Parameters);
0166
0167
0168
0169
0170 static void markMissingParents(const LVSymbols *References,
0171 const LVSymbols *Targets);
0172
0173
0174 bool equals(const LVSymbol *Symbol) const;
0175
0176
0177
0178 static bool equals(const LVSymbols *References, const LVSymbols *Targets);
0179
0180
0181 void report(LVComparePass Pass) override;
0182
0183 void print(raw_ostream &OS, bool Full = true) const override;
0184 void printExtra(raw_ostream &OS, bool Full = true) const override;
0185
0186 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
0187 void dump() const override { print(dbgs()); }
0188 #endif
0189 };
0190
0191 }
0192 }
0193
0194 #endif