[Lldb-commits] [PATCH] D94271: [lldb] Replace GetModuleAtIndexUnlocked and GetModulePointerAtIndexUnlocked with iterators (NFC)

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Jan 7 16:45:39 PST 2021

JDevlieghere added inline comments.

Comment at: lldb/include/lldb/Core/ModuleList.h:485-486
   typedef AdaptedIterable<collection, lldb::ModuleSP, vector_adapter>
-  ModuleIterableNoLocking ModulesNoLocking() {
+  ModuleIterableNoLocking ModulesNoLocking() const {
     return ModuleIterableNoLocking(m_modules);
mib wrote:
> nit: Can we rename that to ModuleIterableNo**n**Locking and ModulesNo**n**Locking ?
> Sounds more correct to me ^^
If you feel strongly about it I can do it as a pre-commit change, but personally I don't think it's worth the churn.

Comment at: lldb/source/Commands/CommandObjectTarget.cpp:1404
   std::lock_guard<std::recursive_mutex> guard(module_list.GetMutex());
   const size_t num_modules = module_list.GetSize();
   if (num_modules > 0) {
mib wrote:
> Same here, we could remove the check and just use `module_list.GetSize()` in the printf.
There's a few places in this file where that's true, but here we still need it for both the early return and the print statement. I'm being pedantic, but generally `::size` is only guaranteed to be `O(n)` as opposed to `::empty` which is `O(1)`. I think having the temporary variable here is fine. 

Comment at: lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp:406
+  Target &target = m_process->GetTarget();
+  const size_t num_modules = target.GetImages().GetSize();
mib wrote:
> This doesn't seem to be used anymore.
It is below, but I've inlined it. 



More information about the lldb-commits mailing list