Index: test/tools/llvm-pdbdump/checksum-string.test =================================================================== --- test/tools/llvm-pdbdump/checksum-string.test +++ test/tools/llvm-pdbdump/checksum-string.test @@ -1,3 +1,4 @@ +; REQUIRES: diasdk ; RUN: llvm-pdbutil pretty -lines %p/Inputs/PrettyFuncDumperTest.pdb > %t ; CHECK: ---COMPILANDS--- Index: test/tools/llvm-pdbdump/class-layout.test =================================================================== --- test/tools/llvm-pdbdump/class-layout.test +++ test/tools/llvm-pdbdump/class-layout.test @@ -1,3 +1,5 @@ +; REQUIRES: diasdk + ; RUN: llvm-pdbutil pretty -all -class-recurse-depth=1 \ ; RUN: %p/Inputs/ClassLayoutTest.pdb > %t ; RUN: FileCheck -input-file=%t %s -check-prefix=GLOBALS_TEST Index: test/tools/llvm-pdbdump/complex-padding-graphical.test =================================================================== --- test/tools/llvm-pdbdump/complex-padding-graphical.test +++ test/tools/llvm-pdbdump/complex-padding-graphical.test @@ -1,3 +1,5 @@ +; REQUIRES: diasdk + ; RUN: llvm-pdbutil pretty -classes -class-definitions=layout \ ; RUN: -include-types=Test %p/Inputs/ComplexPaddingTest.pdb > %t Index: test/tools/llvm-pdbdump/enum-layout.test =================================================================== --- test/tools/llvm-pdbdump/enum-layout.test +++ test/tools/llvm-pdbdump/enum-layout.test @@ -1,3 +1,5 @@ +; REQUIRES: diasdk + ; RUN: llvm-pdbutil pretty -types %p/Inputs/ClassLayoutTest.pdb > %t ; RUN: FileCheck -input-file=%t %s -check-prefix=GLOBAL_ENUM ; RUN: FileCheck -input-file=%t %s -check-prefix=MEMBER_ENUM Index: test/tools/llvm-pdbdump/explain-dbi-stream.test =================================================================== --- test/tools/llvm-pdbdump/explain-dbi-stream.test +++ test/tools/llvm-pdbdump/explain-dbi-stream.test @@ -1,3 +1,5 @@ +; REQUIRES: diasdk + ; RUN: llvm-pdbutil explain \ ; RUN: -offset=0xF000 \ ; RUN: -offset=0xF004 \ Index: test/tools/llvm-pdbdump/explain-pdb-stream.test =================================================================== --- test/tools/llvm-pdbdump/explain-pdb-stream.test +++ test/tools/llvm-pdbdump/explain-pdb-stream.test @@ -1,3 +1,5 @@ +; REQUIRES: diasdk + ; RUN: llvm-pdbutil explain \ ; RUN: -offset=0x11000 \ ; RUN: -offset=0x11004 \ Index: test/tools/llvm-pdbdump/explain.test =================================================================== --- test/tools/llvm-pdbdump/explain.test +++ test/tools/llvm-pdbdump/explain.test @@ -1,3 +1,5 @@ +; REQUIRES: diasdk + ; RUN: llvm-pdbutil explain -offset=0 %p/Inputs/InjectedSource.pdb \ ; RUN: | FileCheck --check-prefix=ZERO %s ; RUN: llvm-pdbutil explain -offset=40 %p/Inputs/InjectedSource.pdb \ Index: test/tools/llvm-pdbdump/injected-sources.test =================================================================== --- test/tools/llvm-pdbdump/injected-sources.test +++ test/tools/llvm-pdbdump/injected-sources.test @@ -1,6 +1,8 @@ ; The PDB committed to the repo does not seem to be recognized by older ; versions of DIA SDK, so we xfail the test temporarily until we can ; figure out how to get a PDB that makes all versions of MSVC happy. +; REQUIRES: diasdk + ; RUN: llvm-pdbutil pretty -injected-sources -injected-source-content \ ; RUN: %p/Inputs/InjectedSource.pdb | FileCheck %s ; RUN: llvm-pdbutil pretty -injected-sources -injected-source-content \ Index: test/tools/llvm-pdbdump/lit.local.cfg =================================================================== --- test/tools/llvm-pdbdump/lit.local.cfg +++ test/tools/llvm-pdbdump/lit.local.cfg @@ -1 +1,2 @@ -config.unsupported = not config.have_dia_sdk +if config.have_dia_sdk: + config.available_features.add("diasdk") Index: test/tools/llvm-pdbdump/load-address.test =================================================================== --- test/tools/llvm-pdbdump/load-address.test +++ test/tools/llvm-pdbdump/load-address.test @@ -1,3 +1,5 @@ +; REQUIRES: diasdk + ; RUN: llvm-pdbutil pretty -externals %p/Inputs/LoadAddressTest.pdb \ ; RUN: | FileCheck --check-prefix=RVA %s ; RUN: llvm-pdbutil pretty -externals -load-address=0x40000000 \ Index: test/tools/llvm-pdbdump/pretty-func-dumper.test =================================================================== --- test/tools/llvm-pdbdump/pretty-func-dumper.test +++ test/tools/llvm-pdbdump/pretty-func-dumper.test @@ -1,3 +1,5 @@ +; REQUIRES: diasdk + ; RUN: llvm-pdbutil pretty -all -class-recurse-depth=1 \ ; RUN: %p/Inputs/PrettyFuncDumperTest.pdb > %t ; RUN: FileCheck -input-file=%t %s -check-prefix=GLOBALS_FUNC Index: test/tools/llvm-pdbdump/regex-filter.test =================================================================== --- test/tools/llvm-pdbdump/regex-filter.test +++ test/tools/llvm-pdbdump/regex-filter.test @@ -1,3 +1,5 @@ +; REQUIRES: diasdk + ; RUN: llvm-pdbutil pretty -module-syms -globals -types %p/Inputs/FilterTest.pdb \ ; RUN: | FileCheck --check-prefix=NO_FILTER %s Index: test/tools/llvm-pdbdump/simple-padding-graphical.test =================================================================== --- test/tools/llvm-pdbdump/simple-padding-graphical.test +++ test/tools/llvm-pdbdump/simple-padding-graphical.test @@ -1,3 +1,5 @@ +; REQUIRES: diasdk + ; RUN: llvm-pdbutil pretty -classes -class-definitions=layout \ ; RUN: -include-types=SimplePad %p/Inputs/SimplePaddingTest.pdb > %t Index: test/tools/llvm-pdbdump/stripped.test =================================================================== --- test/tools/llvm-pdbdump/stripped.test +++ test/tools/llvm-pdbdump/stripped.test @@ -0,0 +1,70 @@ +; RUN: llvm-pdbutil dump -all %p/Inputs/Stripped.pdb > %t +; RUN: FileCheck -input-file=%t %s + +; CHECK: Summary +; CHECK-NEXT: ============================================================ + +; CHECK: Streams +; CHECK-NEXT: ============================================================ + +; CHECK: Module Stats +; CHECK-NEXT: ============================================================ + +; CHECK: S_UDT Record Stats +; CHECK-NEXT: ============================================================ + +; CHECK: String Table +; CHECK-NEXT: ============================================================ + +; CHECK: Modules +; CHECK-NEXT: ============================================================ + +; CHECK: Files +; CHECK-NEXT: ============================================================ + +; CHECK: Lines +; CHECK-NEXT: ============================================================ + +; CHECK: Inlinee Lines +; CHECK-NEXT: ============================================================ + +; CHECK: Cross Module Imports +; CHECK-NEXT: ============================================================ + +; CHECK: Cross Module Exports +; CHECK-NEXT: ============================================================ + +; CHECK: Old FPO Data +; CHECK-NEXT: ============================================================ + +; CHECK: New FPO Data +; CHECK-NEXT: ============================================================ + +; CHECK: Types (TPI Stream) +; CHECK-NEXT: ============================================================ + +; CHECK: Types (IPI Stream) +; CHECK-NEXT: ============================================================ + +; CHECK: Global Symbols +; CHECK-NEXT: ============================================================ + +; CHECK: Public Symbols +; CHECK-NEXT: ============================================================ + +; CHECK: Symbols +; CHECK-NEXT: ============================================================ + +; CHECK: Section Headers +; CHECK-NEXT: ============================================================ + +; CHECK: Original Section Headers +; CHECK-NEXT: ============================================================ + +; CHECK: Section Contributions +; CHECK-NEXT: ============================================================ + +; CHECK: Section Map +; CHECK-NEXT: ============================================================ + + Index: test/tools/llvm-pdbdump/symbol-filters.test =================================================================== --- test/tools/llvm-pdbdump/symbol-filters.test +++ test/tools/llvm-pdbdump/symbol-filters.test @@ -1,3 +1,5 @@ +; REQUIRES: diasdk + ; RUN: llvm-pdbutil pretty -globals -module-syms -sym-types=data %p/Inputs/FilterTest.pdb \ ; RUN: | FileCheck --check-prefix=ONLY_DATA %s Index: test/tools/llvm-pdbdump/type-qualifiers.test =================================================================== --- test/tools/llvm-pdbdump/type-qualifiers.test +++ test/tools/llvm-pdbdump/type-qualifiers.test @@ -1,3 +1,5 @@ +; REQUIRES: diasdk + ; RUN: llvm-pdbutil pretty -all -class-recurse-depth=1 \ ; RUN: %p/Inputs/TypeQualifiersTest.pdb > %t ; RUN: FileCheck -input-file=%t %s -check-prefix=GLOBALS_FUNC Index: test/tools/llvm-pdbdump/usingnamespace.test =================================================================== --- test/tools/llvm-pdbdump/usingnamespace.test +++ test/tools/llvm-pdbdump/usingnamespace.test @@ -1,3 +1,5 @@ +; REQUIRES: diasdk + ; RUN: llvm-pdbutil pretty -module-syms %p/Inputs/UsingNamespaceTest.pdb > %t ; RUN: FileCheck -input-file=%t %s Index: tools/llvm-pdbutil/DumpOutputStyle.cpp =================================================================== --- tools/llvm-pdbutil/DumpOutputStyle.cpp +++ tools/llvm-pdbutil/DumpOutputStyle.cpp @@ -250,7 +250,7 @@ static StatCollection getSymbolStats(const SymbolGroup &SG, StatCollection &CumulativeStats) { StatCollection Stats; - if (SG.getFile().isPdb()) { + if (SG.getFile().isPdb() && SG.hasDebugStream()) { // For PDB files, all symbols are packed into one stream. for (const auto &S : SG.getPdbModuleStream().symbols(nullptr)) { Stats.update(S.kind(), S.length()); @@ -1420,19 +1420,21 @@ P.formatLine("TI: {0}, Offset: {1}", IO.Type, fmtle(IO.Offset)); } - P.NewLine(); - P.formatLine("Hash Adjusters:"); - auto &Adjusters = Stream.getHashAdjusters(); - auto &Strings = Err(getPdb().getStringTable()); - for (const auto &A : Adjusters) { - AutoIndent Indent2(P); - auto ExpectedStr = Strings.getStringForID(A.first); - TypeIndex TI(A.second); - if (ExpectedStr) - P.formatLine("`{0}` -> {1}", *ExpectedStr, TI); - else { - P.formatLine("unknown str id ({0}) -> {1}", A.first, TI); - consumeError(ExpectedStr.takeError()); + if (getPdb().hasPDBStringTable()) { + P.NewLine(); + P.formatLine("Hash Adjusters:"); + auto &Adjusters = Stream.getHashAdjusters(); + auto &Strings = Err(getPdb().getStringTable()); + for (const auto &A : Adjusters) { + AutoIndent Indent2(P); + auto ExpectedStr = Strings.getStringForID(A.first); + TypeIndex TI(A.second); + if (ExpectedStr) + P.formatLine("`{0}` -> {1}", *ExpectedStr, TI); + else { + P.formatLine("unknown str id ({0}) -> {1}", A.first, TI); + consumeError(ExpectedStr.takeError()); + } } } } Index: tools/llvm-pdbutil/InputFile.h =================================================================== --- tools/llvm-pdbutil/InputFile.h +++ tools/llvm-pdbutil/InputFile.h @@ -110,6 +110,8 @@ const InputFile &getFile() const { return *File; } InputFile &getFile() { return *File; } + bool hasDebugStream() const { return DebugStream != nullptr; } + private: void initializeForPdb(uint32_t Modi); void updatePdbModi(uint32_t Modi); Index: tools/llvm-pdbutil/InputFile.cpp =================================================================== --- tools/llvm-pdbutil/InputFile.cpp +++ tools/llvm-pdbutil/InputFile.cpp @@ -116,10 +116,6 @@ return formatUnknownEnum(Kind); } -static const DebugStringTableSubsectionRef &extractStringTable(PDBFile &File) { - return cantFail(File.getStringTable()).getStringTable(); -} - template static void formatInternal(LinePrinter &Printer, bool Append, Args &&... args) { if (Append) @@ -168,8 +164,13 @@ // PDB always uses the same string table, but each module has its own // checksums. So we only set the strings if they're not already set. - if (!SC.hasStrings()) - SC.setStrings(extractStringTable(File->pdb())); + if (!SC.hasStrings()) { + auto StringTable = File->pdb().getStringTable(); + if (StringTable) + SC.setStrings(StringTable->getStringTable()); + else + consumeError(StringTable.takeError()); + } SC.resetChecksums(); auto MDS = getModuleDebugStream(File->pdb(), Name, Modi); @@ -179,6 +180,7 @@ } DebugStream = std::make_shared(std::move(*MDS)); + assert(DebugStream); Subsections = DebugStream->getSubsectionsArray(); SC.initialize(Subsections); rebuildChecksumMap();