[lldb][NFC] Modernize for-loops in ModuleList
Reviewed By: mib Differential Revision: https://reviews.llvm.org/D112379
This commit is contained in:
parent
85bcc1eb2f
commit
4cf9d1e449
|
|
@ -159,7 +159,7 @@ public:
|
||||||
/// ModulesDidLoad may be deferred when adding multiple Modules
|
/// ModulesDidLoad may be deferred when adding multiple Modules
|
||||||
/// to the Target, but it must be called at the end,
|
/// to the Target, but it must be called at the end,
|
||||||
/// before resuming execution.
|
/// before resuming execution.
|
||||||
bool AppendIfNeeded(const lldb::ModuleSP &module_sp, bool notify = true);
|
bool AppendIfNeeded(const lldb::ModuleSP &new_module, bool notify = true);
|
||||||
|
|
||||||
void Append(const ModuleList &module_list);
|
void Append(const ModuleList &module_list);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -200,16 +200,15 @@ void ModuleList::ReplaceEquivalent(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModuleList::AppendIfNeeded(const ModuleSP &module_sp, bool notify) {
|
bool ModuleList::AppendIfNeeded(const ModuleSP &new_module, bool notify) {
|
||||||
if (module_sp) {
|
if (new_module) {
|
||||||
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
||||||
collection::iterator pos, end = m_modules.end();
|
for (const ModuleSP &module_sp : m_modules) {
|
||||||
for (pos = m_modules.begin(); pos != end; ++pos) {
|
if (module_sp.get() == new_module.get())
|
||||||
if (pos->get() == module_sp.get())
|
|
||||||
return false; // Already in the list
|
return false; // Already in the list
|
||||||
}
|
}
|
||||||
// Only push module_sp on the list if it wasn't already in there.
|
// Only push module_sp on the list if it wasn't already in there.
|
||||||
Append(module_sp, notify);
|
Append(new_module, notify);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -372,10 +371,10 @@ void ModuleList::FindFunctions(ConstString name,
|
||||||
Module::LookupInfo lookup_info(name, name_type_mask, eLanguageTypeUnknown);
|
Module::LookupInfo lookup_info(name, name_type_mask, eLanguageTypeUnknown);
|
||||||
|
|
||||||
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
||||||
collection::const_iterator pos, end = m_modules.end();
|
for (const ModuleSP &module_sp : m_modules) {
|
||||||
for (pos = m_modules.begin(); pos != end; ++pos) {
|
module_sp->FindFunctions(lookup_info.GetLookupName(),
|
||||||
(*pos)->FindFunctions(lookup_info.GetLookupName(), CompilerDeclContext(),
|
CompilerDeclContext(),
|
||||||
lookup_info.GetNameTypeMask(), options, sc_list);
|
lookup_info.GetNameTypeMask(), options, sc_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
const size_t new_size = sc_list.GetSize();
|
const size_t new_size = sc_list.GetSize();
|
||||||
|
|
@ -384,10 +383,9 @@ void ModuleList::FindFunctions(ConstString name,
|
||||||
lookup_info.Prune(sc_list, old_size);
|
lookup_info.Prune(sc_list, old_size);
|
||||||
} else {
|
} else {
|
||||||
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
||||||
collection::const_iterator pos, end = m_modules.end();
|
for (const ModuleSP &module_sp : m_modules) {
|
||||||
for (pos = m_modules.begin(); pos != end; ++pos) {
|
module_sp->FindFunctions(name, CompilerDeclContext(), name_type_mask,
|
||||||
(*pos)->FindFunctions(name, CompilerDeclContext(), name_type_mask,
|
options, sc_list);
|
||||||
options, sc_list);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -401,10 +399,9 @@ void ModuleList::FindFunctionSymbols(ConstString name,
|
||||||
Module::LookupInfo lookup_info(name, name_type_mask, eLanguageTypeUnknown);
|
Module::LookupInfo lookup_info(name, name_type_mask, eLanguageTypeUnknown);
|
||||||
|
|
||||||
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
||||||
collection::const_iterator pos, end = m_modules.end();
|
for (const ModuleSP &module_sp : m_modules) {
|
||||||
for (pos = m_modules.begin(); pos != end; ++pos) {
|
module_sp->FindFunctionSymbols(lookup_info.GetLookupName(),
|
||||||
(*pos)->FindFunctionSymbols(lookup_info.GetLookupName(),
|
lookup_info.GetNameTypeMask(), sc_list);
|
||||||
lookup_info.GetNameTypeMask(), sc_list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const size_t new_size = sc_list.GetSize();
|
const size_t new_size = sc_list.GetSize();
|
||||||
|
|
@ -413,9 +410,8 @@ void ModuleList::FindFunctionSymbols(ConstString name,
|
||||||
lookup_info.Prune(sc_list, old_size);
|
lookup_info.Prune(sc_list, old_size);
|
||||||
} else {
|
} else {
|
||||||
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
||||||
collection::const_iterator pos, end = m_modules.end();
|
for (const ModuleSP &module_sp : m_modules) {
|
||||||
for (pos = m_modules.begin(); pos != end; ++pos) {
|
module_sp->FindFunctionSymbols(name, name_type_mask, sc_list);
|
||||||
(*pos)->FindFunctionSymbols(name, name_type_mask, sc_list);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -424,28 +420,23 @@ void ModuleList::FindFunctions(const RegularExpression &name,
|
||||||
const ModuleFunctionSearchOptions &options,
|
const ModuleFunctionSearchOptions &options,
|
||||||
SymbolContextList &sc_list) {
|
SymbolContextList &sc_list) {
|
||||||
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
||||||
collection::const_iterator pos, end = m_modules.end();
|
for (const ModuleSP &module_sp : m_modules)
|
||||||
for (pos = m_modules.begin(); pos != end; ++pos) {
|
module_sp->FindFunctions(name, options, sc_list);
|
||||||
(*pos)->FindFunctions(name, options, sc_list);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleList::FindCompileUnits(const FileSpec &path,
|
void ModuleList::FindCompileUnits(const FileSpec &path,
|
||||||
SymbolContextList &sc_list) const {
|
SymbolContextList &sc_list) const {
|
||||||
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
||||||
collection::const_iterator pos, end = m_modules.end();
|
for (const ModuleSP &module_sp : m_modules)
|
||||||
for (pos = m_modules.begin(); pos != end; ++pos) {
|
module_sp->FindCompileUnits(path, sc_list);
|
||||||
(*pos)->FindCompileUnits(path, sc_list);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleList::FindGlobalVariables(ConstString name, size_t max_matches,
|
void ModuleList::FindGlobalVariables(ConstString name, size_t max_matches,
|
||||||
VariableList &variable_list) const {
|
VariableList &variable_list) const {
|
||||||
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
||||||
collection::const_iterator pos, end = m_modules.end();
|
for (const ModuleSP &module_sp : m_modules) {
|
||||||
for (pos = m_modules.begin(); pos != end; ++pos) {
|
module_sp->FindGlobalVariables(name, CompilerDeclContext(), max_matches,
|
||||||
(*pos)->FindGlobalVariables(name, CompilerDeclContext(), max_matches,
|
variable_list);
|
||||||
variable_list);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -453,36 +444,30 @@ void ModuleList::FindGlobalVariables(const RegularExpression ®ex,
|
||||||
size_t max_matches,
|
size_t max_matches,
|
||||||
VariableList &variable_list) const {
|
VariableList &variable_list) const {
|
||||||
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
||||||
collection::const_iterator pos, end = m_modules.end();
|
for (const ModuleSP &module_sp : m_modules)
|
||||||
for (pos = m_modules.begin(); pos != end; ++pos) {
|
module_sp->FindGlobalVariables(regex, max_matches, variable_list);
|
||||||
(*pos)->FindGlobalVariables(regex, max_matches, variable_list);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleList::FindSymbolsWithNameAndType(ConstString name,
|
void ModuleList::FindSymbolsWithNameAndType(ConstString name,
|
||||||
SymbolType symbol_type,
|
SymbolType symbol_type,
|
||||||
SymbolContextList &sc_list) const {
|
SymbolContextList &sc_list) const {
|
||||||
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
||||||
collection::const_iterator pos, end = m_modules.end();
|
for (const ModuleSP &module_sp : m_modules)
|
||||||
for (pos = m_modules.begin(); pos != end; ++pos)
|
module_sp->FindSymbolsWithNameAndType(name, symbol_type, sc_list);
|
||||||
(*pos)->FindSymbolsWithNameAndType(name, symbol_type, sc_list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleList::FindSymbolsMatchingRegExAndType(
|
void ModuleList::FindSymbolsMatchingRegExAndType(
|
||||||
const RegularExpression ®ex, lldb::SymbolType symbol_type,
|
const RegularExpression ®ex, lldb::SymbolType symbol_type,
|
||||||
SymbolContextList &sc_list) const {
|
SymbolContextList &sc_list) const {
|
||||||
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
||||||
collection::const_iterator pos, end = m_modules.end();
|
for (const ModuleSP &module_sp : m_modules)
|
||||||
for (pos = m_modules.begin(); pos != end; ++pos)
|
module_sp->FindSymbolsMatchingRegExAndType(regex, symbol_type, sc_list);
|
||||||
(*pos)->FindSymbolsMatchingRegExAndType(regex, symbol_type, sc_list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleList::FindModules(const ModuleSpec &module_spec,
|
void ModuleList::FindModules(const ModuleSpec &module_spec,
|
||||||
ModuleList &matching_module_list) const {
|
ModuleList &matching_module_list) const {
|
||||||
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
||||||
collection::const_iterator pos, end = m_modules.end();
|
for (const ModuleSP &module_sp : m_modules) {
|
||||||
for (pos = m_modules.begin(); pos != end; ++pos) {
|
|
||||||
ModuleSP module_sp(*pos);
|
|
||||||
if (module_sp->MatchesModuleSpec(module_spec))
|
if (module_sp->MatchesModuleSpec(module_spec))
|
||||||
matching_module_list.Append(module_sp);
|
matching_module_list.Append(module_sp);
|
||||||
}
|
}
|
||||||
|
|
@ -558,9 +543,8 @@ void ModuleList::FindTypes(Module *search_first, ConstString name,
|
||||||
bool ModuleList::FindSourceFile(const FileSpec &orig_spec,
|
bool ModuleList::FindSourceFile(const FileSpec &orig_spec,
|
||||||
FileSpec &new_spec) const {
|
FileSpec &new_spec) const {
|
||||||
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
||||||
collection::const_iterator pos, end = m_modules.end();
|
for (const ModuleSP &module_sp : m_modules) {
|
||||||
for (pos = m_modules.begin(); pos != end; ++pos) {
|
if (module_sp->FindSourceFile(orig_spec, new_spec))
|
||||||
if ((*pos)->FindSourceFile(orig_spec, new_spec))
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -572,10 +556,9 @@ void ModuleList::FindAddressesForLine(const lldb::TargetSP target_sp,
|
||||||
std::vector<Address> &output_local,
|
std::vector<Address> &output_local,
|
||||||
std::vector<Address> &output_extern) {
|
std::vector<Address> &output_extern) {
|
||||||
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
||||||
collection::const_iterator pos, end = m_modules.end();
|
for (const ModuleSP &module_sp : m_modules) {
|
||||||
for (pos = m_modules.begin(); pos != end; ++pos) {
|
module_sp->FindAddressesForLine(target_sp, file, line, function,
|
||||||
(*pos)->FindAddressesForLine(target_sp, file, line, function, output_local,
|
output_local, output_extern);
|
||||||
output_extern);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -602,10 +585,8 @@ size_t ModuleList::GetSize() const {
|
||||||
|
|
||||||
void ModuleList::Dump(Stream *s) const {
|
void ModuleList::Dump(Stream *s) const {
|
||||||
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
||||||
collection::const_iterator pos, end = m_modules.end();
|
for (const ModuleSP &module_sp : m_modules)
|
||||||
for (pos = m_modules.begin(); pos != end; ++pos) {
|
module_sp->Dump(s);
|
||||||
(*pos)->Dump(s);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModuleList::LogUUIDAndPaths(Log *log, const char *prefix_cstr) {
|
void ModuleList::LogUUIDAndPaths(Log *log, const char *prefix_cstr) {
|
||||||
|
|
@ -628,9 +609,8 @@ void ModuleList::LogUUIDAndPaths(Log *log, const char *prefix_cstr) {
|
||||||
bool ModuleList::ResolveFileAddress(lldb::addr_t vm_addr,
|
bool ModuleList::ResolveFileAddress(lldb::addr_t vm_addr,
|
||||||
Address &so_addr) const {
|
Address &so_addr) const {
|
||||||
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
||||||
collection::const_iterator pos, end = m_modules.end();
|
for (const ModuleSP &module_sp : m_modules) {
|
||||||
for (pos = m_modules.begin(); pos != end; ++pos) {
|
if (module_sp->ResolveFileAddress(vm_addr, so_addr))
|
||||||
if ((*pos)->ResolveFileAddress(vm_addr, so_addr))
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -673,10 +653,9 @@ uint32_t ModuleList::ResolveSymbolContextsForFileSpec(
|
||||||
const FileSpec &file_spec, uint32_t line, bool check_inlines,
|
const FileSpec &file_spec, uint32_t line, bool check_inlines,
|
||||||
SymbolContextItem resolve_scope, SymbolContextList &sc_list) const {
|
SymbolContextItem resolve_scope, SymbolContextList &sc_list) const {
|
||||||
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
|
||||||
collection::const_iterator pos, end = m_modules.end();
|
for (const ModuleSP &module_sp : m_modules) {
|
||||||
for (pos = m_modules.begin(); pos != end; ++pos) {
|
module_sp->ResolveSymbolContextsForFileSpec(file_spec, line, check_inlines,
|
||||||
(*pos)->ResolveSymbolContextsForFileSpec(file_spec, line, check_inlines,
|
resolve_scope, sc_list);
|
||||||
resolve_scope, sc_list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return sc_list.GetSize();
|
return sc_list.GetSize();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue