summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-06-05 21:40:33 +0000
committerZachary Turner <zturner@google.com>2017-06-05 21:40:33 +0000
commit349c18f8377aa46af024e0ba7d312304ad2ac28a (patch)
tree1bbd719c419cb69fa87cd037de57ab206216741e /llvm/lib
parent5b0bf2ff0d80998804871ab151ec2f00ff2dee8b (diff)
downloadbcm5719-llvm-349c18f8377aa46af024e0ba7d312304ad2ac28a.tar.gz
bcm5719-llvm-349c18f8377aa46af024e0ba7d312304ad2ac28a.zip
[CodeView] Handle Cross Module Imports and Exports.
While it's not entirely clear why a compiler or linker might put this information into an object or PDB file, one has been spotted in the wild which was causing llvm-pdbdump to crash. This patch adds support for reading-writing these sections. Since I don't know how to get one of the native tools to generate this kind of debug info, the only test here is one in which we feed YAML into the tool to produce a PDB and then spit out YAML from the resulting PDB and make sure that it matches. llvm-svn: 304738
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/DebugInfo/CodeView/CMakeLists.txt10
-rw-r--r--llvm/lib/DebugInfo/CodeView/DebugCrossExSubsection.cpp49
-rw-r--r--llvm/lib/DebugInfo/CodeView/DebugCrossImpSubsection.cpp91
-rw-r--r--llvm/lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp2
-rw-r--r--llvm/lib/DebugInfo/CodeView/DebugSubsectionVisitor.cpp14
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp4
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/PublicsStream.cpp10
-rw-r--r--llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp155
-rw-r--r--llvm/lib/ObjectYAML/CodeViewYAMLSymbols.cpp13
9 files changed, 329 insertions, 19 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/CMakeLists.txt b/llvm/lib/DebugInfo/CodeView/CMakeLists.txt
index 410b89bc949..c543a6e9ae1 100644
--- a/llvm/lib/DebugInfo/CodeView/CMakeLists.txt
+++ b/llvm/lib/DebugInfo/CodeView/CMakeLists.txt
@@ -3,11 +3,9 @@ add_llvm_library(LLVMDebugInfoCodeView
CodeViewRecordIO.cpp
CVSymbolVisitor.cpp
CVTypeVisitor.cpp
- EnumTables.cpp
- Formatters.cpp
- LazyRandomTypeCollection.cpp
- Line.cpp
DebugChecksumsSubsection.cpp
+ DebugCrossExSubsection.cpp
+ DebugCrossImpSubsection.cpp
DebugFrameDataSubsection.cpp
DebugInlineeLinesSubsection.cpp
DebugLinesSubsection.cpp
@@ -16,6 +14,10 @@ add_llvm_library(LLVMDebugInfoCodeView
DebugSubsectionRecord.cpp
DebugSubsectionVisitor.cpp
DebugSymbolsSubsection.cpp
+ EnumTables.cpp
+ Formatters.cpp
+ LazyRandomTypeCollection.cpp
+ Line.cpp
RecordSerialization.cpp
SymbolRecordMapping.cpp
SymbolDumper.cpp
diff --git a/llvm/lib/DebugInfo/CodeView/DebugCrossExSubsection.cpp b/llvm/lib/DebugInfo/CodeView/DebugCrossExSubsection.cpp
new file mode 100644
index 00000000000..d8dca5d5c63
--- /dev/null
+++ b/llvm/lib/DebugInfo/CodeView/DebugCrossExSubsection.cpp
@@ -0,0 +1,49 @@
+//===- DebugCrossExSubsection.cpp -------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/DebugInfo/CodeView/DebugCrossExSubsection.h"
+
+#include "llvm/DebugInfo/CodeView/CodeViewError.h"
+
+using namespace llvm;
+using namespace llvm::codeview;
+
+Error DebugCrossModuleExportsSubsectionRef::initialize(
+ BinaryStreamReader Reader) {
+ if (Reader.bytesRemaining() % sizeof(CrossModuleExport) != 0)
+ return make_error<CodeViewError>(
+ cv_error_code::corrupt_record,
+ "Cross Scope Exports section is an invalid size!");
+
+ uint32_t Size = Reader.bytesRemaining() / sizeof(CrossModuleExport);
+ return Reader.readArray(References, Size);
+}
+
+Error DebugCrossModuleExportsSubsectionRef::initialize(BinaryStreamRef Stream) {
+ BinaryStreamReader Reader(Stream);
+ return initialize(Reader);
+}
+
+void DebugCrossModuleExportsSubsection::addMapping(uint32_t Local,
+ uint32_t Global) {
+ Mappings[Local] = Global;
+}
+
+uint32_t DebugCrossModuleExportsSubsection::calculateSerializedSize() const {
+ return Mappings.size() * sizeof(CrossModuleExport);
+}
+
+Error DebugCrossModuleExportsSubsection::commit(
+ BinaryStreamWriter &Writer) const {
+ for (const auto &M : Mappings) {
+ if (auto EC = Writer.writeObject(M))
+ return EC;
+ }
+ return Error::success();
+}
diff --git a/llvm/lib/DebugInfo/CodeView/DebugCrossImpSubsection.cpp b/llvm/lib/DebugInfo/CodeView/DebugCrossImpSubsection.cpp
new file mode 100644
index 00000000000..e0ceefcd5fa
--- /dev/null
+++ b/llvm/lib/DebugInfo/CodeView/DebugCrossImpSubsection.cpp
@@ -0,0 +1,91 @@
+//===- DebugCrossImpSubsection.cpp ------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/DebugInfo/CodeView/DebugCrossImpSubsection.h"
+
+#include "llvm/DebugInfo/CodeView/CodeViewError.h"
+#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
+
+using namespace llvm;
+using namespace llvm::codeview;
+
+namespace llvm {
+Error VarStreamArrayExtractor<CrossModuleImportItem>::extract(
+ BinaryStreamRef Stream, uint32_t &Len,
+ codeview::CrossModuleImportItem &Item) {
+ BinaryStreamReader Reader(Stream);
+ if (Reader.bytesRemaining() < sizeof(CrossModuleImport))
+ return make_error<CodeViewError>(
+ cv_error_code::insufficient_buffer,
+ "Not enough bytes for a Cross Module Import Header!");
+ if (auto EC = Reader.readObject(Item.Header))
+ return EC;
+ if (Reader.bytesRemaining() < Item.Header->Count * sizeof(uint32_t))
+ return make_error<CodeViewError>(
+ cv_error_code::insufficient_buffer,
+ "Not enough to read specified number of Cross Module References!");
+ if (auto EC = Reader.readArray(Item.Imports, Item.Header->Count))
+ return EC;
+ return Error::success();
+}
+}
+
+Error DebugCrossModuleImportsSubsectionRef::initialize(
+ BinaryStreamReader Reader) {
+ return Reader.readArray(References, Reader.bytesRemaining());
+}
+
+Error DebugCrossModuleImportsSubsectionRef::initialize(BinaryStreamRef Stream) {
+ BinaryStreamReader Reader(Stream);
+ return initialize(Reader);
+}
+
+void DebugCrossModuleImportsSubsection::addImport(StringRef Module,
+ uint32_t ImportId) {
+ Strings.insert(Module);
+ std::vector<support::ulittle32_t> Targets = {support::ulittle32_t(ImportId)};
+ auto Result = Mappings.insert(std::make_pair(Module, Targets));
+ if (!Result.second)
+ Result.first->getValue().push_back(Targets[0]);
+}
+
+uint32_t DebugCrossModuleImportsSubsection::calculateSerializedSize() const {
+ uint32_t Size = 0;
+ for (const auto &Item : Mappings) {
+ Size += sizeof(CrossModuleImport);
+ Size += sizeof(support::ulittle32_t) * Item.second.size();
+ }
+ return Size;
+}
+
+Error DebugCrossModuleImportsSubsection::commit(
+ BinaryStreamWriter &Writer) const {
+ using T = decltype(&*Mappings.begin());
+ std::vector<T> Ids;
+ Ids.reserve(Mappings.size());
+
+ for (const auto &M : Mappings)
+ Ids.push_back(&M);
+
+ std::sort(Ids.begin(), Ids.end(), [this](const T &L1, const T &L2) {
+ return Strings.getStringId(L1->getKey()) <
+ Strings.getStringId(L2->getKey());
+ });
+
+ for (const auto &Item : Ids) {
+ CrossModuleImport Imp;
+ Imp.ModuleNameOffset = Strings.getStringId(Item->getKey());
+ Imp.Count = Item->getValue().size();
+ if (auto EC = Writer.writeObject(Imp))
+ return EC;
+ if (auto EC = Writer.writeArray(makeArrayRef(Item->getValue())))
+ return EC;
+ }
+ return Error::success();
+}
diff --git a/llvm/lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp b/llvm/lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp
index cfd1c5d3ab0..0cf31846f25 100644
--- a/llvm/lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp
+++ b/llvm/lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp
@@ -38,6 +38,8 @@ Error DebugSubsectionRecord::initialize(BinaryStreamRef Stream,
case DebugSubsectionKind::FileChecksums:
case DebugSubsectionKind::Lines:
case DebugSubsectionKind::InlineeLines:
+ case DebugSubsectionKind::CrossScopeExports:
+ case DebugSubsectionKind::CrossScopeImports:
break;
default:
llvm_unreachable("Unexpected debug fragment kind!");
diff --git a/llvm/lib/DebugInfo/CodeView/DebugSubsectionVisitor.cpp b/llvm/lib/DebugInfo/CodeView/DebugSubsectionVisitor.cpp
index f2c4dea8685..93fe4e1914b 100644
--- a/llvm/lib/DebugInfo/CodeView/DebugSubsectionVisitor.cpp
+++ b/llvm/lib/DebugInfo/CodeView/DebugSubsectionVisitor.cpp
@@ -10,6 +10,8 @@
#include "llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h"
#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
+#include "llvm/DebugInfo/CodeView/DebugCrossExSubsection.h"
+#include "llvm/DebugInfo/CodeView/DebugCrossImpSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
@@ -44,6 +46,18 @@ Error llvm::codeview::visitDebugSubsection(const DebugSubsectionRecord &R,
return EC;
return V.visitInlineeLines(Fragment);
}
+ case DebugSubsectionKind::CrossScopeExports: {
+ DebugCrossModuleExportsSubsectionRef Section;
+ if (auto EC = Section.initialize(Reader))
+ return EC;
+ return V.visitCrossModuleExports(Section);
+ }
+ case DebugSubsectionKind::CrossScopeImports: {
+ DebugCrossModuleImportsSubsectionRef Section;
+ if (auto EC = Section.initialize(Reader))
+ return EC;
+ return V.visitCrossModuleImports(Section);
+ }
default: {
DebugUnknownSubsectionRef Fragment(R.kind(), R.getRecordData());
return V.visitUnknown(Fragment);
diff --git a/llvm/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp b/llvm/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp
index c4ff30011a1..4186f2eb6ba 100644
--- a/llvm/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp
@@ -90,14 +90,14 @@ Error ModuleDebugStreamRef::commit() { return Error::success(); }
Expected<codeview::DebugChecksumsSubsectionRef>
ModuleDebugStreamRef::findChecksumsSubsection() const {
+ codeview::DebugChecksumsSubsectionRef Result;
for (const auto &SS : subsections()) {
if (SS.kind() != DebugSubsectionKind::FileChecksums)
continue;
- codeview::DebugChecksumsSubsectionRef Result;
if (auto EC = Result.initialize(SS.getRecordData()))
return std::move(EC);
return Result;
}
- return make_error<RawError>(raw_error_code::no_entry);
+ return Result;
}
diff --git a/llvm/lib/DebugInfo/PDB/Native/PublicsStream.cpp b/llvm/lib/DebugInfo/PDB/Native/PublicsStream.cpp
index 58202577672..091ac67035d 100644
--- a/llvm/lib/DebugInfo/PDB/Native/PublicsStream.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/PublicsStream.cpp
@@ -105,10 +105,12 @@ Error PublicsStream::reload() {
"Could not read a thunk map."));
// Something called "section map" follows.
- if (auto EC = Reader.readArray(SectionOffsets, Header->NumSections))
- return joinErrors(std::move(EC),
- make_error<RawError>(raw_error_code::corrupt_file,
- "Could not read a section map."));
+ if (Reader.bytesRemaining() > 0) {
+ if (auto EC = Reader.readArray(SectionOffsets, Header->NumSections))
+ return joinErrors(std::move(EC),
+ make_error<RawError>(raw_error_code::corrupt_file,
+ "Could not read a section map."));
+ }
if (Reader.bytesRemaining() > 0)
return make_error<RawError>(raw_error_code::corrupt_file,
diff --git a/llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp b/llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp
index 21d29835624..fc3d0ceaa15 100644
--- a/llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp
+++ b/llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp
@@ -18,6 +18,8 @@
#include "llvm/ADT/StringSwitch.h"
#include "llvm/DebugInfo/CodeView/CodeViewError.h"
#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
+#include "llvm/DebugInfo/CodeView/DebugCrossExSubsection.h"
+#include "llvm/DebugInfo/CodeView/DebugCrossImpSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
@@ -38,13 +40,19 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(SourceLineBlock)
LLVM_YAML_IS_SEQUENCE_VECTOR(SourceLineInfo)
LLVM_YAML_IS_SEQUENCE_VECTOR(InlineeSite)
LLVM_YAML_IS_SEQUENCE_VECTOR(InlineeInfo)
+LLVM_YAML_IS_SEQUENCE_VECTOR(CrossModuleExport)
+LLVM_YAML_IS_SEQUENCE_VECTOR(YAMLCrossModuleImport)
LLVM_YAML_IS_SEQUENCE_VECTOR(StringRef)
+LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(uint32_t)
LLVM_YAML_DECLARE_SCALAR_TRAITS(HexFormattedString, false)
LLVM_YAML_DECLARE_ENUM_TRAITS(DebugSubsectionKind)
LLVM_YAML_DECLARE_ENUM_TRAITS(FileChecksumKind)
LLVM_YAML_DECLARE_BITSET_TRAITS(LineFlags)
+LLVM_YAML_DECLARE_MAPPING_TRAITS(CrossModuleExport)
+LLVM_YAML_DECLARE_MAPPING_TRAITS(YAMLCrossModuleImport)
+LLVM_YAML_DECLARE_MAPPING_TRAITS(CrossModuleImportItem)
LLVM_YAML_DECLARE_MAPPING_TRAITS(SourceLineEntry)
LLVM_YAML_DECLARE_MAPPING_TRAITS(SourceColumnEntry)
LLVM_YAML_DECLARE_MAPPING_TRAITS(SourceFileChecksumEntry)
@@ -114,6 +122,35 @@ struct YAMLInlineeLinesSubsection : public YAMLSubsectionBase {
InlineeInfo InlineeLines;
};
+
+struct YAMLCrossModuleExportsSubsection : public YAMLSubsectionBase {
+ YAMLCrossModuleExportsSubsection()
+ : YAMLSubsectionBase(DebugSubsectionKind::CrossScopeExports) {}
+
+ void map(IO &IO) override;
+ std::unique_ptr<DebugSubsection>
+ toCodeViewSubsection(DebugStringTableSubsection *Strings,
+ DebugChecksumsSubsection *Checksums) const override;
+ static Expected<std::shared_ptr<YAMLCrossModuleExportsSubsection>>
+ fromCodeViewSubsection(const DebugCrossModuleExportsSubsectionRef &Exports);
+
+ std::vector<CrossModuleExport> Exports;
+};
+
+struct YAMLCrossModuleImportsSubsection : public YAMLSubsectionBase {
+ YAMLCrossModuleImportsSubsection()
+ : YAMLSubsectionBase(DebugSubsectionKind::CrossScopeImports) {}
+
+ void map(IO &IO) override;
+ std::unique_ptr<DebugSubsection>
+ toCodeViewSubsection(DebugStringTableSubsection *Strings,
+ DebugChecksumsSubsection *Checksums) const override;
+ static Expected<std::shared_ptr<YAMLCrossModuleImportsSubsection>>
+ fromCodeViewSubsection(const DebugStringTableSubsectionRef &Strings,
+ const DebugCrossModuleImportsSubsectionRef &Imports);
+
+ std::vector<YAMLCrossModuleImport> Imports;
+};
}
void ScalarBitSetTraits<LineFlags>::bitset(IO &io, LineFlags &Flags) {
@@ -161,6 +198,17 @@ void MappingTraits<SourceLineBlock>::mapping(IO &IO, SourceLineBlock &Obj) {
IO.mapRequired("Columns", Obj.Columns);
}
+void MappingTraits<CrossModuleExport>::mapping(IO &IO, CrossModuleExport &Obj) {
+ IO.mapRequired("LocalId", Obj.Local);
+ IO.mapRequired("GlobalId", Obj.Global);
+}
+
+void MappingTraits<YAMLCrossModuleImport>::mapping(IO &IO,
+ YAMLCrossModuleImport &Obj) {
+ IO.mapRequired("Module", Obj.ModuleName);
+ IO.mapRequired("Imports", Obj.ImportIds);
+}
+
void MappingTraits<SourceFileChecksumEntry>::mapping(
IO &IO, SourceFileChecksumEntry &Obj) {
IO.mapRequired("FileName", Obj.FileName);
@@ -196,6 +244,16 @@ void YAMLInlineeLinesSubsection::map(IO &IO) {
IO.mapRequired("Sites", InlineeLines.Sites);
}
+void YAMLCrossModuleExportsSubsection::map(IO &IO) {
+ IO.mapTag("!CrossModuleExports", true);
+ IO.mapOptional("Exports", Exports);
+}
+
+void YAMLCrossModuleImportsSubsection::map(IO &IO) {
+ IO.mapTag("!CrossModuleImports", true);
+ IO.mapOptional("Imports", Imports);
+}
+
void MappingTraits<YAMLDebugSubsection>::mapping(
IO &IO, YAMLDebugSubsection &Subsection) {
if (!IO.outputting()) {
@@ -206,6 +264,12 @@ void MappingTraits<YAMLDebugSubsection>::mapping(
Subsection.Subsection = std::make_shared<YAMLLinesSubsection>();
} else if (IO.mapTag("!InlineeLines")) {
Subsection.Subsection = std::make_shared<YAMLInlineeLinesSubsection>();
+ } else if (IO.mapTag("!CrossModuleExports")) {
+ Subsection.Subsection =
+ std::make_shared<YAMLCrossModuleExportsSubsection>();
+ } else if (IO.mapTag("!CrossModuleImports")) {
+ Subsection.Subsection =
+ std::make_shared<YAMLCrossModuleImportsSubsection>();
} else {
llvm_unreachable("Unexpected subsection tag!");
}
@@ -213,14 +277,15 @@ void MappingTraits<YAMLDebugSubsection>::mapping(
Subsection.Subsection->map(IO);
}
-static Expected<const YAMLChecksumsSubsection &>
+static std::shared_ptr<YAMLChecksumsSubsection>
findChecksums(ArrayRef<YAMLDebugSubsection> Subsections) {
for (const auto &SS : Subsections) {
if (SS.Subsection->Kind == DebugSubsectionKind::FileChecksums) {
- return static_cast<const YAMLChecksumsSubsection &>(*SS.Subsection);
+ return std::static_pointer_cast<YAMLChecksumsSubsection>(SS.Subsection);
}
}
- return make_error<CodeViewError>(cv_error_code::no_records);
+
+ return nullptr;
}
std::unique_ptr<DebugSubsection> YAMLChecksumsSubsection::toCodeViewSubsection(
@@ -285,6 +350,28 @@ YAMLInlineeLinesSubsection::toCodeViewSubsection(
return llvm::cast<DebugSubsection>(std::move(Result));
}
+std::unique_ptr<DebugSubsection>
+YAMLCrossModuleExportsSubsection::toCodeViewSubsection(
+ DebugStringTableSubsection *Strings,
+ DebugChecksumsSubsection *Checksums) const {
+ auto Result = llvm::make_unique<DebugCrossModuleExportsSubsection>();
+ for (const auto &M : Exports)
+ Result->addMapping(M.Local, M.Global);
+ return llvm::cast<DebugSubsection>(std::move(Result));
+}
+
+std::unique_ptr<DebugSubsection>
+YAMLCrossModuleImportsSubsection::toCodeViewSubsection(
+ DebugStringTableSubsection *Strings,
+ DebugChecksumsSubsection *Checksums) const {
+ auto Result = llvm::make_unique<DebugCrossModuleImportsSubsection>(*Strings);
+ for (const auto &M : Imports) {
+ for (const auto Id : M.ImportIds)
+ Result->addImport(M.ModuleName, Id);
+ }
+ return llvm::cast<DebugSubsection>(std::move(Result));
+}
+
static Expected<SourceFileChecksumEntry>
convertOneChecksum(const DebugStringTableSubsectionRef &Strings,
const FileChecksumEntry &CS) {
@@ -391,6 +478,31 @@ YAMLInlineeLinesSubsection::fromCodeViewSubsection(
return Result;
}
+Expected<std::shared_ptr<YAMLCrossModuleExportsSubsection>>
+YAMLCrossModuleExportsSubsection::fromCodeViewSubsection(
+ const DebugCrossModuleExportsSubsectionRef &Exports) {
+ auto Result = std::make_shared<YAMLCrossModuleExportsSubsection>();
+ Result->Exports.assign(Exports.begin(), Exports.end());
+ return Result;
+}
+
+Expected<std::shared_ptr<YAMLCrossModuleImportsSubsection>>
+YAMLCrossModuleImportsSubsection::fromCodeViewSubsection(
+ const DebugStringTableSubsectionRef &Strings,
+ const DebugCrossModuleImportsSubsectionRef &Imports) {
+ auto Result = std::make_shared<YAMLCrossModuleImportsSubsection>();
+ for (const auto &CMI : Imports) {
+ YAMLCrossModuleImport YCMI;
+ auto ExpectedStr = Strings.getString(CMI.Header->ModuleNameOffset);
+ if (!ExpectedStr)
+ return ExpectedStr.takeError();
+ YCMI.ModuleName = *ExpectedStr;
+ YCMI.ImportIds.assign(CMI.Imports.begin(), CMI.Imports.end());
+ Result->Imports.push_back(YCMI);
+ }
+ return Result;
+}
+
Expected<std::vector<std::unique_ptr<DebugSubsection>>>
llvm::CodeViewYAML::convertSubsectionList(
ArrayRef<YAMLDebugSubsection> Subsections,
@@ -400,11 +512,11 @@ llvm::CodeViewYAML::convertSubsectionList(
return std::move(Result);
auto Checksums = findChecksums(Subsections);
- if (!Checksums)
- return Checksums.takeError();
- auto ChecksumsBase = Checksums->toCodeViewSubsection(&Strings, nullptr);
- DebugChecksumsSubsection &CS =
- llvm::cast<DebugChecksumsSubsection>(*ChecksumsBase);
+ std::unique_ptr<DebugSubsection> ChecksumsBase;
+ if (Checksums)
+ ChecksumsBase = Checksums->toCodeViewSubsection(&Strings, nullptr);
+ DebugChecksumsSubsection *CS =
+ static_cast<DebugChecksumsSubsection *>(ChecksumsBase.get());
for (const auto &SS : Subsections) {
// We've already converted the checksums subsection, don't do it
// twice.
@@ -412,7 +524,8 @@ llvm::CodeViewYAML::convertSubsectionList(
if (SS.Subsection->Kind == DebugSubsectionKind::FileChecksums)
CVS = std::move(ChecksumsBase);
else
- CVS = SS.Subsection->toCodeViewSubsection(&Strings, &CS);
+ CVS = SS.Subsection->toCodeViewSubsection(&Strings, CS);
+ assert(CVS != nullptr);
Result.push_back(std::move(CVS));
}
return std::move(Result);
@@ -429,6 +542,10 @@ struct SubsectionConversionVisitor : public DebugSubsectionVisitor {
Error visitLines(DebugLinesSubsectionRef &Lines) override;
Error visitFileChecksums(DebugChecksumsSubsectionRef &Checksums) override;
Error visitInlineeLines(DebugInlineeLinesSubsectionRef &Inlinees) override;
+ Error visitCrossModuleExports(
+ DebugCrossModuleExportsSubsectionRef &Checksums) override;
+ Error visitCrossModuleImports(
+ DebugCrossModuleImportsSubsectionRef &Inlinees) override;
YAMLDebugSubsection Subsection;
@@ -470,6 +587,26 @@ Error SubsectionConversionVisitor::visitInlineeLines(
Subsection.Subsection = *Result;
return Error::success();
}
+
+Error SubsectionConversionVisitor::visitCrossModuleExports(
+ DebugCrossModuleExportsSubsectionRef &Exports) {
+ auto Result =
+ YAMLCrossModuleExportsSubsection::fromCodeViewSubsection(Exports);
+ if (!Result)
+ return Result.takeError();
+ Subsection.Subsection = *Result;
+ return Error::success();
+}
+
+Error SubsectionConversionVisitor::visitCrossModuleImports(
+ DebugCrossModuleImportsSubsectionRef &Imports) {
+ auto Result = YAMLCrossModuleImportsSubsection::fromCodeViewSubsection(
+ Strings, Imports);
+ if (!Result)
+ return Result.takeError();
+ Subsection.Subsection = *Result;
+ return Error::success();
+}
}
Expected<YAMLDebugSubsection> YAMLDebugSubsection::fromCodeViewSubection(
diff --git a/llvm/lib/ObjectYAML/CodeViewYAMLSymbols.cpp b/llvm/lib/ObjectYAML/CodeViewYAMLSymbols.cpp
index bd97af3a932..fa3f1e0b60a 100644
--- a/llvm/lib/ObjectYAML/CodeViewYAMLSymbols.cpp
+++ b/llvm/lib/ObjectYAML/CodeViewYAMLSymbols.cpp
@@ -47,6 +47,18 @@ LLVM_YAML_DECLARE_ENUM_TRAITS(RegisterId)
LLVM_YAML_DECLARE_ENUM_TRAITS(TrampolineType)
LLVM_YAML_DECLARE_ENUM_TRAITS(ThunkOrdinal)
+LLVM_YAML_STRONG_TYPEDEF(llvm::StringRef, TypeName)
+
+LLVM_YAML_DECLARE_SCALAR_TRAITS(TypeName, true)
+
+StringRef ScalarTraits<TypeName>::input(StringRef S, void *V, TypeName &T) {
+ return ScalarTraits<StringRef>::input(S, V, T.value);
+}
+void ScalarTraits<TypeName>::output(const TypeName &T, void *V,
+ llvm::raw_ostream &R) {
+ ScalarTraits<StringRef>::output(T.value, V, R);
+}
+
void ScalarEnumerationTraits<SymbolKind>::enumeration(IO &io,
SymbolKind &Value) {
auto SymbolNames = getSymbolTypeNames();
@@ -264,6 +276,7 @@ template <> void SymbolRecordImpl<InlineSiteSym>::map(IO &IO) {
template <> void SymbolRecordImpl<LocalSym>::map(IO &IO) {
IO.mapRequired("Type", Symbol.Type);
IO.mapRequired("Flags", Symbol.Flags);
+
IO.mapRequired("VarName", Symbol.Name);
}
OpenPOWER on IntegriCloud