diff options
author | Greg Clayton <gclayton@apple.com> | 2011-08-11 02:48:45 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2011-08-11 02:48:45 +0000 |
commit | aa149cbd863d1722f8e5263cac26b9c9f4461f57 (patch) | |
tree | 03b9bb36184a893d7fd5f3c44deb48f4046a28f9 /lldb/source/Core/ModuleList.cpp | |
parent | 8e4c74bb7c515099d97a330c24a48126c3222a6d (diff) | |
download | bcm5719-llvm-aa149cbd863d1722f8e5263cac26b9c9f4461f57.tar.gz bcm5719-llvm-aa149cbd863d1722f8e5263cac26b9c9f4461f57.zip |
Added the ability to remove orphaned module shared pointers from a ModuleList.
This is helping us track down some extra references to ModuleSP objects that
are causing things to get kept around for too long.
Added a module pointer accessor to target and change a lot of code to use
it where it would be more efficient.
"taret delete" can now specify "--clean=1" which will cleanup the global module
list for any orphaned module in the shared module cache which can save memory
and also help track down module reference leaks like we have now.
llvm-svn: 137294
Diffstat (limited to 'lldb/source/Core/ModuleList.cpp')
-rw-r--r-- | lldb/source/Core/ModuleList.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index 7a4748338e9..cf83d4b4476 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -108,6 +108,28 @@ ModuleList::Remove (ModuleSP &module_sp) return false; } + +size_t +ModuleList::RemoveOrphans () +{ + Mutex::Locker locker(m_modules_mutex); + collection::reverse_iterator pos = m_modules.rbegin(); + size_t remove_count = 0; + while (pos != m_modules.rend()) + { + if (pos->unique()) + { + pos = m_modules.erase (pos); + ++remove_count; + } + else + { + ++pos; + } + } + return remove_count; +} + size_t ModuleList::Remove (ModuleList &module_list) { @@ -680,6 +702,12 @@ ModuleList::FindSharedModules return shared_module_list.FindModules (&in_file_spec, &arch, uuid_ptr, object_name_ptr, matching_module_list); } +uint32_t +ModuleList::RemoveOrphanSharedModules () +{ + return GetSharedModuleList ().RemoveOrphans(); +} + Error ModuleList::GetSharedModule ( |