[lld] r303352 - [COFF] Fix interaction between /DEBUG and /PDB

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Thu May 18 08:15:11 PDT 2017


Author: zturner
Date: Thu May 18 10:15:10 2017
New Revision: 303352

URL: http://llvm.org/viewvc/llvm-project?rev=303352&view=rev
Log:
[COFF] Fix interaction between /DEBUG and /PDB

When /DEBUG is not specified, /PDB should be ignored.  When
/DEBUG is specified, a PDB should be output regardless of
whether or not /PDB is specified.  /PDB just overrides the
default name.

This patch implements this behavior, and adds some tests, while
also removing a dead option /DEBUGPDB which was unused in any
code.

Differential Revision: https://reviews.llvm.org/D33302

Added:
    lld/trunk/test/COFF/pdb-options.test
Modified:
    lld/trunk/COFF/Config.h
    lld/trunk/COFF/Driver.cpp
    lld/trunk/COFF/Options.td
    lld/trunk/COFF/Writer.cpp
    lld/trunk/test/COFF/invalid-debug-type.test
    lld/trunk/test/COFF/pdb-none.test
    lld/trunk/test/COFF/pdb.test

Modified: lld/trunk/COFF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Config.h?rev=303352&r1=303351&r2=303352&view=diff
==============================================================================
--- lld/trunk/COFF/Config.h (original)
+++ lld/trunk/COFF/Config.h Thu May 18 10:15:10 2017
@@ -164,7 +164,6 @@ struct Configuration {
   bool AppContainer = false;
 
   // This is for debugging.
-  bool DebugPdb = false;
   bool DumpPdb = false;
 };
 

Modified: lld/trunk/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=303352&r1=303351&r2=303352&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.cpp (original)
+++ lld/trunk/COFF/Driver.cpp Thu May 18 10:15:10 2017
@@ -834,7 +834,6 @@ void LinkerDriver::link(ArrayRef<const c
   if (Args.hasArg(OPT_nosymtab))
     Config->WriteSymtab = false;
   Config->DumpPdb = Args.hasArg(OPT_dumppdb);
-  Config->DebugPdb = Args.hasArg(OPT_debugpdb);
 
   Config->MapFile = getMapFile(Args);
 

Modified: lld/trunk/COFF/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Options.td?rev=303352&r1=303351&r2=303352&view=diff
==============================================================================
--- lld/trunk/COFF/Options.td (original)
+++ lld/trunk/COFF/Options.td Thu May 18 10:15:10 2017
@@ -102,7 +102,6 @@ def nosymtab : F<"nosymtab">;
 def msvclto : F<"msvclto">;
 
 // Flags for debugging
-def debugpdb : F<"debugpdb">;
 def dumppdb : Joined<["/", "-"], "dumppdb">;
 def lldmap : F<"lldmap">;
 def lldmap_file : Joined<["/", "-"], "lldmap:">;

Modified: lld/trunk/COFF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Writer.cpp?rev=303352&r1=303351&r2=303352&view=diff
==============================================================================
--- lld/trunk/COFF/Writer.cpp (original)
+++ lld/trunk/COFF/Writer.cpp Thu May 18 10:15:10 2017
@@ -258,7 +258,7 @@ void Writer::run() {
   sortExceptionTable();
   writeBuildId();
 
-  if (!Config->PDBPath.empty()) {
+  if (!Config->PDBPath.empty() && Config->Debug) {
     const llvm::codeview::DebugInfo *DI = nullptr;
     if (Config->DebugTypes & static_cast<unsigned>(coff::DebugType::CV))
       DI = BuildId->DI;

Modified: lld/trunk/test/COFF/invalid-debug-type.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/invalid-debug-type.test?rev=303352&r1=303351&r2=303352&view=diff
==============================================================================
--- lld/trunk/test/COFF/invalid-debug-type.test (original)
+++ lld/trunk/test/COFF/invalid-debug-type.test Thu May 18 10:15:10 2017
@@ -1,5 +1,5 @@
 # RUN: yaml2obj < %p/Inputs/pdb1.yaml > %t1.obj
 # RUN: yaml2obj < %p/Inputs/pdb2.yaml > %t2.obj
 # RUN: lld-link /debug /debugtype:invalid /pdb:%t.pdb /dll /out:%t.dll /entry:main /nodefaultlib \
-# RUN:   /debugpdb %t1.obj %t2.obj
+# RUN:   %t1.obj %t2.obj
 

Modified: lld/trunk/test/COFF/pdb-none.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/pdb-none.test?rev=303352&r1=303351&r2=303352&view=diff
==============================================================================
--- lld/trunk/test/COFF/pdb-none.test (original)
+++ lld/trunk/test/COFF/pdb-none.test Thu May 18 10:15:10 2017
@@ -1,7 +1,7 @@
 # RUN: yaml2obj < %p/Inputs/pdb1.yaml > %t1.obj
 # RUN: yaml2obj < %p/Inputs/pdb2.yaml > %t2.obj
 # RUN: lld-link /debug /debugtype:pdata /pdb:%t.pdb /dll /out:%t.dll /entry:main /nodefaultlib \
-# RUN:   /debugpdb %t1.obj %t2.obj
+# RUN:   %t1.obj %t2.obj
 
 # RUN: llvm-pdbdump pdb2yaml -pdb-stream %t.pdb | FileCheck %s
 

Added: lld/trunk/test/COFF/pdb-options.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/pdb-options.test?rev=303352&view=auto
==============================================================================
--- lld/trunk/test/COFF/pdb-options.test (added)
+++ lld/trunk/test/COFF/pdb-options.test Thu May 18 10:15:10 2017
@@ -0,0 +1,20 @@
+# RUN: yaml2obj < %p/Inputs/pdb1.yaml > %t1.obj
+# RUN: yaml2obj < %p/Inputs/pdb2.yaml > %t2.obj
+
+; If /DEBUG is not specified, /pdb is ignored.
+# RUN: lld-link /pdb:%t.pdb /entry:main /nodefaultlib %t1.obj %t2.obj
+# RUN: not ls %t.pdb
+
+; If /DEBUG and /pdb are specified, it uses the specified name.
+# RUN: lld-link /DEBUG /pdb:%t.pdb /entry:main /nodefaultlib %t1.obj %t2.obj
+# RUN: ls %t.pdb
+# RUN: rm %t.pdb
+
+; If /DEBUG is specified but not /pdb, it uses a default name in the current
+; directory.  This is a bit hacky since but we need to be IN our test specific
+; temporary directory when we run this command or we can't test this
+# RUN: cd %T
+# RUN: lld-link /DEBUG /entry:main /nodefaultlib %t1.obj %t2.obj
+# RUN: ls %t1.pdb
+# RUN: rm %t*
+# RUN: cd %T/..

Modified: lld/trunk/test/COFF/pdb.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/pdb.test?rev=303352&r1=303351&r2=303352&view=diff
==============================================================================
--- lld/trunk/test/COFF/pdb.test (original)
+++ lld/trunk/test/COFF/pdb.test Thu May 18 10:15:10 2017
@@ -1,7 +1,7 @@
 # RUN: yaml2obj < %p/Inputs/pdb1.yaml > %t1.obj
 # RUN: yaml2obj < %p/Inputs/pdb2.yaml > %t2.obj
 # RUN: lld-link /debug /pdb:%t.pdb /dll /out:%t.dll /entry:main /nodefaultlib \
-# RUN:   /debugpdb %t1.obj %t2.obj
+# RUN:   %t1.obj %t2.obj
 
 # RUN: llvm-pdbdump pdb2yaml -stream-metadata -stream-directory -pdb-stream \
 # RUN:   -dbi-stream -ipi-stream -tpi-stream %t.pdb | FileCheck %s




More information about the llvm-commits mailing list