<br><br>On Monday, August 8, 2016, Saleem Abdulrasool via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: compnerd<br>
Date: Mon Aug  8 17:02:44 2016<br>
New Revision: 278056<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=278056&view=rev" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=278056&view=rev</a><br>
Log:<br>
COFF: handle /debugtype option<br>
<br>
Add the support infrastructure for the /debugtype option which takes a comma<br>
delimited list of debug info to generate. The defaults are based on other<br>
options potentially (/driver or /profile). This sets up the infrastructure to<br>
allow us to emit RSDS records to get "build id" equivalents on COFF (similar to<br>
binutils).<br>
<br>
Modified:<br>
    lld/trunk/COFF/Config.h<br>
    lld/trunk/COFF/Driver.cpp<br>
    lld/trunk/COFF/Options.td<br>
<br>
Modified: lld/trunk/COFF/Config.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Config.h?rev=278056&r1=278055&r2=278056&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/COFF/Config.<wbr>h?rev=278056&r1=278055&r2=<wbr>278056&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/COFF/Config.h (original)<br>
+++ lld/trunk/COFF/Config.h Mon Aug  8 17:02:44 2016<br>
@@ -61,6 +61,13 @@ struct Export {<br>
   }<br>
 };<br>
<br>
+enum class DebugType {<br>
+  None  = 0x0,<br>
+  CV    = 0x1,  /// CodeView<br>
+  PData = 0x2,  /// Procedure Data<br>
+  Fixup = 0x4,  /// Relocation Table<br>
+};<br>
+<br>
 // Global configuration.<br>
 struct Configuration {<br>
   enum ManifestKind { SideBySide, Embed, No };<br>
@@ -78,6 +85,7 @@ struct Configuration {<br>
   bool Force = false;<br>
   bool Debug = false;<br>
   bool WriteSymtab = true;<br>
+  unsigned DebugTypes = static_cast<unsigned>(<wbr>DebugType::None);<br>
<br>
   // Symbols in this set are considered as live by the garbage collector.<br>
   std::set<Undefined *> GCRoot;<br>
<br>
Modified: lld/trunk/COFF/Driver.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=278056&r1=278055&r2=278056&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/COFF/Driver.<wbr>cpp?rev=278056&r1=278055&r2=<wbr>278056&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/COFF/Driver.cpp (original)<br>
+++ lld/trunk/COFF/Driver.cpp Mon Aug  8 17:02:44 2016<br>
@@ -16,6 +16,7 @@<br>
 #include "Writer.h"<br>
 #include "lld/Driver/Driver.h"<br>
 #include "llvm/ADT/Optional.h"<br>
+#include "llvm/ADT/StringSwitch.h"<br>
 #include "llvm/LibDriver/LibDriver.h"<br>
 #include "llvm/Option/Arg.h"<br>
 #include "llvm/Option/ArgList.h"<br>
@@ -282,6 +283,28 @@ static std::string createResponseFile(co<br>
   return Data.str();<br>
 }<br>
<br>
+static unsigned getDefaultDebugType(const llvm::opt::InputArgList &Args) {<br>
+  unsigned DebugTypes = static_cast<unsigned>(<wbr>DebugType::CV);<br>
+  if (Args.hasArg(OPT_driver))<br>
+    DebugTypes |= static_cast<unsigned>(<wbr>DebugType::PData);<br>
+  if (Args.hasArg(OPT_profile))<br>
+    DebugTypes |= static_cast<unsigned>(<wbr>DebugType::Fixup);<br>
+  return DebugTypes;<br>
+}<br>
+<br>
+static unsigned parseDebugType(StringRef Arg) {<br>
+  llvm::SmallVector<StringRef, 3> Types;<br>
+  Arg.split(Types, ',', /*KeepEmpty=*/false);<br>
+<br>
+  unsigned DebugTypes = static_cast<unsigned>(<wbr>DebugType::None);<br>
+  for (StringRef Type : Types)<br>
+    DebugTypes |= StringSwitch<unsigned>(Type.<wbr>lower())<br>
+                      .Case("cv", static_cast<unsigned>(<wbr>DebugType::CV))<br>
+                      .Case("pdata", static_cast<unsigned>(<wbr>DebugType::PData))<br>
+                      .Case("fixup", static_cast<unsigned>(<wbr>DebugType::Fixup));</blockquote><div><br></div><div>What if Type is none of the above? Don't you need a .Default call?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+  return DebugTypes;<br>
+}<br>
+<br>
 void LinkerDriver::link(llvm::<wbr>ArrayRef<const char *> ArgsArr) {<br>
   // If the first command line argument is "/lib", link.exe acts like lib.exe.<br>
   // We call our own implementation of lib.exe that understands bitcode files.<br>
@@ -341,8 +364,13 @@ void LinkerDriver::link(llvm::<wbr>ArrayRef<c<br>
     Config->Force = true;<br>
<br>
   // Handle /debug<br>
-  if (Args.hasArg(OPT_debug))<br>
+  if (Args.hasArg(OPT_debug)) {<br>
     Config->Debug = true;<br>
+    Config->DebugTypes =<br>
+        Args.hasArg(OPT_debugtype)<br>
+            ? parseDebugType(Args.<wbr>getLastArg(OPT_debugtype)-><wbr>getValue())<br>
+            : getDefaultDebugType(Args);<br>
+  }<br>
<br>
   // Handle /noentry<br>
   if (Args.hasArg(OPT_noentry)) {<br>
<br>
Modified: lld/trunk/COFF/Options.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Options.td?rev=278056&r1=278055&r2=278056&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/COFF/<wbr>Options.td?rev=278056&r1=<wbr>278055&r2=278056&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/COFF/Options.td (original)<br>
+++ lld/trunk/COFF/Options.td Mon Aug  8 17:02:44 2016<br>
@@ -62,7 +62,9 @@ def deffile : Joined<["/", "-"], "def:"><br>
     HelpText<"Use module-definition file">;<br>
<br>
 def debug : F<"debug">, HelpText<"Embed a symbol table in the image">;<br>
+def debugtype : P<"debugtype", "Debug Info Options">;<br>
 def dll : F<"dll">, HelpText<"Create a DLL">;<br>
+def driver : P<"driver", "Generate a Windows NT Kernel Mode Driver">;<br>
 def nodefaultlib_all : F<"nodefaultlib">;<br>
 def noentry : F<"noentry">;<br>
 def profile : F<"profile">;<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="javascript:;" onclick="_e(event, 'cvml', 'llvm-commits@lists.llvm.org')">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote>