r209124 - Pass -gdwarf-N options to integrated assembler

Oliver Stannard oliver.stannard at arm.com
Mon May 19 06:39:13 PDT 2014


Author: olista01
Date: Mon May 19 08:39:13 2014
New Revision: 209124

URL: http://llvm.org/viewvc/llvm-project?rev=209124&view=rev
Log:
Pass -gdwarf-N options to integrated assembler

Modified:
    cfe/trunk/include/clang/Driver/CC1AsOptions.td
    cfe/trunk/lib/Driver/Tools.cpp
    cfe/trunk/test/Driver/integrated-as.s
    cfe/trunk/tools/driver/cc1as_main.cpp

Modified: cfe/trunk/include/clang/Driver/CC1AsOptions.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1AsOptions.td?rev=209124&r1=209123&r2=209124&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1AsOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CC1AsOptions.td Mon May 19 08:39:13 2014
@@ -88,6 +88,13 @@ def compress_debug_sections : Flag<["-"]
 
 def g : Flag<["-"], "g">, HelpText<"Generate source level debug information">;
 
+def gdwarf_2 : Flag<["-"], "gdwarf-2">,
+  HelpText<"Generate source level debug information with dwarf version 2">;
+def gdwarf_3 : Flag<["-"], "gdwarf-3">,
+  HelpText<"Generate source level debug information with dwarf version 3">;
+def gdwarf_4 : Flag<["-"], "gdwarf-4">,
+  HelpText<"Generate source level debug information with dwarf version 4">;
+
 def fdebug_compilation_dir : Separate<["-"], "fdebug-compilation-dir">,
   HelpText<"The compilation directory to embed in the debug info.">;
 

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=209124&r1=209123&r2=209124&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon May 19 08:39:13 2014
@@ -1855,6 +1855,8 @@ static void CollectArgsForIntegratedAsse
           // -I. The next arg will be the include directory.
           if (Value == "-I")
             TakeNextArg = true;
+        } else if (Value.startswith("-gdwarf-")) {
+          CmdArgs.push_back(Value.data());
         } else {
           D.Diag(diag::err_drv_unsupported_option_argument)
             << A->getOption().getName() << Value;
@@ -4442,6 +4444,13 @@ void ClangAs::ConstructJob(Compilation &
       if (!A->getOption().matches(options::OPT_g0))
         CmdArgs.push_back("-g");
 
+    if (Args.hasArg(options::OPT_gdwarf_2))
+      CmdArgs.push_back("-gdwarf-2");
+    if (Args.hasArg(options::OPT_gdwarf_3))
+      CmdArgs.push_back("-gdwarf-3");
+    if (Args.hasArg(options::OPT_gdwarf_4))
+      CmdArgs.push_back("-gdwarf-4");
+
     // Add the -fdebug-compilation-dir flag if needed.
     addDebugCompDirArg(Args, CmdArgs);
 

Modified: cfe/trunk/test/Driver/integrated-as.s
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/integrated-as.s?rev=209124&r1=209123&r2=209124&view=diff
==============================================================================
--- cfe/trunk/test/Driver/integrated-as.s (original)
+++ cfe/trunk/test/Driver/integrated-as.s Mon May 19 08:39:13 2014
@@ -29,3 +29,17 @@
 // XA_INCLUDE2: cc1as
 // XA_INCLUDE2: "-Ifoo_dir"
 
+// RUN: %clang -### -c -integrated-as %s -gdwarf-2 2>&1 | FileCheck --check-prefix=DWARF2 %s
+// DWARF2: "-g" "-gdwarf-2"
+
+// RUN: %clang -### -c -integrated-as %s -gdwarf-3 2>&1 | FileCheck --check-prefix=DWARF3 %s
+// DWARF3: "-g" "-gdwarf-3"
+
+// RUN: %clang -### -c -integrated-as %s -gdwarf-4 2>&1 | FileCheck --check-prefix=DWARF4 %s
+// DWARF4: "-g" "-gdwarf-4"
+
+// RUN: %clang -### -c -integrated-as %s -Xassembler -gdwarf-2 2>&1 | FileCheck --check-prefix=DWARF2XASSEMBLER %s
+// DWARF2XASSEMBLER: "-gdwarf-2"
+
+// RUN: %clang -### -c -integrated-as %s -Wa,-gdwarf-2 2>&1 | FileCheck --check-prefix=DWARF2WA %s
+// DWARF2WA: "-gdwarf-2"

Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=209124&r1=209123&r2=209124&view=diff
==============================================================================
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Mon May 19 08:39:13 2014
@@ -87,6 +87,7 @@ struct AssemblerInvocation {
   unsigned SaveTemporaryLabels : 1;
   unsigned GenDwarfForAssembly : 1;
   unsigned CompressDebugSections : 1;
+  unsigned DwarfVersion;
   std::string DwarfDebugFlags;
   std::string DwarfDebugProducer;
   std::string DebugCompilationDir;
@@ -137,6 +138,7 @@ public:
     ShowEncoding = 0;
     RelaxAll = 0;
     NoExecStack = 0;
+    DwarfVersion = 3;
   }
 
   static bool CreateFromArgs(AssemblerInvocation &Res, const char **ArgBegin,
@@ -189,6 +191,12 @@ bool AssemblerInvocation::CreateFromArgs
   Opts.SaveTemporaryLabels = Args->hasArg(OPT_msave_temp_labels);
   Opts.GenDwarfForAssembly = Args->hasArg(OPT_g);
   Opts.CompressDebugSections = Args->hasArg(OPT_compress_debug_sections);
+  if (Args->hasArg(OPT_gdwarf_2))
+    Opts.DwarfVersion = 2;
+  if (Args->hasArg(OPT_gdwarf_3))
+    Opts.DwarfVersion = 3;
+  if (Args->hasArg(OPT_gdwarf_4))
+    Opts.DwarfVersion = 4;
   Opts.DwarfDebugFlags = Args->getLastArgValue(OPT_dwarf_debug_flags);
   Opts.DwarfDebugProducer = Args->getLastArgValue(OPT_dwarf_debug_producer);
   Opts.DebugCompilationDir = Args->getLastArgValue(OPT_fdebug_compilation_dir);
@@ -327,6 +335,7 @@ static bool ExecuteAssembler(AssemblerIn
     Ctx.setCompilationDir(Opts.DebugCompilationDir);
   if (!Opts.MainFileName.empty())
     Ctx.setMainFileName(StringRef(Opts.MainFileName));
+  Ctx.setDwarfVersion(Opts.DwarfVersion);
 
   // Build up the feature string from the target feature list.
   std::string FS;





More information about the cfe-commits mailing list