From abb17cc084d917a54b3e5021bbb3ecdfc1a49d23 Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Fri, 1 Sep 2017 20:06:56 +0000 Subject: [llvm-pdbutil] Support dumping CodeView from object files. We have llvm-readobj for dumping CodeView from object files, and llvm-pdbutil has always been more focused on PDB. However, llvm-pdbutil has a lot of useful options for summarizing debug information in aggregate and presenting high level statistical views. Furthermore, it's arguably better as a testing tool since we don't have to write tests to conform to a state-machine like structure where you match multiple lines in succession, each depending on a previous match. llvm-pdbutil dumps much more concisely, so it's possible to use single-line matches in many cases where as with readobj tests you have to use multi-line matches with an implicit state machine. Because of this, I'm adding object file support to llvm-pdbutil. In fact, this mirrors the cvdump tool from Microsoft, which also supports both object files and pdb files. In the future we could perhaps rename this tool llvm-cvutil. In the meantime, this allows us to deep dive into object files the same way we already can with PDB files. llvm-svn: 312358 --- llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp') diff --git a/llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp b/llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp index 414de7be91f..15b31d821b1 100644 --- a/llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp @@ -312,6 +312,9 @@ Expected PDBFile::getPDBTpiStream() { Expected PDBFile::getPDBIpiStream() { if (!Ipi) { + if (!hasPDBIpiStream()) + return make_error(raw_error_code::no_stream); + auto IpiS = safelyCreateIndexedStream(ContainerLayout, *Buffer, StreamIPI); if (!IpiS) return IpiS.takeError(); @@ -407,9 +410,18 @@ bool PDBFile::hasPDBGlobalsStream() { return DbiS->getGlobalSymbolStreamIndex() < getNumStreams(); } -bool PDBFile::hasPDBInfoStream() { return StreamPDB < getNumStreams(); } +bool PDBFile::hasPDBInfoStream() const { return StreamPDB < getNumStreams(); } + +bool PDBFile::hasPDBIpiStream() const { + if (!hasPDBInfoStream()) + return false; + + if (StreamIPI >= getNumStreams()) + return false; -bool PDBFile::hasPDBIpiStream() const { return StreamIPI < getNumStreams(); } + auto &InfoStream = cantFail(const_cast(this)->getPDBInfoStream()); + return InfoStream.containsIdStream(); +} bool PDBFile::hasPDBPublicsStream() { auto DbiS = getPDBDbiStream(); -- cgit v1.2.3