Skip to content

Commit 3a2995b

Browse files
Merge pull request swiftlang#11336 from adrian-prantl/repl-gmodules
[LLDB] Initialize ClangImporter with -gmodules
2 parents 9799617 + bd3e758 commit 3a2995b

File tree

6 files changed

+9
-62
lines changed

6 files changed

+9
-62
lines changed

lldb/source/Expression/IRExecutionUnit.cpp

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -582,62 +582,7 @@ lldb::SectionType IRExecutionUnit::GetSectionTypeFromSectionName(
582582
else if (name.starts_with("__debug_") || name.starts_with(".debug_")) {
583583
const uint32_t name_idx = name[0] == '_' ? 8 : 7;
584584
llvm::StringRef dwarf_name(name.substr(name_idx));
585-
switch (dwarf_name[0]) {
586-
case 'a':
587-
if (dwarf_name == "abbrev")
588-
sect_type = lldb::eSectionTypeDWARFDebugAbbrev;
589-
else if (dwarf_name == "aranges")
590-
sect_type = lldb::eSectionTypeDWARFDebugAranges;
591-
else if (dwarf_name == "addr")
592-
sect_type = lldb::eSectionTypeDWARFDebugAddr;
593-
break;
594-
595-
case 'f':
596-
if (dwarf_name == "frame")
597-
sect_type = lldb::eSectionTypeDWARFDebugFrame;
598-
break;
599-
600-
case 'i':
601-
if (dwarf_name == "info")
602-
sect_type = lldb::eSectionTypeDWARFDebugInfo;
603-
break;
604-
605-
case 'l':
606-
if (dwarf_name == "line")
607-
sect_type = lldb::eSectionTypeDWARFDebugLine;
608-
else if (dwarf_name == "loc")
609-
sect_type = lldb::eSectionTypeDWARFDebugLoc;
610-
else if (dwarf_name == "loclists")
611-
sect_type = lldb::eSectionTypeDWARFDebugLocLists;
612-
break;
613-
614-
case 'm':
615-
if (dwarf_name == "macinfo")
616-
sect_type = lldb::eSectionTypeDWARFDebugMacInfo;
617-
break;
618-
619-
case 'p':
620-
if (dwarf_name == "pubnames")
621-
sect_type = lldb::eSectionTypeDWARFDebugPubNames;
622-
else if (dwarf_name == "pubtypes")
623-
sect_type = lldb::eSectionTypeDWARFDebugPubTypes;
624-
break;
625-
626-
case 's':
627-
if (dwarf_name == "str")
628-
sect_type = lldb::eSectionTypeDWARFDebugStr;
629-
else if (dwarf_name == "str_offsets")
630-
sect_type = lldb::eSectionTypeDWARFDebugStrOffsets;
631-
break;
632-
633-
case 'r':
634-
if (dwarf_name == "ranges")
635-
sect_type = lldb::eSectionTypeDWARFDebugRanges;
636-
break;
637-
638-
default:
639-
break;
640-
}
585+
sect_type = ObjectFile::GetDWARFSectionTypeFromName(dwarf_name);
641586
} else if (name.starts_with("__apple_") || name.starts_with(".apple_"))
642587
sect_type = lldb::eSectionTypeInvalid;
643588
else if (name == "__objc_imageinfo")

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,9 @@ void SwiftASTContext::SetCompilerInvocationLLDBOverrides() {
10331033
m_compiler_invocation_ap->getIRGenOptions();
10341034
ir_gen_opts.OutputKind = swift::IRGenOutputKind::Module;
10351035
ir_gen_opts.UseJIT = true;
1036+
// In the JIT we don't benefit from the indexed indirections in DWARF 5.
1037+
ir_gen_opts.DWARFVersion = 4;
1038+
ir_gen_opts.DebugInfoFormat = swift::IRGenDebugInfoFormat::DWARF;
10361039
// Allow deserializing @_implementationOnly dependencies
10371040
// to avoid crashing due to module recovery issues.
10381041
swift::LangOptions &lang_opts = m_compiler_invocation_ap->getLangOptions();
@@ -3037,6 +3040,7 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
30373040
// perform implicit Clang module imports. They will always use the SDK
30383041
// version as deployment target, even if that is in the future. To
30393042
// avoid building modules twice, match this behavior.
3043+
auto &ci_args = swift_ast_sp->GetClangImporterOptions().ExtraArgs;
30403044
auto darwin_sdk_info = clang::parseDarwinSDKInfo(
30413045
*llvm::vfs::getRealFileSystem(), swift_ast_sp->GetPlatformSDKPath());
30423046
if (!darwin_sdk_info)
@@ -3045,10 +3049,11 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
30453049
auto sdk_triple = triple;
30463050
sdk_triple.setOSName(std::string(triple.getOSTypeName(triple.getOS())) +
30473051
(*darwin_sdk_info)->getVersion().getAsString());
3048-
auto &ci_args = swift_ast_sp->GetClangImporterOptions().ExtraArgs;
30493052
ci_args.push_back("-target");
30503053
ci_args.push_back(sdk_triple.str());
30513054
}
3055+
ci_args.push_back("-gmodules");
3056+
ci_args.push_back("-g");
30523057
}
30533058

30543059
std::vector<swift::PluginSearchOption> plugin_search_options;
@@ -3190,7 +3195,7 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
31903195
{
31913196
auto ast_context = swift_ast_sp->GetASTContext();
31923197
if (!ast_context) {
3193-
logError("couldn't initialize Swift cxompiler");
3198+
logError("couldn't initialize Swift compiler");
31943199
return {};
31953200
}
31963201

lldb/source/Symbol/ObjectFile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ ObjectFile::GetDWARFSectionTypeFromName(llvm::StringRef name) {
672672
.Case("rnglists.dwo", eSectionTypeDWARFDebugRngListsDwo)
673673
.Case("str", eSectionTypeDWARFDebugStr)
674674
.Case("str.dwo", eSectionTypeDWARFDebugStrDwo)
675-
.Case("str_offsets", eSectionTypeDWARFDebugStrOffsets)
675+
.Cases("str_offsets", "str_offs", eSectionTypeDWARFDebugStrOffsets)
676676
.Case("str_offsets.dwo", eSectionTypeDWARFDebugStrOffsetsDwo)
677677
.Case("tu_index", eSectionTypeDWARFDebugTuIndex)
678678
.Case("types", eSectionTypeDWARFDebugTypes)

lldb/test/Shell/SwiftREPL/FrameworkPath.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
REQUIRES: rdar159531316
21
// Test target.swift-framework-search-paths works in the REPL.
32
// REQUIRES: system-darwin
43
// REQUIRES: swift

lldb/test/Shell/SwiftREPL/ImportCocoa.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// REQUIRES: rdar159531346
21
// Test that importing Cocoa works.
32
// REQUIRES: system-darwin
43
// REQUIRES: swift

lldb/test/Shell/SwiftREPL/SwiftInterfaceForceModuleLoadMode.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
REQUIRES: rdar159531365
21
// This test checks that the value of the symbols.swift-module-loading-mode
32
// setting is respected when loading Swift modules.
43
// Note: It intentionally does not check the only-interface or prefer-interface

0 commit comments

Comments
 (0)