summaryrefslogtreecommitdiff
path: root/include/llvm/DebugInfo/PDB
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/DebugInfo/PDB')
-rw-r--r--include/llvm/DebugInfo/PDB/DIA/DIAEnumTables.h37
-rw-r--r--include/llvm/DebugInfo/PDB/DIA/DIARawSymbol.h1
-rw-r--r--include/llvm/DebugInfo/PDB/DIA/DIASession.h1
-rw-r--r--include/llvm/DebugInfo/PDB/DIA/DIATable.h32
-rw-r--r--include/llvm/DebugInfo/PDB/IPDBRawSymbol.h1
-rw-r--r--include/llvm/DebugInfo/PDB/IPDBSession.h2
-rw-r--r--include/llvm/DebugInfo/PDB/IPDBTable.h28
-rw-r--r--include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h11
-rw-r--r--include/llvm/DebugInfo/PDB/Native/GSIStreamBuilder.h82
-rw-r--r--include/llvm/DebugInfo/PDB/Native/GlobalsStream.h57
-rw-r--r--include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h4
-rw-r--r--include/llvm/DebugInfo/PDB/Native/NativeEnumSymbol.h60
-rw-r--r--include/llvm/DebugInfo/PDB/Native/NativeEnumTypes.h51
-rw-r--r--include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h1
-rw-r--r--include/llvm/DebugInfo/PDB/Native/NativeSession.h11
-rw-r--r--include/llvm/DebugInfo/PDB/Native/PDBFile.h10
-rw-r--r--include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h8
-rw-r--r--include/llvm/DebugInfo/PDB/Native/PublicsStream.h24
-rw-r--r--include/llvm/DebugInfo/PDB/Native/PublicsStreamBuilder.h54
-rw-r--r--include/llvm/DebugInfo/PDB/Native/RawTypes.h14
-rw-r--r--include/llvm/DebugInfo/PDB/Native/SymbolStream.h2
-rw-r--r--include/llvm/DebugInfo/PDB/PDBSymbol.h4
-rw-r--r--include/llvm/DebugInfo/PDB/PDBTypes.h34
23 files changed, 431 insertions, 98 deletions
diff --git a/include/llvm/DebugInfo/PDB/DIA/DIAEnumTables.h b/include/llvm/DebugInfo/PDB/DIA/DIAEnumTables.h
new file mode 100644
index 0000000000000..926fcfe696481
--- /dev/null
+++ b/include/llvm/DebugInfo/PDB/DIA/DIAEnumTables.h
@@ -0,0 +1,37 @@
+//===- DIAEnumTables.h - DIA Tables Enumerator Impl -------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_PDB_DIA_DIAENUMTABLES_H
+#define LLVM_DEBUGINFO_PDB_DIA_DIAENUMTABLES_H
+
+#include "DIASupport.h"
+#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
+#include "llvm/DebugInfo/PDB/IPDBTable.h"
+
+namespace llvm {
+namespace pdb {
+class IPDBTable;
+
+class DIAEnumTables : public IPDBEnumChildren<IPDBTable> {
+public:
+ explicit DIAEnumTables(CComPtr<IDiaEnumTables> DiaEnumerator);
+
+ uint32_t getChildCount() const override;
+ std::unique_ptr<IPDBTable> getChildAtIndex(uint32_t Index) const override;
+ std::unique_ptr<IPDBTable> getNext() override;
+ void reset() override;
+ DIAEnumTables *clone() const override;
+
+private:
+ CComPtr<IDiaEnumTables> Enumerator;
+};
+}
+}
+
+#endif // LLVM_DEBUGINFO_PDB_DIA_DIAENUMTABLES_H
diff --git a/include/llvm/DebugInfo/PDB/DIA/DIARawSymbol.h b/include/llvm/DebugInfo/PDB/DIA/DIARawSymbol.h
index d37b48540ffa2..2d6c44905ce08 100644
--- a/include/llvm/DebugInfo/PDB/DIA/DIARawSymbol.h
+++ b/include/llvm/DebugInfo/PDB/DIA/DIARawSymbol.h
@@ -96,6 +96,7 @@ public:
uint32_t getTypeId() const override;
uint32_t getUavSlot() const override;
std::string getUndecoratedName() const override;
+ std::string getUndecoratedNameEx(PDB_UndnameFlags Flags) const override;
uint32_t getUnmodifiedTypeId() const override;
uint32_t getUpperBoundId() const override;
Variant getValue() const override;
diff --git a/include/llvm/DebugInfo/PDB/DIA/DIASession.h b/include/llvm/DebugInfo/PDB/DIA/DIASession.h
index 350442556bef8..66bd7a7e9c4e6 100644
--- a/include/llvm/DebugInfo/PDB/DIA/DIASession.h
+++ b/include/llvm/DebugInfo/PDB/DIA/DIASession.h
@@ -64,6 +64,7 @@ public:
std::unique_ptr<IPDBEnumDataStreams> getDebugStreams() const override;
+ std::unique_ptr<IPDBEnumTables> getEnumTables() const override;
private:
CComPtr<IDiaSession> Session;
};
diff --git a/include/llvm/DebugInfo/PDB/DIA/DIATable.h b/include/llvm/DebugInfo/PDB/DIA/DIATable.h
new file mode 100644
index 0000000000000..ce93fa0b86c34
--- /dev/null
+++ b/include/llvm/DebugInfo/PDB/DIA/DIATable.h
@@ -0,0 +1,32 @@
+//===- DIATable.h - DIA implementation of IPDBTable -------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_PDB_DIA_DIATABLE_H
+#define LLVM_DEBUGINFO_PDB_DIA_DIATABLE_H
+
+#include "DIASupport.h"
+#include "llvm/DebugInfo/PDB/IPDBTable.h"
+
+namespace llvm {
+namespace pdb {
+class DIATable : public IPDBTable {
+public:
+ explicit DIATable(CComPtr<IDiaTable> DiaTable);
+
+ uint32_t getItemCount() const override;
+ std::string getName() const override;
+ PDB_TableType getTableType() const override;
+
+private:
+ CComPtr<IDiaTable> Table;
+};
+}
+}
+
+#endif // LLVM_DEBUGINFO_PDB_DIA_DIATABLE_H
diff --git a/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h b/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h
index eefc365187288..18b9423378a02 100644
--- a/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h
+++ b/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h
@@ -108,6 +108,7 @@ public:
virtual uint32_t getTypeId() const = 0;
virtual uint32_t getUavSlot() const = 0;
virtual std::string getUndecoratedName() const = 0;
+ virtual std::string getUndecoratedNameEx(PDB_UndnameFlags Flags) const = 0;
virtual uint32_t getUnmodifiedTypeId() const = 0;
virtual uint32_t getUpperBoundId() const = 0;
virtual Variant getValue() const = 0;
diff --git a/include/llvm/DebugInfo/PDB/IPDBSession.h b/include/llvm/DebugInfo/PDB/IPDBSession.h
index cf195095c8d22..6291289de5bfb 100644
--- a/include/llvm/DebugInfo/PDB/IPDBSession.h
+++ b/include/llvm/DebugInfo/PDB/IPDBSession.h
@@ -67,6 +67,8 @@ public:
getSourceFileById(uint32_t FileId) const = 0;
virtual std::unique_ptr<IPDBEnumDataStreams> getDebugStreams() const = 0;
+
+ virtual std::unique_ptr<IPDBEnumTables> getEnumTables() const = 0;
};
}
}
diff --git a/include/llvm/DebugInfo/PDB/IPDBTable.h b/include/llvm/DebugInfo/PDB/IPDBTable.h
new file mode 100644
index 0000000000000..4561c4e847b2b
--- /dev/null
+++ b/include/llvm/DebugInfo/PDB/IPDBTable.h
@@ -0,0 +1,28 @@
+//===- IPDBTable.h - Base Interface for a PDB Symbol Context ----*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_PDB_IPDBTABLE_H
+#define LLVM_DEBUGINFO_PDB_IPDBTABLE_H
+
+#include "PDBTypes.h"
+
+namespace llvm {
+namespace pdb {
+class IPDBTable {
+public:
+ virtual ~IPDBTable();
+
+ virtual std::string getName() const = 0;
+ virtual uint32_t getItemCount() const = 0;
+ virtual PDB_TableType getTableType() const = 0;
+};
+}
+}
+
+#endif // LLVM_DEBUGINFO_PDB_IPDBTABLE_H
diff --git a/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h b/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h
index 63eb34f0326af..ad4a0d1bcb6bf 100644
--- a/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h
+++ b/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h
@@ -59,11 +59,11 @@ public:
uint32_t calculateSerializedLength() const;
+ void setGlobalsStreamIndex(uint32_t Index);
void setPublicsStreamIndex(uint32_t Index);
void setSymbolRecordStreamIndex(uint32_t Index);
Expected<DbiModuleDescriptorBuilder &> addModuleInfo(StringRef ModuleName);
- Error addModuleSourceFile(StringRef Module, StringRef File);
Error addModuleSourceFile(DbiModuleDescriptorBuilder &Module, StringRef File);
Expected<uint32_t> getSourceFileNameIndex(StringRef FileName);
@@ -71,8 +71,9 @@ public:
Error commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef MsfBuffer);
- void addSectionContrib(DbiModuleDescriptorBuilder *ModuleDbi,
- const llvm::object::coff_section *SecHdr);
+ void addSectionContrib(const SectionContrib &SC) {
+ SectionContribs.emplace_back(SC);
+ }
// A helper function to create a Section Map from a COFF section header.
static std::vector<SecMapEntry>
@@ -105,13 +106,13 @@ private:
uint16_t PdbDllRbld;
uint16_t Flags;
PDB_Machine MachineType;
+ uint32_t GlobalsStreamIndex = kInvalidStreamIndex;
uint32_t PublicsStreamIndex = kInvalidStreamIndex;
uint32_t SymRecordStreamIndex = kInvalidStreamIndex;
const DbiStreamHeader *Header;
- StringMap<std::unique_ptr<DbiModuleDescriptorBuilder>> ModiMap;
- std::vector<DbiModuleDescriptorBuilder *> ModiList;
+ std::vector<std::unique_ptr<DbiModuleDescriptorBuilder>> ModiList;
StringMap<uint32_t> SourceFileNames;
diff --git a/include/llvm/DebugInfo/PDB/Native/GSIStreamBuilder.h b/include/llvm/DebugInfo/PDB/Native/GSIStreamBuilder.h
new file mode 100644
index 0000000000000..1a4f89d607dff
--- /dev/null
+++ b/include/llvm/DebugInfo/PDB/Native/GSIStreamBuilder.h
@@ -0,0 +1,82 @@
+//===- GSIStreamBuilder.h - PDB Publics/Globals Stream Creation -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_PDB_RAW_GSISTREAMBUILDER_H
+#define LLVM_DEBUGINFO_PDB_RAW_GSISTREAMBUILDER_H
+
+#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
+#include "llvm/DebugInfo/PDB/Native/GlobalsStream.h"
+#include "llvm/DebugInfo/PDB/Native/RawConstants.h"
+#include "llvm/DebugInfo/PDB/Native/RawTypes.h"
+#include "llvm/Support/BinaryByteStream.h"
+#include "llvm/Support/BinaryItemStream.h"
+#include "llvm/Support/BinaryStreamRef.h"
+#include "llvm/Support/BinaryStreamWriter.h"
+#include "llvm/Support/Endian.h"
+#include "llvm/Support/Error.h"
+
+namespace llvm {
+
+template <> struct BinaryItemTraits<codeview::CVSymbol> {
+ static size_t length(const codeview::CVSymbol &Item) {
+ return Item.RecordData.size();
+ }
+ static ArrayRef<uint8_t> bytes(const codeview::CVSymbol &Item) {
+ return Item.RecordData;
+ }
+};
+
+namespace msf {
+class MSFBuilder;
+struct MSFLayout;
+} // namespace msf
+namespace pdb {
+struct GSIHashStreamBuilder;
+
+class GSIStreamBuilder {
+
+public:
+ explicit GSIStreamBuilder(msf::MSFBuilder &Msf);
+ ~GSIStreamBuilder();
+
+ GSIStreamBuilder(const GSIStreamBuilder &) = delete;
+ GSIStreamBuilder &operator=(const GSIStreamBuilder &) = delete;
+
+ Error finalizeMsfLayout();
+
+ Error commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef Buffer);
+
+ uint32_t getPublicsStreamIndex() const;
+ uint32_t getGlobalsStreamIndex() const;
+ uint32_t getRecordStreamIdx() const { return RecordStreamIdx; }
+
+ void addPublicSymbol(const codeview::PublicSym32 &Pub);
+
+ void addGlobalSymbol(const codeview::ProcRefSym &Sym);
+ void addGlobalSymbol(const codeview::DataSym &Sym);
+ void addGlobalSymbol(const codeview::ConstantSym &Sym);
+ void addGlobalSymbol(const codeview::UDTSym &Sym);
+ void addGlobalSymbol(const codeview::CVSymbol &Sym);
+
+private:
+ uint32_t calculatePublicsHashStreamSize() const;
+ uint32_t calculateGlobalsHashStreamSize() const;
+ Error commitSymbolRecordStream(WritableBinaryStreamRef Stream);
+ Error commitPublicsHashStream(WritableBinaryStreamRef Stream);
+ Error commitGlobalsHashStream(WritableBinaryStreamRef Stream);
+
+ uint32_t RecordStreamIdx = kInvalidStreamIndex;
+ msf::MSFBuilder &Msf;
+ std::unique_ptr<GSIHashStreamBuilder> PSH;
+ std::unique_ptr<GSIHashStreamBuilder> GSH;
+};
+} // namespace pdb
+} // namespace llvm
+
+#endif
diff --git a/include/llvm/DebugInfo/PDB/Native/GlobalsStream.h b/include/llvm/DebugInfo/PDB/Native/GlobalsStream.h
index dcea3d3be0ab8..fdc58dc60f7e0 100644
--- a/include/llvm/DebugInfo/PDB/Native/GlobalsStream.h
+++ b/include/llvm/DebugInfo/PDB/Native/GlobalsStream.h
@@ -1,4 +1,4 @@
-//===- GlobalsStream.h - PDB Index of Symbols by Name ------ ----*- C++ -*-===//
+//===- GlobalsStream.h - PDB Index of Symbols by Name -----------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -16,27 +16,66 @@
#include "llvm/DebugInfo/PDB/PDBTypes.h"
#include "llvm/Support/BinaryStreamArray.h"
#include "llvm/Support/Error.h"
+#include "llvm/ADT/iterator.h"
namespace llvm {
namespace pdb {
class DbiStream;
class PDBFile;
+/// Iterator over hash records producing symbol record offsets. Abstracts away
+/// the fact that symbol record offsets on disk are off-by-one.
+class GSIHashIterator
+ : public iterator_adaptor_base<
+ GSIHashIterator, FixedStreamArrayIterator<PSHashRecord>,
+ std::random_access_iterator_tag, const uint32_t> {
+public:
+ GSIHashIterator() = default;
+
+ template <typename T>
+ GSIHashIterator(T &&v)
+ : GSIHashIterator::iterator_adaptor_base(std::forward<T &&>(v)) {}
+
+ uint32_t operator*() const {
+ uint32_t Off = this->I->Off;
+ return --Off;
+ }
+};
+
+/// From https://github.com/Microsoft/microsoft-pdb/blob/master/PDB/dbi/gsi.cpp
+enum : unsigned { IPHR_HASH = 4096 };
+
+/// A readonly view of a hash table used in the globals and publics streams.
+/// Most clients will only want to iterate this to get symbol record offsets
+/// into the PDB symbol stream.
+class GSIHashTable {
+public:
+ const GSIHashHeader *HashHdr;
+ FixedStreamArray<PSHashRecord> HashRecords;
+ ArrayRef<uint8_t> HashBitmap;
+ FixedStreamArray<support::ulittle32_t> HashBuckets;
+
+ Error read(BinaryStreamReader &Reader);
+
+ uint32_t getVerSignature() const { return HashHdr->VerSignature; }
+ uint32_t getVerHeader() const { return HashHdr->VerHdr; }
+ uint32_t getHashRecordSize() const { return HashHdr->HrSize; }
+ uint32_t getNumBuckets() const { return HashHdr->NumBuckets; }
+
+ typedef GSIHashHeader iterator;
+ GSIHashIterator begin() const { return GSIHashIterator(HashRecords.begin()); }
+ GSIHashIterator end() const { return GSIHashIterator(HashRecords.end()); }
+};
+
class GlobalsStream {
public:
explicit GlobalsStream(std::unique_ptr<msf::MappedBlockStream> Stream);
~GlobalsStream();
- Error commit();
- FixedStreamArray<support::ulittle32_t> getHashBuckets() const {
- return HashBuckets;
- }
- uint32_t getNumBuckets() const { return NumBuckets; }
+ const GSIHashTable &getGlobalsTable() const { return GlobalsTable; }
Error reload();
private:
- FixedStreamArray<support::ulittle32_t> HashBuckets;
- FixedStreamArray<PSHashRecord> HashRecords;
- uint32_t NumBuckets;
+ GSIHashTable GlobalsTable;
std::unique_ptr<msf::MappedBlockStream> Stream;
};
}
diff --git a/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h b/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h
index f413fd1b336ec..6602264d1b747 100644
--- a/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h
+++ b/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h
@@ -32,6 +32,7 @@ public:
ModuleDebugStreamRef(const DbiModuleDescriptor &Module,
std::unique_ptr<msf::MappedBlockStream> Stream);
ModuleDebugStreamRef(ModuleDebugStreamRef &&Other) = default;
+ ModuleDebugStreamRef(const ModuleDebugStreamRef &Other) = default;
~ModuleDebugStreamRef();
Error reload();
@@ -51,6 +52,9 @@ public:
ModuleDebugStreamRef &operator=(ModuleDebugStreamRef &&Other) = default;
iterator_range<DebugSubsectionIterator> subsections() const;
+ codeview::DebugSubsectionArray getSubsectionsArray() const {
+ return Subsections;
+ }
bool hasDebugSubsections() const;
diff --git a/include/llvm/DebugInfo/PDB/Native/NativeEnumSymbol.h b/include/llvm/DebugInfo/PDB/Native/NativeEnumSymbol.h
new file mode 100644
index 0000000000000..41b7b78b8d80a
--- /dev/null
+++ b/include/llvm/DebugInfo/PDB/Native/NativeEnumSymbol.h
@@ -0,0 +1,60 @@
+//===- NativeEnumSymbol.h - info about enum type ----------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMSYMBOL_H
+#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMSYMBOL_H
+
+#include "llvm/DebugInfo/CodeView/CodeView.h"
+#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
+#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h"
+#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
+
+namespace llvm {
+namespace pdb {
+
+class NativeEnumSymbol : public NativeRawSymbol,
+ public codeview::TypeVisitorCallbacks {
+public:
+ NativeEnumSymbol(NativeSession &Session, SymIndexId Id,
+ const codeview::CVType &CV);
+ ~NativeEnumSymbol() override;
+
+ std::unique_ptr<NativeRawSymbol> clone() const override;
+
+ std::unique_ptr<IPDBEnumSymbols>
+ findChildren(PDB_SymType Type) const override;
+
+ Error visitKnownRecord(codeview::CVType &CVR,
+ codeview::EnumRecord &Record) override;
+ Error visitKnownMember(codeview::CVMemberRecord &CVM,
+ codeview::EnumeratorRecord &Record) override;
+
+ PDB_SymType getSymTag() const override;
+ uint32_t getClassParentId() const override;
+ uint32_t getUnmodifiedTypeId() const override;
+ bool hasConstructor() const override;
+ bool hasAssignmentOperator() const override;
+ bool hasCastOperator() const override;
+ uint64_t getLength() const override;
+ std::string getName() const override;
+ bool isNested() const override;
+ bool hasOverloadedOperator() const override;
+ bool isPacked() const override;
+ bool isScoped() const override;
+ uint32_t getTypeId() const override;
+
+protected:
+ codeview::CVType CV;
+ codeview::EnumRecord Record;
+};
+
+} // namespace pdb
+} // namespace llvm
+
+#endif // LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMSYMBOL_H
diff --git a/include/llvm/DebugInfo/PDB/Native/NativeEnumTypes.h b/include/llvm/DebugInfo/PDB/Native/NativeEnumTypes.h
new file mode 100644
index 0000000000000..e0a5c8d9ad814
--- /dev/null
+++ b/include/llvm/DebugInfo/PDB/Native/NativeEnumTypes.h
@@ -0,0 +1,51 @@
+//==- NativeEnumTypes.h - Native Type Enumerator impl ------------*- C++ -*-==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMTYPES_H
+#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVEENUMTYPES_H
+
+#include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.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 NativeEnumTypes : public IPDBEnumChildren<PDBSymbol> {
+public:
+ NativeEnumTypes(NativeSession &Session,
+ codeview::LazyRandomTypeCollection &TypeCollection,
+ codeview::TypeLeafKind Kind);
+
+ uint32_t getChildCount() const override;
+ std::unique_ptr<PDBSymbol> getChildAtIndex(uint32_t Index) const override;
+ std::unique_ptr<PDBSymbol> getNext() override;
+ void reset() override;
+ NativeEnumTypes *clone() const override;
+
+private:
+ NativeEnumTypes(NativeSession &Session,
+ const std::vector<codeview::TypeIndex> &Matches,
+ codeview::TypeLeafKind Kind);
+
+ std::vector<codeview::TypeIndex> Matches;
+ uint32_t Index;
+ NativeSession &Session;
+ codeview::TypeLeafKind Kind;
+};
+
+} // namespace pdb
+} // namespace llvm
+
+#endif
diff --git a/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h b/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h
index 2c6548dcce21f..931b93fb7266c 100644
--- a/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h
+++ b/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h
@@ -101,6 +101,7 @@ public:
uint32_t getTypeId() const override;
uint32_t getUavSlot() const override;
std::string getUndecoratedName() const override;
+ std::string getUndecoratedNameEx(PDB_UndnameFlags Flags) const override;
uint32_t getUnmodifiedTypeId() const override;
uint32_t getUpperBoundId() const override;
Variant getValue() const override;
diff --git a/include/llvm/DebugInfo/PDB/Native/NativeSession.h b/include/llvm/DebugInfo/PDB/Native/NativeSession.h
index b16ce231c349c..2e68ced46bfe8 100644
--- a/include/llvm/DebugInfo/PDB/Native/NativeSession.h
+++ b/include/llvm/DebugInfo/PDB/Native/NativeSession.h
@@ -22,6 +22,7 @@
#include "llvm/Support/Error.h"
namespace llvm {
+class MemoryBuffer;
namespace pdb {
class PDBFile;
@@ -31,7 +32,7 @@ public:
std::unique_ptr<BumpPtrAllocator> Allocator);
~NativeSession() override;
- static Error createFromPdb(StringRef Path,
+ static Error createFromPdb(std::unique_ptr<MemoryBuffer> MB,
std::unique_ptr<IPDBSession> &Session);
static Error createFromExe(StringRef Path,
std::unique_ptr<IPDBSession> &Session);
@@ -39,6 +40,12 @@ public:
std::unique_ptr<PDBSymbolCompiland>
createCompilandSymbol(DbiModuleDescriptor MI);
+ std::unique_ptr<PDBSymbolTypeEnum>
+ createEnumSymbol(codeview::TypeIndex Index);
+
+ std::unique_ptr<IPDBEnumSymbols>
+ createTypeEnumerator(codeview::TypeLeafKind Kind);
+
SymIndexId findSymbolByTypeIndex(codeview::TypeIndex TI);
uint64_t getLoadAddress() const override;
@@ -76,6 +83,8 @@ public:
std::unique_ptr<IPDBEnumDataStreams> getDebugStreams() const override;
+ std::unique_ptr<IPDBEnumTables> getEnumTables() const override;
+
PDBFile &getPDBFile() { return *Pdb; }
const PDBFile &getPDBFile() const { return *Pdb; }
diff --git a/include/llvm/DebugInfo/PDB/Native/PDBFile.h b/include/llvm/DebugInfo/PDB/Native/PDBFile.h
index 4f6ad115e7dfd..5e39ac3e37b72 100644
--- a/include/llvm/DebugInfo/PDB/Native/PDBFile.h
+++ b/include/llvm/DebugInfo/PDB/Native/PDBFile.h
@@ -13,7 +13,6 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/DebugInfo/MSF/IMSFFile.h"
#include "llvm/DebugInfo/MSF/MSFCommon.h"
-#include "llvm/DebugInfo/MSF/MSFStreamLayout.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/BinaryStreamRef.h"
#include "llvm/Support/Endian.h"
@@ -62,6 +61,7 @@ public:
uint64_t getBlockMapOffset() const;
uint32_t getNumStreams() const override;
+ uint32_t getMaxStreamSize() const;
uint32_t getStreamByteSize(uint32_t StreamIndex) const override;
ArrayRef<support::ulittle32_t>
getStreamBlockList(uint32_t StreamIndex) const override;
@@ -72,8 +72,6 @@ public:
Error setBlockData(uint32_t BlockIndex, uint32_t Offset,
ArrayRef<uint8_t> Data) const override;
- ArrayRef<uint32_t> getFpmPages() const { return FpmPages; }
-
ArrayRef<support::ulittle32_t> getStreamSizes() const {
return ContainerLayout.StreamSizes;
}
@@ -86,7 +84,10 @@ public:
ArrayRef<support::ulittle32_t> getDirectoryBlockArray() const;
+ std::unique_ptr<msf::MappedBlockStream> createIndexedStream(uint16_t SN);
+
msf::MSFStreamLayout getStreamLayout(uint32_t StreamIdx) const;
+ msf::MSFStreamLayout getFpmStreamLayout() const;
Error parseFileHeaders();
Error parseStreamData();
@@ -104,7 +105,7 @@ public:
bool hasPDBDbiStream() const;
bool hasPDBGlobalsStream();
- bool hasPDBInfoStream();
+ bool hasPDBInfoStream() const;
bool hasPDBIpiStream() const;
bool hasPDBPublicsStream();
bool hasPDBSymbolStream();
@@ -124,7 +125,6 @@ private:
std::unique_ptr<BinaryStream> Buffer;
- std::vector<uint32_t> FpmPages;
msf::MSFLayout ContainerLayout;
std::unique_ptr<GlobalsStream> Globals;
diff --git a/include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h b/include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h
index 2dc23f819d3bd..7ed164bee9ee2 100644
--- a/include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h
+++ b/include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h
@@ -31,7 +31,7 @@ class MSFBuilder;
namespace pdb {
class DbiStreamBuilder;
class InfoStreamBuilder;
-class PublicsStreamBuilder;
+class GSIStreamBuilder;
class TpiStreamBuilder;
class PDBFileBuilder {
@@ -49,7 +49,7 @@ public:
TpiStreamBuilder &getTpiBuilder();
TpiStreamBuilder &getIpiBuilder();
PDBStringTableBuilder &getStringTableBuilder();
- PublicsStreamBuilder &getPublicsBuilder();
+ GSIStreamBuilder &getGsiBuilder();
Error commit(StringRef Filename);
@@ -59,12 +59,14 @@ public:
private:
Expected<msf::MSFLayout> finalizeMsfLayout();
+ void commitFpm(WritableBinaryStream &MsfBuffer, const msf::MSFLayout &Layout);
+
BumpPtrAllocator &Allocator;
std::unique_ptr<msf::MSFBuilder> Msf;
std::unique_ptr<InfoStreamBuilder> Info;
std::unique_ptr<DbiStreamBuilder> Dbi;
- std::unique_ptr<PublicsStreamBuilder> Publics;
+ std::unique_ptr<GSIStreamBuilder> Gsi;
std::unique_ptr<TpiStreamBuilder> Tpi;
std::unique_ptr<TpiStreamBuilder> Ipi;
diff --git a/include/llvm/DebugInfo/PDB/Native/PublicsStream.h b/include/llvm/DebugInfo/PDB/Native/PublicsStream.h
index 9ace826bd8f71..2d0222a9071a0 100644
--- a/include/llvm/DebugInfo/PDB/Native/PublicsStream.h
+++ b/include/llvm/DebugInfo/PDB/Native/PublicsStream.h
@@ -12,6 +12,7 @@
#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
#include "llvm/DebugInfo/MSF/MappedBlockStream.h"
+#include "llvm/DebugInfo/PDB/Native/GlobalsStream.h"
#include "llvm/DebugInfo/PDB/Native/RawConstants.h"
#include "llvm/DebugInfo/PDB/Native/RawTypes.h"
#include "llvm/DebugInfo/PDB/PDBTypes.h"
@@ -26,19 +27,14 @@ class PDBFile;
class PublicsStream {
public:
- PublicsStream(PDBFile &File, std::unique_ptr<msf::MappedBlockStream> Stream);
+ PublicsStream(std::unique_ptr<msf::MappedBlockStream> Stream);
~PublicsStream();
Error reload();
uint32_t getSymHash() const;
- uint32_t getAddrMap() const;
- uint32_t getNumBuckets() const { return NumBuckets; }
- Expected<const codeview::CVSymbolArray &> getSymbolArray() const;
- iterator_range<codeview::CVSymbolArray::Iterator>
- getSymbols(bool *HadError) const;
- FixedStreamArray<support::ulittle32_t> getHashBuckets() const {
- return HashBuckets;
- }
+ uint16_t getThunkTableSection() const;
+ uint32_t getThunkTableOffset() const;
+ const GSIHashTable &getPublicsTable() const { return PublicsTable; }
FixedStreamArray<support::ulittle32_t> getAddressMap() const {
return AddressMap;
}
@@ -49,22 +45,14 @@ public:
return SectionOffsets;
}
- Error commit();
-
private:
- PDBFile &Pdb;
-
std::unique_ptr<msf::MappedBlockStream> Stream;
- uint32_t NumBuckets = 0;
- ArrayRef<uint8_t> Bitmap;
- FixedStreamArray<PSHashRecord> HashRecords;
- FixedStreamArray<support::ulittle32_t> HashBuckets;
+ GSIHashTable PublicsTable;
FixedStreamArray<support::ulittle32_t> AddressMap;
FixedStreamArray<support::ulittle32_t> ThunkMap;
FixedStreamArray<SectionOffset> SectionOffsets;
const PublicsStreamHeader *Header;
- const GSIHashHeader *HashHdr;
};
}
}
diff --git a/include/llvm/DebugInfo/PDB/Native/PublicsStreamBuilder.h b/include/llvm/DebugInfo/PDB/Native/PublicsStreamBuilder.h
deleted file mode 100644
index 5ab57ebef53d4..0000000000000
--- a/include/llvm/DebugInfo/PDB/Native/PublicsStreamBuilder.h
+++ /dev/null
@@ -1,54 +0,0 @@
-//===- PublicsStreamBuilder.h - PDB Publics Stream Creation -----*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_DEBUGINFO_PDB_RAW_PDBPUBLICSTREAMBUILDER_H
-#define LLVM_DEBUGINFO_PDB_RAW_PDBPUBLICSTREAMBUILDER_H
-
-#include "llvm/DebugInfo/PDB/Native/RawConstants.h"
-#include "llvm/DebugInfo/PDB/Native/RawTypes.h"
-#include "llvm/Support/BinaryByteStream.h"
-#include "llvm/Support/BinaryStreamRef.h"
-#include "llvm/Support/BinaryStreamWriter.h"
-#include "llvm/Support/Endian.h"
-#include "llvm/Support/Error.h"
-
-namespace llvm {
-namespace msf {
-class MSFBuilder;
-}
-namespace pdb {
-class PublicsStream;
-struct PublicsStreamHeader;
-
-class PublicsStreamBuilder {
-public:
- explicit PublicsStreamBuilder(msf::MSFBuilder &Msf);
- ~PublicsStreamBuilder();
-
- PublicsStreamBuilder(const PublicsStreamBuilder &) = delete;
- PublicsStreamBuilder &operator=(const PublicsStreamBuilder &) = delete;
-
- Error finalizeMsfLayout();
- uint32_t calculateSerializedLength() const;
-
- Error commit(BinaryStreamWriter &PublicsWriter);
-
- uint32_t getStreamIndex() const { return StreamIdx; }
- uint32_t getRecordStreamIdx() const { return RecordStreamIdx; }
-
-private:
- uint32_t StreamIdx = kInvalidStreamIndex;
- uint32_t RecordStreamIdx = kInvalidStreamIndex;
- std::vector<PSHashRecord> HashRecords;
- msf::MSFBuilder &Msf;
-};
-} // namespace pdb
-} // namespace llvm
-
-#endif
diff --git a/include/llvm/DebugInfo/PDB/Native/RawTypes.h b/include/llvm/DebugInfo/PDB/Native/RawTypes.h
index b6321cbf45a82..8cc083685265a 100644
--- a/include/llvm/DebugInfo/PDB/Native/RawTypes.h
+++ b/include/llvm/DebugInfo/PDB/Native/RawTypes.h
@@ -23,6 +23,20 @@ struct SectionOffset {
char Padding[2];
};
+/// Header of the hash tables found in the globals and publics sections.
+/// Based on GSIHashHdr in
+/// https://github.com/Microsoft/microsoft-pdb/blob/master/PDB/dbi/gsi.h
+struct GSIHashHeader {
+ enum : unsigned {
+ HdrSignature = ~0U,
+ HdrVersion = 0xeffe0000 + 19990810,
+ };
+ support::ulittle32_t VerSignature;
+ support::ulittle32_t VerHdr;
+ support::ulittle32_t HrSize;
+ support::ulittle32_t NumBuckets;
+};
+
// This is HRFile.
struct PSHashRecord {
support::ulittle32_t Off; // Offset in the symbol record stream
diff --git a/include/llvm/DebugInfo/PDB/Native/SymbolStream.h b/include/llvm/DebugInfo/PDB/Native/SymbolStream.h
index 17695f587849e..ae9f7d657b701 100644
--- a/include/llvm/DebugInfo/PDB/Native/SymbolStream.h
+++ b/include/llvm/DebugInfo/PDB/Native/SymbolStream.h
@@ -31,6 +31,8 @@ public:
return SymbolRecords;
}
+ codeview::CVSymbol readRecord(uint32_t Offset) const;
+
iterator_range<codeview::CVSymbolArray::Iterator>
getSymbols(bool *HadError) const;
diff --git a/include/llvm/DebugInfo/PDB/PDBSymbol.h b/include/llvm/DebugInfo/PDB/PDBSymbol.h
index 9e883d2f99a7a..04373463212b1 100644
--- a/include/llvm/DebugInfo/PDB/PDBSymbol.h
+++ b/include/llvm/DebugInfo/PDB/PDBSymbol.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_DEBUGINFO_PDB_IPDBSYMBOL_H
-#define LLVM_DEBUGINFO_PDB_IPDBSYMBOL_H
+#ifndef LLVM_DEBUGINFO_PDB_PDBSYMBOL_H
+#define LLVM_DEBUGINFO_PDB_PDBSYMBOL_H
#include "ConcreteSymbolEnumerator.h"
#include "IPDBRawSymbol.h"
diff --git a/include/llvm/DebugInfo/PDB/PDBTypes.h b/include/llvm/DebugInfo/PDB/PDBTypes.h
index 79ec7ce906d57..a6c6da37d1ccc 100644
--- a/include/llvm/DebugInfo/PDB/PDBTypes.h
+++ b/include/llvm/DebugInfo/PDB/PDBTypes.h
@@ -13,6 +13,7 @@
#include "llvm/DebugInfo/CodeView/CodeView.h"
#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
#include "llvm/DebugInfo/PDB/Native/RawTypes.h"
+#include <cctype>
#include <cstddef>
#include <cstdint>
#include <cstring>
@@ -24,6 +25,7 @@ namespace pdb {
class IPDBDataStream;
class IPDBLineNumber;
class IPDBSourceFile;
+class IPDBTable;
class PDBSymDumper;
class PDBSymbol;
class PDBSymbolExe;
@@ -62,6 +64,7 @@ using IPDBEnumSymbols = IPDBEnumChildren<PDBSymbol>;
using IPDBEnumSourceFiles = IPDBEnumChildren<IPDBSourceFile>;
using IPDBEnumDataStreams = IPDBEnumChildren<IPDBDataStream>;
using IPDBEnumLineNumbers = IPDBEnumChildren<IPDBLineNumber>;
+using IPDBEnumTables = IPDBEnumChildren<IPDBTable>;
/// Specifies which PDB reader implementation is to be used. Only a value
/// of PDB_ReaderType::DIA is currently supported, but Native is in the works.
@@ -72,13 +75,16 @@ enum class PDB_ReaderType {
/// An enumeration indicating the type of data contained in this table.
enum class PDB_TableType {
+ TableInvalid = 0,
Symbols,
SourceFiles,
LineNumbers,
SectionContribs,
Segments,
InjectedSources,
- FrameData
+ FrameData,
+ InputAssemblyFiles,
+ Dbg
};
/// Defines flags used for enumerating child symbols. This corresponds to the
@@ -241,6 +247,32 @@ enum class PDB_BuiltinType {
HResult = 31
};
+/// These values correspond to the flags that can be combined to control the
+/// return of an undecorated name for a C++ decorated name, and are documented
+/// here: https://msdn.microsoft.com/en-us/library/kszfk0fs.aspx
+enum PDB_UndnameFlags: uint32_t {
+ Undname_Complete = 0x0,
+ Undname_NoLeadingUnderscores = 0x1,
+ Undname_NoMsKeywords = 0x2,
+ Undname_NoFuncReturns = 0x4,
+ Undname_NoAllocModel = 0x8,
+ Undname_NoAllocLang = 0x10,
+ Undname_Reserved1 = 0x20,
+ Undname_Reserved2 = 0x40,
+ Undname_NoThisType = 0x60,
+ Undname_NoAccessSpec = 0x80,
+ Undname_NoThrowSig = 0x100,
+ Undname_NoMemberType = 0x200,
+ Undname_NoReturnUDTModel = 0x400,
+ Undname_32BitDecode = 0x800,
+ Undname_NameOnly = 0x1000,
+ Undname_TypeOnly = 0x2000,
+ Undname_HaveParams = 0x4000,
+ Undname_NoECSU = 0x8000,
+ Undname_NoIdentCharCheck = 0x10000,
+ Undname_NoPTR64 = 0x20000
+};
+
enum class PDB_MemberAccess { Private = 1, Protected = 2, Public = 3 };
struct VersionInfo {