diff options
Diffstat (limited to 'contrib/llvm-project/llvm/include/llvm/DebugInfo')
48 files changed, 425 insertions, 188 deletions
diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/CVRecord.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/CVRecord.h index 784c47e3bf5d..bb29ef5f2ce8 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/CVRecord.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/CVRecord.h @@ -11,9 +11,9 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" #include "llvm/DebugInfo/CodeView/CodeViewError.h" #include "llvm/DebugInfo/CodeView/RecordSerialization.h" -#include "llvm/DebugInfo/CodeView/TypeIndex.h" #include "llvm/Support/BinaryStreamReader.h" #include "llvm/Support/BinaryStreamRef.h" #include "llvm/Support/Endian.h" @@ -61,12 +61,9 @@ public: ArrayRef<uint8_t> RecordData; }; -template <typename Kind> struct RemappedRecord { - explicit RemappedRecord(const CVRecord<Kind> &R) : OriginalRecord(R) {} - - CVRecord<Kind> OriginalRecord; - SmallVector<std::pair<uint32_t, TypeIndex>, 8> Mappings; -}; +// There are two kinds of codeview records: type and symbol records. +using CVType = CVRecord<TypeLeafKind>; +using CVSymbol = CVRecord<SymbolKind>; template <typename Record, typename Func> Error forEachCodeViewRecord(ArrayRef<uint8_t> StreamBuffer, Func F) { @@ -126,6 +123,12 @@ struct VarStreamArrayExtractor<codeview::CVRecord<Kind>> { } }; +namespace codeview { +using CVSymbolArray = VarStreamArray<CVSymbol>; +using CVTypeArray = VarStreamArray<CVType>; +using CVTypeRange = iterator_range<CVTypeArray::Iterator>; +} // namespace codeview + } // end namespace llvm #endif // LLVM_DEBUGINFO_CODEVIEW_RECORDITERATOR_H diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/CVSymbolVisitor.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/CVSymbolVisitor.h index 1615ff41df12..82ef8c173bee 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/CVSymbolVisitor.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/CVSymbolVisitor.h @@ -10,9 +10,6 @@ #define LLVM_DEBUGINFO_CODEVIEW_CVSYMBOLVISITOR_H #include "llvm/DebugInfo/CodeView/CVRecord.h" -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/SymbolRecord.h" -#include "llvm/DebugInfo/CodeView/SymbolVisitorDelegate.h" #include "llvm/Support/ErrorOr.h" namespace llvm { diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h index f26e80ebe2a9..d851dea0a27f 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h @@ -15,7 +15,8 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/DebugInfo/CodeView/CodeViewError.h" -#include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/DebugInfo/CodeView/GUID.h" +#include "llvm/DebugInfo/CodeView/TypeIndex.h" #include "llvm/Support/BinaryStreamReader.h" #include "llvm/Support/BinaryStreamWriter.h" #include "llvm/Support/Error.h" diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/CodeViewRegisters.def b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/CodeViewRegisters.def index ed5c143818e6..48ea7e52c172 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/CodeViewRegisters.def +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/CodeViewRegisters.def @@ -15,6 +15,7 @@ #endif #if !defined(CV_REGISTERS_ALL) && !defined(CV_REGISTERS_X86) && \ + !defined(CV_REGISTERS_ARM) && \ !defined(CV_REGISTERS_ARM64) #error Need include at least one register set. #endif @@ -393,13 +394,46 @@ CV_REGISTER(ARM_PC, 25) // Status register -CV_REGISTER(ARM_CPSR, 25) +CV_REGISTER(ARM_CPSR, 26) // ARM VFPv1 registers CV_REGISTER(ARM_FPSCR, 40) CV_REGISTER(ARM_FPEXC, 41) +CV_REGISTER(ARM_FS0, 50) +CV_REGISTER(ARM_FS1, 51) +CV_REGISTER(ARM_FS2, 52) +CV_REGISTER(ARM_FS3, 53) +CV_REGISTER(ARM_FS4, 54) +CV_REGISTER(ARM_FS5, 55) +CV_REGISTER(ARM_FS6, 56) +CV_REGISTER(ARM_FS7, 57) +CV_REGISTER(ARM_FS8, 58) +CV_REGISTER(ARM_FS9, 59) +CV_REGISTER(ARM_FS10, 60) +CV_REGISTER(ARM_FS11, 61) +CV_REGISTER(ARM_FS12, 62) +CV_REGISTER(ARM_FS13, 63) +CV_REGISTER(ARM_FS14, 64) +CV_REGISTER(ARM_FS15, 65) +CV_REGISTER(ARM_FS16, 66) +CV_REGISTER(ARM_FS17, 67) +CV_REGISTER(ARM_FS18, 68) +CV_REGISTER(ARM_FS19, 69) +CV_REGISTER(ARM_FS20, 70) +CV_REGISTER(ARM_FS21, 71) +CV_REGISTER(ARM_FS22, 72) +CV_REGISTER(ARM_FS23, 73) +CV_REGISTER(ARM_FS24, 74) +CV_REGISTER(ARM_FS25, 75) +CV_REGISTER(ARM_FS26, 76) +CV_REGISTER(ARM_FS27, 77) +CV_REGISTER(ARM_FS28, 78) +CV_REGISTER(ARM_FS29, 79) +CV_REGISTER(ARM_FS30, 80) +CV_REGISTER(ARM_FS31, 81) + // ARM VFPv3/NEON registers CV_REGISTER(ARM_FS32, 200) diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h index 720b1b49581f..624a623e75b8 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h @@ -10,10 +10,8 @@ #define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTVISITOR_H #include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h" #include "llvm/DebugInfo/CodeView/StringsAndChecksums.h" #include "llvm/Support/Error.h" -#include <cstdint> namespace llvm { @@ -30,7 +28,6 @@ class DebugStringTableSubsectionRef; class DebugSymbolRVASubsectionRef; class DebugSymbolsSubsectionRef; class DebugUnknownSubsectionRef; -class StringsAndChecksumsRef; class DebugSubsectionVisitor { public: diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/DebugSymbolsSubsection.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/DebugSymbolsSubsection.h index 784fc59484b9..51b8523ed969 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/DebugSymbolsSubsection.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/DebugSymbolsSubsection.h @@ -9,8 +9,8 @@ #ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGSYMBOLSSUBSECTION_H #define LLVM_DEBUGINFO_CODEVIEW_DEBUGSYMBOLSSUBSECTION_H +#include "llvm/DebugInfo/CodeView/CVRecord.h" #include "llvm/DebugInfo/CodeView/DebugSubsection.h" -#include "llvm/DebugInfo/CodeView/SymbolRecord.h" #include "llvm/Support/Error.h" namespace llvm { diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h index 35eeef5a327e..ddbb4e3c5e6c 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h @@ -14,7 +14,6 @@ #include "llvm/ADT/StringRef.h" #include "llvm/DebugInfo/CodeView/TypeCollection.h" #include "llvm/DebugInfo/CodeView/TypeIndex.h" -#include "llvm/DebugInfo/CodeView/TypeRecord.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/BinaryStreamArray.h" #include "llvm/Support/Error.h" diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/RecordName.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/RecordName.h index cc09db8933bd..8e06be9e41e8 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/RecordName.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/RecordName.h @@ -9,7 +9,6 @@ #ifndef LLVM_DEBUGINFO_CODEVIEW_RECORDNAME_H #define LLVM_DEBUGINFO_CODEVIEW_RECORDNAME_H -#include "llvm/DebugInfo/CodeView/SymbolRecord.h" #include "llvm/DebugInfo/CodeView/TypeCollection.h" #include "llvm/DebugInfo/CodeView/TypeIndex.h" diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/SymbolDumper.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/SymbolDumper.h index d832a48b1265..aaeffb2446ad 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/SymbolDumper.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/SymbolDumper.h @@ -11,8 +11,8 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringSet.h" +#include "llvm/DebugInfo/CodeView/CVRecord.h" #include "llvm/DebugInfo/CodeView/SymbolDumpDelegate.h" -#include "llvm/DebugInfo/CodeView/SymbolRecord.h" #include "llvm/DebugInfo/CodeView/TypeIndex.h" namespace llvm { diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/SymbolRecord.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/SymbolRecord.h index 4383534b0db2..c37f6b4d5fa7 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/SymbolRecord.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/SymbolRecord.h @@ -1003,9 +1003,6 @@ public: uint32_t RecordOffset = 0; }; -using CVSymbol = CVRecord<SymbolKind>; -using CVSymbolArray = VarStreamArray<CVSymbol>; - Expected<CVSymbol> readSymbolFromStream(BinaryStreamRef Stream, uint32_t Offset); diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h index 57dbc56c0769..71bc70dde6ed 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/SymbolRecordHelpers.h @@ -9,7 +9,8 @@ #ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLRECORDHELPERS_H #define LLVM_DEBUGINFO_CODEVIEW_SYMBOLRECORDHELPERS_H -#include "llvm/DebugInfo/CodeView/SymbolRecord.h" +#include "llvm/DebugInfo/CodeView/CVRecord.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" namespace llvm { namespace codeview { diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/TypeCollection.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/TypeCollection.h index 102d68c3fb2a..bde5a8b3ab2f 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/TypeCollection.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/TypeCollection.h @@ -10,9 +10,8 @@ #define LLVM_DEBUGINFO_CODEVIEW_TYPECOLLECTION_H #include "llvm/ADT/StringRef.h" - +#include "llvm/DebugInfo/CodeView/CVRecord.h" #include "llvm/DebugInfo/CodeView/TypeIndex.h" -#include "llvm/DebugInfo/CodeView/TypeRecord.h" namespace llvm { namespace codeview { diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h index b0a16cccbff3..9f34d026b1ba 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/TypeHashing.h @@ -86,6 +86,16 @@ struct GloballyHashedType { bool empty() const { return *(const uint64_t*)Hash.data() == 0; } + friend inline bool operator==(const GloballyHashedType &L, + const GloballyHashedType &R) { + return L.Hash == R.Hash; + } + + friend inline bool operator!=(const GloballyHashedType &L, + const GloballyHashedType &R) { + return !(L.Hash == R.Hash); + } + /// Given a sequence of bytes representing a record, compute a global hash for /// this record. Due to the nature of global hashes incorporating the hashes /// of referenced records, this function requires a list of types and ids @@ -161,15 +171,10 @@ struct GloballyHashedType { return Hashes; } }; -#if defined(_MSC_VER) -// is_trivially_copyable is not available in older versions of libc++, but it is -// available in all supported versions of MSVC, so at least this gives us some -// coverage. static_assert(std::is_trivially_copyable<GloballyHashedType>::value, "GloballyHashedType must be trivially copyable so that we can " "reinterpret_cast arrays of hash data to arrays of " "GloballyHashedType"); -#endif } // namespace codeview template <> struct DenseMapInfo<codeview::LocallyHashedType> { @@ -206,7 +211,7 @@ template <> struct DenseMapInfo<codeview::GloballyHashedType> { static bool isEqual(codeview::GloballyHashedType LHS, codeview::GloballyHashedType RHS) { - return LHS.Hash == RHS.Hash; + return LHS == RHS; } }; diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/TypeIndex.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/TypeIndex.h index b9e2562bfc2b..bdc6cf46509b 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/TypeIndex.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/TypeIndex.h @@ -116,13 +116,22 @@ public: uint32_t toArrayIndex() const { assert(!isSimple()); - return getIndex() - FirstNonSimpleIndex; + return (getIndex() & ~DecoratedItemIdMask) - FirstNonSimpleIndex; } static TypeIndex fromArrayIndex(uint32_t Index) { return TypeIndex(Index + FirstNonSimpleIndex); } + static TypeIndex fromDecoratedArrayIndex(bool IsItem, uint32_t Index) { + return TypeIndex((Index + FirstNonSimpleIndex) | + (IsItem ? DecoratedItemIdMask : 0)); + } + + TypeIndex removeDecoration() { + return TypeIndex(Index & ~DecoratedItemIdMask); + } + SimpleTypeKind getSimpleKind() const { assert(isSimple()); return static_cast<SimpleTypeKind>(Index & SimpleKindMask); diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/TypeIndexDiscovery.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/TypeIndexDiscovery.h index 469768787274..f4f5835d8b57 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/TypeIndexDiscovery.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/TypeIndexDiscovery.h @@ -10,8 +10,8 @@ #define LLVM_DEBUGINFO_CODEVIEW_TYPEINDEXDISCOVERY_H #include "llvm/ADT/SmallVector.h" -#include "llvm/DebugInfo/CodeView/SymbolRecord.h" -#include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/DebugInfo/CodeView/CVRecord.h" +#include "llvm/DebugInfo/CodeView/TypeIndex.h" #include "llvm/Support/Error.h" namespace llvm { diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h index 35f5c0561138..3b6d1b0b1a70 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h @@ -14,7 +14,6 @@ #include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" -#include "llvm/ADT/iterator_range.h" #include "llvm/DebugInfo/CodeView/CVRecord.h" #include "llvm/DebugInfo/CodeView/CodeView.h" #include "llvm/DebugInfo/CodeView/GUID.h" @@ -32,15 +31,10 @@ using support::little32_t; using support::ulittle16_t; using support::ulittle32_t; -using CVType = CVRecord<TypeLeafKind>; -using RemappedType = RemappedRecord<TypeLeafKind>; - struct CVMemberRecord { TypeLeafKind Kind; ArrayRef<uint8_t> Data; }; -using CVTypeArray = VarStreamArray<CVType>; -using CVTypeRange = iterator_range<CVTypeArray::Iterator>; /// Equvalent to CV_fldattr_t in cvinfo.h. struct MemberAttributes { @@ -703,7 +697,7 @@ public: : TypeRecord(TypeRecordKind::VFTable), CompleteClass(CompleteClass), OverriddenVFTable(OverriddenVFTable), VFPtrOffset(VFPtrOffset) { MethodNames.push_back(Name); - MethodNames.insert(MethodNames.end(), Methods.begin(), Methods.end()); + llvm::append_range(MethodNames, Methods); } TypeIndex getCompleteClass() const { return CompleteClass; } diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/TypeRecordHelpers.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/TypeRecordHelpers.h index 19492b93681c..041f5214967c 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/TypeRecordHelpers.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/TypeRecordHelpers.h @@ -9,7 +9,8 @@ #ifndef LLVM_DEBUGINFO_CODEVIEW_TYPERECORDHELPERS_H #define LLVM_DEBUGINFO_CODEVIEW_TYPERECORDHELPERS_H -#include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/DebugInfo/CodeView/CVRecord.h" +#include "llvm/DebugInfo/CodeView/TypeIndex.h" namespace llvm { namespace codeview { diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/TypeStreamMerger.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/TypeStreamMerger.h index d0506cce8176..04d7c7b0420a 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/TypeStreamMerger.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/CodeView/TypeStreamMerger.h @@ -11,7 +11,7 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallVector.h" -#include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/DebugInfo/CodeView/CVRecord.h" #include "llvm/Support/Error.h" namespace llvm { diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DIContext.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DIContext.h index 661d30d04c94..ae78fe912188 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DIContext.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DIContext.h @@ -35,6 +35,7 @@ struct DILineInfo { static constexpr const char *const Addr2LineBadString = "??"; std::string FileName; std::string FunctionName; + std::string StartFileName; Optional<StringRef> Source; uint32_t Line = 0; uint32_t Column = 0; @@ -43,12 +44,15 @@ struct DILineInfo { // DWARF-specific. uint32_t Discriminator = 0; - DILineInfo() : FileName(BadString), FunctionName(BadString) {} + DILineInfo() + : FileName(BadString), FunctionName(BadString), StartFileName(BadString) { + } bool operator==(const DILineInfo &RHS) const { return Line == RHS.Line && Column == RHS.Column && FileName == RHS.FileName && FunctionName == RHS.FunctionName && - StartLine == RHS.StartLine && Discriminator == RHS.Discriminator; + StartFileName == RHS.StartFileName && StartLine == RHS.StartLine && + Discriminator == RHS.Discriminator; } bool operator!=(const DILineInfo &RHS) const { @@ -56,10 +60,10 @@ struct DILineInfo { } bool operator<(const DILineInfo &RHS) const { - return std::tie(FileName, FunctionName, Line, Column, StartLine, - Discriminator) < - std::tie(RHS.FileName, RHS.FunctionName, RHS.Line, RHS.Column, - RHS.StartLine, RHS.Discriminator); + return std::tie(FileName, FunctionName, StartFileName, Line, Column, + StartLine, Discriminator) < + std::tie(RHS.FileName, RHS.FunctionName, RHS.StartFileName, RHS.Line, + RHS.Column, RHS.StartLine, RHS.Discriminator); } explicit operator bool() const { return *this != DILineInfo(); } @@ -72,6 +76,8 @@ struct DILineInfo { OS << "function '" << FunctionName << "', "; OS << "line " << Line << ", "; OS << "column " << Column << ", "; + if (StartFileName != BadString) + OS << "start file '" << StartFileName << "', "; OS << "start line " << StartLine << '\n'; } }; diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h index 39ae53c4e7fe..cf4c827b9267 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h @@ -111,6 +111,16 @@ public: return AttributeSpecs[idx].Attr; } + bool getAttrIsImplicitConstByIndex(uint32_t idx) const { + assert(idx < AttributeSpecs.size()); + return AttributeSpecs[idx].isImplicitConst(); + } + + int64_t getAttrImplicitConstValueByIndex(uint32_t idx) const { + assert(idx < AttributeSpecs.size()); + return AttributeSpecs[idx].getImplicitConstValue(); + } + /// Get the index of the specified attribute. /// /// Searches the this abbreviation declaration for the index of the specified diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h index 97903a96b3fc..7d88e1447dca 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h @@ -146,6 +146,7 @@ public: bool verify(raw_ostream &OS, DIDumpOptions DumpOpts = {}) override; using unit_iterator_range = DWARFUnitVector::iterator_range; + using compile_unit_range = DWARFUnitVector::compile_unit_range; /// Get units from .debug_info in this context. unit_iterator_range info_section_units() { @@ -163,10 +164,12 @@ public: } /// Get compile units in this context. - unit_iterator_range compile_units() { return info_section_units(); } + compile_unit_range compile_units() { + return make_filter_range(info_section_units(), isCompileUnit); + } - /// Get type units in this context. - unit_iterator_range type_units() { return types_section_units(); } + // If you want type_units(), it'll need to be a concat iterator of a filter of + // TUs in info_section + all the (all type) units in types_section /// Get all normal compile/type units in this context. unit_iterator_range normal_units() { @@ -189,10 +192,13 @@ public: } /// Get compile units in the DWO context. - unit_iterator_range dwo_compile_units() { return dwo_info_section_units(); } + compile_unit_range dwo_compile_units() { + return make_filter_range(dwo_info_section_units(), isCompileUnit); + } - /// Get type units in the DWO context. - unit_iterator_range dwo_type_units() { return dwo_types_section_units(); } + // If you want dwo_type_units(), it'll need to be a concat iterator of a + // filter of TUs in dwo_info_section + all the (all type) units in + // dwo_types_section. /// Get all units in the DWO context. unit_iterator_range dwo_units() { diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h index 32844ffd570f..69e67866946c 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h @@ -74,6 +74,24 @@ public: /// Return the full length of this table, including the length field. /// Return None if the length cannot be identified reliably. Optional<uint64_t> getFullLength() const; + + /// Return the DWARF format of this table. + dwarf::DwarfFormat getFormat() const { return Format; } + + /// Return the length of this table. + uint64_t getLength() const { return Length; } + + /// Return the version of this table. + uint16_t getVersion() const { return Version; } + + /// Return the address size of this table. + uint8_t getAddressSize() const { return AddrSize; } + + /// Return the segment selector size of this table. + uint8_t getSegmentSelectorSize() const { return SegSize; } + + /// Return the parsed addresses of this table. + ArrayRef<uint64_t> getAddressEntries() const { return Addrs; } }; } // end namespace llvm diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h index 0681a2e33a50..3d5852ee1518 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h @@ -60,7 +60,8 @@ public: DWARFDebugArangeSet() { clear(); } void clear(); - Error extract(DWARFDataExtractor data, uint64_t *offset_ptr); + Error extract(DWARFDataExtractor data, uint64_t *offset_ptr, + function_ref<void(Error)> WarningHandler); void dump(raw_ostream &OS) const; uint64_t getCompileUnitDIEOffset() const { return HeaderData.CuOffset; } diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h index 233b55cc55c1..af87811f5d7d 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h @@ -71,8 +71,8 @@ public: /// where a problem occurred in case an error is returned. Error parse(DWARFDataExtractor Data, uint64_t *Offset, uint64_t EndOffset); - void dump(raw_ostream &OS, const MCRegisterInfo *MRI, bool IsEH, - unsigned IndentLevel = 1) const; + void dump(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *MRI, + bool IsEH, unsigned IndentLevel = 1) const; private: std::vector<Instruction> Instructions; @@ -121,7 +121,8 @@ private: static ArrayRef<OperandType[2]> getOperandTypes(); /// Print \p Opcode's operand number \p OperandIdx which has value \p Operand. - void printOperand(raw_ostream &OS, const MCRegisterInfo *MRI, bool IsEH, + void printOperand(raw_ostream &OS, DIDumpOptions DumpOpts, + const MCRegisterInfo *MRI, bool IsEH, const Instruction &Instr, unsigned OperandIdx, uint64_t Operand) const; }; @@ -146,8 +147,8 @@ public: CFIProgram &cfis() { return CFIs; } /// Dump the instructions in this CFI fragment - virtual void dump(raw_ostream &OS, const MCRegisterInfo *MRI, - bool IsEH) const = 0; + virtual void dump(raw_ostream &OS, DIDumpOptions DumpOpts, + const MCRegisterInfo *MRI, bool IsEH) const = 0; protected: const FrameKind Kind; @@ -201,7 +202,7 @@ public: uint32_t getLSDAPointerEncoding() const { return LSDAPointerEncoding; } - void dump(raw_ostream &OS, const MCRegisterInfo *MRI, + void dump(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *MRI, bool IsEH) const override; private: @@ -242,7 +243,7 @@ public: uint64_t getAddressRange() const { return AddressRange; } Optional<uint64_t> getLSDAAddress() const { return LSDAAddress; } - void dump(raw_ostream &OS, const MCRegisterInfo *MRI, + void dump(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *MRI, bool IsEH) const override; static bool classof(const FrameEntry *FE) { return FE->getKind() == FK_FDE; } @@ -285,7 +286,7 @@ public: ~DWARFDebugFrame(); /// Dump the section data into the given stream. - void dump(raw_ostream &OS, const MCRegisterInfo *MRI, + void dump(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *MRI, Optional<uint64_t> Offset) const; /// Parse the section from raw data. \p Data is assumed to contain the whole diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h index fe46d613aedd..bc6c67ae6c5d 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h @@ -121,6 +121,8 @@ public: bool hasFileAtIndex(uint64_t FileIndex) const; + Optional<uint64_t> getLastValidFileIndex() const; + bool getFileNameByIndex(uint64_t FileIndex, StringRef CompDir, DILineInfoSpecifier::FileLineInfoKind Kind, @@ -251,6 +253,10 @@ public: return Prologue.hasFileAtIndex(FileIndex); } + Optional<uint64_t> getLastValidFileIndex() const { + return Prologue.getLastValidFileIndex(); + } + /// Extracts filename by its index in filename table in prologue. /// In Dwarf 4, the files are 1-indexed and the current compilation file /// name is not represented in the list. In DWARF v5, the files are @@ -309,12 +315,10 @@ public: /// Helper to allow for parsing of an entire .debug_line section in sequence. class SectionParser { public: - using cu_range = DWARFUnitVector::iterator_range; - using tu_range = DWARFUnitVector::iterator_range; using LineToUnitMap = std::map<uint64_t, DWARFUnit *>; - SectionParser(DWARFDataExtractor &Data, const DWARFContext &C, cu_range CUs, - tu_range TUs); + SectionParser(DWARFDataExtractor &Data, const DWARFContext &C, + DWARFUnitVector::iterator_range Units); /// Get the next line table from the section. Report any issues via the /// handlers. diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h index 3b141304f85f..dbc11c51a789 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h @@ -72,6 +72,8 @@ public: std::function<Optional<object::SectionedAddress>(uint32_t)> LookupAddr, function_ref<bool(Expected<DWARFLocationExpression>)> Callback) const; + const DWARFDataExtractor &getData() { return Data; } + protected: DWARFDataExtractor Data; diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h index 4d463d8fe6f5..f1768a1ddab5 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h @@ -96,6 +96,9 @@ class DWARFDebugMacro { MacroHeader Header; SmallVector<Entry, 4> Macros; uint64_t Offset; + + /// Whether or not this is a .debug_macro section. + bool IsDebugMacro; }; /// A list of all the macro entries in the debug_macinfo section. @@ -107,7 +110,7 @@ public: /// Print the macro list found within the debug_macinfo/debug_macro section. void dump(raw_ostream &OS) const; - Error parseMacro(DWARFUnitVector::iterator_range Units, + Error parseMacro(DWARFUnitVector::compile_unit_range Units, DataExtractor StringExtractor, DWARFDataExtractor MacroData) { return parseImpl(Units, StringExtractor, MacroData, /*IsMacro=*/true); @@ -123,7 +126,7 @@ public: private: /// Parse the debug_macinfo/debug_macro section accessible via the 'MacroData' /// parameter. - Error parseImpl(Optional<DWARFUnitVector::iterator_range> Units, + Error parseImpl(Optional<DWARFUnitVector::compile_unit_range> Units, Optional<DataExtractor> StringExtractor, DWARFDataExtractor Data, bool IsMacro); }; diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h index 88e5432851d6..4d28bdcde2e4 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h @@ -34,7 +34,7 @@ struct RangeListEntry : public DWARFListEntryBase { uint64_t Value0; uint64_t Value1; - Error extract(DWARFDataExtractor Data, uint64_t End, uint64_t *OffsetPtr); + Error extract(DWARFDataExtractor Data, uint64_t *OffsetPtr); void dump(raw_ostream &OS, uint8_t AddrSize, uint8_t MaxEncodingStringLength, uint64_t &CurrentBase, DIDumpOptions DumpOpts, llvm::function_ref<Optional<object::SectionedAddress>(uint32_t)> @@ -48,6 +48,7 @@ public: /// Build a DWARFAddressRangesVector from a rangelist. DWARFAddressRangesVector getAbsoluteRanges(Optional<object::SectionedAddress> BaseAddr, + uint8_t AddressByteSize, function_ref<Optional<object::SectionedAddress>(uint32_t)> LookupPooledAddress) const; diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h index 05a6056e8e21..0f76d7f1b31c 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h @@ -262,6 +262,7 @@ public: /// for this subprogram by resolving DW_AT_sepcification or /// DW_AT_abstract_origin references if necessary. uint64_t getDeclLine() const; + std::string getDeclFile(DILineInfoSpecifier::FileLineInfoKind Kind) const; /// Retrieves values of DW_AT_call_file, DW_AT_call_line and DW_AT_call_column /// from DIE (or zeroes if they are missing). This function looks for @@ -381,11 +382,6 @@ inline bool operator==(const DWARFDie::iterator &LHS, return LHS.Die == RHS.Die; } -inline bool operator!=(const DWARFDie::iterator &LHS, - const DWARFDie::iterator &RHS) { - return !(LHS == RHS); -} - // These inline functions must follow the DWARFDie::iterator definition above // as they use functions from that class. inline DWARFDie::iterator DWARFDie::begin() const { diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h index edfa68d49a60..447ad66b9352 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h @@ -10,10 +10,11 @@ #define LLVM_DEBUGINFO_DWARFEXPRESSION_H #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/iterator.h" #include "llvm/ADT/iterator_range.h" -#include "llvm/ADT/Optional.h" #include "llvm/BinaryFormat/Dwarf.h" +#include "llvm/DebugInfo/DIContext.h" #include "llvm/Support/DataExtractor.h" namespace llvm { @@ -93,8 +94,9 @@ public: bool extract(DataExtractor Data, uint8_t AddressSize, uint64_t Offset, Optional<dwarf::DwarfFormat> Format); bool isError() { return Error; } - bool print(raw_ostream &OS, const DWARFExpression *Expr, - const MCRegisterInfo *RegInfo, DWARFUnit *U, bool isEH); + bool print(raw_ostream &OS, DIDumpOptions DumpOpts, + const DWARFExpression *Expr, const MCRegisterInfo *RegInfo, + DWARFUnit *U, bool isEH); bool verify(DWARFUnit *U); }; @@ -143,7 +145,8 @@ public: iterator begin() const { return iterator(this, 0); } iterator end() const { return iterator(this, Data.getData().size()); } - void print(raw_ostream &OS, const MCRegisterInfo *RegInfo, DWARFUnit *U, + void print(raw_ostream &OS, DIDumpOptions DumpOpts, + const MCRegisterInfo *RegInfo, DWARFUnit *U, bool IsEH = false) const; /// Print the expression in a format intended to be compact and useful to a @@ -164,10 +167,5 @@ inline bool operator==(const DWARFExpression::iterator &LHS, const DWARFExpression::iterator &RHS) { return LHS.Expr == RHS.Expr && LHS.Offset == RHS.Offset; } - -inline bool operator!=(const DWARFExpression::iterator &LHS, - const DWARFExpression::iterator &RHS) { - return !(LHS == RHS); -} } #endif diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h index 3f1be4e5a592..1342e645934c 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h @@ -82,6 +82,9 @@ public: void dump(raw_ostream &OS, DIDumpOptions DumpOpts = DIDumpOptions()) const; void dumpSectionedAddress(raw_ostream &OS, DIDumpOptions DumpOpts, object::SectionedAddress SA) const; + void dumpAddress(raw_ostream &OS, uint64_t Address) const; + static void dumpAddress(raw_ostream &OS, uint8_t AddressSize, + uint64_t Address); static void dumpAddressSection(const DWARFObject &Obj, raw_ostream &OS, DIDumpOptions DumpOpts, uint64_t SectionIndex); diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h index 496fdb2477f9..8f58b4e6458e 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h @@ -46,7 +46,7 @@ public: const ListEntries &getEntries() const { return Entries; } bool empty() const { return Entries.empty(); } void clear() { Entries.clear(); } - Error extract(DWARFDataExtractor Data, uint64_t HeaderOffset, uint64_t End, + Error extract(DWARFDataExtractor Data, uint64_t HeaderOffset, uint64_t *OffsetPtr, StringRef SectionName, StringRef ListStringName); }; @@ -72,10 +72,6 @@ class DWARFListTableHeader { }; Header HeaderData; - /// The offset table, which contains offsets to the individual list entries. - /// It is used by forms such as DW_FORM_rnglistx. - /// FIXME: Generate the table and use the appropriate forms. - std::vector<uint64_t> Offsets; /// The table's format, either DWARF32 or DWARF64. dwarf::DwarfFormat Format; /// The offset at which the header (and hence the table) is located within @@ -93,7 +89,6 @@ public: void clear() { HeaderData = {}; - Offsets.clear(); } uint64_t getHeaderOffset() const { return HeaderOffset; } uint8_t getAddrSize() const { return HeaderData.AddrSize; } @@ -115,11 +110,23 @@ public: llvm_unreachable("Invalid DWARF format (expected DWARF32 or DWARF64"); } - void dump(raw_ostream &OS, DIDumpOptions DumpOpts = {}) const; - Optional<uint64_t> getOffsetEntry(uint32_t Index) const { - if (Index < Offsets.size()) - return Offsets[Index]; - return None; + void dump(DataExtractor Data, raw_ostream &OS, + DIDumpOptions DumpOpts = {}) const; + Optional<uint64_t> getOffsetEntry(DataExtractor Data, uint32_t Index) const { + if (Index > HeaderData.OffsetEntryCount) + return None; + + return getOffsetEntry(Data, getHeaderOffset() + getHeaderSize(Format), Format, Index); + } + + static Optional<uint64_t> getOffsetEntry(DataExtractor Data, + uint64_t OffsetTableOffset, + dwarf::DwarfFormat Format, + uint32_t Index) { + uint8_t OffsetByteSize = Format == dwarf::DWARF64 ? 8 : 4; + uint64_t Offset = OffsetTableOffset + OffsetByteSize * Index; + auto R = Data.getUnsigned(&Offset, OffsetByteSize); + return R; } /// Extract the table header and the array of offsets. @@ -169,14 +176,14 @@ public: uint8_t getAddrSize() const { return Header.getAddrSize(); } dwarf::DwarfFormat getFormat() const { return Header.getFormat(); } - void dump(raw_ostream &OS, + void dump(DWARFDataExtractor Data, raw_ostream &OS, llvm::function_ref<Optional<object::SectionedAddress>(uint32_t)> LookupPooledAddress, DIDumpOptions DumpOpts = {}) const; /// Return the contents of the offset entry designated by a given index. - Optional<uint64_t> getOffsetEntry(uint32_t Index) const { - return Header.getOffsetEntry(Index); + Optional<uint64_t> getOffsetEntry(DataExtractor Data, uint32_t Index) const { + return Header.getOffsetEntry(Data, Index); } /// Return the size of the table header including the length but not including /// the offsets. This is dependent on the table format, which is unambiguously @@ -196,18 +203,18 @@ Error DWARFListTableBase<DWARFListType>::extract(DWARFDataExtractor Data, return E; Data.setAddressSize(Header.getAddrSize()); - uint64_t End = getHeaderOffset() + Header.length(); - while (*OffsetPtr < End) { + Data = DWARFDataExtractor(Data, getHeaderOffset() + Header.length()); + while (Data.isValidOffset(*OffsetPtr)) { DWARFListType CurrentList; uint64_t Off = *OffsetPtr; - if (Error E = CurrentList.extract(Data, getHeaderOffset(), End, OffsetPtr, + if (Error E = CurrentList.extract(Data, getHeaderOffset(), OffsetPtr, Header.getSectionName(), Header.getListTypeString())) return E; ListMap[Off] = CurrentList; } - assert(*OffsetPtr == End && + assert(*OffsetPtr == Data.size() && "mismatch between expected length of table and length " "of extracted data"); return Error::success(); @@ -215,18 +222,18 @@ Error DWARFListTableBase<DWARFListType>::extract(DWARFDataExtractor Data, template <typename ListEntryType> Error DWARFListType<ListEntryType>::extract(DWARFDataExtractor Data, - uint64_t HeaderOffset, uint64_t End, + uint64_t HeaderOffset, uint64_t *OffsetPtr, StringRef SectionName, StringRef ListTypeString) { - if (*OffsetPtr < HeaderOffset || *OffsetPtr >= End) + if (*OffsetPtr < HeaderOffset || *OffsetPtr >= Data.size()) return createStringError(errc::invalid_argument, "invalid %s list offset 0x%" PRIx64, ListTypeString.data(), *OffsetPtr); Entries.clear(); - while (*OffsetPtr < End) { + while (Data.isValidOffset(*OffsetPtr)) { ListEntryType Entry; - if (Error E = Entry.extract(Data, End, OffsetPtr)) + if (Error E = Entry.extract(Data, OffsetPtr)) return E; Entries.push_back(Entry); if (Entry.isSentinel()) @@ -240,11 +247,11 @@ Error DWARFListType<ListEntryType>::extract(DWARFDataExtractor Data, template <typename DWARFListType> void DWARFListTableBase<DWARFListType>::dump( - raw_ostream &OS, + DWARFDataExtractor Data, raw_ostream &OS, llvm::function_ref<Optional<object::SectionedAddress>(uint32_t)> LookupPooledAddress, DIDumpOptions DumpOpts) const { - Header.dump(OS, DumpOpts); + Header.dump(Data, OS, DumpOpts); OS << HeaderString << "\n"; // Determine the length of the longest encoding string we have in the table, @@ -269,19 +276,14 @@ template <typename DWARFListType> Expected<DWARFListType> DWARFListTableBase<DWARFListType>::findList(DWARFDataExtractor Data, uint64_t Offset) { - auto Entry = ListMap.find(Offset); - if (Entry != ListMap.end()) - return Entry->second; - // Extract the list from the section and enter it into the list map. DWARFListType List; - uint64_t End = getHeaderOffset() + Header.length(); - uint64_t StartingOffset = Offset; + if (Header.length()) + Data = DWARFDataExtractor(Data, getHeaderOffset() + Header.length()); if (Error E = - List.extract(Data, getHeaderOffset(), End, &Offset, + List.extract(Data, Header.length() ? getHeaderOffset() : 0, &Offset, Header.getSectionName(), Header.getListTypeString())) return std::move(E); - ListMap[StartingOffset] = List; return List; } diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h index 5b3b46626059..369cbdc28c2e 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h @@ -113,6 +113,8 @@ public: const DWARFUnitIndex &getDWARFUnitIndex(DWARFContext &Context, DWARFSectionKind Kind); +bool isCompileUnit(const std::unique_ptr<DWARFUnit> &U); + /// Describe a collection of units. Intended to hold all units either from /// .debug_info and .debug_types, or from .debug_info.dwo and .debug_types.dwo. class DWARFUnitVector final : public SmallVector<std::unique_ptr<DWARFUnit>, 1> { @@ -127,6 +129,9 @@ public: using iterator = typename UnitVector::iterator; using iterator_range = llvm::iterator_range<typename UnitVector::iterator>; + using compile_unit_range = + decltype(make_filter_range(std::declval<iterator_range>(), isCompileUnit)); + DWARFUnit *getUnitForOffset(uint64_t Offset) const; DWARFUnit *getUnitForIndexEntry(const DWARFUnitIndex::Entry &E); @@ -204,7 +209,6 @@ class DWARFUnit { const DWARFDebugAbbrev *Abbrev; const DWARFSection *RangeSection; uint64_t RangeSectionBase; - const DWARFSection *LocSection; uint64_t LocSectionBase; /// Location table of this unit. @@ -223,10 +227,6 @@ class DWARFUnit { /// offsets table (DWARF v5). Optional<StrOffsetsContributionDescriptor> StringOffsetsTableContribution; - /// A table of range lists (DWARF v5 and later). - Optional<DWARFDebugRnglistTable> RngListTable; - Optional<DWARFListTableHeader> LoclistTableHeader; - mutable const DWARFAbbreviationDeclarationSet *Abbrevs; llvm::Optional<object::SectionedAddress> BaseAddr; /// The compile unit debug information entry items. @@ -294,6 +294,7 @@ public: dwarf::DwarfFormat getFormat() const { return Header.getFormat(); } uint8_t getUnitType() const { return Header.getUnitType(); } bool isTypeUnit() const { return Header.isTypeUnit(); } + uint64_t getAbbrOffset() const { return Header.getAbbrOffset(); } uint64_t getNextUnitOffset() const { return Header.getNextUnitOffset(); } const DWARFSection &getLineSection() const { return LineSection; } StringRef getStringSection() const { return StringSection; } @@ -313,10 +314,6 @@ public: RangeSection = RS; RangeSectionBase = Base; } - void setLocSection(const DWARFSection *LS, uint64_t Base) { - LocSection = LS; - LocSectionBase = Base; - } uint64_t getLocSectionBase() const { return LocSectionBase; @@ -411,21 +408,10 @@ public: /// Return a rangelist's offset based on an index. The index designates /// an entry in the rangelist table's offset array and is supplied by /// DW_FORM_rnglistx. - Optional<uint64_t> getRnglistOffset(uint32_t Index) { - if (!RngListTable) - return None; - if (Optional<uint64_t> Off = RngListTable->getOffsetEntry(Index)) - return *Off + RangeSectionBase; - return None; - } + Optional<uint64_t> getRnglistOffset(uint32_t Index); + + Optional<uint64_t> getLoclistOffset(uint32_t Index); - Optional<uint64_t> getLoclistOffset(uint32_t Index) { - if (!LoclistTableHeader) - return None; - if (Optional<uint64_t> Off = LoclistTableHeader->getOffsetEntry(Index)) - return *Off + getLocSectionBase(); - return None; - } Expected<DWARFAddressRangesVector> collectAddressRanges(); Expected<DWARFLocationExpressionsVector> @@ -480,7 +466,6 @@ public: /// The unit needs to have its DIEs extracted for this method to work. DWARFDie getDIEForOffset(uint64_t Offset) { extractDIEsIfNeeded(false); - assert(!DieArray.empty()); auto It = llvm::partition_point(DieArray, [=](const DWARFDebugInfoEntry &DIE) { return DIE.getOffset() < Offset; @@ -529,6 +514,10 @@ private: bool parseDWO(); }; +inline bool isCompileUnit(const std::unique_ptr<DWARFUnit> &U) { + return !U->isTypeUnit(); +} + } // end namespace llvm #endif // LLVM_DEBUGINFO_DWARF_DWARFUNIT_H diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h index 22b1d722fc89..18d889f5cadb 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h @@ -12,25 +12,22 @@ #include "llvm/ADT/Optional.h" #include "llvm/DebugInfo/DIContext.h" #include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h" -#include "llvm/DebugInfo/DWARF/DWARFAddressRange.h" #include "llvm/DebugInfo/DWARF/DWARFDie.h" #include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h" - #include <cstdint> #include <map> #include <set> namespace llvm { class raw_ostream; +struct DWARFAddressRange; struct DWARFAttribute; class DWARFContext; -class DWARFDie; -class DWARFUnit; -class DWARFCompileUnit; class DWARFDataExtractor; class DWARFDebugAbbrev; class DataExtractor; struct DWARFSection; +class DWARFUnit; /// A class that verifies DWARF debug information given a DWARF Context. class DWARFVerifier { diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/MSF/MappedBlockStream.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/MSF/MappedBlockStream.h index 593d781b990e..473c89e8106f 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/MSF/MappedBlockStream.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/MSF/MappedBlockStream.h @@ -24,8 +24,6 @@ namespace llvm { namespace msf { -struct MSFLayout; - /// MappedBlockStream represents data stored in an MSF file into chunks of a /// particular size (called the Block Size), and whose chunks may not be /// necessarily contiguous. The arrangement of these chunks MSF the file diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h index beaaef0c5a6c..82b63d729454 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h @@ -34,6 +34,34 @@ struct MSFLayout; } namespace pdb { +// Represents merged or unmerged symbols. Merged symbols can be written to the +// output file as is, but unmerged symbols must be rewritten first. In either +// case, the size must be known up front. +struct SymbolListWrapper { + explicit SymbolListWrapper(ArrayRef<uint8_t> Syms) + : SymPtr(const_cast<uint8_t *>(Syms.data())), SymSize(Syms.size()), + NeedsToBeMerged(false) {} + explicit SymbolListWrapper(void *SymSrc, uint32_t Length) + : SymPtr(SymSrc), SymSize(Length), NeedsToBeMerged(true) {} + + ArrayRef<uint8_t> asArray() const { + return ArrayRef<uint8_t>(static_cast<const uint8_t *>(SymPtr), SymSize); + } + + uint32_t size() const { return SymSize; } + + void *SymPtr = nullptr; + uint32_t SymSize = 0; + bool NeedsToBeMerged = false; +}; + +/// Represents a string table reference at some offset in the module symbol +/// stream. +struct StringTableFixup { + uint32_t StrTabOffset = 0; + uint32_t SymOffsetOfReference = 0; +}; + class DbiModuleDescriptorBuilder { friend class DbiStreamBuilder; @@ -48,10 +76,28 @@ public: void setPdbFilePathNI(uint32_t NI); void setObjFileName(StringRef Name); + + // Callback to merge one source of unmerged symbols. + using MergeSymbolsCallback = Error (*)(void *Ctx, void *Symbols, + BinaryStreamWriter &Writer); + + void setMergeSymbolsCallback(void *Ctx, MergeSymbolsCallback Callback) { + MergeSymsCtx = Ctx; + MergeSymsCallback = Callback; + } + + void setStringTableFixups(std::vector<StringTableFixup> &&Fixups) { + StringTableFixups = std::move(Fixups); + } + void setFirstSectionContrib(const SectionContrib &SC); void addSymbol(codeview::CVSymbol Symbol); void addSymbolsInBulk(ArrayRef<uint8_t> BulkSymbols); + // Add symbols of known size which will be merged (rewritten) when committing + // the PDB to disk. + void addUnmergedSymbols(void *SymSrc, uint32_t SymLength); + void addDebugSubsection(std::shared_ptr<codeview::DebugSubsection> Subsection); @@ -77,8 +123,14 @@ public: void finalize(); Error finalizeMsfLayout(); - Error commit(BinaryStreamWriter &ModiWriter, const msf::MSFLayout &MsfLayout, - WritableBinaryStreamRef MsfBuffer); + /// Commit the DBI descriptor to the DBI stream. + Error commit(BinaryStreamWriter &ModiWriter); + + /// Commit the accumulated symbols to the module symbol stream. Safe to call + /// in parallel on different DbiModuleDescriptorBuilder objects. Only modifies + /// the pre-allocated stream in question. + Error commitSymbolStream(const msf::MSFLayout &MsfLayout, + WritableBinaryStreamRef MsfBuffer); private: uint32_t calculateC13DebugInfoSize() const; @@ -91,7 +143,12 @@ private: std::string ModuleName; std::string ObjFileName; std::vector<std::string> SourceFiles; - std::vector<ArrayRef<uint8_t>> Symbols; + std::vector<SymbolListWrapper> Symbols; + + void *MergeSymsCtx = nullptr; + MergeSymbolsCallback MergeSymsCallback = nullptr; + + std::vector<StringTableFixup> StringTableFixups; std::vector<codeview::DebugSubsectionRecordBuilder> C13Builders; diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/NativeEnumSymbols.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/NativeEnumSymbols.h new file mode 100644 index 000000000000..480b3fb11419 --- /dev/null +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/NativeEnumSymbols.h @@ -0,0 +1,41 @@ +//==- NativeEnumSymbols.h - Native Symbols Enumerator impl -------*- C++ -*-==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMSYMBOLS_H +#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMSYMBOLS_H + +#include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" +#include "llvm/DebugInfo/PDB/PDBSymbol.h" + +#include <vector> + +namespace llvm { +namespace pdb { + +class NativeSession; + +class NativeEnumSymbols : public IPDBEnumChildren<PDBSymbol> { +public: + NativeEnumSymbols(NativeSession &Session, std::vector<SymIndexId> Symbols); + + uint32_t getChildCount() const override; + std::unique_ptr<PDBSymbol> getChildAtIndex(uint32_t Index) const override; + std::unique_ptr<PDBSymbol> getNext() override; + void reset() override; + +private: + std::vector<SymIndexId> Symbols; + uint32_t Index; + NativeSession &Session; +}; + +} // namespace pdb +} // namespace llvm + +#endif diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/NativeFunctionSymbol.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/NativeFunctionSymbol.h index 4adf89f0d69a..b219055d2153 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/NativeFunctionSymbol.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/NativeFunctionSymbol.h @@ -20,7 +20,7 @@ namespace pdb { class NativeFunctionSymbol : public NativeRawSymbol { public: NativeFunctionSymbol(NativeSession &Session, SymIndexId Id, - const codeview::ProcSym &Sym); + const codeview::ProcSym &Sym, uint32_t RecordOffset); ~NativeFunctionSymbol() override; @@ -30,13 +30,15 @@ public: uint32_t getAddressOffset() const override; uint32_t getAddressSection() const override; std::string getName() const override; - PDB_SymType getSymTag() const override; uint64_t getLength() const override; uint32_t getRelativeVirtualAddress() const override; uint64_t getVirtualAddress() const override; + std::unique_ptr<IPDBEnumSymbols> + findInlineFramesByVA(uint64_t VA) const override; protected: const codeview::ProcSym Sym; + uint32_t RecordOffset = 0; }; } // namespace pdb diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/NativeInlineSiteSymbol.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/NativeInlineSiteSymbol.h new file mode 100644 index 000000000000..2f6aba038ae8 --- /dev/null +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/NativeInlineSiteSymbol.h @@ -0,0 +1,46 @@ +//===- NativeInlineSiteSymbol.h - info about inline sites -------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVEINLINESITESYMBOL_H +#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVEINLINESITESYMBOL_H + +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/SymbolRecord.h" +#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h" +#include "llvm/DebugInfo/PDB/Native/NativeSession.h" + +namespace llvm { +namespace pdb { + +class NativeInlineSiteSymbol : public NativeRawSymbol { +public: + NativeInlineSiteSymbol(NativeSession &Session, SymIndexId Id, + const codeview::InlineSiteSym &Sym, + uint64_t ParentAddr); + + ~NativeInlineSiteSymbol() override; + + void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, + PdbSymbolIdField RecurseIdFields) const override; + + std::string getName() const override; + std::unique_ptr<IPDBEnumLineNumbers> + findInlineeLinesByVA(uint64_t VA, uint32_t Length) const override; + +private: + const codeview::InlineSiteSym Sym; + uint64_t ParentAddr; + + void getLineOffset(uint32_t OffsetInFunc, uint32_t &LineOffset, + uint32_t &FileOffset) const; +}; + +} // namespace pdb +} // namespace llvm + +#endif // LLVM_DEBUGINFO_PDB_NATIVE_NATIVEINLINESITESYMBOL_H diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/NativeLineNumber.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/NativeLineNumber.h index a7ce82c70b08..5dedc70f11ba 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/NativeLineNumber.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/NativeLineNumber.h @@ -22,7 +22,7 @@ public: const codeview::LineInfo Line, uint32_t ColumnNumber, uint32_t Length, uint32_t Section, uint32_t Offset, - uint32_t SrcFileId); + uint32_t SrcFileId, uint32_t CompilandId); uint32_t getLineNumber() const override; uint32_t getLineNumberEnd() const override; @@ -45,6 +45,7 @@ private: uint32_t Offset; uint32_t Length; uint32_t SrcFileId; + uint32_t CompilandId; }; } // namespace pdb } // namespace llvm diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/NativePublicSymbol.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/NativePublicSymbol.h index 0a1451530f18..9f410e27f4cb 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/NativePublicSymbol.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/NativePublicSymbol.h @@ -30,7 +30,6 @@ public: uint32_t getAddressOffset() const override; uint32_t getAddressSection() const override; std::string getName() const override; - PDB_SymType getSymTag() const override; uint32_t getRelativeVirtualAddress() const override; uint64_t getVirtualAddress() const override; diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/NativeSession.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/NativeSession.h index 342e63599e66..5f8fc587e546 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/NativeSession.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/NativeSession.h @@ -110,9 +110,14 @@ public: const SymbolCache &getSymbolCache() const { return Cache; } uint32_t getRVAFromSectOffset(uint32_t Section, uint32_t Offset) const; uint64_t getVAFromSectOffset(uint32_t Section, uint32_t Offset) const; + bool moduleIndexForVA(uint64_t VA, uint16_t &ModuleIndex) const; + bool moduleIndexForSectOffset(uint32_t Sect, uint32_t Offset, + uint16_t &ModuleIndex) const; + Expected<ModuleDebugStreamRef> getModuleDebugStream(uint32_t Index) const; private: void initializeExeSymbol(); + void parseSectionContribs(); std::unique_ptr<PDBFile> Pdb; std::unique_ptr<BumpPtrAllocator> Allocator; @@ -120,6 +125,12 @@ private: SymbolCache Cache; SymIndexId ExeSymbol = 0; uint64_t LoadAddress = 0; + + /// Map from virtual address to module index. + using IMap = + IntervalMap<uint64_t, uint16_t, 8, IntervalMapHalfOpenInfo<uint64_t>>; + IMap::Allocator IMapAllocator; + IMap AddrToModuleIndex; }; } // namespace pdb } // namespace llvm diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/SymbolCache.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/SymbolCache.h index 90fd19a7a2fb..1ff6ca173b2b 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/SymbolCache.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/SymbolCache.h @@ -37,40 +37,40 @@ class SymbolCache { /// an Id. Id allocation is an implementation, with the only guarantee /// being that once an Id is allocated, the symbol can be assumed to be /// cached. - std::vector<std::unique_ptr<NativeRawSymbol>> Cache; + mutable std::vector<std::unique_ptr<NativeRawSymbol>> Cache; /// For type records from the TPI stream which have been paresd and cached, /// stores a mapping to SymIndexId of the cached symbol. - DenseMap<codeview::TypeIndex, SymIndexId> TypeIndexToSymbolId; + mutable DenseMap<codeview::TypeIndex, SymIndexId> TypeIndexToSymbolId; /// For field list members which have been parsed and cached, stores a mapping /// from (IndexOfClass, MemberIndex) to the corresponding SymIndexId of the /// cached symbol. - DenseMap<std::pair<codeview::TypeIndex, uint32_t>, SymIndexId> + mutable DenseMap<std::pair<codeview::TypeIndex, uint32_t>, SymIndexId> FieldListMembersToSymbolId; /// List of SymIndexIds for each compiland, indexed by compiland index as they /// appear in the PDB file. - std::vector<SymIndexId> Compilands; + mutable std::vector<SymIndexId> Compilands; /// List of source files, indexed by unique source file index. mutable std::vector<std::unique_ptr<NativeSourceFile>> SourceFiles; + + /// Map from string table offset to source file Id. mutable DenseMap<uint32_t, SymIndexId> FileNameOffsetToId; /// Map from global symbol offset to SymIndexId. - DenseMap<uint32_t, SymIndexId> GlobalOffsetToSymbolId; - - /// Map from segment and code offset to SymIndexId. - DenseMap<std::pair<uint32_t, uint32_t>, SymIndexId> AddressToFunctionSymId; - DenseMap<std::pair<uint32_t, uint32_t>, SymIndexId> AddressToPublicSymId; + mutable DenseMap<uint32_t, SymIndexId> GlobalOffsetToSymbolId; - /// Map from virtual address to module index. - using IMap = - IntervalMap<uint64_t, uint16_t, 8, IntervalMapHalfOpenInfo<uint64_t>>; - IMap::Allocator IMapAllocator; - IMap AddrToModuleIndex; + /// Map from segment and code offset to function symbols. + mutable DenseMap<std::pair<uint32_t, uint32_t>, SymIndexId> AddressToSymbolId; + /// Map from segment and code offset to public symbols. + mutable DenseMap<std::pair<uint32_t, uint32_t>, SymIndexId> + AddressToPublicSymId; - Expected<ModuleDebugStreamRef> getModuleDebugStream(uint32_t Index) const; + /// Map from module index and symbol table offset to SymIndexId. + mutable DenseMap<std::pair<uint16_t, uint32_t>, SymIndexId> + SymTabOffsetToSymbolId; struct LineTableEntry { uint64_t Addr; @@ -83,7 +83,7 @@ class SymbolCache { std::vector<LineTableEntry> findLineTable(uint16_t Modi) const; mutable DenseMap<uint16_t, std::vector<LineTableEntry>> LineTable; - SymIndexId createSymbolPlaceholder() { + SymIndexId createSymbolPlaceholder() const { SymIndexId Id = Cache.size(); Cache.push_back(nullptr); return Id; @@ -91,7 +91,7 @@ class SymbolCache { template <typename ConcreteSymbolT, typename CVRecordT, typename... Args> SymIndexId createSymbolForType(codeview::TypeIndex TI, codeview::CVType CVT, - Args &&... ConstructorArgs) { + Args &&...ConstructorArgs) const { CVRecordT Record; if (auto EC = codeview::TypeDeserializer::deserializeAs<CVRecordT>(CVT, Record)) { @@ -104,10 +104,10 @@ class SymbolCache { } SymIndexId createSymbolForModifiedType(codeview::TypeIndex ModifierTI, - codeview::CVType CVT); + codeview::CVType CVT) const; SymIndexId createSimpleType(codeview::TypeIndex TI, - codeview::ModifierOptions Mods); + codeview::ModifierOptions Mods) const; std::unique_ptr<PDBSymbol> findFunctionSymbolBySectOffset(uint32_t Sect, uint32_t Offset); @@ -118,7 +118,7 @@ public: SymbolCache(NativeSession &Session, DbiStream *Dbi); template <typename ConcreteSymbolT, typename... Args> - SymIndexId createSymbol(Args &&... ConstructorArgs) { + SymIndexId createSymbol(Args &&...ConstructorArgs) const { SymIndexId Id = Cache.size(); // Initial construction must not access the cache, since it must be done @@ -145,7 +145,7 @@ public: std::unique_ptr<IPDBEnumSymbols> createGlobalsEnumerator(codeview::SymbolKind Kind); - SymIndexId findSymbolByTypeIndex(codeview::TypeIndex TI); + SymIndexId findSymbolByTypeIndex(codeview::TypeIndex TI) const; template <typename ConcreteSymbolT, typename... Args> SymIndexId getOrCreateFieldListMember(codeview::TypeIndex FieldListTI, @@ -163,6 +163,9 @@ public: } SymIndexId getOrCreateGlobalSymbolByOffset(uint32_t Offset); + SymIndexId getOrCreateInlineSymbol(codeview::InlineSiteSym Sym, + uint64_t ParentAddr, uint16_t Modi, + uint32_t RecordOffset) const; std::unique_ptr<PDBSymbol> findSymbolBySectOffset(uint32_t Sect, uint32_t Offset, PDB_SymType Type); @@ -185,9 +188,6 @@ public: std::unique_ptr<IPDBSourceFile> getSourceFileById(SymIndexId FileId) const; SymIndexId getOrCreateSourceFile(const codeview::FileChecksumEntry &Checksum) const; - - void parseSectionContribs(); - Optional<uint16_t> getModuleIndexForAddr(uint64_t Addr) const; }; } // namespace pdb diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/TpiStream.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/TpiStream.h index 1b7fd2d54cb2..70288868ca21 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/TpiStream.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/TpiStream.h @@ -9,7 +9,7 @@ #ifndef LLVM_DEBUGINFO_PDB_RAW_PDBTPISTREAM_H #define LLVM_DEBUGINFO_PDB_RAW_PDBTPISTREAM_H -#include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/DebugInfo/CodeView/CVRecord.h" #include "llvm/DebugInfo/PDB/Native/HashTable.h" #include "llvm/DebugInfo/PDB/Native/RawConstants.h" #include "llvm/DebugInfo/PDB/Native/RawTypes.h" diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h index 72d98e9c2c4d..9ef2ee6a9307 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h @@ -54,16 +54,20 @@ public: void setVersionHeader(PdbRaw_TpiVer Version); void addTypeRecord(ArrayRef<uint8_t> Type, Optional<uint32_t> Hash); + void addTypeRecords(ArrayRef<uint8_t> Types, ArrayRef<uint16_t> Sizes, + ArrayRef<uint32_t> Hashes); Error finalizeMsfLayout(); - uint32_t getRecordCount() const { return TypeRecords.size(); } + uint32_t getRecordCount() const { return TypeRecordCount; } Error commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef Buffer); uint32_t calculateSerializedLength(); private: + void updateTypeIndexOffsets(ArrayRef<uint16_t> Sizes); + uint32_t calculateHashBufferSize() const; uint32_t calculateIndexOffsetSize() const; Error finalize(); @@ -71,10 +75,11 @@ private: msf::MSFBuilder &Msf; BumpPtrAllocator &Allocator; + uint32_t TypeRecordCount = 0; size_t TypeRecordBytes = 0; PdbRaw_TpiVer VerHeader = PdbRaw_TpiVer::PdbTpiV80; - std::vector<ArrayRef<uint8_t>> TypeRecords; + std::vector<ArrayRef<uint8_t>> TypeRecBuffers; std::vector<uint32_t> TypeHashes; std::vector<codeview::TypeIndexOffset> TypeIndexOffsets; uint32_t HashStreamIndex = kInvalidStreamIndex; diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/PDBExtras.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/PDBExtras.h index 45aba013e7c8..802d18a069ee 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/PDBExtras.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/PDBExtras.h @@ -9,16 +9,15 @@ #ifndef LLVM_DEBUGINFO_PDB_PDBEXTRAS_H #define LLVM_DEBUGINFO_PDB_PDBEXTRAS_H +#include "llvm/ADT/StringRef.h" #include "llvm/DebugInfo/CodeView/CodeView.h" #include "llvm/DebugInfo/PDB/PDBTypes.h" #include "llvm/Support/raw_ostream.h" - +#include <cstdint> #include <unordered_map> namespace llvm { -class raw_ostream; - namespace pdb { using TagStats = std::unordered_map<PDB_SymType, int>; @@ -51,7 +50,6 @@ void dumpSymbolField(raw_ostream &OS, StringRef Name, T Value, int Indent) { OS << Name << ": " << Value; } - } // end namespace pdb } // end namespace llvm diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/PDBSymbol.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/PDBSymbol.h index 2982146f960c..24cf1e459f92 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/PDBSymbol.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/PDB/PDBSymbol.h @@ -42,7 +42,6 @@ class StringRef; class raw_ostream; namespace pdb { -class IPDBRawSymbol; class IPDBSession; #define DECLARE_PDB_SYMBOL_CONCRETE_TYPE(TagValue) \ @@ -141,7 +140,14 @@ public: StringRef Name, PDB_NameSearchFlags Flags, uint32_t RVA) const; + std::unique_ptr<IPDBEnumSymbols> findInlineFramesByVA(uint64_t VA) const; std::unique_ptr<IPDBEnumSymbols> findInlineFramesByRVA(uint32_t RVA) const; + std::unique_ptr<IPDBEnumLineNumbers> + findInlineeLinesByVA(uint64_t VA, uint32_t Length) const; + std::unique_ptr<IPDBEnumLineNumbers> + findInlineeLinesByRVA(uint32_t RVA, uint32_t Length) const; + + std::string getName() const; const IPDBRawSymbol &getRawSymbol() const { return *RawSymbol; } IPDBRawSymbol &getRawSymbol() { return *RawSymbol; } diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h index 085e4bb4ccb8..1c8fa11660af 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h @@ -43,7 +43,7 @@ public: bool Demangle = true; bool RelativeAddresses = false; bool UntagAddresses = false; - bool UseNativePDBReader = false; + bool UseDIA = false; std::string DefaultArch; std::vector<std::string> DsymHints; std::string FallbackDebugPath; |