summaryrefslogtreecommitdiff
path: root/include/llvm/DebugInfo
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-07-13 19:25:18 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-07-13 19:25:18 +0000
commitca089b24d48ef6fa8da2d0bb8c25bb802c4a95c0 (patch)
tree3a28a772df9b17aef34f49e3c727965ad28c0c93 /include/llvm/DebugInfo
parent9df3605dea17e84f8183581f6103bd0c79e2a606 (diff)
Notes
Diffstat (limited to 'include/llvm/DebugInfo')
-rw-r--r--include/llvm/DebugInfo/CodeView/SymbolRecord.h4
-rw-r--r--include/llvm/DebugInfo/CodeView/TypeIndex.h21
-rw-r--r--include/llvm/DebugInfo/DIContext.h24
-rw-r--r--include/llvm/DebugInfo/DWARF/DWARFContext.h25
-rw-r--r--include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h6
-rw-r--r--include/llvm/DebugInfo/PDB/Native/DbiStream.h2
-rw-r--r--include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h12
-rw-r--r--include/llvm/DebugInfo/PDB/Native/NamedStreamMap.h2
-rw-r--r--include/llvm/DebugInfo/PDB/Native/NativeBuiltinSymbol.h49
-rw-r--r--include/llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h2
-rw-r--r--include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h2
-rw-r--r--include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h6
-rw-r--r--include/llvm/DebugInfo/PDB/Native/NativeSession.h7
-rw-r--r--include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h4
-rw-r--r--include/llvm/DebugInfo/PDB/Native/PDBStringTable.h1
-rw-r--r--include/llvm/DebugInfo/PDB/Native/PublicsStream.h4
-rw-r--r--include/llvm/DebugInfo/PDB/Native/PublicsStreamBuilder.h54
-rw-r--r--include/llvm/DebugInfo/PDB/Native/RawTypes.h13
18 files changed, 213 insertions, 25 deletions
diff --git a/include/llvm/DebugInfo/CodeView/SymbolRecord.h b/include/llvm/DebugInfo/CodeView/SymbolRecord.h
index 7941af8be8af2..cdfc1745cea5d 100644
--- a/include/llvm/DebugInfo/CodeView/SymbolRecord.h
+++ b/include/llvm/DebugInfo/CodeView/SymbolRecord.h
@@ -735,6 +735,10 @@ public:
uint16_t VersionBackendQFE;
StringRef Version;
+ void setLanguage(SourceLanguage Lang) {
+ Flags = CompileSym3Flags((uint32_t(Flags) & 0xFFFFFF00) | uint32_t(Lang));
+ }
+
uint8_t getLanguage() const { return static_cast<uint32_t>(Flags) & 0xFF; }
uint32_t getFlags() const { return static_cast<uint32_t>(Flags) & ~0xFF; }
diff --git a/include/llvm/DebugInfo/CodeView/TypeIndex.h b/include/llvm/DebugInfo/CodeView/TypeIndex.h
index 10d51c2d6244f..e0c2226bdbd74 100644
--- a/include/llvm/DebugInfo/CodeView/TypeIndex.h
+++ b/include/llvm/DebugInfo/CodeView/TypeIndex.h
@@ -10,9 +10,11 @@
#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEINDEX_H
#define LLVM_DEBUGINFO_CODEVIEW_TYPEINDEX_H
+#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/Support/Endian.h"
#include <cassert>
#include <cinttypes>
+#include <functional>
namespace llvm {
@@ -265,6 +267,23 @@ struct TypeIndexOffset {
void printTypeIndex(ScopedPrinter &Printer, StringRef FieldName, TypeIndex TI,
TypeCollection &Types);
}
-}
+
+template <> struct DenseMapInfo<codeview::TypeIndex> {
+ static inline codeview::TypeIndex getEmptyKey() {
+ return codeview::TypeIndex{DenseMapInfo<uint32_t>::getEmptyKey()};
+ }
+ static inline codeview::TypeIndex getTombstoneKey() {
+ return codeview::TypeIndex{DenseMapInfo<uint32_t>::getTombstoneKey()};
+ }
+ static unsigned getHashValue(const codeview::TypeIndex &TI) {
+ return DenseMapInfo<uint32_t>::getHashValue(TI.getIndex());
+ }
+ static bool isEqual(const codeview::TypeIndex &LHS,
+ const codeview::TypeIndex &RHS) {
+ return LHS == RHS;
+ }
+};
+
+} // namespace llvm
#endif
diff --git a/include/llvm/DebugInfo/DIContext.h b/include/llvm/DebugInfo/DIContext.h
index 4126e245ff139..936813dc6abc0 100644
--- a/include/llvm/DebugInfo/DIContext.h
+++ b/include/llvm/DebugInfo/DIContext.h
@@ -204,7 +204,9 @@ public:
/// need to be consistent with the addresses used to query the DIContext and
/// the output of this function should be deterministic, i.e. repeated calls with
/// the same Sec should give the same address.
- virtual uint64_t getSectionLoadAddress(const object::SectionRef &Sec) const = 0;
+ virtual uint64_t getSectionLoadAddress(const object::SectionRef &Sec) const {
+ return 0;
+ }
/// If conveniently available, return the content of the given Section.
///
@@ -221,12 +223,28 @@ public:
return false;
}
+ // FIXME: This is untested and unused anywhere in the LLVM project, it's
+ // used/needed by Julia (an external project). It should have some coverage
+ // (at least tests, but ideally example functionality).
/// Obtain a copy of this LoadedObjectInfo.
- ///
- /// The caller is responsible for deallocation once the copy is no longer required.
virtual std::unique_ptr<LoadedObjectInfo> clone() const = 0;
};
+template <typename Derived, typename Base = LoadedObjectInfo>
+struct LoadedObjectInfoHelper : Base {
+protected:
+ LoadedObjectInfoHelper(const LoadedObjectInfoHelper &) = default;
+ LoadedObjectInfoHelper() = default;
+
+public:
+ template <typename... Ts>
+ LoadedObjectInfoHelper(Ts &&... Args) : Base(std::forward<Ts>(Args)...) {}
+
+ std::unique_ptr<llvm::LoadedObjectInfo> clone() const override {
+ return llvm::make_unique<Derived>(static_cast<const Derived &>(*this));
+ }
+};
+
} // end namespace llvm
#endif // LLVM_DEBUGINFO_DICONTEXT_H
diff --git a/include/llvm/DebugInfo/DWARF/DWARFContext.h b/include/llvm/DebugInfo/DWARF/DWARFContext.h
index 739aa1f9ee749..ee2e805050c01 100644
--- a/include/llvm/DebugInfo/DWARF/DWARFContext.h
+++ b/include/llvm/DebugInfo/DWARF/DWARFContext.h
@@ -226,11 +226,7 @@ public:
virtual bool isLittleEndian() const = 0;
virtual uint8_t getAddressSize() const = 0;
virtual const DWARFSection &getInfoSection() = 0;
-
- using TypeSectionMap = MapVector<object::SectionRef, DWARFSection,
- std::map<object::SectionRef, unsigned>>;
-
- virtual const TypeSectionMap &getTypesSections() = 0;
+ virtual void forEachTypesSections(function_ref<void(DWARFSection &)> F) = 0;
virtual StringRef getAbbrevSection() = 0;
virtual const DWARFSection &getLocSection() = 0;
virtual StringRef getARangeSection() = 0;
@@ -252,7 +248,8 @@ public:
// Sections for DWARF5 split dwarf proposal.
virtual const DWARFSection &getInfoDWOSection() = 0;
- virtual const TypeSectionMap &getTypesDWOSections() = 0;
+ virtual void
+ forEachTypesDWOSections(function_ref<void(DWARFSection &)> F) = 0;
virtual StringRef getAbbrevDWOSection() = 0;
virtual const DWARFSection &getLineDWOSection() = 0;
virtual const DWARFSection &getLocDWOSection() = 0;
@@ -294,6 +291,9 @@ enum class ErrorPolicy { Halt, Continue };
class DWARFContextInMemory : public DWARFContext {
virtual void anchor();
+ using TypeSectionMap = MapVector<object::SectionRef, DWARFSection,
+ std::map<object::SectionRef, unsigned>>;
+
StringRef FileName;
bool IsLittleEndian;
uint8_t AddressSize;
@@ -338,7 +338,8 @@ class DWARFContextInMemory : public DWARFContext {
SmallVector<SmallString<32>, 4> UncompressedSections;
- StringRef *MapSectionToMember(StringRef Name);
+ DWARFSection *mapNameToDWARFSection(StringRef Name);
+ StringRef *mapSectionToMember(StringRef Name);
/// If Sec is compressed section, decompresses and updates its contents
/// provided by Data. Otherwise leaves it unchanged.
@@ -362,7 +363,10 @@ public:
bool isLittleEndian() const override { return IsLittleEndian; }
uint8_t getAddressSize() const override { return AddressSize; }
const DWARFSection &getInfoSection() override { return InfoSection; }
- const TypeSectionMap &getTypesSections() override { return TypesSections; }
+ void forEachTypesSections(function_ref<void(DWARFSection &)> F) override {
+ for (auto &P : TypesSections)
+ F(P.second);
+ }
StringRef getAbbrevSection() override { return AbbrevSection; }
const DWARFSection &getLocSection() override { return LocSection; }
StringRef getARangeSection() override { return ARangeSection; }
@@ -389,8 +393,9 @@ public:
// Sections for DWARF5 split dwarf proposal.
const DWARFSection &getInfoDWOSection() override { return InfoDWOSection; }
- const TypeSectionMap &getTypesDWOSections() override {
- return TypesDWOSections;
+ void forEachTypesDWOSections(function_ref<void(DWARFSection &)> F) override {
+ for (auto &P : TypesDWOSections)
+ F(P.second);
}
StringRef getAbbrevDWOSection() override { return AbbrevDWOSection; }
diff --git a/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h b/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h
index e4cb1b24e30d0..c918a5d5e976d 100644
--- a/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h
+++ b/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h
@@ -47,6 +47,7 @@ public:
DbiModuleDescriptorBuilder &
operator=(const DbiModuleDescriptorBuilder &) = delete;
+ void setPdbFilePathNI(uint32_t NI);
void setObjFileName(StringRef Name);
void addSymbol(codeview::CVSymbol Symbol);
@@ -68,6 +69,10 @@ public:
uint32_t calculateSerializedLength() const;
+ /// Return the offset within the module symbol stream of the next symbol
+ /// record passed to addSymbol. Add four to account for the signature.
+ uint32_t getNextSymbolOffset() const { return SymbolByteSize + 4; }
+
void finalize();
Error finalizeMsfLayout();
@@ -81,6 +86,7 @@ private:
msf::MSFBuilder &MSF;
uint32_t SymbolByteSize = 0;
+ uint32_t PdbFilePathNI = 0;
std::string ModuleName;
std::string ObjFileName;
std::vector<std::string> SourceFiles;
diff --git a/include/llvm/DebugInfo/PDB/Native/DbiStream.h b/include/llvm/DebugInfo/PDB/Native/DbiStream.h
index 3bf7907266564..4be113f28d6f5 100644
--- a/include/llvm/DebugInfo/PDB/Native/DbiStream.h
+++ b/include/llvm/DebugInfo/PDB/Native/DbiStream.h
@@ -83,6 +83,8 @@ public:
FixedStreamArray<SecMapEntry> getSectionMap() const;
void visitSectionContributions(ISectionContribVisitor &Visitor) const;
+ Expected<StringRef> getECName(uint32_t NI) const;
+
private:
Error initializeSectionContributionData();
Error initializeSectionHeadersData();
diff --git a/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h b/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h
index 744411854181f..63eb34f0326af 100644
--- a/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h
+++ b/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h
@@ -15,6 +15,7 @@
#include "llvm/Support/Error.h"
#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
+#include "llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h"
#include "llvm/DebugInfo/PDB/Native/RawConstants.h"
#include "llvm/DebugInfo/PDB/PDBTypes.h"
#include "llvm/Support/BinaryByteStream.h"
@@ -54,8 +55,13 @@ public:
// Add given bytes as a new stream.
Error addDbgStream(pdb::DbgHeaderType Type, ArrayRef<uint8_t> Data);
+ uint32_t addECName(StringRef Name);
+
uint32_t calculateSerializedLength() const;
+ 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);
@@ -75,7 +81,7 @@ public:
private:
struct DebugStream {
ArrayRef<uint8_t> Data;
- uint16_t StreamNumber = 0;
+ uint16_t StreamNumber = kInvalidStreamIndex;
};
Error finalize();
@@ -87,7 +93,6 @@ private:
uint32_t calculateNamesBufferSize() const;
uint32_t calculateDbgStreamsSize() const;
- Error generateModiSubstream();
Error generateFileInfoSubstream();
msf::MSFBuilder &Msf;
@@ -100,6 +105,8 @@ private:
uint16_t PdbDllRbld;
uint16_t Flags;
PDB_Machine MachineType;
+ uint32_t PublicsStreamIndex = kInvalidStreamIndex;
+ uint32_t SymRecordStreamIndex = kInvalidStreamIndex;
const DbiStreamHeader *Header;
@@ -108,6 +115,7 @@ private:
StringMap<uint32_t> SourceFileNames;
+ PDBStringTableBuilder ECNamesBuilder;
WritableBinaryStreamRef NamesBuffer;
MutableBinaryByteStream FileInfoBuffer;
std::vector<SectionContrib> SectionContribs;
diff --git a/include/llvm/DebugInfo/PDB/Native/NamedStreamMap.h b/include/llvm/DebugInfo/PDB/Native/NamedStreamMap.h
index 25f66240a6a24..17a82b7ce12db 100644
--- a/include/llvm/DebugInfo/PDB/Native/NamedStreamMap.h
+++ b/include/llvm/DebugInfo/PDB/Native/NamedStreamMap.h
@@ -44,7 +44,7 @@ public:
bool get(StringRef Stream, uint32_t &StreamNo) const;
void set(StringRef Stream, uint32_t StreamNo);
void remove(StringRef Stream);
-
+ const StringMap<uint32_t> &getStringMap() const { return Mapping; }
iterator_range<StringMapConstIterator<uint32_t>> entries() const;
private:
diff --git a/include/llvm/DebugInfo/PDB/Native/NativeBuiltinSymbol.h b/include/llvm/DebugInfo/PDB/Native/NativeBuiltinSymbol.h
new file mode 100644
index 0000000000000..4f532c6e38299
--- /dev/null
+++ b/include/llvm/DebugInfo/PDB/Native/NativeBuiltinSymbol.h
@@ -0,0 +1,49 @@
+//===- NativeBuiltinSymbol.h -------------------------------------- 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_NATIVEBUILTINSYMBOL_H
+#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVEBUILTINSYMBOL_H
+
+#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h"
+
+#include "llvm/DebugInfo/PDB/PDBTypes.h"
+
+namespace llvm {
+namespace pdb {
+
+class NativeSession;
+
+class NativeBuiltinSymbol : public NativeRawSymbol {
+public:
+ NativeBuiltinSymbol(NativeSession &PDBSession, SymIndexId Id,
+ PDB_BuiltinType T, uint64_t L);
+ ~NativeBuiltinSymbol() override;
+
+ virtual std::unique_ptr<NativeRawSymbol> clone() const override;
+
+ void dump(raw_ostream &OS, int Indent) const override;
+
+ PDB_SymType getSymTag() const override;
+
+ PDB_BuiltinType getBuiltinType() const override;
+ bool isConstType() const override;
+ uint64_t getLength() const override;
+ bool isUnalignedType() const override;
+ bool isVolatileType() const override;
+
+protected:
+ NativeSession &Session;
+ PDB_BuiltinType Type;
+ uint64_t Length;
+};
+
+} // namespace pdb
+} // namespace llvm
+
+#endif
diff --git a/include/llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h b/include/llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h
index 1687737f0e7f9..bd5c09e5ff76d 100644
--- a/include/llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h
+++ b/include/llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h
@@ -18,7 +18,7 @@ namespace pdb {
class NativeCompilandSymbol : public NativeRawSymbol {
public:
- NativeCompilandSymbol(NativeSession &Session, uint32_t SymbolId,
+ NativeCompilandSymbol(NativeSession &Session, SymIndexId SymbolId,
DbiModuleDescriptor MI);
std::unique_ptr<NativeRawSymbol> clone() const override;
diff --git a/include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h b/include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h
index 15bac78df191b..ddb7f811da384 100644
--- a/include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h
+++ b/include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h
@@ -18,7 +18,7 @@ namespace pdb {
class NativeExeSymbol : public NativeRawSymbol {
public:
- NativeExeSymbol(NativeSession &Session, uint32_t SymbolId);
+ NativeExeSymbol(NativeSession &Session, SymIndexId SymbolId);
std::unique_ptr<NativeRawSymbol> clone() const override;
diff --git a/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h b/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h
index a24a972879d2c..66a9eae28e235 100644
--- a/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h
+++ b/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h
@@ -19,9 +19,11 @@ namespace pdb {
class NativeSession;
+typedef uint32_t SymIndexId;
+
class NativeRawSymbol : public IPDBRawSymbol {
public:
- NativeRawSymbol(NativeSession &PDBSession, uint32_t SymbolId);
+ NativeRawSymbol(NativeSession &PDBSession, SymIndexId SymbolId);
virtual std::unique_ptr<NativeRawSymbol> clone() const = 0;
@@ -205,7 +207,7 @@ public:
protected:
NativeSession &Session;
- uint32_t SymbolId;
+ SymIndexId SymbolId;
};
} // end namespace pdb
diff --git a/include/llvm/DebugInfo/PDB/Native/NativeSession.h b/include/llvm/DebugInfo/PDB/Native/NativeSession.h
index dd40874dc5f26..b16ce231c349c 100644
--- a/include/llvm/DebugInfo/PDB/Native/NativeSession.h
+++ b/include/llvm/DebugInfo/PDB/Native/NativeSession.h
@@ -10,9 +10,13 @@
#ifndef LLVM_DEBUGINFO_PDB_NATIVE_NATIVESESSION_H
#define LLVM_DEBUGINFO_PDB_NATIVE_NATIVESESSION_H
+#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/DebugInfo/CodeView/TypeIndex.h"
+#include "llvm/DebugInfo/PDB/IPDBRawSymbol.h"
#include "llvm/DebugInfo/PDB/IPDBSession.h"
#include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h"
+#include "llvm/DebugInfo/PDB/Native/NativeBuiltinSymbol.h"
#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/Error.h"
@@ -35,6 +39,8 @@ public:
std::unique_ptr<PDBSymbolCompiland>
createCompilandSymbol(DbiModuleDescriptor MI);
+ SymIndexId findSymbolByTypeIndex(codeview::TypeIndex TI);
+
uint64_t getLoadAddress() const override;
void setLoadAddress(uint64_t Address) override;
std::unique_ptr<PDBSymbolExe> getGlobalScope() override;
@@ -77,6 +83,7 @@ private:
std::unique_ptr<PDBFile> Pdb;
std::unique_ptr<BumpPtrAllocator> Allocator;
std::vector<std::unique_ptr<NativeRawSymbol>> SymbolCache;
+ DenseMap<codeview::TypeIndex, SymIndexId> TypeIndexToSymbolId;
};
}
}
diff --git a/include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h b/include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h
index cd7d3b0637933..2dc23f819d3bd 100644
--- a/include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h
+++ b/include/llvm/DebugInfo/PDB/Native/PDBFileBuilder.h
@@ -31,11 +31,13 @@ class MSFBuilder;
namespace pdb {
class DbiStreamBuilder;
class InfoStreamBuilder;
+class PublicsStreamBuilder;
class TpiStreamBuilder;
class PDBFileBuilder {
public:
explicit PDBFileBuilder(BumpPtrAllocator &Allocator);
+ ~PDBFileBuilder();
PDBFileBuilder(const PDBFileBuilder &) = delete;
PDBFileBuilder &operator=(const PDBFileBuilder &) = delete;
@@ -47,6 +49,7 @@ public:
TpiStreamBuilder &getTpiBuilder();
TpiStreamBuilder &getIpiBuilder();
PDBStringTableBuilder &getStringTableBuilder();
+ PublicsStreamBuilder &getPublicsBuilder();
Error commit(StringRef Filename);
@@ -61,6 +64,7 @@ private:
std::unique_ptr<msf::MSFBuilder> Msf;
std::unique_ptr<InfoStreamBuilder> Info;
std::unique_ptr<DbiStreamBuilder> Dbi;
+ std::unique_ptr<PublicsStreamBuilder> Publics;
std::unique_ptr<TpiStreamBuilder> Tpi;
std::unique_ptr<TpiStreamBuilder> Ipi;
diff --git a/include/llvm/DebugInfo/PDB/Native/PDBStringTable.h b/include/llvm/DebugInfo/PDB/Native/PDBStringTable.h
index 86ef1136b41d7..29167c966d427 100644
--- a/include/llvm/DebugInfo/PDB/Native/PDBStringTable.h
+++ b/include/llvm/DebugInfo/PDB/Native/PDBStringTable.h
@@ -56,7 +56,6 @@ private:
const PDBStringTableHeader *Header = nullptr;
codeview::DebugStringTableSubsectionRef Strings;
FixedStreamArray<support::ulittle32_t> IDs;
- uint32_t ByteSize = 0;
uint32_t NameCount = 0;
};
diff --git a/include/llvm/DebugInfo/PDB/Native/PublicsStream.h b/include/llvm/DebugInfo/PDB/Native/PublicsStream.h
index 4570c80c76d7c..9ace826bd8f71 100644
--- a/include/llvm/DebugInfo/PDB/Native/PublicsStream.h
+++ b/include/llvm/DebugInfo/PDB/Native/PublicsStream.h
@@ -25,8 +25,6 @@ struct GSIHashHeader;
class PDBFile;
class PublicsStream {
- struct HeaderInfo;
-
public:
PublicsStream(PDBFile &File, std::unique_ptr<msf::MappedBlockStream> Stream);
~PublicsStream();
@@ -65,7 +63,7 @@ private:
FixedStreamArray<support::ulittle32_t> ThunkMap;
FixedStreamArray<SectionOffset> SectionOffsets;
- const HeaderInfo *Header;
+ const PublicsStreamHeader *Header;
const GSIHashHeader *HashHdr;
};
}
diff --git a/include/llvm/DebugInfo/PDB/Native/PublicsStreamBuilder.h b/include/llvm/DebugInfo/PDB/Native/PublicsStreamBuilder.h
new file mode 100644
index 0000000000000..5ab57ebef53d4
--- /dev/null
+++ b/include/llvm/DebugInfo/PDB/Native/PublicsStreamBuilder.h
@@ -0,0 +1,54 @@
+//===- 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 771272d6a47d1..a3cdd3f09a44e 100644
--- a/include/llvm/DebugInfo/PDB/Native/RawTypes.h
+++ b/include/llvm/DebugInfo/PDB/Native/RawTypes.h
@@ -255,6 +255,19 @@ struct ModuleInfoHeader {
/// char ObjFileName[];
};
+// This is PSGSIHDR struct defined in
+// https://github.com/Microsoft/microsoft-pdb/blob/master/PDB/dbi/gsi.h
+struct PublicsStreamHeader {
+ support::ulittle32_t SymHash;
+ support::ulittle32_t AddrMap;
+ support::ulittle32_t NumThunks;
+ support::ulittle32_t SizeOfThunk;
+ support::ulittle16_t ISectThunkTable;
+ char Padding[2];
+ support::ulittle32_t OffThunkTable;
+ support::ulittle32_t NumSections;
+};
+
/// Defines a 128-bit unique identifier. This maps to a GUID on Windows, but
/// is abstracted here for the purposes of non-Windows platforms that don't have
/// the GUID structure defined.