From: Rui Ueyama Date: Wed, 3 Aug 2016 23:43:23 +0000 (+0000) Subject: pdbdump: Fix crash bug. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d1d8c8312a41f10f294978decc57c3f5dcfef205;p=platform%2Fupstream%2Fllvm.git pdbdump: Fix crash bug. pdbdump calls DbiStreamBuilder::commit through PDBFileBuilder::commit without calling DbiStreamBuilder::finalize. Because `finalize` initializes `Header` member, `Header` remained nullptr which caused a crash bug. Differential Revision: https://reviews.llvm.org/D23143 llvm-svn: 277681 --- diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/DbiStreamBuilder.h b/llvm/include/llvm/DebugInfo/PDB/Raw/DbiStreamBuilder.h index 9b93efe..d0f8754 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Raw/DbiStreamBuilder.h +++ b/llvm/include/llvm/DebugInfo/PDB/Raw/DbiStreamBuilder.h @@ -49,7 +49,7 @@ public: Expected> build(PDBFile &File, const msf::WritableStream &Buffer); Error commit(const msf::MSFLayout &Layout, - const msf::WritableStream &Buffer) const; + const msf::WritableStream &Buffer); private: Error finalize(); diff --git a/llvm/lib/DebugInfo/PDB/Raw/DbiStreamBuilder.cpp b/llvm/lib/DebugInfo/PDB/Raw/DbiStreamBuilder.cpp index 711295d..b0bb4a0 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/DbiStreamBuilder.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/DbiStreamBuilder.cpp @@ -249,7 +249,10 @@ DbiStreamBuilder::build(PDBFile &File, const msf::WritableStream &Buffer) { } Error DbiStreamBuilder::commit(const msf::MSFLayout &Layout, - const msf::WritableStream &Buffer) const { + const msf::WritableStream &Buffer) { + if (auto EC = finalize()) + return EC; + auto InfoS = WritableMappedBlockStream::createIndexedStream(Layout, Buffer, StreamDBI); diff --git a/llvm/test/DebugInfo/PDB/pdbdump-readwrite.test b/llvm/test/DebugInfo/PDB/pdbdump-readwrite.test new file mode 100644 index 0000000..e533ab7 --- /dev/null +++ b/llvm/test/DebugInfo/PDB/pdbdump-readwrite.test @@ -0,0 +1,4 @@ +; RUN: llvm-pdbdump pdb2yaml -dbi-module-info -dbi-module-source-info \ +; RUN: -dbi-stream -pdb-stream -stream-directory -stream-metadata \ +; RUN: %p/Inputs/empty.pdb > %t.1 +; RUN: llvm-pdbdump yaml2pdb -pdb=%t.2 %t.1