namespace clang {
namespace codegenoptions {
+enum DebugInfoFormat {
+ DIF_DWARF,
+ DIF_CodeView,
+};
+
enum DebugInfoKind {
NoDebugInfo, /// Don't generate debug info.
LocTrackingOnly, /// Emit location information but do not generate
#include "clang/Basic/LLVM.h"
#include "clang/Basic/Sanitizers.h"
+#include "clang/Basic/DebugInfoOptions.h"
#include "clang/Driver/Action.h"
#include "clang/Driver/Multilib.h"
#include "clang/Driver/Types.h"
/// Complain if this tool chain doesn't support Objective-C ARC.
virtual void CheckObjCARC() const {}
+ /// Get the default debug info format. Typically, this is DWARF.
+ virtual codegenoptions::DebugInfoFormat getDefaultDebugFormat() const {
+ return codegenoptions::DIF_DWARF;
+ }
+
/// UseDwarfDebugFlags - Embed the compile options to clang into the Dwarf
/// compile unit information.
virtual bool UseDwarfDebugFlags() const { return false; }
if (checkDebugInfoOption(A, Args, D, TC))
DWARFVersion = DwarfVersionNum(A->getSpelling());
- // Forward -gcodeview. EmitCodeView might have been set by CL-compatibility
- // argument parsing.
- if (EmitCodeView) {
- if (const Arg *A = Args.getLastArg(options::OPT_gcodeview)) {
- EmitCodeView = checkDebugInfoOption(A, Args, D, TC);
- if (EmitCodeView) {
- // DWARFVersion remains at 0 if no explicit choice was made.
- CmdArgs.push_back("-gcodeview");
- }
- }
+ if (const Arg *A = Args.getLastArg(options::OPT_gcodeview)) {
+ if (checkDebugInfoOption(A, Args, D, TC))
+ EmitCodeView = true;
}
+ // If the user asked for debug info but did not explicitly specify -gcodeview
+ // or -gdwarf, ask the toolchain for the default format.
if (!EmitCodeView && DWARFVersion == 0 &&
- DebugInfoKind != codegenoptions::NoDebugInfo)
- DWARFVersion = TC.GetDefaultDwarfVersion();
+ DebugInfoKind != codegenoptions::NoDebugInfo) {
+ switch (TC.getDefaultDebugFormat()) {
+ case codegenoptions::DIF_CodeView:
+ EmitCodeView = true;
+ break;
+ case codegenoptions::DIF_DWARF:
+ DWARFVersion = TC.GetDefaultDwarfVersion();
+ break;
+ }
+ }
// -gline-directives-only supported only for the DWARF debug info.
if (DWARFVersion == 0 && DebugInfoKind == codegenoptions::DebugDirectivesOnly)
CmdArgs.push_back("-gembed-source");
}
+ if (EmitCodeView)
+ CmdArgs.push_back("-gcodeview");
+
RenderDebugEnablingArgs(Args, CmdArgs, DebugInfoKind, DWARFVersion,
DebuggerTuning);
types::ID InputType = Input.getType();
if (D.IsCLMode())
AddClangCLArgs(Args, InputType, CmdArgs, &DebugInfoKind, &EmitCodeView);
- else
- EmitCodeView = Args.hasArg(options::OPT_gcodeview);
DwarfFissionKind DwarfFission;
RenderDebugOptions(TC, D, RawTriple, Args, EmitCodeView, IsWindowsMSVC,
*DebugInfoKind = codegenoptions::LimitedDebugInfo;
else
*DebugInfoKind = codegenoptions::DebugLineTablesOnly;
- CmdArgs.push_back("-gcodeview");
} else {
*EmitCodeView = false;
}
#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MSVC_H
#include "Cuda.h"
+#include "clang/Basic/DebugInfoOptions.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Tool.h"
#include "clang/Driver/ToolChain.h"
bool isPIEDefault() const override;
bool isPICDefaultForced() const override;
+ /// Set CodeView as the default debug info format. Users can use -gcodeview
+ /// and -gdwarf to override the default.
+ codegenoptions::DebugInfoFormat getDefaultDebugFormat() const override {
+ return codegenoptions::DIF_CodeView;
+ }
+
+ /// Set the debugger tuning to "default", since we're definitely not tuning
+ /// for GDB.
+ llvm::DebuggerKind getDefaultDebuggerTuning() const override {
+ return llvm::DebuggerKind::Default;
+ }
+
enum class SubDirectoryType {
Bin,
Include,
// RUN: %clang -target powerpc-unknown-openbsd -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER2
// RUN: %clang -target powerpc-unknown-freebsd -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER2
// RUN: %clang -target i386-pc-solaris -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER2
-//
-// Test what -gcodeview and -gdwarf do on Windows.
-// RUN: %clang -target i686-pc-windows-msvc -gcodeview -S -emit-llvm -o - %s | FileCheck %s --check-prefix=NODWARF --check-prefix=CODEVIEW
-// RUN: %clang -target i686-pc-windows-msvc -gdwarf -gcodeview -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER4 --check-prefix=CODEVIEW
+
+// Check which debug info formats we use on Windows. By default, in an MSVC
+// environment, we should use codeview. You can enable dwarf, which implicitly
+// disables codeview, of you can explicitly ask for both if you don't know how
+// the app will be debugged.
+// Default is codeview.
+// RUN: %clang -target i686-pc-windows-msvc -g -S -emit-llvm -o - %s \
+// RUN: | FileCheck %s --check-prefixes=NODWARF,CODEVIEW
+// Explicitly request codeview.
+// RUN: %clang -target i686-pc-windows-msvc -gcodeview -S -emit-llvm -o - %s \
+// RUN: | FileCheck %s --check-prefixes=NODWARF,CODEVIEW
+// Explicitly request DWARF.
+// RUN: %clang -target i686-pc-windows-msvc -gdwarf -S -emit-llvm -o - %s \
+// RUN: | FileCheck %s --check-prefixes=VER4,NOCODEVIEW
+// Explicitly request both.
+// RUN: %clang -target i686-pc-windows-msvc -gdwarf -gcodeview -S -emit-llvm -o - %s \
+// RUN: | FileCheck %s --check-prefixes=VER4,CODEVIEW
int main (void) {
return 0;
}
+// NOCODEVIEW-NOT: !"CodeView"
+
// VER2: !{i32 2, !"Dwarf Version", i32 2}
// VER3: !{i32 2, !"Dwarf Version", i32 3}
// VER4: !{i32 2, !"Dwarf Version", i32 4}
// NODWARF-NOT: !"Dwarf Version"
// CODEVIEW: !{i32 2, !"CodeView", i32 1}
+// NOCODEVIEW-NOT: !"CodeView"
// NODWARF-NOT: !"Dwarf Version"
// FIXME: Check IR rather than asm, then triple is not needed.
-// RUN: %clang -Xclang -triple=%itanium_abi_triple -g -S %s -o - | FileCheck %s
+// RUN: %clang --target=%itanium_abi_triple -g -S %s -o - | FileCheck %s
// Test to check presence of debug info for byval parameter.
// Radar 8350436.
class DAG {
// FIXME: Check IR rather than asm, then triple is not needed.
-// RUN: %clang -Xclang -triple=%itanium_abi_triple -fverbose-asm -g -S %s -o - | grep AT_explicit
+// RUN: %clang --target=%itanium_abi_triple -fverbose-asm -g -S %s -o - | grep AT_explicit
class MyClass
// FIXME: Check IR rather than asm, then triple is not needed.
-// RUN: %clang -Xclang -triple=%itanium_abi_triple -fverbose-asm -g -S %s -o - | grep DW_ACCESS_public
+// RUN: %clang --target=%itanium_abi_triple -fverbose-asm -g -S %s -o - | grep DW_ACCESS_public
class A {
public:
int x;
// FIXME: Check IR rather than asm, then triple is not needed.
-// RUN: %clang -Xclang -triple=%itanium_abi_triple -fverbose-asm -g -S %s -o - | grep DW_AT_specification
+// RUN: %clang --target=%itanium_abi_triple -fverbose-asm -g -S %s -o - | grep DW_AT_specification
// Radar 9254491
class A {
public:
// RUN: %clang -### -c -g %s -target x86_64-pc-freebsd10.0 2>&1 \
// RUN: | FileCheck -check-prefix=G_GDB %s
+// Windows.
+// RUN: %clang -### -c -g %s -target x86_64-w64-windows-gnu 2>&1 \
+// RUN: | FileCheck -check-prefix=G_GDB %s
+// RUN: %clang -### -c -g %s -target x86_64-windows-msvc 2>&1 \
+// RUN: | FileCheck -check-prefix=G_NOTUNING %s
+// RUN: %clang_cl -### -c -Z7 -target x86_64-windows-msvc -- %s 2>&1 \
+// RUN: | FileCheck -check-prefix=G_NOTUNING %s
+
// On the PS4, -g defaults to -gno-column-info, and we always generate the
// arange section.
// RUN: %clang -### -c %s -target x86_64-scei-ps4 2>&1 \
// RUN: %clang -### -gmodules -gline-tables-only %s 2>&1 \
// RUN: | FileCheck -check-prefix=GLTO_ONLY %s
//
-// RUN: %clang -### -gmodules -gline-directives-only %s 2>&1 \
+// RUN: %clang -### -target %itanium_abi_triple -gmodules -gline-directives-only %s 2>&1 \
// RUN: | FileCheck -check-prefix=GLIO_ONLY %s
//
// G: "-cc1"
// G_LLDB: "-debugger-tuning=lldb"
// G_SCE: "-debugger-tuning=sce"
//
+// G_NOTUNING: "-cc1"
+// G_NOTUNING-NOT: "-debugger-tuning="
+//
// This tests asserts that "-gline-tables-only" "-g0" disables debug info.
// GLTO_NO: "-cc1"
// GLTO_NO-NOT: -debug-info-kind=
//
// NOCI-NOT: "-dwarf-column-info"
//
-// GEXTREFS: "-dwarf-ext-refs" "-fmodule-format=obj" "-debug-info-kind={{standalone|limited}}"
+// GEXTREFS: "-dwarf-ext-refs" "-fmodule-format=obj"
+// GEXTREFS: "-debug-info-kind={{standalone|limited}}"
// RUN: not %clang -cc1 -debug-info-kind=watkind 2>&1 | FileCheck -check-prefix=BADSTRING1 %s
// BADSTRING1: error: invalid value 'watkind' in '-debug-info-kind=watkind'