Michael137 created this revision. Michael137 added a reviewer: aprantl. Herald added a project: All. Michael137 requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D139083 Files: lldb/include/lldb/Core/ModuleList.h lldb/source/Core/ModuleList.cpp Index: lldb/source/Core/ModuleList.cpp =================================================================== --- lldb/source/Core/ModuleList.cpp +++ lldb/source/Core/ModuleList.cpp @@ -1074,3 +1074,15 @@ break; } } + +bool ModuleList::AnyOf( + std::function<bool(const ModuleSP &module_sp)> const &callback) const { + std::lock_guard<std::recursive_mutex> guard(m_modules_mutex); + for (const auto &module_sp : m_modules) { + assert(module_sp != nullptr); + if (callback(module_sp)) + return true; + } + + return false; +} Index: lldb/include/lldb/Core/ModuleList.h =================================================================== --- lldb/include/lldb/Core/ModuleList.h +++ lldb/include/lldb/Core/ModuleList.h @@ -473,6 +473,13 @@ void ForEach(std::function<bool(const lldb::ModuleSP &module_sp)> 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<bool(const lldb::ModuleSP &module_sp)> const + &callback) const; + protected: // Class typedefs. typedef std::vector<lldb::ModuleSP>
Index: lldb/source/Core/ModuleList.cpp =================================================================== --- lldb/source/Core/ModuleList.cpp +++ lldb/source/Core/ModuleList.cpp @@ -1074,3 +1074,15 @@ break; } } + +bool ModuleList::AnyOf( + std::function<bool(const ModuleSP &module_sp)> const &callback) const { + std::lock_guard<std::recursive_mutex> guard(m_modules_mutex); + for (const auto &module_sp : m_modules) { + assert(module_sp != nullptr); + if (callback(module_sp)) + return true; + } + + return false; +} Index: lldb/include/lldb/Core/ModuleList.h =================================================================== --- lldb/include/lldb/Core/ModuleList.h +++ lldb/include/lldb/Core/ModuleList.h @@ -473,6 +473,13 @@ void ForEach(std::function<bool(const lldb::ModuleSP &module_sp)> 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<bool(const lldb::ModuleSP &module_sp)> const + &callback) const; + protected: // Class typedefs. typedef std::vector<lldb::ModuleSP>
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits