This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Replace GetModuleAtIndexUnlocked and GetModulePointerAtIndexUnlocked with iterators (NFC)
ClosedPublic

Authored by JDevlieghere on Jan 7 2021, 3:49 PM.

Details

Summary

Replace uses of GetModuleAtIndexUnlocked and GetModulePointerAtIndexUnlocked with the ModuleIterable and ModuleIterableNoLocking where applicable.

Diff Detail

Event Timeline

JDevlieghere created this revision.Jan 7 2021, 3:49 PM
JDevlieghere requested review of this revision.Jan 7 2021, 3:49 PM
mib accepted this revision.Jan 7 2021, 4:15 PM

LGTM apart from few nits.

lldb/include/lldb/Core/ModuleList.h
485–486

nit: Can we rename that to ModuleIterableNonLocking and ModulesNonLocking ?

Sounds more correct to me ^^

lldb/source/Commands/CommandObjectTarget.cpp
1404

Same here, we could remove the check and just use module_list.GetSize() in the printf.

2279

Same.

3911–3914

Early return instead to get rid of num_modules ?

lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
409

This doesn't seem to be used anymore.

This revision is now accepted and ready to land.Jan 7 2021, 4:15 PM
JDevlieghere marked 5 inline comments as done.

Address @mib's code review feedback.

lldb/include/lldb/Core/ModuleList.h
485–486

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.

lldb/source/Commands/CommandObjectTarget.cpp
1404

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.

lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
409

It is below, but I've inlined it.

mib added inline comments.Jan 7 2021, 4:52 PM
lldb/include/lldb/Core/ModuleList.h
485–486

Not really, it can remain as is.

mib added inline comments.Jan 7 2021, 4:54 PM
lldb/source/Commands/CommandObjectTarget.cpp
1404

Sounds good then!

lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
409

Oh! The code was collapsed --' My bad!

Herald added a project: Restricted Project. · View Herald TranscriptJan 7 2021, 9:06 PM