From ea91fafd33b59fa6e50e084b8ef247194cc945ea Mon Sep 17 00:00:00 2001 From: Bob Haarman Date: Thu, 25 May 2017 18:04:17 +0000 Subject: [PATCH] [llvm-pdbdump] [yaml2pdb] always include object file name in module info Summary: Previously, the yaml2pdb subcommand of llvm-pdbdump only included object file names in module info if a module info stream was present. This change makes it so that we include the object file name even if there is no module info stream for the module. As a result, running llvm-pdbdump pdb2yaml -dbi-module-info original.pdb > original.yaml && llvm-pdbdump yaml2pdb -pdb=new.pdb original.yaml && llvm-pdbdump pdb2yaml -dbi-module-info new.pdb > new.yaml now produces identical original.yaml and new.yaml files. Reviewers: amccarth, zturner Reviewed By: zturner Subscribers: fhahn, llvm-commits Differential Revision: https://reviews.llvm.org/D33463 llvm-svn: 303891 --- llvm/test/DebugInfo/PDB/pdbdump-objfilename.yaml | 14 ++++++++++++++ llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 llvm/test/DebugInfo/PDB/pdbdump-objfilename.yaml diff --git a/llvm/test/DebugInfo/PDB/pdbdump-objfilename.yaml b/llvm/test/DebugInfo/PDB/pdbdump-objfilename.yaml new file mode 100644 index 000000000000..fac9ce9083c7 --- /dev/null +++ b/llvm/test/DebugInfo/PDB/pdbdump-objfilename.yaml @@ -0,0 +1,14 @@ +# RUN: llvm-pdbdump yaml2pdb -pdb=%T/objfilename.pdb %s +# RUN: llvm-pdbdump pdb2yaml -dbi-module-info %T/objfilename.pdb \ +# RUN: | FileCheck %s +# +# CHECK: DbiStream: +# CHECK: Modules: +# CHECK-NEXT: - Module:{{ *}}'C:\src\test.obj' +# CHECK-NEXT: ObjFile:{{ *}}'C:\src\test.obj' +--- +DbiStream: + Modules: + - Module: 'C:\src\test.obj' + ObjFile: 'C:\src\test.obj' +... diff --git a/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp b/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp index dd54eabd2c33..b095cab246f8 100644 --- a/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp +++ b/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp @@ -525,12 +525,12 @@ static void yamlToPdb(StringRef Path) { DbiBuilder.setVersionHeader(Dbi.VerHeader); for (const auto &MI : Dbi.ModInfos) { auto &ModiBuilder = ExitOnErr(DbiBuilder.addModuleInfo(MI.Mod)); + ModiBuilder.setObjFileName(MI.Obj); for (auto S : MI.SourceFiles) ExitOnErr(DbiBuilder.addModuleSourceFile(MI.Mod, S)); if (MI.Modi.hasValue()) { const auto &ModiStream = *MI.Modi; - ModiBuilder.setObjFileName(MI.Obj); for (auto Symbol : ModiStream.Symbols) ModiBuilder.addSymbol(Symbol.Record); }