summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp3
-rw-r--r--llvm/lib/DebugInfo/CodeView/DebugSubsectionVisitor.cpp45
-rw-r--r--llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp57
3 files changed, 71 insertions, 34 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp b/llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp
index 2e72242181b..7b972a1a277 100644
--- a/llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp
+++ b/llvm/lib/DebugInfo/CodeView/DebugStringTableSubsection.cpp
@@ -23,6 +23,9 @@ Error DebugStringTableSubsectionRef::initialize(BinaryStreamRef Contents) {
Stream = Contents;
return Error::success();
}
+Error DebugStringTableSubsectionRef::initialize(BinaryStreamReader &Reader) {
+ return Reader.readStreamRef(Stream, Reader.bytesRemaining());
+}
Expected<StringRef>
DebugStringTableSubsectionRef::getString(uint32_t Offset) const {
diff --git a/llvm/lib/DebugInfo/CodeView/DebugSubsectionVisitor.cpp b/llvm/lib/DebugInfo/CodeView/DebugSubsectionVisitor.cpp
index 93fe4e1914b..ee769d3970f 100644
--- a/llvm/lib/DebugInfo/CodeView/DebugSubsectionVisitor.cpp
+++ b/llvm/lib/DebugInfo/CodeView/DebugSubsectionVisitor.cpp
@@ -14,6 +14,7 @@
#include "llvm/DebugInfo/CodeView/DebugCrossImpSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h"
+#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
#include "llvm/DebugInfo/CodeView/DebugUnknownSubsection.h"
#include "llvm/Support/BinaryStreamReader.h"
@@ -22,8 +23,40 @@
using namespace llvm;
using namespace llvm::codeview;
+DebugSubsectionState::DebugSubsectionState() {}
+
+DebugSubsectionState::DebugSubsectionState(
+ const DebugStringTableSubsectionRef &Strings)
+ : Strings(&Strings) {}
+
+DebugSubsectionState::DebugSubsectionState(
+ const DebugStringTableSubsectionRef &Strings,
+ const DebugChecksumsSubsectionRef &Checksums)
+ : Strings(&Strings), Checksums(&Checksums) {}
+
+void DebugSubsectionState::initializeStrings(const DebugSubsectionRecord &SR) {
+ assert(SR.kind() == DebugSubsectionKind::StringTable);
+ assert(!Strings && "Found a string table even though we already have one!");
+
+ OwnedStrings = llvm::make_unique<DebugStringTableSubsectionRef>();
+ consumeError(OwnedStrings->initialize(SR.getRecordData()));
+ Strings = OwnedStrings.get();
+}
+
+void DebugSubsectionState::initializeChecksums(
+ const DebugSubsectionRecord &FCR) {
+ assert(FCR.kind() == DebugSubsectionKind::FileChecksums);
+ if (Checksums)
+ return;
+
+ OwnedChecksums = llvm::make_unique<DebugChecksumsSubsectionRef>();
+ consumeError(OwnedChecksums->initialize(FCR.getRecordData()));
+ Checksums = OwnedChecksums.get();
+}
+
Error llvm::codeview::visitDebugSubsection(const DebugSubsectionRecord &R,
- DebugSubsectionVisitor &V) {
+ DebugSubsectionVisitor &V,
+ const DebugSubsectionState &State) {
BinaryStreamReader Reader(R.getRecordData());
switch (R.kind()) {
case DebugSubsectionKind::Lines: {
@@ -31,32 +64,32 @@ Error llvm::codeview::visitDebugSubsection(const DebugSubsectionRecord &R,
if (auto EC = Fragment.initialize(Reader))
return EC;
- return V.visitLines(Fragment);
+ return V.visitLines(Fragment, State);
}
case DebugSubsectionKind::FileChecksums: {
DebugChecksumsSubsectionRef Fragment;
if (auto EC = Fragment.initialize(Reader))
return EC;
- return V.visitFileChecksums(Fragment);
+ return V.visitFileChecksums(Fragment, State);
}
case DebugSubsectionKind::InlineeLines: {
DebugInlineeLinesSubsectionRef Fragment;
if (auto EC = Fragment.initialize(Reader))
return EC;
- return V.visitInlineeLines(Fragment);
+ return V.visitInlineeLines(Fragment, State);
}
case DebugSubsectionKind::CrossScopeExports: {
DebugCrossModuleExportsSubsectionRef Section;
if (auto EC = Section.initialize(Reader))
return EC;
- return V.visitCrossModuleExports(Section);
+ return V.visitCrossModuleExports(Section, State);
}
case DebugSubsectionKind::CrossScopeImports: {
DebugCrossModuleImportsSubsectionRef Section;
if (auto EC = Section.initialize(Reader))
return EC;
- return V.visitCrossModuleImports(Section);
+ return V.visitCrossModuleImports(Section, State);
}
default: {
DebugUnknownSubsectionRef Fragment(R.kind(), R.getRecordData());
diff --git a/llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp b/llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp
index fc3d0ceaa15..baf98d1b083 100644
--- a/llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp
+++ b/llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp
@@ -533,25 +533,21 @@ llvm::CodeViewYAML::convertSubsectionList(
namespace {
struct SubsectionConversionVisitor : public DebugSubsectionVisitor {
- explicit SubsectionConversionVisitor(
- const DebugStringTableSubsectionRef &Strings,
- const DebugChecksumsSubsectionRef &Checksums)
- : Strings(Strings), Checksums(Checksums) {}
+ SubsectionConversionVisitor() {}
Error visitUnknown(DebugUnknownSubsectionRef &Unknown) override;
- 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;
+ Error visitLines(DebugLinesSubsectionRef &Lines,
+ const DebugSubsectionState &State) override;
+ Error visitFileChecksums(DebugChecksumsSubsectionRef &Checksums,
+ const DebugSubsectionState &State) override;
+ Error visitInlineeLines(DebugInlineeLinesSubsectionRef &Inlinees,
+ const DebugSubsectionState &State) override;
+ Error visitCrossModuleExports(DebugCrossModuleExportsSubsectionRef &Checksums,
+ const DebugSubsectionState &State) override;
+ Error visitCrossModuleImports(DebugCrossModuleImportsSubsectionRef &Inlinees,
+ const DebugSubsectionState &State) override;
YAMLDebugSubsection Subsection;
-
-private:
- const DebugStringTableSubsectionRef &Strings;
- const DebugChecksumsSubsectionRef &Checksums;
};
Error SubsectionConversionVisitor::visitUnknown(
@@ -559,9 +555,10 @@ Error SubsectionConversionVisitor::visitUnknown(
return make_error<CodeViewError>(cv_error_code::operation_unsupported);
}
-Error SubsectionConversionVisitor::visitLines(DebugLinesSubsectionRef &Lines) {
- auto Result =
- YAMLLinesSubsection::fromCodeViewSubsection(Strings, Checksums, Lines);
+Error SubsectionConversionVisitor::visitLines(
+ DebugLinesSubsectionRef &Lines, const DebugSubsectionState &State) {
+ auto Result = YAMLLinesSubsection::fromCodeViewSubsection(
+ State.strings(), State.checksums(), Lines);
if (!Result)
return Result.takeError();
Subsection.Subsection = *Result;
@@ -569,9 +566,9 @@ Error SubsectionConversionVisitor::visitLines(DebugLinesSubsectionRef &Lines) {
}
Error SubsectionConversionVisitor::visitFileChecksums(
- DebugChecksumsSubsectionRef &Checksums) {
- auto Result =
- YAMLChecksumsSubsection::fromCodeViewSubsection(Strings, Checksums);
+ DebugChecksumsSubsectionRef &Checksums, const DebugSubsectionState &State) {
+ auto Result = YAMLChecksumsSubsection::fromCodeViewSubsection(State.strings(),
+ Checksums);
if (!Result)
return Result.takeError();
Subsection.Subsection = *Result;
@@ -579,9 +576,10 @@ Error SubsectionConversionVisitor::visitFileChecksums(
}
Error SubsectionConversionVisitor::visitInlineeLines(
- DebugInlineeLinesSubsectionRef &Inlinees) {
+ DebugInlineeLinesSubsectionRef &Inlinees,
+ const DebugSubsectionState &State) {
auto Result = YAMLInlineeLinesSubsection::fromCodeViewSubsection(
- Strings, Checksums, Inlinees);
+ State.strings(), State.checksums(), Inlinees);
if (!Result)
return Result.takeError();
Subsection.Subsection = *Result;
@@ -589,7 +587,8 @@ Error SubsectionConversionVisitor::visitInlineeLines(
}
Error SubsectionConversionVisitor::visitCrossModuleExports(
- DebugCrossModuleExportsSubsectionRef &Exports) {
+ DebugCrossModuleExportsSubsectionRef &Exports,
+ const DebugSubsectionState &State) {
auto Result =
YAMLCrossModuleExportsSubsection::fromCodeViewSubsection(Exports);
if (!Result)
@@ -599,9 +598,10 @@ Error SubsectionConversionVisitor::visitCrossModuleExports(
}
Error SubsectionConversionVisitor::visitCrossModuleImports(
- DebugCrossModuleImportsSubsectionRef &Imports) {
+ DebugCrossModuleImportsSubsectionRef &Imports,
+ const DebugSubsectionState &State) {
auto Result = YAMLCrossModuleImportsSubsection::fromCodeViewSubsection(
- Strings, Imports);
+ State.strings(), Imports);
if (!Result)
return Result.takeError();
Subsection.Subsection = *Result;
@@ -613,8 +613,9 @@ Expected<YAMLDebugSubsection> YAMLDebugSubsection::fromCodeViewSubection(
const DebugStringTableSubsectionRef &Strings,
const DebugChecksumsSubsectionRef &Checksums,
const DebugSubsectionRecord &SS) {
- SubsectionConversionVisitor V(Strings, Checksums);
- if (auto EC = visitDebugSubsection(SS, V))
+ DebugSubsectionState State(Strings, Checksums);
+ SubsectionConversionVisitor V;
+ if (auto EC = visitDebugSubsection(SS, V, State))
return std::move(EC);
return V.Subsection;
OpenPOWER on IntegriCloud