Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lldb/include/lldb/Core/ModuleList.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "lldb/Utility/Status.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-forward.h"
#include "lldb/lldb-private-enumerations.h"
#include "lldb/lldb-types.h"

#include "llvm/ADT/DenseSet.h"
Expand Down Expand Up @@ -488,8 +489,9 @@ class ModuleList {
/// be non-null.
///
/// This function is thread-safe.
void ForEach(std::function<bool(const lldb::ModuleSP &module_sp)> const
&callback) const;
void
ForEach(std::function<IterationAction(const lldb::ModuleSP &module_sp)> const
&callback) const;

/// Returns true if 'callback' returns true for one of the modules
/// in this ModuleList.
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Commands/CommandCompletions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ void CommandCompletions::ModuleUUIDs(CommandInterpreter &interpreter,
lldb::eDescriptionLevelInitial);
request.TryCompleteCurrentArg(module->GetUUID().GetAsString(),
strm.GetString());
return true;
return IterationAction::Continue;
});
}

Expand Down
6 changes: 3 additions & 3 deletions lldb/source/Core/ModuleList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1077,12 +1077,12 @@ bool ModuleList::LoadScriptingResourcesInTarget(Target *target,
}

void ModuleList::ForEach(
std::function<bool(const ModuleSP &module_sp)> const &callback) const {
std::function<IterationAction(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 the callback returns false, then stop iterating and break out
if (!callback(module_sp))
if (callback(module_sp) == IterationAction::Stop)
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ lldb::ModuleSP GetPreferredAsanModule(const Target &target) {
target.GetImages().ForEach([&](const lldb::ModuleSP &m) {
if (pattern.match(m->GetFileSpec().GetFilename().GetStringRef())) {
module = m;
return false;
return IterationAction::Stop;
}

return true;
return IterationAction::Continue;
});

return module;
Expand Down
8 changes: 4 additions & 4 deletions lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5260,17 +5260,17 @@ llvm::Error ProcessGDBRemote::LoadModules() {
loaded_modules.Remove(removed_modules);
m_process->GetTarget().ModulesDidUnload(removed_modules, false);

new_modules.ForEach([&target](const lldb::ModuleSP module_sp) -> bool {
new_modules.ForEach([&target](const lldb::ModuleSP module_sp) {
lldb_private::ObjectFile *obj = module_sp->GetObjectFile();
if (!obj)
return true;
return IterationAction::Continue;

if (obj->GetType() != ObjectFile::Type::eTypeExecutable)
return true;
return IterationAction::Continue;

lldb::ModuleSP module_copy_sp = module_sp;
target.SetExecutableModule(module_copy_sp, eLoadDependentsNo);
return false;
return IterationAction::Stop;
});

loaded_modules.AppendIfNeeded(new_modules);
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ void ProcessMinidump::BuildMemoryRegions() {
to_add.back().SetName(module_sp->GetFileSpec().GetPath().c_str());
}
}
return true;
return IterationAction::Continue;
});
m_memory_regions->insert(m_memory_regions->end(), to_add.begin(),
to_add.end());
Expand Down
8 changes: 4 additions & 4 deletions lldb/source/Target/InstrumentationRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ void InstrumentationRuntime::ModulesDidLoad(
return;
}

module_list.ForEach([this](const lldb::ModuleSP module_sp) -> bool {
module_list.ForEach([this](const lldb::ModuleSP module_sp) {
const FileSpec &file_spec = module_sp->GetFileSpec();
if (!file_spec)
return true; // Keep iterating.
return IterationAction::Continue;

const RegularExpression &runtime_regex = GetPatternForRuntimeLibrary();
if (runtime_regex.Execute(file_spec.GetFilename().GetCString()) ||
Expand All @@ -62,11 +62,11 @@ void InstrumentationRuntime::ModulesDidLoad(
Activate();
if (!IsActive())
SetRuntimeModuleSP({}); // Don't cache module if activation failed.
return false; // Stop iterating, we're done.
return IterationAction::Stop;
}
}

return true;
return IterationAction::Continue;
});
}

Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Target/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2487,9 +2487,9 @@ ModuleSP Target::GetOrCreateModule(const ModuleSpec &orig_module_spec,

ModuleList found_modules;
m_images.FindModules(module_spec_copy, found_modules);
found_modules.ForEach([&](const ModuleSP &found_module) -> bool {
found_modules.ForEach([&](const ModuleSP &found_module) {
old_modules.push_back(found_module);
return true;
return IterationAction::Continue;
});
}

Expand Down
Loading