Add a (currently disabled) bear trap where instead of deallocating pages, we remove all permissions.

llvm-svn: 124012
diff --git a/lldb/tools/debugserver/source/MacOSX/MachTask.cpp b/lldb/tools/debugserver/source/MacOSX/MachTask.cpp
index 62ebac29..316540f 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachTask.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachTask.cpp
@@ -626,7 +626,7 @@
     if (err.Error() == KERN_SUCCESS)
     {
         // Set the protections:
-        vm_prot_t mach_prot = 0;
+        vm_prot_t mach_prot = VM_PROT_NONE;
         if (permissions & eMemoryPermissionsReadable)
             mach_prot |= VM_PROT_READ;
         if (permissions & eMemoryPermissionsWritable)
@@ -663,7 +663,14 @@
         if ((*pos).first == addr)
         {
             m_allocations.erase(pos);
-            return ::mach_vm_deallocate (task, (*pos).first, (*pos).second) == KERN_SUCCESS;
+#define ALWAYS_ZOMBIE_ALLOCATIONS 0
+            if (ALWAYS_ZOMBIE_ALLOCATIONS || getenv ("DEBUGSERVER_ZOMBIE_ALLOCATIONS"))
+            {
+                ::mach_vm_protect (task, (*pos).first, (*pos).second, 0, VM_PROT_NONE);
+                return true;
+            }
+            else
+                return ::mach_vm_deallocate (task, (*pos).first, (*pos).second) == KERN_SUCCESS;
         }
         
     }