diff options
-rw-r--r-- | include/clang/Driver/CC1AsOptions.td | 7 | ||||
-rw-r--r-- | lib/Driver/Tools.cpp | 9 | ||||
-rw-r--r-- | test/Driver/integrated-as.s | 14 | ||||
-rw-r--r-- | tools/driver/cc1as_main.cpp | 9 |
4 files changed, 39 insertions, 0 deletions
diff --git a/include/clang/Driver/CC1AsOptions.td b/include/clang/Driver/CC1AsOptions.td index 3e130d077b..34d60847ef 100644 --- a/include/clang/Driver/CC1AsOptions.td +++ b/include/clang/Driver/CC1AsOptions.td @@ -88,6 +88,13 @@ def compress_debug_sections : Flag<["-"], "compress-debug-sections">, 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.">; diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 7862ffb446..534afc5a0d 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -1855,6 +1855,8 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, // -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 &C, const JobAction &JA, 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); diff --git a/test/Driver/integrated-as.s b/test/Driver/integrated-as.s index ee2c8cf852..9a7d2c5dfe 100644 --- a/test/Driver/integrated-as.s +++ b/test/Driver/integrated-as.s @@ -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" diff --git a/tools/driver/cc1as_main.cpp b/tools/driver/cc1as_main.cpp index debc94725f..c4456e2f1d 100644 --- a/tools/driver/cc1as_main.cpp +++ b/tools/driver/cc1as_main.cpp @@ -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(AssemblerInvocation &Opts, 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(AssemblerInvocation &Opts, 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; |