Skip to content

Commit b1e0afc

Browse files
Merge pull request #3350 from adrian-prantl/25498103
Debug info diet!
2 parents ff45b5a + 361beff commit b1e0afc

18 files changed

+262
-161
lines changed

include/swift/AST/IRGenOptions.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ enum class IRGenOutputKind : unsigned {
4848
enum class IRGenDebugInfoKind : unsigned {
4949
None, /// No debug info.
5050
LineTables, /// Line tables only.
51-
Normal /// Line tables + DWARF types.
51+
ASTTypes, /// Line tables + AST type references.
52+
DwarfTypes, /// Line tables + AST type references + DWARF types.
53+
Normal = ASTTypes /// The setting LLDB prefers.
5254
};
5355

5456
enum class IRGenEmbedMode : unsigned {

include/swift/Option/Options.td

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,12 +293,16 @@ def Oplayground : Flag<["-"], "Oplayground">, Group<O_Group>,
293293
def g_Group : OptionGroup<"<debug info options>">;
294294

295295
def g : Flag<["-"], "g">, Group<g_Group>, Flags<[FrontendOption]>,
296-
HelpText<"Emit debug info">;
296+
HelpText<"Emit debug info. "
297+
"This is the preferred setting for debugging with LLDB.">;
297298
def gnone : Flag<["-"], "gnone">, Group<g_Group>, Flags<[FrontendOption]>,
298299
HelpText<"Don't emit debug info">;
299300
def gline_tables_only : Flag<["-"], "gline-tables-only">,
300301
Group<g_Group>, Flags<[FrontendOption]>,
301302
HelpText<"Emit minimal debug info for backtraces only">;
303+
def gdwarf_types : Flag<["-"], "gdwarf-types">,
304+
Group<g_Group>, Flags<[FrontendOption]>,
305+
HelpText<"Emit full DWARF type info.">;
302306

303307
// Assert configuration identifiers.
304308
def AssertConfig : Separate<["-"], "assert-config">,

lib/Driver/Driver.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,8 @@ void Driver::buildOutputInfo(const ToolChain &TC, const DerivedArgList &Args,
975975
OI.DebugInfoKind = IRGenDebugInfoKind::Normal;
976976
else if (A->getOption().matches(options::OPT_gline_tables_only))
977977
OI.DebugInfoKind = IRGenDebugInfoKind::LineTables;
978+
else if (A->getOption().matches(options::OPT_gdwarf_types))
979+
OI.DebugInfoKind = IRGenDebugInfoKind::DwarfTypes;
978980
else
979981
assert(A->getOption().matches(options::OPT_gnone) &&
980982
"unknown -g<kind> option");
@@ -985,7 +987,7 @@ void Driver::buildOutputInfo(const ToolChain &TC, const DerivedArgList &Args,
985987
// top-level output.
986988
OI.ShouldGenerateModule = true;
987989
OI.ShouldTreatModuleAsTopLevelOutput = true;
988-
} else if ((OI.DebugInfoKind == IRGenDebugInfoKind::Normal &&
990+
} else if ((OI.DebugInfoKind > IRGenDebugInfoKind::LineTables &&
989991
OI.shouldLink()) ||
990992
Args.hasArg(options::OPT_emit_objc_header,
991993
options::OPT_emit_objc_header_path)) {

lib/Driver/ToolChains.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ toolchains::Darwin::constructInvocation(const LinkJobAction &job,
964964

965965
addInputsOfType(Arguments, context.InputActions, types::TY_Object);
966966

967-
if (context.OI.DebugInfoKind == IRGenDebugInfoKind::Normal) {
967+
if (context.OI.DebugInfoKind > IRGenDebugInfoKind::LineTables) {
968968
size_t argCount = Arguments.size();
969969
if (context.OI.CompilerMode == OutputInfo::Mode::SingleCompile)
970970
addInputsOfType(Arguments, context.Inputs, types::TY_SwiftModuleFile);

lib/Frontend/CompilerInvocation.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1143,11 +1143,13 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
11431143
Opts.DebugInfoKind = IRGenDebugInfoKind::Normal;
11441144
else if (A->getOption().matches(options::OPT_gline_tables_only))
11451145
Opts.DebugInfoKind = IRGenDebugInfoKind::LineTables;
1146+
else if (A->getOption().matches(options::OPT_gdwarf_types))
1147+
Opts.DebugInfoKind = IRGenDebugInfoKind::DwarfTypes;
11461148
else
11471149
assert(A->getOption().matches(options::OPT_gnone) &&
11481150
"unknown -g<kind> option");
11491151

1150-
if (Opts.DebugInfoKind == IRGenDebugInfoKind::Normal) {
1152+
if (Opts.DebugInfoKind > IRGenDebugInfoKind::LineTables) {
11511153
ArgStringList RenderedArgs;
11521154
for (auto A : Args)
11531155
A->render(Args, RenderedArgs);

0 commit comments

Comments
 (0)