llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: Jason Molenda (jasonmolenda) <details> <summary>Changes</summary> I introduced a dependency from Host on Core without realizing it in an earlier PR, while adding a setting to disable the new shared cache binary blob scanning/reading in HostInfoMacOSX, which caused build problems. Thanks to Alex for figuring out the build failure I caused. Add a bool to the methods in HostInfoMacOSX, and have the callers (in Core and various plugins etc) all fetch the symbols.shared-cache-binary-loading setting from ModuleList, and pass the result in. The least obvious part of this is in ProcessGDBRemote where we first learn the shared cache filepath & uuid, it calls HostInfoMacOSX::SharedCacheIndexFiles() - this is only called when the shared cache binary loading is enabled, so I conditionalize the call to this method based on the setting. rdar://148939795 --- Full diff: https://github.com/llvm/llvm-project/pull/181406.diff 8 Files Affected: - (modified) lldb/include/lldb/Host/HostInfoBase.h (+14-2) - (modified) lldb/include/lldb/Host/macosx/HostInfoMacOSX.h (+4-2) - (modified) lldb/source/Host/macosx/objcxx/CMakeLists.txt (-1) - (modified) lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm (+16-16) - (modified) lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp (+4-2) - (modified) lldb/source/Plugins/Platform/MacOSX/PlatformDarwinDevice.cpp (+5-2) - (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (+5-1) - (modified) lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp (+8-2) ``````````diff diff --git a/lldb/include/lldb/Host/HostInfoBase.h b/lldb/include/lldb/Host/HostInfoBase.h index bc80e5e62ed39..d88bc27a2757f 100644 --- a/lldb/include/lldb/Host/HostInfoBase.h +++ b/lldb/include/lldb/Host/HostInfoBase.h @@ -185,16 +185,28 @@ class HostInfoBase { /// Return information about module \p image_name if it is loaded in /// the current process's address space. + /// + /// \param[in] use_sc_binary_directly + /// Flag to control if this method can try to read a shared + /// cache binary blob directly, needed to keep user settings out of + /// Host. static SharedCacheImageInfo - GetSharedCacheImageInfo(llvm::StringRef image_name) { + GetSharedCacheImageInfo(llvm::StringRef image_name, + bool use_sc_binary_directly) { return {}; } /// Return information about module \p image_name if it is loaded in /// the current process's address space using shared cache \p uuid. /// The shared cache UUID must have been previously indexed. + /// + /// \param[in] use_sc_binary_directly + /// Flag to control if this method can try to read a shared + /// cache binary blob directly, needed to keep user settings out of + /// Host. static SharedCacheImageInfo - GetSharedCacheImageInfo(llvm::StringRef image_name, const UUID &uuid) { + GetSharedCacheImageInfo(llvm::StringRef image_name, const UUID &uuid, + bool use_sc_binary_directly) { return {}; } diff --git a/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h b/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h index c58056cb492b7..9fcf922d00b80 100644 --- a/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h +++ b/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h @@ -43,10 +43,12 @@ class HostInfoMacOSX : public HostInfoPosix { /// Shared cache utilities static SharedCacheImageInfo - GetSharedCacheImageInfo(llvm::StringRef image_name); + GetSharedCacheImageInfo(llvm::StringRef image_name, + bool use_sc_binary_directly); static SharedCacheImageInfo - GetSharedCacheImageInfo(llvm::StringRef image_name, const UUID &uuid); + GetSharedCacheImageInfo(llvm::StringRef image_name, const UUID &uuid, + bool use_sc_binary_directly); static bool SharedCacheIndexFiles(FileSpec &filepath, UUID &uuid); diff --git a/lldb/source/Host/macosx/objcxx/CMakeLists.txt b/lldb/source/Host/macosx/objcxx/CMakeLists.txt index a47a1e5086eee..1d7573335b8ec 100644 --- a/lldb/source/Host/macosx/objcxx/CMakeLists.txt +++ b/lldb/source/Host/macosx/objcxx/CMakeLists.txt @@ -14,7 +14,6 @@ add_lldb_library(lldbHostMacOSXObjCXX NO_PLUGIN_DEPENDENCIES Support TargetParser LINK_LIBS - lldbCore lldbUtility ${EXTRA_LIBS} ) diff --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm index d37062b152a00..dc81d831f0638 100644 --- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm +++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include "lldb/Host/macosx/HostInfoMacOSX.h" -#include "lldb/Core/ModuleList.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" @@ -702,7 +701,7 @@ bool GetImages(llvm::StringMap<SharedCacheImageInfo> **images, /// system, open it and add all of the binary images to m_caches. bool CreateSharedCacheImageList(UUID uuid, std::string filepath); - SharedCacheInfo(); + SharedCacheInfo(bool use_sc_binary_directly); private: bool CreateSharedCacheInfoWithInstrospectionSPIs(); @@ -721,7 +720,7 @@ bool GetImages(llvm::StringMap<SharedCacheImageInfo> **images, } // namespace -SharedCacheInfo::SharedCacheInfo() { +SharedCacheInfo::SharedCacheInfo(bool use_sc_binary_directly) { // macOS 26.4 and newer m_dyld_image_retain_4HWTrace = (void (*)(void *))dlsym(RTLD_DEFAULT, "dyld_image_retain_4HWTrace"); @@ -735,9 +734,7 @@ bool GetImages(llvm::StringMap<SharedCacheImageInfo> **images, _dyld_get_shared_cache_uuid(dsc_uuid); m_host_uuid = UUID(dsc_uuid); - if (ModuleList::GetGlobalModuleListProperties() - .GetSharedCacheBinaryLoading() && - CreateHostSharedCacheImageList()) + if (use_sc_binary_directly && CreateHostSharedCacheImageList()) return; if (CreateSharedCacheInfoWithInstrospectionSPIs()) @@ -973,21 +970,24 @@ static dispatch_data_t (*g_dyld_image_segment_data_4HWTrace)( }); } -SharedCacheInfo &GetSharedCacheSingleton() { - static SharedCacheInfo g_shared_cache_info; +SharedCacheInfo &GetSharedCacheSingleton(bool use_sc_binary_directly) { + static SharedCacheInfo g_shared_cache_info(use_sc_binary_directly); return g_shared_cache_info; } SharedCacheImageInfo -HostInfoMacOSX::GetSharedCacheImageInfo(llvm::StringRef image_name) { - return GetSharedCacheSingleton().GetImages().lookup(image_name); +HostInfoMacOSX::GetSharedCacheImageInfo(llvm::StringRef image_name, + bool use_sc_binary_directly) { + return GetSharedCacheSingleton(use_sc_binary_directly) + .GetImages() + .lookup(image_name); } -SharedCacheImageInfo -HostInfoMacOSX::GetSharedCacheImageInfo(llvm::StringRef image_name, - const UUID &uuid) { +SharedCacheImageInfo HostInfoMacOSX::GetSharedCacheImageInfo( + llvm::StringRef image_name, const UUID &uuid, bool use_sc_binary_directly) { llvm::StringMap<SharedCacheImageInfo> *shared_cache_info; - if (GetSharedCacheSingleton().GetImages(&shared_cache_info, uuid)) + if (GetSharedCacheSingleton(use_sc_binary_directly) + .GetImages(&shared_cache_info, uuid)) return shared_cache_info->lookup(image_name); return {}; } @@ -998,7 +998,7 @@ static dispatch_data_t (*g_dyld_image_segment_data_4HWTrace)( // cache is installed. So require that we are given a filepath of // the shared cache. if (FileSystem::Instance().Exists(filepath)) - return GetSharedCacheSingleton().CreateSharedCacheImageList( - uuid, filepath.GetPath()); + return GetSharedCacheSingleton(/*use_sc_binary_directly=*/true) + .CreateSharedCacheImageList(uuid, filepath.GetPath()); return false; } diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp index 0a8aa51a1469c..70a6cf8ebc57c 100644 --- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp @@ -141,14 +141,16 @@ ModuleSP DynamicLoaderDarwin::FindTargetModuleForImageInfo( LazyBool using_sc; LazyBool private_sc; FileSpec sc_path; + bool use_sc_binary_directly = ModuleList::GetGlobalModuleListProperties() + .GetSharedCacheBinaryLoading(); if (GetSharedCacheInformation(sc_base_addr, sc_uuid, using_sc, private_sc, sc_path) && sc_uuid) image_info = HostInfo::GetSharedCacheImageInfo( - module_spec.GetFileSpec().GetPath(), sc_uuid); + module_spec.GetFileSpec().GetPath(), sc_uuid, use_sc_binary_directly); else image_info = HostInfo::GetSharedCacheImageInfo( - module_spec.GetFileSpec().GetPath()); + module_spec.GetFileSpec().GetPath(), use_sc_binary_directly); // If we found it and it has the correct UUID, let's proceed with // creating a module from the memory contents. diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinDevice.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinDevice.cpp index 59d2f9ed9d856..f81167f7443fd 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinDevice.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinDevice.cpp @@ -319,6 +319,8 @@ lldb_private::Status PlatformDarwinDevice::GetSharedModuleWithLocalCache( // exist on the filesystem, so let's use the images in our own memory // to create the modules. + bool use_sc_binary_directly = ModuleList::GetGlobalModuleListProperties() + .GetSharedCacheBinaryLoading(); SharedCacheImageInfo image_info; if (process && process->GetDynamicLoader()) { addr_t sc_base_addr; @@ -328,12 +330,13 @@ lldb_private::Status PlatformDarwinDevice::GetSharedModuleWithLocalCache( if (process->GetDynamicLoader()->GetSharedCacheInformation( sc_base_addr, sc_uuid, using_sc, private_sc, sc_path)) image_info = HostInfo::GetSharedCacheImageInfo( - module_spec.GetFileSpec().GetPath(), sc_uuid); + module_spec.GetFileSpec().GetPath(), sc_uuid, + use_sc_binary_directly); } if (!image_info.GetUUID()) image_info = HostInfo::GetSharedCacheImageInfo( - module_spec.GetFileSpec().GetPath()); + module_spec.GetFileSpec().GetPath(), use_sc_binary_directly); // If we found it and it has the correct UUID, let's proceed with // creating a module from the memory contents. diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 767684e01ee3b..65d0ed6f51c79 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -4375,9 +4375,13 @@ StructuredData::ObjectSP ProcessGDBRemote::GetSharedCacheInfo() { FileSpec sc_path( dict->GetValueForKey("shared_cache_path")->GetStringValue()); + bool use_sc_binary_directly = + ModuleList::GetGlobalModuleListProperties() + .GetSharedCacheBinaryLoading(); // Attempt to open the shared cache at sc_path, and // if the uuid matches, index all the files. - HostInfo::SharedCacheIndexFiles(sc_path, uuid); + if (use_sc_binary_directly) + HostInfo::SharedCacheIndexFiles(sc_path, uuid); } m_shared_cache_info_sp = response_sp; } diff --git a/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp b/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp index f4b572c9e88ac..d885e5bfe5ee3 100644 --- a/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp +++ b/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp @@ -203,8 +203,11 @@ std::optional<ModuleSpec> SymbolLocatorDebugSymbols::LocateExecutableObjectFile( // Check if the requested image is in our shared cache. if (!success) { + bool use_sc_binary_directly = + ModuleList::GetGlobalModuleListProperties() + .GetSharedCacheBinaryLoading(); SharedCacheImageInfo image_info = HostInfo::GetSharedCacheImageInfo( - module_spec.GetFileSpec().GetPath()); + module_spec.GetFileSpec().GetPath(), use_sc_binary_directly); // If we found it and it has the correct UUID, let's proceed with // creating a module from the memory contents. @@ -646,8 +649,11 @@ static int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec &module_spec, // Check if the requested image is in our shared cache. if (!success) { + bool use_sc_binary_directly = + ModuleList::GetGlobalModuleListProperties() + .GetSharedCacheBinaryLoading(); SharedCacheImageInfo image_info = HostInfo::GetSharedCacheImageInfo( - module_spec.GetFileSpec().GetPath()); + module_spec.GetFileSpec().GetPath(), use_sc_binary_directly); // If we found it and it has the correct UUID, let's proceed with // creating a module from the memory contents. `````````` </details> https://github.com/llvm/llvm-project/pull/181406 _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
