diff options
author | Zachary Turner <zturner@google.com> | 2017-06-14 15:59:27 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2017-06-14 15:59:27 +0000 |
commit | 63d2fab3cfd80f03b1530c0464a7d45249f8ce99 (patch) | |
tree | 985ea7dcb499a8b1fa7afd266f2e2733d10e662d /tools/llvm-pdbutil | |
parent | b9bba8a9e8b2aa6f0a7e482fc871942438c48fcd (diff) |
Resubmit "[codeview] Make obj2yaml/yaml2obj support .debug$S..."
This was originally reverted because of some non-deterministic
failures on certain buildbots. Luckily ASAN eventually caught
this as a stack-use-after-scope, so the fix is included in
this patch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305393 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-pdbutil')
-rw-r--r-- | tools/llvm-pdbutil/LLVMOutputStyle.cpp | 27 | ||||
-rw-r--r-- | tools/llvm-pdbutil/YAMLOutputStyle.cpp | 7 | ||||
-rw-r--r-- | tools/llvm-pdbutil/llvm-pdbutil.cpp | 17 |
3 files changed, 31 insertions, 20 deletions
diff --git a/tools/llvm-pdbutil/LLVMOutputStyle.cpp b/tools/llvm-pdbutil/LLVMOutputStyle.cpp index 980e3d3d41b..c4af4583a10 100644 --- a/tools/llvm-pdbutil/LLVMOutputStyle.cpp +++ b/tools/llvm-pdbutil/LLVMOutputStyle.cpp @@ -28,6 +28,7 @@ #include "llvm/DebugInfo/CodeView/EnumTables.h" #include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h" #include "llvm/DebugInfo/CodeView/Line.h" +#include "llvm/DebugInfo/CodeView/StringsAndChecksums.h" #include "llvm/DebugInfo/CodeView/SymbolDumper.h" #include "llvm/DebugInfo/CodeView/TypeDatabaseVisitor.h" #include "llvm/DebugInfo/CodeView/TypeDumpVisitor.h" @@ -105,7 +106,7 @@ public: } Error visitLines(DebugLinesSubsectionRef &Lines, - const DebugSubsectionState &State) override { + const StringsAndChecksumsRef &State) override { if (!opts::checkModuleSubsection(opts::ModuleSubsection::Lines)) return Error::success(); @@ -146,7 +147,7 @@ public: } Error visitFileChecksums(DebugChecksumsSubsectionRef &Checksums, - const DebugSubsectionState &State) override { + const StringsAndChecksumsRef &State) override { if (!opts::checkModuleSubsection(opts::ModuleSubsection::FileChecksums)) return Error::success(); @@ -164,7 +165,7 @@ public: } Error visitInlineeLines(DebugInlineeLinesSubsectionRef &Inlinees, - const DebugSubsectionState &State) override { + const StringsAndChecksumsRef &State) override { if (!opts::checkModuleSubsection(opts::ModuleSubsection::InlineeLines)) return Error::success(); @@ -191,7 +192,7 @@ public: } Error visitCrossModuleExports(DebugCrossModuleExportsSubsectionRef &CSE, - const DebugSubsectionState &State) override { + const StringsAndChecksumsRef &State) override { if (!opts::checkModuleSubsection(opts::ModuleSubsection::CrossScopeExports)) return Error::success(); @@ -205,7 +206,7 @@ public: } Error visitCrossModuleImports(DebugCrossModuleImportsSubsectionRef &CSI, - const DebugSubsectionState &State) override { + const StringsAndChecksumsRef &State) override { if (!opts::checkModuleSubsection(opts::ModuleSubsection::CrossScopeImports)) return Error::success(); @@ -222,7 +223,7 @@ public: } Error visitFrameData(DebugFrameDataSubsectionRef &FD, - const DebugSubsectionState &State) override { + const StringsAndChecksumsRef &State) override { if (!opts::checkModuleSubsection(opts::ModuleSubsection::FrameData)) return Error::success(); @@ -248,7 +249,7 @@ public: } Error visitSymbols(DebugSymbolsSubsectionRef &Symbols, - const DebugSubsectionState &State) override { + const StringsAndChecksumsRef &State) override { if (!opts::checkModuleSubsection(opts::ModuleSubsection::Symbols)) return Error::success(); ListScope L(P, "Symbols"); @@ -270,7 +271,7 @@ public: } Error visitStringTable(DebugStringTableSubsectionRef &Strings, - const DebugSubsectionState &State) override { + const StringsAndChecksumsRef &State) override { if (!opts::checkModuleSubsection(opts::ModuleSubsection::StringTable)) return Error::success(); @@ -288,7 +289,7 @@ public: } Error visitCOFFSymbolRVAs(DebugSymbolRVASubsectionRef &RVAs, - const DebugSubsectionState &State) override { + const StringsAndChecksumsRef &State) override { if (!opts::checkModuleSubsection(opts::ModuleSubsection::CoffSymbolRVAs)) return Error::success(); @@ -309,7 +310,7 @@ private: return EC; } } - + if (!Success) { P.printString( llvm::formatv("Index: {0:x} (unknown function)", Index.getIndex()) @@ -318,7 +319,7 @@ private: return Error::success(); } Error printFileName(StringRef Label, uint32_t Offset, - const DebugSubsectionState &State) { + const StringsAndChecksumsRef &State) { if (auto Result = getNameFromChecksumsBuffer(Offset, State)) { P.printString(Label, *Result); return Error::success(); @@ -327,13 +328,13 @@ private: } Expected<StringRef> - getNameFromStringTable(uint32_t Offset, const DebugSubsectionState &State) { + getNameFromStringTable(uint32_t Offset, const StringsAndChecksumsRef &State) { return State.strings().getString(Offset); } Expected<StringRef> getNameFromChecksumsBuffer(uint32_t Offset, - const DebugSubsectionState &State) { + const StringsAndChecksumsRef &State) { auto Array = State.checksums().getArray(); auto ChecksumIter = Array.at(Offset); if (ChecksumIter == Array.end()) diff --git a/tools/llvm-pdbutil/YAMLOutputStyle.cpp b/tools/llvm-pdbutil/YAMLOutputStyle.cpp index 4ab7cd39b29..8f7aba6d30c 100644 --- a/tools/llvm-pdbutil/YAMLOutputStyle.cpp +++ b/tools/llvm-pdbutil/YAMLOutputStyle.cpp @@ -18,6 +18,7 @@ #include "llvm/DebugInfo/CodeView/DebugSubsection.h" #include "llvm/DebugInfo/CodeView/DebugUnknownSubsection.h" #include "llvm/DebugInfo/CodeView/Line.h" +#include "llvm/DebugInfo/CodeView/StringsAndChecksums.h" #include "llvm/DebugInfo/MSF/MappedBlockStream.h" #include "llvm/DebugInfo/PDB/Native/DbiStream.h" #include "llvm/DebugInfo/PDB/Native/InfoStream.h" @@ -236,14 +237,16 @@ Error YAMLOutputStyle::dumpDbiStream() { if (!ExpectedChecksums) return ExpectedChecksums.takeError(); + StringsAndChecksumsRef SC(ExpectedST->getStringTable(), + *ExpectedChecksums); + for (const auto &SS : ModS.subsections()) { opts::ModuleSubsection OptionKind = convertSubsectionKind(SS.kind()); if (!opts::checkModuleSubsection(OptionKind)) continue; auto Converted = - CodeViewYAML::YAMLDebugSubsection::fromCodeViewSubection( - ExpectedST->getStringTable(), *ExpectedChecksums, SS); + CodeViewYAML::YAMLDebugSubsection::fromCodeViewSubection(SC, SS); if (!Converted) return Converted.takeError(); DMI.Subsections.push_back(*Converted); diff --git a/tools/llvm-pdbutil/llvm-pdbutil.cpp b/tools/llvm-pdbutil/llvm-pdbutil.cpp index dc46da4a90f..3826ba79a20 100644 --- a/tools/llvm-pdbutil/llvm-pdbutil.cpp +++ b/tools/llvm-pdbutil/llvm-pdbutil.cpp @@ -35,6 +35,7 @@ #include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h" #include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h" #include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h" +#include "llvm/DebugInfo/CodeView/StringsAndChecksums.h" #include "llvm/DebugInfo/CodeView/TypeStreamMerger.h" #include "llvm/DebugInfo/CodeView/TypeTableBuilder.h" #include "llvm/DebugInfo/MSF/MSFBuilder.h" @@ -511,10 +512,12 @@ static void yamlToPdb(StringRef Path) { for (uint32_t I = 0; I < kSpecialStreamCount; ++I) ExitOnErr(Builder.getMsfBuilder().addStream(0)); + StringsAndChecksums Strings; + Strings.setStrings(std::make_shared<DebugStringTableSubsection>()); + if (YamlObj.StringTable.hasValue()) { - auto &Strings = Builder.getStringTableBuilder(); for (auto S : *YamlObj.StringTable) - Strings.insert(S); + Strings.strings()->insert(S); } pdb::yaml::PdbInfoStream DefaultInfoStream; @@ -532,8 +535,6 @@ static void yamlToPdb(StringRef Path) { for (auto F : Info.Features) InfoBuilder.addFeature(F); - auto &Strings = Builder.getStringTableBuilder().getStrings(); - const auto &Dbi = YamlObj.DbiStream.getValueOr(DefaultDbiStream); auto &DbiBuilder = Builder.getDbiBuilder(); DbiBuilder.setAge(Dbi.Age); @@ -557,10 +558,14 @@ static void yamlToPdb(StringRef Path) { } } + // Each module has its own checksum subsection, so scan for it every time. + Strings.setChecksums(nullptr); + CodeViewYAML::initializeStringsAndChecksums(MI.Subsections, Strings); + auto CodeViewSubsections = ExitOnErr(CodeViewYAML::toCodeViewSubsectionList( Allocator, MI.Subsections, Strings)); for (auto &SS : CodeViewSubsections) { - ModiBuilder.addDebugSubsection(std::move(SS)); + ModiBuilder.addDebugSubsection(SS); } } @@ -580,6 +585,8 @@ static void yamlToPdb(StringRef Path) { IpiBuilder.addTypeRecord(Type.RecordData, None); } + Builder.getStringTableBuilder().setStrings(*Strings.strings()); + ExitOnErr(Builder.commit(opts::yaml2pdb::YamlPdbOutputFile)); } |