From 0f1a17bdeacdfcca77424021204d181094558fdb Mon Sep 17 00:00:00 2001 From: Tom Yang Date: Tue, 14 Oct 2025 00:13:03 -0700 Subject: [PATCH 1/7] move preload out of GetOrCreateModules and parallelize Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D86004440 --- lldb/include/lldb/Core/ModuleList.h | 3 ++ lldb/include/lldb/Target/DynamicLoader.h | 17 +++++++- lldb/include/lldb/Target/Target.h | 10 ++++- lldb/source/Core/DynamicLoader.cpp | 12 ++++-- lldb/source/Core/ModuleList.cpp | 13 ++++++ .../POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp | 40 ++++++++++++------- .../POSIX-DYLD/DynamicLoaderPOSIXDYLD.h | 9 +++-- .../wasm-DYLD/DynamicLoaderWasmDYLD.cpp | 6 ++- .../wasm-DYLD/DynamicLoaderWasmDYLD.h | 9 +++-- lldb/source/Target/Target.cpp | 6 ++- 10 files changed, 91 insertions(+), 34 deletions(-) diff --git a/lldb/include/lldb/Core/ModuleList.h b/lldb/include/lldb/Core/ModuleList.h index df473dff091f8..74fb642b2efaa 100644 --- a/lldb/include/lldb/Core/ModuleList.h +++ b/lldb/include/lldb/Core/ModuleList.h @@ -511,6 +511,9 @@ class ModuleList { /// Atomically swaps the contents of this module list with \a other. void Swap(ModuleList &other); + /// For each module in this ModuleList, preload its symbols. + void PreloadSymbols() const; + protected: // Class typedefs. typedef std::vector diff --git a/lldb/include/lldb/Target/DynamicLoader.h b/lldb/include/lldb/Target/DynamicLoader.h index 75bb6cb6bb907..271d5f761696c 100644 --- a/lldb/include/lldb/Target/DynamicLoader.h +++ b/lldb/include/lldb/Target/DynamicLoader.h @@ -207,10 +207,17 @@ class DynamicLoader : public PluginInterface { /// resulting module at the virtual base address \p base_addr. /// Note that this calls Target::GetOrCreateModule with notify being false, /// so it is necessary to call Target::ModulesDidLoad afterwards. + /// + /// \param[in] defer_module_preload + /// If the module needs to be loaded, prevent the module from being + /// preloaded even if the user sets the preload symbols option. This is + /// used as a performance optimization should the caller preload the + /// modules in parallel after calling this function. virtual lldb::ModuleSP LoadModuleAtAddress(const lldb_private::FileSpec &file, lldb::addr_t link_map_addr, lldb::addr_t base_addr, - bool base_addr_is_offset); + bool base_addr_is_offset, + bool defer_module_preload = false); /// Find/load a binary into lldb given a UUID and the address where it is /// loaded in memory, or a slide to be applied to the file address. @@ -352,7 +359,13 @@ class DynamicLoader : public PluginInterface { protected: // Utility methods for derived classes - lldb::ModuleSP FindModuleViaTarget(const FileSpec &file); + /// Find a module in the target that matches the given file. + /// + /// \param[in] defer_module_preload + /// If the module needs to be loaded, prevent the module from being + /// preloaded even if the user sets the preload symbols option. + lldb::ModuleSP FindModuleViaTarget(const FileSpec &file, + bool defer_module_preload = false); /// Checks to see if the target module has changed, updates the target /// accordingly and returns the target executable module. diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index 40f9c9bea1c12..207738d4a127e 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -649,12 +649,20 @@ class Target : public std::enable_shared_from_this, /// will handle / summarize the failures in a custom way and /// don't use these messages. /// + /// \param[in] defer_preload + /// If true, the module will not be preloaded even if + /// Target::GetPreloadSymbols() is true. This is useful when the caller + /// wishes to preload loaded modules in parallel after calling this + /// function for better performance. This is because it's currently not + /// thread-safe to do so during the execution of this function. + /// /// \return /// An empty ModuleSP will be returned if no matching file /// was found. If error_ptr was non-nullptr, an error message /// will likely be provided. lldb::ModuleSP GetOrCreateModule(const ModuleSpec &module_spec, bool notify, - Status *error_ptr = nullptr); + Status *error_ptr = nullptr, + bool defer_preload = false); // Settings accessors diff --git a/lldb/source/Core/DynamicLoader.cpp b/lldb/source/Core/DynamicLoader.cpp index b309e0f0a72fd..d9c21158d4c5e 100644 --- a/lldb/source/Core/DynamicLoader.cpp +++ b/lldb/source/Core/DynamicLoader.cpp @@ -154,7 +154,8 @@ DynamicLoader::GetSectionListFromModule(const ModuleSP module) const { return sections; } -ModuleSP DynamicLoader::FindModuleViaTarget(const FileSpec &file) { +ModuleSP DynamicLoader::FindModuleViaTarget(const FileSpec &file, + bool defer_module_preload) { Target &target = m_process->GetTarget(); ModuleSpec module_spec(file, target.GetArchitecture()); if (UUID uuid = m_process->FindModuleUUID(file.GetPath())) { @@ -165,7 +166,9 @@ ModuleSP DynamicLoader::FindModuleViaTarget(const FileSpec &file) { if (ModuleSP module_sp = target.GetImages().FindFirstModule(module_spec)) return module_sp; - if (ModuleSP module_sp = target.GetOrCreateModule(module_spec, false)) + if (ModuleSP module_sp = target.GetOrCreateModule( + module_spec, false /* notify */, nullptr /* error_ptr */, + defer_module_preload)) return module_sp; return nullptr; @@ -174,8 +177,9 @@ ModuleSP DynamicLoader::FindModuleViaTarget(const FileSpec &file) { ModuleSP DynamicLoader::LoadModuleAtAddress(const FileSpec &file, addr_t link_map_addr, addr_t base_addr, - bool base_addr_is_offset) { - if (ModuleSP module_sp = FindModuleViaTarget(file)) { + bool base_addr_is_offset, + bool defer_module_preload) { + if (ModuleSP module_sp = FindModuleViaTarget(file, defer_module_preload)) { UpdateLoadedSections(module_sp, link_map_addr, base_addr, base_addr_is_offset); return module_sp; diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index d9f845681e701..c6f081ae03877 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -6,6 +6,7 @@ // //===----------------------------------------------------------------------===// +#include "lldb/Core/Debugger.h" #include "lldb/Core/ModuleList.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" @@ -15,6 +16,7 @@ #include "lldb/Interpreter/OptionValueFileSpecList.h" #include "lldb/Interpreter/OptionValueProperties.h" #include "lldb/Interpreter/Property.h" +#include "llvm/Support/ThreadPool.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/TypeList.h" @@ -1381,3 +1383,14 @@ void ModuleList::Swap(ModuleList &other) { m_modules_mutex, other.m_modules_mutex); m_modules.swap(other.m_modules); } + +void ModuleList::PreloadSymbols() const { + std::lock_guard guard(m_modules_mutex); + llvm::ThreadPoolTaskGroup task_group(Debugger::GetThreadPool()); + for (const ModuleSP &module_sp : m_modules) + task_group.async([module_sp] { + if (module_sp) + module_sp->PreloadSymbols(); + }); + // task group destructor waits for all tasks to complete +} diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp index 470fc2a2fdbb9..ddd0fbd5bcf35 100644 --- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp @@ -453,7 +453,8 @@ void DynamicLoaderPOSIXDYLD::RefreshModules() { // exists for the duration of this call in `m_rendezvous`. auto load_module_fn = [this, &loaded_modules, &new_modules, - &interpreter_module_mutex](const DYLDRendezvous::SOEntry &so_entry) { + &interpreter_module_mutex](const DYLDRendezvous::SOEntry &so_entry, + bool defer_module_preload) { // Don't load a duplicate copy of ld.so if we have already loaded it // earlier in LoadInterpreterModule. If we instead loaded then // unloaded it later, the section information for ld.so would be @@ -469,7 +470,8 @@ void DynamicLoaderPOSIXDYLD::RefreshModules() { } ModuleSP module_sp = LoadModuleAtAddress( - so_entry.file_spec, so_entry.link_addr, so_entry.base_addr, true); + so_entry.file_spec, so_entry.link_addr, so_entry.base_addr, + true /* base_addr_is_offset */, defer_module_preload); if (!module_sp.get()) return; @@ -503,11 +505,14 @@ void DynamicLoaderPOSIXDYLD::RefreshModules() { if (m_process->GetTarget().GetParallelModuleLoad()) { llvm::ThreadPoolTaskGroup task_group(Debugger::GetThreadPool()); for (; I != E; ++I) - task_group.async(load_module_fn, *I); + task_group.async(load_module_fn, *I, true /* defer_module_preload */); task_group.wait(); + + if (m_process->GetTarget().GetPreloadSymbols()) + new_modules.PreloadSymbols(); } else { for (; I != E; ++I) - load_module_fn(*I); + load_module_fn(*I, false /* defer_module_preload */); } m_process->GetTarget().ModulesDidLoad(new_modules); @@ -644,12 +649,12 @@ ModuleSP DynamicLoaderPOSIXDYLD::LoadInterpreterModule() { return nullptr; } -ModuleSP DynamicLoaderPOSIXDYLD::LoadModuleAtAddress(const FileSpec &file, - addr_t link_map_addr, - addr_t base_addr, - bool base_addr_is_offset) { +ModuleSP DynamicLoaderPOSIXDYLD::LoadModuleAtAddress( + const FileSpec &file, addr_t link_map_addr, addr_t base_addr, + bool base_addr_is_offset, bool defer_module_preload) { if (ModuleSP module_sp = DynamicLoader::LoadModuleAtAddress( - file, link_map_addr, base_addr, base_addr_is_offset)) + file, link_map_addr, base_addr, base_addr_is_offset, + defer_module_preload)) return module_sp; // This works around an dynamic linker "bug" on android <= 23, where the @@ -668,7 +673,7 @@ ModuleSP DynamicLoaderPOSIXDYLD::LoadModuleAtAddress(const FileSpec &file, !(memory_info.GetName().IsEmpty())) { if (ModuleSP module_sp = DynamicLoader::LoadModuleAtAddress( FileSpec(memory_info.GetName().GetStringRef()), link_map_addr, - base_addr, base_addr_is_offset)) + base_addr, base_addr_is_offset, defer_module_preload)) return module_sp; } } @@ -704,9 +709,11 @@ void DynamicLoaderPOSIXDYLD::LoadAllCurrentModules() { module_names, m_process->GetTarget().GetArchitecture().GetTriple()); auto load_module_fn = [this, &module_list, - &log](const DYLDRendezvous::SOEntry &so_entry) { - ModuleSP module_sp = LoadModuleAtAddress( - so_entry.file_spec, so_entry.link_addr, so_entry.base_addr, true); + &log](const DYLDRendezvous::SOEntry &so_entry, + bool defer_module_preload) { + ModuleSP module_sp = + LoadModuleAtAddress(so_entry.file_spec, so_entry.link_addr, + so_entry.base_addr, true, defer_module_preload); if (module_sp.get()) { LLDB_LOG(log, "LoadAllCurrentModules loading module: {0}", so_entry.file_spec.GetFilename()); @@ -723,11 +730,14 @@ void DynamicLoaderPOSIXDYLD::LoadAllCurrentModules() { if (m_process->GetTarget().GetParallelModuleLoad()) { llvm::ThreadPoolTaskGroup task_group(Debugger::GetThreadPool()); for (I = m_rendezvous.begin(), E = m_rendezvous.end(); I != E; ++I) - task_group.async(load_module_fn, *I); + task_group.async(load_module_fn, *I, true /* defer_module_preload */); task_group.wait(); + + if (m_process->GetTarget().GetPreloadSymbols()) + module_list.PreloadSymbols(); } else { for (I = m_rendezvous.begin(), E = m_rendezvous.end(); I != E; ++I) { - load_module_fn(*I); + load_module_fn(*I, false /* defer_module_preload */); } } diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h index 6efb92673a13c..2d9dba9bca9fa 100644 --- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h +++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h @@ -55,10 +55,11 @@ class DynamicLoaderPOSIXDYLD : public lldb_private::DynamicLoader { // PluginInterface protocol llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); } - lldb::ModuleSP LoadModuleAtAddress(const lldb_private::FileSpec &file, - lldb::addr_t link_map_addr, - lldb::addr_t base_addr, - bool base_addr_is_offset) override; + lldb::ModuleSP + LoadModuleAtAddress(const lldb_private::FileSpec &file, + lldb::addr_t link_map_addr, lldb::addr_t base_addr, + bool base_addr_is_offset, + bool defer_module_preload = false) override; void CalculateDynamicSaveCoreRanges( lldb_private::Process &process, diff --git a/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp b/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp index d019415cb67a6..09cde464ccdc8 100644 --- a/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp @@ -67,9 +67,11 @@ ThreadPlanSP DynamicLoaderWasmDYLD::GetStepThroughTrampolinePlan(Thread &thread, lldb::ModuleSP DynamicLoaderWasmDYLD::LoadModuleAtAddress( const lldb_private::FileSpec &file, lldb::addr_t link_map_addr, - lldb::addr_t base_addr, bool base_addr_is_offset) { + lldb::addr_t base_addr, bool base_addr_is_offset, + bool defer_module_preload) { if (ModuleSP module_sp = DynamicLoader::LoadModuleAtAddress( - file, link_map_addr, base_addr, base_addr_is_offset)) + file, link_map_addr, base_addr, base_addr_is_offset, + defer_module_preload)) return module_sp; if (ModuleSP module_sp = m_process->ReadModuleFromMemory(file, base_addr)) { diff --git a/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.h b/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.h index 5ed855395cca7..9c13bdff0279a 100644 --- a/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.h +++ b/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.h @@ -33,10 +33,11 @@ class DynamicLoaderWasmDYLD : public DynamicLoader { Status CanLoadImage() override { return Status(); } lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread, bool stop) override; - lldb::ModuleSP LoadModuleAtAddress(const lldb_private::FileSpec &file, - lldb::addr_t link_map_addr, - lldb::addr_t base_addr, - bool base_addr_is_offset) override; + lldb::ModuleSP + LoadModuleAtAddress(const lldb_private::FileSpec &file, + lldb::addr_t link_map_addr, lldb::addr_t base_addr, + bool base_addr_is_offset, + bool defer_module_preload = false) override; /// \} diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 3b51e17d1c4e0..49f0f4f4b788d 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -2343,7 +2343,8 @@ bool Target::ReadPointerFromMemory(const Address &addr, Status &error, } ModuleSP Target::GetOrCreateModule(const ModuleSpec &orig_module_spec, - bool notify, Status *error_ptr) { + bool notify, Status *error_ptr, + bool defer_preload) { ModuleSP module_sp; Status error; @@ -2511,8 +2512,9 @@ ModuleSP Target::GetOrCreateModule(const ModuleSpec &orig_module_spec, // Preload symbols outside of any lock, so hopefully we can do this for // each library in parallel. - if (GetPreloadSymbols()) + if (GetPreloadSymbols() && !defer_preload) module_sp->PreloadSymbols(); + llvm::SmallVector replaced_modules; for (ModuleSP &old_module_sp : old_modules) { if (m_images.GetIndexForModule(old_module_sp.get()) != From fd2e0ce2d20a3caf54e8e15c75aab2e79d641767 Mon Sep 17 00:00:00 2001 From: Tom Yang Date: Tue, 4 Nov 2025 23:47:31 -0800 Subject: [PATCH 2/7] formatting fix Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- lldb/source/Core/ModuleList.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index c6f081ae03877..11c7a247daa02 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Core/Debugger.h" #include "lldb/Core/ModuleList.h" +#include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" @@ -16,7 +16,6 @@ #include "lldb/Interpreter/OptionValueFileSpecList.h" #include "lldb/Interpreter/OptionValueProperties.h" #include "lldb/Interpreter/Property.h" -#include "llvm/Support/ThreadPool.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/TypeList.h" @@ -30,6 +29,7 @@ #include "lldb/Utility/Log.h" #include "lldb/Utility/UUID.h" #include "lldb/lldb-defines.h" +#include "llvm/Support/ThreadPool.h" #if defined(_WIN32) #include "lldb/Host/windows/PosixApi.h" From fff56d60e80a021a13810252f47355e06d977068 Mon Sep 17 00:00:00 2001 From: Tom Yang Date: Wed, 12 Nov 2025 10:24:04 -0800 Subject: [PATCH 3/7] remove defer_module_preload bool flag, remove preload from Target::GetOrCreateModule Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- lldb/include/lldb/Core/ModuleList.h | 5 +- lldb/include/lldb/Target/DynamicLoader.h | 15 +----- lldb/include/lldb/Target/Target.h | 10 +--- lldb/source/Core/DynamicLoader.cpp | 11 ++-- lldb/source/Core/ModuleList.cpp | 10 +++- .../POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp | 50 +++++++++---------- .../POSIX-DYLD/DynamicLoaderPOSIXDYLD.h | 9 ++-- .../wasm-DYLD/DynamicLoaderWasmDYLD.cpp | 9 ++-- .../wasm-DYLD/DynamicLoaderWasmDYLD.h | 9 ++-- lldb/source/Target/Target.cpp | 8 +-- 10 files changed, 57 insertions(+), 79 deletions(-) diff --git a/lldb/include/lldb/Core/ModuleList.h b/lldb/include/lldb/Core/ModuleList.h index 74fb642b2efaa..1ef90b469c70c 100644 --- a/lldb/include/lldb/Core/ModuleList.h +++ b/lldb/include/lldb/Core/ModuleList.h @@ -512,7 +512,10 @@ class ModuleList { void Swap(ModuleList &other); /// For each module in this ModuleList, preload its symbols. - void PreloadSymbols() const; + /// + /// \param[in] parallelize + /// If true, all modules will be preloaded in parallel. + void PreloadSymbols(bool parallelize) const; protected: // Class typedefs. diff --git a/lldb/include/lldb/Target/DynamicLoader.h b/lldb/include/lldb/Target/DynamicLoader.h index 271d5f761696c..e07bbf099cf60 100644 --- a/lldb/include/lldb/Target/DynamicLoader.h +++ b/lldb/include/lldb/Target/DynamicLoader.h @@ -208,16 +208,10 @@ class DynamicLoader : public PluginInterface { /// Note that this calls Target::GetOrCreateModule with notify being false, /// so it is necessary to call Target::ModulesDidLoad afterwards. /// - /// \param[in] defer_module_preload - /// If the module needs to be loaded, prevent the module from being - /// preloaded even if the user sets the preload symbols option. This is - /// used as a performance optimization should the caller preload the - /// modules in parallel after calling this function. virtual lldb::ModuleSP LoadModuleAtAddress(const lldb_private::FileSpec &file, lldb::addr_t link_map_addr, lldb::addr_t base_addr, - bool base_addr_is_offset, - bool defer_module_preload = false); + bool base_addr_is_offset); /// Find/load a binary into lldb given a UUID and the address where it is /// loaded in memory, or a slide to be applied to the file address. @@ -360,12 +354,7 @@ class DynamicLoader : public PluginInterface { // Utility methods for derived classes /// Find a module in the target that matches the given file. - /// - /// \param[in] defer_module_preload - /// If the module needs to be loaded, prevent the module from being - /// preloaded even if the user sets the preload symbols option. - lldb::ModuleSP FindModuleViaTarget(const FileSpec &file, - bool defer_module_preload = false); + lldb::ModuleSP FindModuleViaTarget(const FileSpec &file); /// Checks to see if the target module has changed, updates the target /// accordingly and returns the target executable module. diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index 207738d4a127e..40f9c9bea1c12 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -649,20 +649,12 @@ class Target : public std::enable_shared_from_this, /// will handle / summarize the failures in a custom way and /// don't use these messages. /// - /// \param[in] defer_preload - /// If true, the module will not be preloaded even if - /// Target::GetPreloadSymbols() is true. This is useful when the caller - /// wishes to preload loaded modules in parallel after calling this - /// function for better performance. This is because it's currently not - /// thread-safe to do so during the execution of this function. - /// /// \return /// An empty ModuleSP will be returned if no matching file /// was found. If error_ptr was non-nullptr, an error message /// will likely be provided. lldb::ModuleSP GetOrCreateModule(const ModuleSpec &module_spec, bool notify, - Status *error_ptr = nullptr, - bool defer_preload = false); + Status *error_ptr = nullptr); // Settings accessors diff --git a/lldb/source/Core/DynamicLoader.cpp b/lldb/source/Core/DynamicLoader.cpp index d9c21158d4c5e..af8f772180dfd 100644 --- a/lldb/source/Core/DynamicLoader.cpp +++ b/lldb/source/Core/DynamicLoader.cpp @@ -154,8 +154,7 @@ DynamicLoader::GetSectionListFromModule(const ModuleSP module) const { return sections; } -ModuleSP DynamicLoader::FindModuleViaTarget(const FileSpec &file, - bool defer_module_preload) { +ModuleSP DynamicLoader::FindModuleViaTarget(const FileSpec &file) { Target &target = m_process->GetTarget(); ModuleSpec module_spec(file, target.GetArchitecture()); if (UUID uuid = m_process->FindModuleUUID(file.GetPath())) { @@ -167,8 +166,7 @@ ModuleSP DynamicLoader::FindModuleViaTarget(const FileSpec &file, return module_sp; if (ModuleSP module_sp = target.GetOrCreateModule( - module_spec, false /* notify */, nullptr /* error_ptr */, - defer_module_preload)) + module_spec, false /* notify */, nullptr /* error_ptr */)) return module_sp; return nullptr; @@ -177,9 +175,8 @@ ModuleSP DynamicLoader::FindModuleViaTarget(const FileSpec &file, ModuleSP DynamicLoader::LoadModuleAtAddress(const FileSpec &file, addr_t link_map_addr, addr_t base_addr, - bool base_addr_is_offset, - bool defer_module_preload) { - if (ModuleSP module_sp = FindModuleViaTarget(file, defer_module_preload)) { + bool base_addr_is_offset) { + if (ModuleSP module_sp = FindModuleViaTarget(file)) { UpdateLoadedSections(module_sp, link_map_addr, base_addr, base_addr_is_offset); return module_sp; diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index 11c7a247daa02..decf825ab230a 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -1384,8 +1384,16 @@ void ModuleList::Swap(ModuleList &other) { m_modules.swap(other.m_modules); } -void ModuleList::PreloadSymbols() const { +void ModuleList::PreloadSymbols(bool parallelize) const { std::lock_guard guard(m_modules_mutex); + + if (!parallelize) { + for (const ModuleSP &module_sp : m_modules) + module_sp->PreloadSymbols(); + return; + } + + // parallelize llvm::ThreadPoolTaskGroup task_group(Debugger::GetThreadPool()); for (const ModuleSP &module_sp : m_modules) task_group.async([module_sp] { diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp index ddd0fbd5bcf35..2b485154a3c4a 100644 --- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp @@ -453,8 +453,7 @@ void DynamicLoaderPOSIXDYLD::RefreshModules() { // exists for the duration of this call in `m_rendezvous`. auto load_module_fn = [this, &loaded_modules, &new_modules, - &interpreter_module_mutex](const DYLDRendezvous::SOEntry &so_entry, - bool defer_module_preload) { + &interpreter_module_mutex](const DYLDRendezvous::SOEntry &so_entry) { // Don't load a duplicate copy of ld.so if we have already loaded it // earlier in LoadInterpreterModule. If we instead loaded then // unloaded it later, the section information for ld.so would be @@ -471,7 +470,7 @@ void DynamicLoaderPOSIXDYLD::RefreshModules() { ModuleSP module_sp = LoadModuleAtAddress( so_entry.file_spec, so_entry.link_addr, so_entry.base_addr, - true /* base_addr_is_offset */, defer_module_preload); + true /* base_addr_is_offset */); if (!module_sp.get()) return; @@ -505,16 +504,17 @@ void DynamicLoaderPOSIXDYLD::RefreshModules() { if (m_process->GetTarget().GetParallelModuleLoad()) { llvm::ThreadPoolTaskGroup task_group(Debugger::GetThreadPool()); for (; I != E; ++I) - task_group.async(load_module_fn, *I, true /* defer_module_preload */); + task_group.async(load_module_fn, *I); task_group.wait(); - - if (m_process->GetTarget().GetPreloadSymbols()) - new_modules.PreloadSymbols(); } else { for (; I != E; ++I) - load_module_fn(*I, false /* defer_module_preload */); + load_module_fn(*I); } + if (m_process->GetTarget().GetPreloadSymbols()) + new_modules.PreloadSymbols( + m_process->GetTarget().GetParallelModuleLoad()); + m_process->GetTarget().ModulesDidLoad(new_modules); } @@ -649,12 +649,12 @@ ModuleSP DynamicLoaderPOSIXDYLD::LoadInterpreterModule() { return nullptr; } -ModuleSP DynamicLoaderPOSIXDYLD::LoadModuleAtAddress( - const FileSpec &file, addr_t link_map_addr, addr_t base_addr, - bool base_addr_is_offset, bool defer_module_preload) { +ModuleSP DynamicLoaderPOSIXDYLD::LoadModuleAtAddress(const FileSpec &file, + addr_t link_map_addr, + addr_t base_addr, + bool base_addr_is_offset) { if (ModuleSP module_sp = DynamicLoader::LoadModuleAtAddress( - file, link_map_addr, base_addr, base_addr_is_offset, - defer_module_preload)) + file, link_map_addr, base_addr, base_addr_is_offset)) return module_sp; // This works around an dynamic linker "bug" on android <= 23, where the @@ -673,7 +673,7 @@ ModuleSP DynamicLoaderPOSIXDYLD::LoadModuleAtAddress( !(memory_info.GetName().IsEmpty())) { if (ModuleSP module_sp = DynamicLoader::LoadModuleAtAddress( FileSpec(memory_info.GetName().GetStringRef()), link_map_addr, - base_addr, base_addr_is_offset, defer_module_preload)) + base_addr, base_addr_is_offset)) return module_sp; } } @@ -709,11 +709,9 @@ void DynamicLoaderPOSIXDYLD::LoadAllCurrentModules() { module_names, m_process->GetTarget().GetArchitecture().GetTriple()); auto load_module_fn = [this, &module_list, - &log](const DYLDRendezvous::SOEntry &so_entry, - bool defer_module_preload) { - ModuleSP module_sp = - LoadModuleAtAddress(so_entry.file_spec, so_entry.link_addr, - so_entry.base_addr, true, defer_module_preload); + &log](const DYLDRendezvous::SOEntry &so_entry) { + ModuleSP module_sp = LoadModuleAtAddress( + so_entry.file_spec, so_entry.link_addr, so_entry.base_addr, true); if (module_sp.get()) { LLDB_LOG(log, "LoadAllCurrentModules loading module: {0}", so_entry.file_spec.GetFilename()); @@ -730,16 +728,14 @@ void DynamicLoaderPOSIXDYLD::LoadAllCurrentModules() { if (m_process->GetTarget().GetParallelModuleLoad()) { llvm::ThreadPoolTaskGroup task_group(Debugger::GetThreadPool()); for (I = m_rendezvous.begin(), E = m_rendezvous.end(); I != E; ++I) - task_group.async(load_module_fn, *I, true /* defer_module_preload */); + task_group.async(load_module_fn, *I); task_group.wait(); + } else + for (I = m_rendezvous.begin(), E = m_rendezvous.end(); I != E; ++I) + load_module_fn(*I); - if (m_process->GetTarget().GetPreloadSymbols()) - module_list.PreloadSymbols(); - } else { - for (I = m_rendezvous.begin(), E = m_rendezvous.end(); I != E; ++I) { - load_module_fn(*I, false /* defer_module_preload */); - } - } + if (m_process->GetTarget().GetPreloadSymbols()) + module_list.PreloadSymbols(m_process->GetTarget().GetParallelModuleLoad()); m_process->GetTarget().ModulesDidLoad(module_list); m_initial_modules_added = true; diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h index 2d9dba9bca9fa..6efb92673a13c 100644 --- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h +++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h @@ -55,11 +55,10 @@ class DynamicLoaderPOSIXDYLD : public lldb_private::DynamicLoader { // PluginInterface protocol llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); } - lldb::ModuleSP - LoadModuleAtAddress(const lldb_private::FileSpec &file, - lldb::addr_t link_map_addr, lldb::addr_t base_addr, - bool base_addr_is_offset, - bool defer_module_preload = false) override; + lldb::ModuleSP LoadModuleAtAddress(const lldb_private::FileSpec &file, + lldb::addr_t link_map_addr, + lldb::addr_t base_addr, + bool base_addr_is_offset) override; void CalculateDynamicSaveCoreRanges( lldb_private::Process &process, diff --git a/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp b/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp index 09cde464ccdc8..c7d4c7455968f 100644 --- a/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp @@ -67,12 +67,13 @@ ThreadPlanSP DynamicLoaderWasmDYLD::GetStepThroughTrampolinePlan(Thread &thread, lldb::ModuleSP DynamicLoaderWasmDYLD::LoadModuleAtAddress( const lldb_private::FileSpec &file, lldb::addr_t link_map_addr, - lldb::addr_t base_addr, bool base_addr_is_offset, - bool defer_module_preload) { + lldb::addr_t base_addr, bool base_addr_is_offset) { if (ModuleSP module_sp = DynamicLoader::LoadModuleAtAddress( - file, link_map_addr, base_addr, base_addr_is_offset, - defer_module_preload)) + file, link_map_addr, base_addr, base_addr_is_offset)) { + if (m_process->GetTarget().GetPreloadSymbols()) + module_sp->PreloadSymbols(); return module_sp; + } if (ModuleSP module_sp = m_process->ReadModuleFromMemory(file, base_addr)) { UpdateLoadedSections(module_sp, link_map_addr, base_addr, false); diff --git a/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.h b/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.h index 9c13bdff0279a..5ed855395cca7 100644 --- a/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.h +++ b/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.h @@ -33,11 +33,10 @@ class DynamicLoaderWasmDYLD : public DynamicLoader { Status CanLoadImage() override { return Status(); } lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread, bool stop) override; - lldb::ModuleSP - LoadModuleAtAddress(const lldb_private::FileSpec &file, - lldb::addr_t link_map_addr, lldb::addr_t base_addr, - bool base_addr_is_offset, - bool defer_module_preload = false) override; + lldb::ModuleSP LoadModuleAtAddress(const lldb_private::FileSpec &file, + lldb::addr_t link_map_addr, + lldb::addr_t base_addr, + bool base_addr_is_offset) override; /// \} diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 49f0f4f4b788d..5ec681178444e 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -2343,8 +2343,7 @@ bool Target::ReadPointerFromMemory(const Address &addr, Status &error, } ModuleSP Target::GetOrCreateModule(const ModuleSpec &orig_module_spec, - bool notify, Status *error_ptr, - bool defer_preload) { + bool notify, Status *error_ptr) { ModuleSP module_sp; Status error; @@ -2510,11 +2509,6 @@ ModuleSP Target::GetOrCreateModule(const ModuleSpec &orig_module_spec, if (symbol_file_spec) module_sp->SetSymbolFileFileSpec(symbol_file_spec); - // Preload symbols outside of any lock, so hopefully we can do this for - // each library in parallel. - if (GetPreloadSymbols() && !defer_preload) - module_sp->PreloadSymbols(); - llvm::SmallVector replaced_modules; for (ModuleSP &old_module_sp : old_modules) { if (m_images.GetIndexForModule(old_module_sp.get()) != From 32ae8f3f6945657a16116ab12c0ef1ad63c9ad73 Mon Sep 17 00:00:00 2001 From: Tom Yang Date: Wed, 12 Nov 2025 15:42:42 -0800 Subject: [PATCH 4/7] address coding style issues Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- lldb/include/lldb/Target/DynamicLoader.h | 1 - lldb/source/Core/DynamicLoader.cpp | 4 ++-- lldb/source/Core/ModuleList.cpp | 3 +-- .../DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp | 5 +++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lldb/include/lldb/Target/DynamicLoader.h b/lldb/include/lldb/Target/DynamicLoader.h index e07bbf099cf60..4131a57df7540 100644 --- a/lldb/include/lldb/Target/DynamicLoader.h +++ b/lldb/include/lldb/Target/DynamicLoader.h @@ -207,7 +207,6 @@ class DynamicLoader : public PluginInterface { /// resulting module at the virtual base address \p base_addr. /// Note that this calls Target::GetOrCreateModule with notify being false, /// so it is necessary to call Target::ModulesDidLoad afterwards. - /// virtual lldb::ModuleSP LoadModuleAtAddress(const lldb_private::FileSpec &file, lldb::addr_t link_map_addr, lldb::addr_t base_addr, diff --git a/lldb/source/Core/DynamicLoader.cpp b/lldb/source/Core/DynamicLoader.cpp index af8f772180dfd..31d277bc19681 100644 --- a/lldb/source/Core/DynamicLoader.cpp +++ b/lldb/source/Core/DynamicLoader.cpp @@ -165,8 +165,8 @@ ModuleSP DynamicLoader::FindModuleViaTarget(const FileSpec &file) { if (ModuleSP module_sp = target.GetImages().FindFirstModule(module_spec)) return module_sp; - if (ModuleSP module_sp = target.GetOrCreateModule( - module_spec, false /* notify */, nullptr /* error_ptr */)) + if (ModuleSP module_sp = + target.GetOrCreateModule(module_spec, /*notify=*/false)) return module_sp; return nullptr; diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index decf825ab230a..cb2314735d954 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -1393,12 +1393,11 @@ void ModuleList::PreloadSymbols(bool parallelize) const { return; } - // parallelize llvm::ThreadPoolTaskGroup task_group(Debugger::GetThreadPool()); for (const ModuleSP &module_sp : m_modules) task_group.async([module_sp] { if (module_sp) module_sp->PreloadSymbols(); }); - // task group destructor waits for all tasks to complete + // Task group destructor waits for all tasks to complete. } diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp index 2b485154a3c4a..ae9fe645f2b53 100644 --- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp @@ -470,7 +470,7 @@ void DynamicLoaderPOSIXDYLD::RefreshModules() { ModuleSP module_sp = LoadModuleAtAddress( so_entry.file_spec, so_entry.link_addr, so_entry.base_addr, - true /* base_addr_is_offset */); + /*base_addr_is_offset=*/true); if (!module_sp.get()) return; @@ -730,9 +730,10 @@ void DynamicLoaderPOSIXDYLD::LoadAllCurrentModules() { for (I = m_rendezvous.begin(), E = m_rendezvous.end(); I != E; ++I) task_group.async(load_module_fn, *I); task_group.wait(); - } else + } else { for (I = m_rendezvous.begin(), E = m_rendezvous.end(); I != E; ++I) load_module_fn(*I); + } if (m_process->GetTarget().GetPreloadSymbols()) module_list.PreloadSymbols(m_process->GetTarget().GetParallelModuleLoad()); From 26f9f93c0067cee6fd3910aaac80e6e8b0f0d098 Mon Sep 17 00:00:00 2001 From: Tom Yang Date: Thu, 13 Nov 2025 12:24:23 -0800 Subject: [PATCH 5/7] remove explicit preloads -- move preloading to Target::ModulesDidLoad Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- lldb/include/lldb/Target/Target.h | 12 ++++++++++++ lldb/source/Core/ModuleList.cpp | 2 +- .../POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp | 7 ------- .../wasm-DYLD/DynamicLoaderWasmDYLD.cpp | 2 -- lldb/source/Target/Target.cpp | 3 +++ 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index 40f9c9bea1c12..b0ebb11d15211 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -629,6 +629,11 @@ class Target : public std::enable_shared_from_this, /// or identify a matching Module already present in the Target, /// and return a shared pointer to it. /// + /// Note that this function previously also preloaded the module's symbols + /// depending on a setting. This function no longer does any module + /// preloading because that can potentially cause deadlocks when called in + /// parallel with this function. + /// /// \param[in] module_spec /// The criteria that must be matched for the binary being loaded. /// e.g. UUID, architecture, file path. @@ -931,6 +936,13 @@ class Target : public std::enable_shared_from_this, // the address of its previous instruction and return that address. lldb::addr_t GetBreakableLoadAddress(lldb::addr_t addr); + /// This call may preload module symbols, and may do so in parallel depending + /// on the following target settings: + /// - TargetProperties::GetPreloadSymbols() + /// - TargetProperties::GetParallelModuleLoad() + /// + /// Warning: if called in parallel with Target::GetOrCreateModule, this may + /// result in a ABBA deadlock situation. void ModulesDidLoad(ModuleList &module_list); void ModulesDidUnload(ModuleList &module_list, bool delete_locations); diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index cb2314735d954..5444c04e74522 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -1399,5 +1399,5 @@ void ModuleList::PreloadSymbols(bool parallelize) const { if (module_sp) module_sp->PreloadSymbols(); }); - // Task group destructor waits for all tasks to complete. + task_group.wait(); } diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp index ae9fe645f2b53..3605e7b2c6960 100644 --- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp @@ -511,10 +511,6 @@ void DynamicLoaderPOSIXDYLD::RefreshModules() { load_module_fn(*I); } - if (m_process->GetTarget().GetPreloadSymbols()) - new_modules.PreloadSymbols( - m_process->GetTarget().GetParallelModuleLoad()); - m_process->GetTarget().ModulesDidLoad(new_modules); } @@ -735,9 +731,6 @@ void DynamicLoaderPOSIXDYLD::LoadAllCurrentModules() { load_module_fn(*I); } - if (m_process->GetTarget().GetPreloadSymbols()) - module_list.PreloadSymbols(m_process->GetTarget().GetParallelModuleLoad()); - m_process->GetTarget().ModulesDidLoad(module_list); m_initial_modules_added = true; } diff --git a/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp b/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp index c7d4c7455968f..90b126adbdd85 100644 --- a/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp @@ -70,8 +70,6 @@ lldb::ModuleSP DynamicLoaderWasmDYLD::LoadModuleAtAddress( lldb::addr_t base_addr, bool base_addr_is_offset) { if (ModuleSP module_sp = DynamicLoader::LoadModuleAtAddress( file, link_map_addr, base_addr, base_addr_is_offset)) { - if (m_process->GetTarget().GetPreloadSymbols()) - module_sp->PreloadSymbols(); return module_sp; } diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 5ec681178444e..6fc8053038d10 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -1855,6 +1855,9 @@ void Target::NotifyModulesRemoved(lldb_private::ModuleList &module_list) { } void Target::ModulesDidLoad(ModuleList &module_list) { + if (GetPreloadSymbols()) + module_list.PreloadSymbols(GetParallelModuleLoad()); + const size_t num_images = module_list.GetSize(); if (m_valid && num_images) { for (size_t idx = 0; idx < num_images; ++idx) { From 8f486e8f891b1052746502a82cc636ddbe73e4f7 Mon Sep 17 00:00:00 2001 From: Tom Yang Date: Fri, 14 Nov 2025 14:55:27 -0800 Subject: [PATCH 6/7] remove small erroneous formatting change in wasmdyld Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- .../Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp b/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp index 90b126adbdd85..d019415cb67a6 100644 --- a/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp @@ -69,9 +69,8 @@ lldb::ModuleSP DynamicLoaderWasmDYLD::LoadModuleAtAddress( const lldb_private::FileSpec &file, lldb::addr_t link_map_addr, lldb::addr_t base_addr, bool base_addr_is_offset) { if (ModuleSP module_sp = DynamicLoader::LoadModuleAtAddress( - file, link_map_addr, base_addr, base_addr_is_offset)) { + file, link_map_addr, base_addr, base_addr_is_offset)) return module_sp; - } if (ModuleSP module_sp = m_process->ReadModuleFromMemory(file, base_addr)) { UpdateLoadedSections(module_sp, link_map_addr, base_addr, false); From b340870d2e5825f6d07c1ec0fc913763f95d43d6 Mon Sep 17 00:00:00 2001 From: Tom Yang Date: Fri, 14 Nov 2025 15:04:00 -0800 Subject: [PATCH 7/7] tweak Target.h documentation Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- lldb/include/lldb/Target/Target.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index b0ebb11d15211..908094bfd888d 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -640,7 +640,9 @@ class Target : public std::enable_shared_from_this, /// /// \param[in] notify /// If notify is true, and the Module is new to this Target, - /// Target::ModulesDidLoad will be called. + /// Target::ModulesDidLoad will be called. See note in + /// Target::ModulesDidLoad about thread-safety with + /// Target::GetOrCreateModule. /// If notify is false, it is assumed that the caller is adding /// multiple Modules and will call ModulesDidLoad with the /// full list at the end. @@ -941,8 +943,8 @@ class Target : public std::enable_shared_from_this, /// - TargetProperties::GetPreloadSymbols() /// - TargetProperties::GetParallelModuleLoad() /// - /// Warning: if called in parallel with Target::GetOrCreateModule, this may - /// result in a ABBA deadlock situation. + /// Warning: if preloading is active and this is called in parallel with + /// Target::GetOrCreateModule, this may result in a ABBA deadlock situation. void ModulesDidLoad(ModuleList &module_list); void ModulesDidUnload(ModuleList &module_list, bool delete_locations);