[Lldb-commits] [lldb] [lldb] Don't report missing object files for shared cache images (PR #237298)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 30 10:03:05 PDT 2026


https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/237298

eb5f248268fb reports an error when a debug map object file does not exist. Unstripped shared cache images have N_OSO entries that point at object files from the OS build. Users have no control over these images, so the error is noise they can't act on.

Skip the report for images with MH_DYLIB_IN_CACHE. LLDB still records the error for "image dump separate-debug-info" and "frame variable". Checking the install name instead would also silence locally built roots at shared cache eligible paths. Those aren't in the cache, and their owners can fix them.

rdar://189926934

>From 7e1f1bf003f253f1b61f81db70cea75c4285b030 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Fri, 30 Oct 2026 10:01:26 -0700
Subject: [PATCH] [lldb] Don't report missing object files for shared cache
 images

eb5f248268fb reports an error when a debug map object file does not
exist. Unstripped shared cache images have N_OSO entries that point at
object files from the OS build. Users have no control over these
images, so the error is noise they can't act on.

Skip the report for images with MH_DYLIB_IN_CACHE. LLDB still records
the error for "image dump separate-debug-info" and "frame variable".
Checking the install name instead would also silence locally built
roots at shared cache eligible paths. Those aren't in the cache, and
their owners can fix them.

rdar://189926934
---
 lldb/include/lldb/Symbol/ObjectFile.h            |  3 +++
 .../Plugins/ObjectFile/Mach-O/ObjectFileMachO.h  |  2 +-
 .../SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp |  7 +++++--
 .../DWARF/missing-oso-shared-cache.cpp           | 16 ++++++++++++++++
 4 files changed, 25 insertions(+), 3 deletions(-)
 create mode 100644 lldb/test/Shell/SymbolFile/DWARF/missing-oso-shared-cache.cpp

diff --git a/lldb/include/lldb/Symbol/ObjectFile.h b/lldb/include/lldb/Symbol/ObjectFile.h
index f626d0395ecf6a..a2f8dc2b619ee1 100644
--- a/lldb/include/lldb/Symbol/ObjectFile.h
+++ b/lldb/include/lldb/Symbol/ObjectFile.h
@@ -261,6 +261,9 @@ class ObjectFile : public std::enable_shared_from_this<ObjectFile>,
   ///     \b true if it is, \b false otherwise.
   virtual bool IsExecutable() const = 0;
 
+  /// Tells whether this object file is part of a shared cache.
+  virtual bool IsSharedCacheBinary() const { return false; }
+
   /// Returns the offset into a file at which this object resides.
   ///
   /// Some files contain many object files, and this function allows access to
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
index bcc76d7e4bec2f..04c9262d2b3e61 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
@@ -88,7 +88,7 @@ class ObjectFileMachO : public lldb_private::ObjectFile {
 
   bool IsDynamicLoader() const;
 
-  bool IsSharedCacheBinary() const;
+  bool IsSharedCacheBinary() const override;
 
   bool IsKext() const;
 
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index b6f72a5cc4a2ac..6caaedffac7535 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -451,8 +451,11 @@ Module *SymbolFileDWARFDebugMap::GetModuleByCompUnitInfo(
               "debug map object file \"%s\" containing debug info does not "
               "exist, debug info will not be loaded",
               comp_unit_info->oso_path.GetCString());
-          obj_file->GetModule()->ReportError(
-              "{0}", comp_unit_info->oso_load_error.AsCString());
+          // Users have no control over shared cache images, so the error is
+          // not actionable.
+          if (!obj_file->IsSharedCacheBinary())
+            obj_file->GetModule()->ReportError(
+                "{0}", comp_unit_info->oso_load_error.AsCString());
           return nullptr;
         }
       }
diff --git a/lldb/test/Shell/SymbolFile/DWARF/missing-oso-shared-cache.cpp b/lldb/test/Shell/SymbolFile/DWARF/missing-oso-shared-cache.cpp
new file mode 100644
index 00000000000000..d14c8246a42b9a
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/missing-oso-shared-cache.cpp
@@ -0,0 +1,16 @@
+// Test that lldb does not report missing debug map object files for shared
+// cache images, but still records the error.
+// REQUIRES: system-darwin
+// RUN: %clang_host %s -g -c -o %t.o
+// RUN: %clang_host %t.o -g -o %t
+// RUN: rm %t.o
+// Set MH_DYLIB_IN_CACHE in the Mach-O header flags.
+// RUN: %python -c "import sys; f = open(sys.argv[1], 'r+b'); f.seek(24); flags = int.from_bytes(f.read(4), 'little'); f.seek(24); f.write((flags | 0x80000000).to_bytes(4, 'little'))" %t
+// RUN: %lldb %t -o "breakpoint set -f %s -l 16" \
+// RUN:   -o "image dump separate-debug-info --errors-only" -o exit 2>&1 \
+// RUN:   | FileCheck %s --implicit-check-not=error:
+
+// CHECK: (lldb) image dump separate-debug-info --errors-only
+// CHECK: E debug map object file "{{.*}}.o" containing debug info does not exist
+
+int main() { return 0; }



More information about the lldb-commits mailing list