diff options
author | Zachary Turner <zturner@google.com> | 2017-06-08 16:00:40 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2017-06-08 16:00:40 +0000 |
commit | 15eb237fd36f7b56320bf1acacb4f8f62e6589b3 (patch) | |
tree | 79cb7504b8c1293fd788be2ce9851230e09d1210 /llvm/tools/llvm-pdbdump | |
parent | 5579eb0a7ad124f5a1b3b86a8f7ecfacd96fa3c6 (diff) | |
download | bcm5719-llvm-15eb237fd36f7b56320bf1acacb4f8f62e6589b3.tar.gz bcm5719-llvm-15eb237fd36f7b56320bf1acacb4f8f62e6589b3.zip |
[PDB] Don't crash on /debug:fastlink PDBs.
Apparently support for /debug:fastlink PDBs isn't part of the
DIA SDK (!), and it was causing llvm-pdbdump to crash because
we weren't checking for a null pointer return value. This
manifests when calling findChildren on the IDiaSymbol, and
it returns E_NOTIMPL.
llvm-svn: 304982
Diffstat (limited to 'llvm/tools/llvm-pdbdump')
-rw-r--r-- | llvm/tools/llvm-pdbdump/PrettyTypeDumper.cpp | 132 |
1 files changed, 68 insertions, 64 deletions
diff --git a/llvm/tools/llvm-pdbdump/PrettyTypeDumper.cpp b/llvm/tools/llvm-pdbdump/PrettyTypeDumper.cpp index cd156f05157..bbbb429f4f3 100644 --- a/llvm/tools/llvm-pdbdump/PrettyTypeDumper.cpp +++ b/llvm/tools/llvm-pdbdump/PrettyTypeDumper.cpp @@ -135,80 +135,84 @@ filterAndSortClassDefs(LinePrinter &Printer, Enumerator &E, TypeDumper::TypeDumper(LinePrinter &P) : PDBSymDumper(true), Printer(P) {} void TypeDumper::start(const PDBSymbolExe &Exe) { + auto Children = Exe.findAllChildren(); if (opts::pretty::Enums) { - auto Enums = Exe.findAllChildren<PDBSymbolTypeEnum>(); - Printer.NewLine(); - WithColor(Printer, PDB_ColorItem::Identifier).get() << "Enums"; - Printer << ": (" << Enums->getChildCount() << " items)"; - Printer.Indent(); - while (auto Enum = Enums->getNext()) - Enum->dump(*this); - Printer.Unindent(); + if (auto Enums = Exe.findAllChildren<PDBSymbolTypeEnum>()) { + Printer.NewLine(); + WithColor(Printer, PDB_ColorItem::Identifier).get() << "Enums"; + Printer << ": (" << Enums->getChildCount() << " items)"; + Printer.Indent(); + while (auto Enum = Enums->getNext()) + Enum->dump(*this); + Printer.Unindent(); + } } if (opts::pretty::Typedefs) { - auto Typedefs = Exe.findAllChildren<PDBSymbolTypeTypedef>(); - Printer.NewLine(); - WithColor(Printer, PDB_ColorItem::Identifier).get() << "Typedefs"; - Printer << ": (" << Typedefs->getChildCount() << " items)"; - Printer.Indent(); - while (auto Typedef = Typedefs->getNext()) - Typedef->dump(*this); - Printer.Unindent(); + if (auto Typedefs = Exe.findAllChildren<PDBSymbolTypeTypedef>()) { + Printer.NewLine(); + WithColor(Printer, PDB_ColorItem::Identifier).get() << "Typedefs"; + Printer << ": (" << Typedefs->getChildCount() << " items)"; + Printer.Indent(); + while (auto Typedef = Typedefs->getNext()) + Typedef->dump(*this); + Printer.Unindent(); + } } if (opts::pretty::Classes) { - auto Classes = Exe.findAllChildren<PDBSymbolTypeUDT>(); - uint32_t All = Classes->getChildCount(); - - Printer.NewLine(); - WithColor(Printer, PDB_ColorItem::Identifier).get() << "Classes"; - - bool Precompute = false; - Precompute = - (opts::pretty::ClassOrder != opts::pretty::ClassSortMode::None); - - // If we're using no sort mode, then we can start getting immediate output - // from the tool by just filtering as we go, rather than processing - // everything up front so that we can sort it. This makes the tool more - // responsive. So only precompute the filtered/sorted set of classes if - // necessary due to the specified options. - std::vector<LayoutPtr> Filtered; - uint32_t Shown = All; - if (Precompute) { - Filtered = filterAndSortClassDefs(Printer, *Classes, All); - - Shown = Filtered.size(); - } + if (auto Classes = Exe.findAllChildren<PDBSymbolTypeUDT>()) { + uint32_t All = Classes->getChildCount(); + + Printer.NewLine(); + WithColor(Printer, PDB_ColorItem::Identifier).get() << "Classes"; + + bool Precompute = false; + Precompute = + (opts::pretty::ClassOrder != opts::pretty::ClassSortMode::None); + + // If we're using no sort mode, then we can start getting immediate output + // from the tool by just filtering as we go, rather than processing + // everything up front so that we can sort it. This makes the tool more + // responsive. So only precompute the filtered/sorted set of classes if + // necessary due to the specified options. + std::vector<LayoutPtr> Filtered; + uint32_t Shown = All; + if (Precompute) { + Filtered = filterAndSortClassDefs(Printer, *Classes, All); + + Shown = Filtered.size(); + } - Printer << ": (Showing " << Shown << " items"; - if (Shown < All) - Printer << ", " << (All - Shown) << " filtered"; - Printer << ")"; - Printer.Indent(); - - // If we pre-computed, iterate the filtered/sorted list, otherwise iterate - // the DIA enumerator and filter on the fly. - if (Precompute) { - for (auto &Class : Filtered) - dumpClassLayout(*Class); - } else { - while (auto Class = Classes->getNext()) { - if (Class->getUnmodifiedTypeId() != 0) - continue; - - if (Printer.IsTypeExcluded(Class->getName(), Class->getLength())) - continue; - - auto Layout = llvm::make_unique<ClassLayout>(std::move(Class)); - if (Layout->deepPaddingSize() < opts::pretty::PaddingThreshold) - continue; - - dumpClassLayout(*Layout); + Printer << ": (Showing " << Shown << " items"; + if (Shown < All) + Printer << ", " << (All - Shown) << " filtered"; + Printer << ")"; + Printer.Indent(); + + // If we pre-computed, iterate the filtered/sorted list, otherwise iterate + // the DIA enumerator and filter on the fly. + if (Precompute) { + for (auto &Class : Filtered) + dumpClassLayout(*Class); + } else { + while (auto Class = Classes->getNext()) { + if (Class->getUnmodifiedTypeId() != 0) + continue; + + if (Printer.IsTypeExcluded(Class->getName(), Class->getLength())) + continue; + + auto Layout = llvm::make_unique<ClassLayout>(std::move(Class)); + if (Layout->deepPaddingSize() < opts::pretty::PaddingThreshold) + continue; + + dumpClassLayout(*Layout); + } } - } - Printer.Unindent(); + Printer.Unindent(); + } } } |