This revision was automatically updated to reflect the committed changes. Closed by commit rGf2f3b1a87ad2: [lldb] Do not deallocate memory after exec (authored by bulbazord).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D140249/new/ https://reviews.llvm.org/D140249 Files: lldb/include/lldb/Target/Memory.h lldb/source/Target/Memory.cpp lldb/source/Target/Process.cpp Index: lldb/source/Target/Process.cpp =================================================================== --- lldb/source/Target/Process.cpp +++ lldb/source/Target/Process.cpp @@ -543,7 +543,7 @@ m_notifications.swap(empty_notifications); m_image_tokens.clear(); m_memory_cache.Clear(); - m_allocated_memory_cache.Clear(); + m_allocated_memory_cache.Clear(/*deallocate_memory=*/true); { std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex); m_language_runtimes.clear(); @@ -5657,7 +5657,9 @@ m_dyld_up.reset(); m_jit_loaders_up.reset(); m_image_tokens.clear(); - m_allocated_memory_cache.Clear(); + // After an exec, the inferior is a new process and these memory regions are + // no longer allocated. + m_allocated_memory_cache.Clear(/*deallocte_memory=*/false); { std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex); m_language_runtimes.clear(); Index: lldb/source/Target/Memory.cpp =================================================================== --- lldb/source/Target/Memory.cpp +++ lldb/source/Target/Memory.cpp @@ -332,9 +332,9 @@ AllocatedMemoryCache::~AllocatedMemoryCache() = default; -void AllocatedMemoryCache::Clear() { +void AllocatedMemoryCache::Clear(bool deallocate_memory) { std::lock_guard<std::recursive_mutex> guard(m_mutex); - if (m_process.IsAlive()) { + if (m_process.IsAlive() && deallocate_memory) { PermissionsToBlockMap::iterator pos, end = m_memory_map.end(); for (pos = m_memory_map.begin(); pos != end; ++pos) m_process.DoDeallocateMemory(pos->second->GetBaseAddress()); Index: lldb/include/lldb/Target/Memory.h =================================================================== --- lldb/include/lldb/Target/Memory.h +++ lldb/include/lldb/Target/Memory.h @@ -116,7 +116,7 @@ ~AllocatedMemoryCache(); - void Clear(); + void Clear(bool deallocate_memory); lldb::addr_t AllocateMemory(size_t byte_size, uint32_t permissions, Status &error);
Index: lldb/source/Target/Process.cpp =================================================================== --- lldb/source/Target/Process.cpp +++ lldb/source/Target/Process.cpp @@ -543,7 +543,7 @@ m_notifications.swap(empty_notifications); m_image_tokens.clear(); m_memory_cache.Clear(); - m_allocated_memory_cache.Clear(); + m_allocated_memory_cache.Clear(/*deallocate_memory=*/true); { std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex); m_language_runtimes.clear(); @@ -5657,7 +5657,9 @@ m_dyld_up.reset(); m_jit_loaders_up.reset(); m_image_tokens.clear(); - m_allocated_memory_cache.Clear(); + // After an exec, the inferior is a new process and these memory regions are + // no longer allocated. + m_allocated_memory_cache.Clear(/*deallocte_memory=*/false); { std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex); m_language_runtimes.clear(); Index: lldb/source/Target/Memory.cpp =================================================================== --- lldb/source/Target/Memory.cpp +++ lldb/source/Target/Memory.cpp @@ -332,9 +332,9 @@ AllocatedMemoryCache::~AllocatedMemoryCache() = default; -void AllocatedMemoryCache::Clear() { +void AllocatedMemoryCache::Clear(bool deallocate_memory) { std::lock_guard<std::recursive_mutex> guard(m_mutex); - if (m_process.IsAlive()) { + if (m_process.IsAlive() && deallocate_memory) { PermissionsToBlockMap::iterator pos, end = m_memory_map.end(); for (pos = m_memory_map.begin(); pos != end; ++pos) m_process.DoDeallocateMemory(pos->second->GetBaseAddress()); Index: lldb/include/lldb/Target/Memory.h =================================================================== --- lldb/include/lldb/Target/Memory.h +++ lldb/include/lldb/Target/Memory.h @@ -116,7 +116,7 @@ ~AllocatedMemoryCache(); - void Clear(); + void Clear(bool deallocate_memory); lldb::addr_t AllocateMemory(size_t byte_size, uint32_t permissions, Status &error);
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits