[Lldb-commits] [lldb] [NFC][lldb] Speed up lookup of shared modules (PR #152054)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Wed Aug 6 06:37:40 PDT 2025
================
@@ -755,11 +755,237 @@ size_t ModuleList::GetIndexForModule(const Module *module) const {
}
namespace {
+/// A wrapper around ModuleList for shared modules. Provides fast lookups for
+/// file-based ModuleSpec queries.
+class SharedModuleList {
+public:
+ /// Finds all the modules matching the module_spec, and adds them to \p
+ /// matching_module_list.
+ void FindModules(const ModuleSpec &module_spec,
+ ModuleList &matching_module_list) const {
+ std::lock_guard<std::recursive_mutex> guard(GetMutex());
+ // Try index first for performance - if found, skip expensive full list
+ // search
+ if (FindModulesInIndex(module_spec, matching_module_list))
+ return;
+ m_list.FindModules(module_spec, matching_module_list);
+ // Assertion validates that if we found modules in the list but not the
+ // index, it's because the module_spec has no filename or the found module
+ // has a different filename (e.g., when searching by UUID and finding a
+ // module with an alias)
----------------
JDevlieghere wrote:
Nit: make this imperative (and add a period)
```suggestion
// Assert that if we found modules in the list but not the
// index, it's because the module_spec has no filename or the found module
// has a different filename. For example, when searching by UUID and finding a
// module with an alias.
```
https://github.com/llvm/llvm-project/pull/152054
More information about the lldb-commits
mailing list