From 0750365765098885fb12ffd4d95f29e84a9d60bc Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Fri, 5 Sep 2025 15:47:04 -0700 Subject: [PATCH 1/5] =?UTF-8?q?[lldb]=20Replace=20IRExecutionUnit::GetSect?= =?UTF-8?q?ionTypeFromSectionName=20with=20Ob=E2=80=A6=20(#157192)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …jectFile API This avoids code duplication. (cherry picked from commit 7c5b535d8c50e52ba13439ce52b9fe6fa34afcab) --- lldb/source/Expression/IRExecutionUnit.cpp | 57 +--------------------- lldb/source/Symbol/ObjectFile.cpp | 2 +- 2 files changed, 2 insertions(+), 57 deletions(-) diff --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp index e9a5e026d79ed..4d8be58869cab 100644 --- a/lldb/source/Expression/IRExecutionUnit.cpp +++ b/lldb/source/Expression/IRExecutionUnit.cpp @@ -582,62 +582,7 @@ lldb::SectionType IRExecutionUnit::GetSectionTypeFromSectionName( else if (name.starts_with("__debug_") || name.starts_with(".debug_")) { const uint32_t name_idx = name[0] == '_' ? 8 : 7; llvm::StringRef dwarf_name(name.substr(name_idx)); - switch (dwarf_name[0]) { - case 'a': - if (dwarf_name == "abbrev") - sect_type = lldb::eSectionTypeDWARFDebugAbbrev; - else if (dwarf_name == "aranges") - sect_type = lldb::eSectionTypeDWARFDebugAranges; - else if (dwarf_name == "addr") - sect_type = lldb::eSectionTypeDWARFDebugAddr; - break; - - case 'f': - if (dwarf_name == "frame") - sect_type = lldb::eSectionTypeDWARFDebugFrame; - break; - - case 'i': - if (dwarf_name == "info") - sect_type = lldb::eSectionTypeDWARFDebugInfo; - break; - - case 'l': - if (dwarf_name == "line") - sect_type = lldb::eSectionTypeDWARFDebugLine; - else if (dwarf_name == "loc") - sect_type = lldb::eSectionTypeDWARFDebugLoc; - else if (dwarf_name == "loclists") - sect_type = lldb::eSectionTypeDWARFDebugLocLists; - break; - - case 'm': - if (dwarf_name == "macinfo") - sect_type = lldb::eSectionTypeDWARFDebugMacInfo; - break; - - case 'p': - if (dwarf_name == "pubnames") - sect_type = lldb::eSectionTypeDWARFDebugPubNames; - else if (dwarf_name == "pubtypes") - sect_type = lldb::eSectionTypeDWARFDebugPubTypes; - break; - - case 's': - if (dwarf_name == "str") - sect_type = lldb::eSectionTypeDWARFDebugStr; - else if (dwarf_name == "str_offsets") - sect_type = lldb::eSectionTypeDWARFDebugStrOffsets; - break; - - case 'r': - if (dwarf_name == "ranges") - sect_type = lldb::eSectionTypeDWARFDebugRanges; - break; - - default: - break; - } + sect_type = ObjectFile::GetDWARFSectionTypeFromName(dwarf_name); } else if (name.starts_with("__apple_") || name.starts_with(".apple_")) sect_type = lldb::eSectionTypeInvalid; else if (name == "__objc_imageinfo") diff --git a/lldb/source/Symbol/ObjectFile.cpp b/lldb/source/Symbol/ObjectFile.cpp index 2f5d33ada50ae..6ea3f8f886910 100644 --- a/lldb/source/Symbol/ObjectFile.cpp +++ b/lldb/source/Symbol/ObjectFile.cpp @@ -672,7 +672,7 @@ ObjectFile::GetDWARFSectionTypeFromName(llvm::StringRef name) { .Case("rnglists.dwo", eSectionTypeDWARFDebugRngListsDwo) .Case("str", eSectionTypeDWARFDebugStr) .Case("str.dwo", eSectionTypeDWARFDebugStrDwo) - .Case("str_offsets", eSectionTypeDWARFDebugStrOffsets) + .Cases("str_offsets", "str_offs", eSectionTypeDWARFDebugStrOffsets) .Case("str_offsets.dwo", eSectionTypeDWARFDebugStrOffsetsDwo) .Case("tu_index", eSectionTypeDWARFDebugTuIndex) .Case("types", eSectionTypeDWARFDebugTypes) From 35685da6e7cfbdb6ec44b345338ae1f9176cf6db Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Fri, 5 Sep 2025 16:08:30 -0700 Subject: [PATCH 2/5] [LLDB] Initialize ClangImporter with -gmodules --- lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp b/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp index 5eae9d0ea7581..e01686b24e950 100644 --- a/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp +++ b/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp @@ -3037,6 +3037,7 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance( // perform implicit Clang module imports. They will always use the SDK // version as deployment target, even if that is in the future. To // avoid building modules twice, match this behavior. + auto &ci_args = swift_ast_sp->GetClangImporterOptions().ExtraArgs; auto darwin_sdk_info = clang::parseDarwinSDKInfo( *llvm::vfs::getRealFileSystem(), swift_ast_sp->GetPlatformSDKPath()); if (!darwin_sdk_info) @@ -3045,10 +3046,11 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance( auto sdk_triple = triple; sdk_triple.setOSName(std::string(triple.getOSTypeName(triple.getOS())) + (*darwin_sdk_info)->getVersion().getAsString()); - auto &ci_args = swift_ast_sp->GetClangImporterOptions().ExtraArgs; ci_args.push_back("-target"); ci_args.push_back(sdk_triple.str()); } + ci_args.push_back("-gmodules"); + ci_args.push_back("-g"); } std::vector plugin_search_options; From 48330f6fed6c07f69a8cf08ddbb0128d330e660c Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Fri, 5 Sep 2025 16:08:53 -0700 Subject: [PATCH 3/5] [LLDB] fix typo --- lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp b/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp index e01686b24e950..653f9c395d5fe 100644 --- a/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp +++ b/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp @@ -3192,7 +3192,7 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance( { auto ast_context = swift_ast_sp->GetASTContext(); if (!ast_context) { - logError("couldn't initialize Swift cxompiler"); + logError("couldn't initialize Swift compiler"); return {}; } From 9261ad423243d5abbc73b460205a69a7c5fc3728 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Fri, 5 Sep 2025 16:09:10 -0700 Subject: [PATCH 4/5] [LLDB] UnSkip passing tests --- lldb/test/Shell/SwiftREPL/FrameworkPath.test | 1 - lldb/test/Shell/SwiftREPL/ImportCocoa.test | 1 - lldb/test/Shell/SwiftREPL/SwiftInterfaceForceModuleLoadMode.test | 1 - 3 files changed, 3 deletions(-) diff --git a/lldb/test/Shell/SwiftREPL/FrameworkPath.test b/lldb/test/Shell/SwiftREPL/FrameworkPath.test index 555672ad007c7..95d0019ce41e4 100644 --- a/lldb/test/Shell/SwiftREPL/FrameworkPath.test +++ b/lldb/test/Shell/SwiftREPL/FrameworkPath.test @@ -1,4 +1,3 @@ -REQUIRES: rdar159531316 // Test target.swift-framework-search-paths works in the REPL. // REQUIRES: system-darwin // REQUIRES: swift diff --git a/lldb/test/Shell/SwiftREPL/ImportCocoa.test b/lldb/test/Shell/SwiftREPL/ImportCocoa.test index 524554e96d91d..9bf2acbebf3b3 100644 --- a/lldb/test/Shell/SwiftREPL/ImportCocoa.test +++ b/lldb/test/Shell/SwiftREPL/ImportCocoa.test @@ -1,4 +1,3 @@ -// REQUIRES: rdar159531346 // Test that importing Cocoa works. // REQUIRES: system-darwin // REQUIRES: swift diff --git a/lldb/test/Shell/SwiftREPL/SwiftInterfaceForceModuleLoadMode.test b/lldb/test/Shell/SwiftREPL/SwiftInterfaceForceModuleLoadMode.test index 9269ad886e161..ac71e2c198458 100644 --- a/lldb/test/Shell/SwiftREPL/SwiftInterfaceForceModuleLoadMode.test +++ b/lldb/test/Shell/SwiftREPL/SwiftInterfaceForceModuleLoadMode.test @@ -1,4 +1,3 @@ -REQUIRES: rdar159531365 // This test checks that the value of the symbols.swift-module-loading-mode // setting is respected when loading Swift modules. // Note: It intentionally does not check the only-interface or prefer-interface From bd3e7585b04ff1f88ff1e50cee789054d79d8509 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Mon, 8 Sep 2025 08:58:51 -0700 Subject: [PATCH 5/5] [LLDB] Clamp expression evaluator DWARF version to 4 --- lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp b/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp index 653f9c395d5fe..98690408c9326 100644 --- a/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp +++ b/lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp @@ -1033,6 +1033,9 @@ void SwiftASTContext::SetCompilerInvocationLLDBOverrides() { m_compiler_invocation_ap->getIRGenOptions(); ir_gen_opts.OutputKind = swift::IRGenOutputKind::Module; ir_gen_opts.UseJIT = true; + // In the JIT we don't benefit from the indexed indirections in DWARF 5. + ir_gen_opts.DWARFVersion = 4; + ir_gen_opts.DebugInfoFormat = swift::IRGenDebugInfoFormat::DWARF; // Allow deserializing @_implementationOnly dependencies // to avoid crashing due to module recovery issues. swift::LangOptions &lang_opts = m_compiler_invocation_ap->getLangOptions();