https://github.com/jasonmolenda updated 
https://github.com/llvm/llvm-project/pull/210206

>From 2ad65ed6686a7699b9d411aea209f2ef39da2d2d Mon Sep 17 00:00:00 2001
From: Jason Molenda <[email protected]>
Date: Thu, 16 Jul 2026 16:07:39 -0700
Subject: [PATCH 1/4] [lldb] Don't use Module's SymbolFileFileSpec to determine
 debug info

There are three places that are using Module::GetSymbolFileFileSpec
to tell if a Module has debug info, and if not, to do additional
searching for a separate debug-info binary.  This would be correct
behavior if we were always debugging a binary + dSYM separated
DWARF configuration, but when the DWARF is embedded in the binary
(the Module's ObjectFile), we may have debug info but no SymbolFile
FileSpec.

These callers should check if the Module has a SymbolFile (which
may point to the same thing as the Module's ObjectFile) instead.
I looked across the calls to GetSymbolFileFileSpec and these sites
were the only ones making the mistake, and I believe I added all
of these myself.

I thought about having Module set the m_symfile_spec to the
ObjectFile's FileSpec at the same time it sets m_symfile_up, but
there are parts of code that are intentionally testing
GetSymbolFileFileSpec for its actual meaning, and I seem to be
the only person who has made this mistake so fixing it like
this seems appropriate.

rdar://182314291
---
 lldb/source/Core/DynamicLoader.cpp                              | 2 +-
 lldb/source/Core/Module.cpp                                     | 2 +-
 .../DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp   | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Core/DynamicLoader.cpp 
b/lldb/source/Core/DynamicLoader.cpp
index dd771a7a3a8ae..1ece89c9122ef 100644
--- a/lldb/source/Core/DynamicLoader.cpp
+++ b/lldb/source/Core/DynamicLoader.cpp
@@ -283,7 +283,7 @@ ModuleSP DynamicLoader::LoadBinaryWithUUIDAndAddress(
 
     // If we haven't found a binary, or we don't have a SymbolFile, see
     // if there is an external search tool that can find it.
-    if (!module_sp || !module_sp->GetSymbolFileFileSpec()) {
+    if (!module_sp || !module_sp->GetSymbolFile(/*can_create=*/ false)) {
       PluginManager::DownloadObjectAndSymbolFile(module_spec, error,
                                                  force_symbol_search);
       if (FileSystem::Instance().Exists(module_spec.GetFileSpec())) {
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index dcdfd67d3e303..377e36347aa8c 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -1259,7 +1259,7 @@ void Module::SectionFileAddressesChanged() {
 }
 
 UnwindTable &Module::GetUnwindTable() {
-  if (!m_symfile_spec)
+  if (!m_symfile_up)
     SymbolLocator::DownloadSymbolFileAsync(GetUUID());
   return m_unwind_table;
 }
diff --git 
a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp 
b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
index 7959a49fd03a1..9f5d3f74ec86d 100644
--- 
a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ 
b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -830,7 +830,7 @@ bool 
DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule(
       // set.
       Status kernel_search_error;
       if (IsKernel() &&
-          (!m_module_sp || !m_module_sp->GetSymbolFileFileSpec())) {
+          (!m_module_sp || !m_module_sp->GetSymbolFile(/*can_create=*/false))) 
{
         if (PluginManager::DownloadObjectAndSymbolFile(
                 module_spec, kernel_search_error, true)) {
           if (FileSystem::Instance().Exists(module_spec.GetFileSpec())) {

>From d25a2a07df0c290e450830eb24dda141b4c5359c Mon Sep 17 00:00:00 2001
From: Jason Molenda <[email protected]>
Date: Thu, 16 Jul 2026 16:32:43 -0700
Subject: [PATCH 2/4] ws fix

---
 lldb/source/Core/DynamicLoader.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Core/DynamicLoader.cpp 
b/lldb/source/Core/DynamicLoader.cpp
index 1ece89c9122ef..ff3c0ecd03ec7 100644
--- a/lldb/source/Core/DynamicLoader.cpp
+++ b/lldb/source/Core/DynamicLoader.cpp
@@ -283,7 +283,7 @@ ModuleSP DynamicLoader::LoadBinaryWithUUIDAndAddress(
 
     // If we haven't found a binary, or we don't have a SymbolFile, see
     // if there is an external search tool that can find it.
-    if (!module_sp || !module_sp->GetSymbolFile(/*can_create=*/ false)) {
+    if (!module_sp || !module_sp->GetSymbolFile(/*can_create=*/false)) {
       PluginManager::DownloadObjectAndSymbolFile(module_spec, error,
                                                  force_symbol_search);
       if (FileSystem::Instance().Exists(module_spec.GetFileSpec())) {

>From 90dd8abaaaeb23806695e4caa9bcfe63a361f059 Mon Sep 17 00:00:00 2001
From: Jason Molenda <[email protected]>
Date: Thu, 16 Jul 2026 16:35:31 -0700
Subject: [PATCH 3/4] Pass `can_create=true` to GetSymbolFile. If no one has
 requested the SymbolFile yet, and it is a debug-info-in-ObjectFile, we need
 to pass this to get back a SymbolFile*.

---
 lldb/source/Core/DynamicLoader.cpp                              | 2 +-
 .../DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Core/DynamicLoader.cpp 
b/lldb/source/Core/DynamicLoader.cpp
index ff3c0ecd03ec7..c82614804f6d7 100644
--- a/lldb/source/Core/DynamicLoader.cpp
+++ b/lldb/source/Core/DynamicLoader.cpp
@@ -283,7 +283,7 @@ ModuleSP DynamicLoader::LoadBinaryWithUUIDAndAddress(
 
     // If we haven't found a binary, or we don't have a SymbolFile, see
     // if there is an external search tool that can find it.
-    if (!module_sp || !module_sp->GetSymbolFile(/*can_create=*/false)) {
+    if (!module_sp || !module_sp->GetSymbolFile(/*can_create=*/true)) {
       PluginManager::DownloadObjectAndSymbolFile(module_spec, error,
                                                  force_symbol_search);
       if (FileSystem::Instance().Exists(module_spec.GetFileSpec())) {
diff --git 
a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp 
b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
index 9f5d3f74ec86d..a92dc46669060 100644
--- 
a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ 
b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -830,7 +830,7 @@ bool 
DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule(
       // set.
       Status kernel_search_error;
       if (IsKernel() &&
-          (!m_module_sp || !m_module_sp->GetSymbolFile(/*can_create=*/false))) 
{
+          (!m_module_sp || !m_module_sp->GetSymbolFile(/*can_create=*/true))) {
         if (PluginManager::DownloadObjectAndSymbolFile(
                 module_spec, kernel_search_error, true)) {
           if (FileSystem::Instance().Exists(module_spec.GetFileSpec())) {

>From 1443c64e9d65258abc152a103f8f12eb65f88b43 Mon Sep 17 00:00:00 2001
From: Jason Molenda <[email protected]>
Date: Thu, 16 Jul 2026 20:49:13 -0700
Subject: [PATCH 4/4] add comment about GetSymbolFileFileSpec

---
 lldb/include/lldb/Core/Module.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h
index 33904ef7be5d8..90c395f7a90c3 100644
--- a/lldb/include/lldb/Core/Module.h
+++ b/lldb/include/lldb/Core/Module.h
@@ -474,6 +474,13 @@ class Module : public std::enable_shared_from_this<Module>,
     m_remote_install_file = file;
   }
 
+  /// Return the FileSpec for the SymbolFile, if this Module has one.
+  /// A Module may have debug information from the ObjectFile; do not
+  /// use the presence of a SymbolFile FileSpec as a way to detect if
+  /// debug information is present.  Module::GetSymbolFile will return
+  /// the binary that contains debug information, which may be the
+  /// same result that Module::GetObjectFile returns when they are in
+  /// the same binary.
   const FileSpec &GetSymbolFileFileSpec() const { return m_symfile_spec; }
 
   ModuleSpecList GetSeparateDebugInfoFiles();

_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to