[Lldb-commits] [lldb] 58def62 - [debugserver] Clear memory allocations after exec

Alex Langford via lldb-commits lldb-commits at lists.llvm.org
Wed Jan 11 13:44:48 PST 2023


Author: Alex Langford
Date: 2023-01-11T13:37:16-08:00
New Revision: 58def623ca46f107d185d7f02b267ffa751aff97

URL: https://github.com/llvm/llvm-project/commit/58def623ca46f107d185d7f02b267ffa751aff97
DIFF: https://github.com/llvm/llvm-project/commit/58def623ca46f107d185d7f02b267ffa751aff97.diff

LOG: [debugserver] Clear memory allocations after exec

After an exec, the inferior is a new process and none of these memory
regions are still allocated. Clear them out.

Differential Revision: https://reviews.llvm.org/D140253

Added: 
    

Modified: 
    lldb/tools/debugserver/source/MacOSX/MachProcess.mm
    lldb/tools/debugserver/source/MacOSX/MachTask.h
    lldb/tools/debugserver/source/MacOSX/MachTask.mm

Removed: 
    


################################################################################
diff  --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
index 3aa2a84bc359f..d524a49defb90 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
+++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
@@ -2285,6 +2285,7 @@ static bool mach_header_validity_test(uint32_t magic, uint32_t cputype) {
         m_thread_list.Clear();
         m_activities.Clear();
         m_breakpoints.DisableAll();
+        m_task.ClearAllocations();
       }
 
       if (m_sent_interrupt_signo != 0) {

diff  --git a/lldb/tools/debugserver/source/MacOSX/MachTask.h b/lldb/tools/debugserver/source/MacOSX/MachTask.h
index a58d5bed3b068..286a57b9e0dd1 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachTask.h
+++ b/lldb/tools/debugserver/source/MacOSX/MachTask.h
@@ -61,6 +61,7 @@ class MachTask {
 
   nub_addr_t AllocateMemory(nub_size_t size, uint32_t permissions);
   nub_bool_t DeallocateMemory(nub_addr_t addr);
+  void ClearAllocations();
 
   mach_port_t ExceptionPort() const;
   bool ExceptionPortIsValid() const;

diff  --git a/lldb/tools/debugserver/source/MacOSX/MachTask.mm b/lldb/tools/debugserver/source/MacOSX/MachTask.mm
index 1e03faf3f2e23..feec85df9ef18 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachTask.mm
+++ b/lldb/tools/debugserver/source/MacOSX/MachTask.mm
@@ -999,6 +999,13 @@ static void get_threads_profile_data(DNBProfileDataScanType scanType,
   return false;
 }
 
+//----------------------------------------------------------------------
+// MachTask::ClearAllocations
+//----------------------------------------------------------------------
+void MachTask::ClearAllocations() {
+  m_allocations.clear();
+}
+
 void MachTask::TaskPortChanged(task_t task)
 {
   m_task = task;


        


More information about the lldb-commits mailing list