This is an archive of the discontinued LLVM Phabricator instance.

Make ModuleCache::Get to return instantiated ModuleSP instance so already created in-memory instance can be returned instead of creating a new one.
ClosedPublic

Authored by ovyalov on Mar 11 2015, 2:51 PM.

Details

Summary

ModuleCache::Get used to return a new ModuleSP instance for the same module spec that may lead to multiple loaded modules for the same shared library.
This CL addresses this issue by storing weak Module pointers within map<UUID, weak_ptr<Module>> - if ModuleCache::Get finds already created module by UUID and it's not null then an existing module instance will be returned.

I'm planning to use this change in future to enforce LRU policy on cache - with map of loaded modules at hand, it will be easy to detect in-use modules.

Diff Detail

Event Timeline

ovyalov updated this revision to Diff 21767.Mar 11 2015, 2:51 PM
ovyalov retitled this revision from to Make ModuleCache::Get to return instantiated ModuleSP instance so already created in-memory instance can be returned instead of creating a new one..
ovyalov updated this object.
ovyalov edited the test plan for this revision. (Show Details)
ovyalov added reviewers: clayborg, tberghammer.
ovyalov added a subscriber: Unknown Object (MLST).
clayborg requested changes to this revision.Mar 11 2015, 2:59 PM
clayborg edited edge metadata.

Use lldb::ModuleWP instead of std::weak_ptr<Module> and this is good to go.

source/Utility/ModuleCache.h
70

Use lldb::ModuleWP instead of std::weak_ptr<Module>.

This revision now requires changes to proceed.Mar 11 2015, 2:59 PM
ovyalov updated this revision to Diff 21779.Mar 11 2015, 3:18 PM
ovyalov edited edge metadata.

Oops - didn't notice WP forward declaration. Fixed.
Please take another look.

Thank you!

clayborg accepted this revision.Mar 11 2015, 3:58 PM
clayborg edited edge metadata.

Looks good.

This revision is now accepted and ready to land.Mar 11 2015, 3:58 PM
tberghammer accepted this revision.Mar 11 2015, 4:43 PM
tberghammer edited edge metadata.
ovyalov closed this revision.Mar 12 2015, 11:21 AM

AFFECTED FILES

/lldb/trunk/include/lldb/Target/Platform.h
/lldb/trunk/source/Target/Platform.cpp
/lldb/trunk/source/Utility/ModuleCache.cpp
/lldb/trunk/source/Utility/ModuleCache.h

USERS

ovyalov (Author)

http://reviews.llvm.org/rL232075