diff options
-rw-r--r-- | lldb/include/lldb/Core/ModuleList.h | 4 | ||||
-rw-r--r-- | lldb/source/Core/ModuleList.cpp | 12 |
2 files changed, 16 insertions, 0 deletions
diff --git a/lldb/include/lldb/Core/ModuleList.h b/lldb/include/lldb/Core/ModuleList.h index a46e212da9b..f4c12cf168a 100644 --- a/lldb/include/lldb/Core/ModuleList.h +++ b/lldb/include/lldb/Core/ModuleList.h @@ -12,6 +12,7 @@ #include <vector> #include <list> +#include <functional> #include "lldb/lldb-private.h" #include "lldb/Host/Mutex.h" @@ -562,6 +563,9 @@ public: static bool RemoveSharedModuleIfOrphaned (const Module *module_ptr); + void + ForEach (std::function <bool (const lldb::ModuleSP &module_sp)> const &callback) const; + protected: //------------------------------------------------------------------ // Class typedefs. diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index 879eb9bd182..5c8e0e0ca8e 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -1162,3 +1162,15 @@ ModuleList::LoadScriptingResourcesInTarget (Target *target, } return errors.size() == 0; } + +void +ModuleList::ForEach (std::function <bool (const ModuleSP &module_sp)> const &callback) const +{ + Mutex::Locker locker(m_modules_mutex); + for (const auto &module : m_modules) + { + // If the callback returns false, then stop iterating and break out + if (!callback (module)) + break; + } +} |