From 45784a79fc700da169f42b6d88cfb1f3b87c64dc Mon Sep 17 00:00:00 2001 From: Paul Robinson Date: Sat, 19 Dec 2015 02:24:10 +0000 Subject: [PATCH] Recommit CC1 part of debugger tuning; pass through setting from driver to LLVM. Reapplies r256063, except instead of frugally re-using an LLVM enum, we define a Clang enum, to avoid exposing too much LLVM interface. Differential Revision: http://reviews.llvm.org/D15650 llvm-svn: 256078 --- clang/include/clang/Driver/CC1Options.td | 1 + clang/include/clang/Frontend/CodeGenOptions.def | 3 +++ clang/include/clang/Frontend/CodeGenOptions.h | 7 +++++++ clang/lib/CodeGen/BackendUtil.cpp | 13 +++++++++++++ clang/lib/Frontend/CompilerInvocation.cpp | 7 +++++++ 5 files changed, 31 insertions(+) diff --git a/clang/include/clang/Driver/CC1Options.td b/clang/include/clang/Driver/CC1Options.td index d510e19ea916..d7f42a991a8f 100644 --- a/clang/include/clang/Driver/CC1Options.td +++ b/clang/include/clang/Driver/CC1Options.td @@ -134,6 +134,7 @@ let Flags = [CC1Option, CC1AsOption, NoDriverOption] in { def debug_info_kind_EQ : Joined<["-"], "debug-info-kind=">; def dwarf_version_EQ : Joined<["-"], "dwarf-version=">; +def debugger_tuning_EQ : Joined<["-"], "debugger-tuning=">; def fdebug_compilation_dir : Separate<["-"], "fdebug-compilation-dir">, HelpText<"The compilation directory to embed in the debug info.">; def dwarf_debug_flags : Separate<["-"], "dwarf-debug-flags">, diff --git a/clang/include/clang/Frontend/CodeGenOptions.def b/clang/include/clang/Frontend/CodeGenOptions.def index 795d7e9bce8b..2e9205fc842f 100644 --- a/clang/include/clang/Frontend/CodeGenOptions.def +++ b/clang/include/clang/Frontend/CodeGenOptions.def @@ -183,6 +183,9 @@ VALUE_CODEGENOPT(SSPBufferSize, 32, 0) /// The kind of generated debug info. ENUM_CODEGENOPT(DebugInfo, DebugInfoKind, 3, NoDebugInfo) +/// Tune the debug info for this debugger. +ENUM_CODEGENOPT(DebuggerTuning, DebuggerKind, 2, DebuggerKindDefault) + /// Dwarf version. Version zero indicates to LLVM that no DWARF should be /// emitted. VALUE_CODEGENOPT(DwarfVersion, 3, 0) diff --git a/clang/include/clang/Frontend/CodeGenOptions.h b/clang/include/clang/Frontend/CodeGenOptions.h index 5bf8f8b92b48..fac6f1a038f3 100644 --- a/clang/include/clang/Frontend/CodeGenOptions.h +++ b/clang/include/clang/Frontend/CodeGenOptions.h @@ -82,6 +82,13 @@ public: FullDebugInfo /// Generate complete debug info. }; + enum DebuggerKind { + DebuggerKindDefault, + DebuggerKindGDB, + DebuggerKindLLDB, + DebuggerKindSCE + }; + enum TLSModel { GeneralDynamicTLSModel, LocalDynamicTLSModel, diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 784e9c7ba5f7..79aff4f49686 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -553,6 +553,19 @@ TargetMachine *EmitAssemblyHelper::CreateTargetMachine(bool MustCreateTM) { Options.DataSections = CodeGenOpts.DataSections; Options.UniqueSectionNames = CodeGenOpts.UniqueSectionNames; Options.EmulatedTLS = CodeGenOpts.EmulatedTLS; + switch (CodeGenOpts.getDebuggerTuning()) { + case CodeGenOptions::DebuggerKindGDB: + Options.DebuggerTuning = llvm::DebuggerKind::GDB; + break; + case CodeGenOptions::DebuggerKindLLDB: + Options.DebuggerTuning = llvm::DebuggerKind::LLDB; + break; + case CodeGenOptions::DebuggerKindSCE: + Options.DebuggerTuning = llvm::DebuggerKind::SCE; + break; + default: + break; + } Options.MCOptions.MCRelaxAll = CodeGenOpts.RelaxAll; Options.MCOptions.MCSaveTempLabels = CodeGenOpts.SaveTempLabels; diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index c6068d7d94dd..7fe0a8675354 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -405,6 +405,13 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, .Case("limited", CodeGenOptions::LimitedDebugInfo) .Case("standalone", CodeGenOptions::FullDebugInfo)); } + if (Arg *A = Args.getLastArg(OPT_debugger_tuning_EQ)) { + Opts.setDebuggerTuning( + llvm::StringSwitch(A->getValue()) + .Case("gdb", CodeGenOptions::DebuggerKindGDB) + .Case("lldb", CodeGenOptions::DebuggerKindLLDB) + .Case("sce", CodeGenOptions::DebuggerKindSCE)); + } Opts.DwarfVersion = getLastArgIntValue(Args, OPT_dwarf_version_EQ, 0, Diags); Opts.DebugColumnInfo = Args.hasArg(OPT_dwarf_column_info); Opts.EmitCodeView = Args.hasArg(OPT_gcodeview);