[Lldb-commits] [lldb] 5941858 - [lldb][Module][NFC] Add ModuleList::AnyOf
Michael Buch via lldb-commits
lldb-commits at lists.llvm.org
Fri Dec 2 02:53:10 PST 2022
Author: Michael Buch
Date: 2022-12-02T10:52:40Z
New Revision: 5941858efdca72425c29bf043d3ec84e7fec6f62
URL: https://github.com/llvm/llvm-project/commit/5941858efdca72425c29bf043d3ec84e7fec6f62
DIFF: https://github.com/llvm/llvm-project/commit/5941858efdca72425c29bf043d3ec84e7fec6f62.diff
LOG: [lldb][Module][NFC] Add ModuleList::AnyOf
Differential Revision: https://reviews.llvm.org/D139083
Added:
Modified:
lldb/include/lldb/Core/ModuleList.h
lldb/source/Core/ModuleList.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Core/ModuleList.h b/lldb/include/lldb/Core/ModuleList.h
index 3ae56f17db744..631d7889f3679 100644
--- a/lldb/include/lldb/Core/ModuleList.h
+++ b/lldb/include/lldb/Core/ModuleList.h
@@ -473,6 +473,13 @@ class ModuleList {
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(lldb_private::Module &module)> const &callback) const;
+
protected:
// Class typedefs.
typedef std::vector<lldb::ModuleSP>
diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index 991163c63dc50..5aa58d9bba6bd 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -1074,3 +1074,16 @@ void ModuleList::ForEach(
break;
}
}
+
+bool ModuleList::AnyOf(
+ std::function<bool(lldb_private::Module &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;
+}
More information about the lldb-commits
mailing list