diff --git a/lldb/include/lldb/Core/ModuleList.h b/lldb/include/lldb/Core/ModuleList.h --- a/lldb/include/lldb/Core/ModuleList.h +++ b/lldb/include/lldb/Core/ModuleList.h @@ -473,6 +473,13 @@ void ForEach(std::function const &callback) const; + /// Returns true if 'callback' returns true for one of the modules + /// in this ModuleList. + /// + /// This function is thread-safe. + bool AnyOf( + std::function const &callback) const; + protected: // Class typedefs. typedef std::vector diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -1074,3 +1074,16 @@ break; } } + +bool ModuleList::AnyOf( + std::function const &callback) + const { + std::lock_guard guard(m_modules_mutex); + for (const auto &module_sp : m_modules) { + assert(module_sp != nullptr); + if (callback(*module_sp)) + return true; + } + + return false; +}