[debugserver] Clear memory allocations after exec
authorAlex Langford <alangford@apple.com>
Sat, 17 Dec 2022 00:19:40 +0000 (16:19 -0800)
committerAlex Langford <alangford@apple.com>
Wed, 11 Jan 2023 21:37:16 +0000 (13:37 -0800)
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

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

index 3aa2a84..d524a49 100644 (file)
@@ -2285,6 +2285,7 @@ task_t MachProcess::ExceptionMessageBundleComplete() {
         m_thread_list.Clear();
         m_activities.Clear();
         m_breakpoints.DisableAll();
+        m_task.ClearAllocations();
       }
 
       if (m_sent_interrupt_signo != 0) {
index a58d5be..286a57b 100644 (file)
@@ -61,6 +61,7 @@ public:
 
   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;
index 1e03faf..feec85d 100644 (file)
@@ -999,6 +999,13 @@ nub_bool_t MachTask::DeallocateMemory(nub_addr_t addr) {
   return false;
 }
 
+//----------------------------------------------------------------------
+// MachTask::ClearAllocations
+//----------------------------------------------------------------------
+void MachTask::ClearAllocations() {
+  m_allocations.clear();
+}
+
 void MachTask::TaskPortChanged(task_t task)
 {
   m_task = task;