From b15675616c826bea039f609e49840566a81f45a1 Mon Sep 17 00:00:00 2001 From: Augusto Noronha Date: Fri, 5 Dec 2025 17:16:08 -0800 Subject: [PATCH 1/2] [lldb] Allow LLDBMemoryReader to provide symbols outside refl. sections There are swift metadata symbols outside the "__swift_" sections. For example, swift context descriptors live in the "const" sections. Allow LLDBMemoryReader::resolvePointerAsSymbol to return any symbol that it finds. rdar://165950673 --- .../LanguageRuntime/Swift/LLDBMemoryReader.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/lldb/source/Plugins/LanguageRuntime/Swift/LLDBMemoryReader.cpp b/lldb/source/Plugins/LanguageRuntime/Swift/LLDBMemoryReader.cpp index 13146fffa73fb..7e617608c6d2f 100644 --- a/lldb/source/Plugins/LanguageRuntime/Swift/LLDBMemoryReader.cpp +++ b/lldb/source/Plugins/LanguageRuntime/Swift/LLDBMemoryReader.cpp @@ -195,19 +195,6 @@ LLDBMemoryReader::resolvePointerAsSymbol(swift::remote::RemoteAddress address) { return {}; } - if (auto section_sp = addr.GetSection()) { - if (auto *obj_file = section_sp->GetObjectFile()) { - auto obj_file_format_type = - obj_file->GetArchitecture().GetTriple().getObjectFormat(); - if (auto swift_obj_file_format = - GetSwiftObjectFileFormat(obj_file_format_type)) { - if (!swift_obj_file_format->sectionContainsReflectionData( - section_sp->GetName().GetStringRef())) - return {}; - } - } - } - if (auto *symbol = addr.CalculateSymbolContextSymbol()) { auto mangledName = symbol->GetMangled().GetMangledName().GetStringRef(); // MemoryReader requires this to be a Swift symbol. LLDB can also be From 841e53e4ad38ab047dc3cb82f823883aa8b851fa Mon Sep 17 00:00:00 2001 From: Augusto Noronha Date: Thu, 11 Dec 2025 18:05:17 -0800 Subject: [PATCH 2/2] [lldb] Disable LLDBMemoryReader::resolvePointerAsSymbol on Linux Address::CalculateSymbolContextSymbol() finds the wrong symbol on Linux when debugging swift application because symbols have an actual size (as opposed to macOS, where they have size 0). This is either an LLDB or a swift compiler bug. For now, disable this optimization on Linux. --- .../Plugins/LanguageRuntime/Swift/LLDBMemoryReader.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lldb/source/Plugins/LanguageRuntime/Swift/LLDBMemoryReader.cpp b/lldb/source/Plugins/LanguageRuntime/Swift/LLDBMemoryReader.cpp index 7e617608c6d2f..b78adcddae734 100644 --- a/lldb/source/Plugins/LanguageRuntime/Swift/LLDBMemoryReader.cpp +++ b/lldb/source/Plugins/LanguageRuntime/Swift/LLDBMemoryReader.cpp @@ -180,6 +180,14 @@ LLDBMemoryReader::resolvePointerAsSymbol(swift::remote::RemoteAddress address) { if (!target.GetSwiftUseReflectionSymbols()) return {}; + auto &triple = m_process.GetTarget().GetArchitecture().GetTriple(); + // On Linux, there seems to be a bug where we can't reliably look for symbols by address, + // since these symbols have an actual size and can overlap. + // This could be an LLDB bug or a compiler bug. + // rdar://166344740 + if (triple.isOSLinux()) + return {}; + std::optional
maybeAddr = remoteAddressToLLDBAddress(address); // This is not an assert, but should never happen. if (!maybeAddr)