<rdar://problem/13338758>

Make it configurable what to profile.
For Mac, we don't use the dirty page size yet and hence there is no need to gather that. This should be way better in not draining the battery since we are operating between 0% to 0.1% on the Mac after this change.

llvm-svn: 176451
diff --git a/lldb/tools/debugserver/source/MacOSX/MachVMMemory.cpp b/lldb/tools/debugserver/source/MacOSX/MachVMMemory.cpp
index d13cbfe..c0ce9c6 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachVMMemory.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachVMMemory.cpp
@@ -397,21 +397,29 @@
 }
 
 nub_bool_t
-MachVMMemory::GetMemoryProfile(task_t task, struct task_basic_info ti, cpu_type_t cputype, nub_process_t pid, vm_statistics_data_t &vm_stats, uint64_t &physical_memory, mach_vm_size_t &rprvt, mach_vm_size_t &rsize, mach_vm_size_t &vprvt, mach_vm_size_t &vsize, mach_vm_size_t &dirty_size)
+MachVMMemory::GetMemoryProfile(DNBProfileDataScanType scanType, task_t task, struct task_basic_info ti, cpu_type_t cputype, nub_process_t pid, vm_statistics_data_t &vm_stats, uint64_t &physical_memory, mach_vm_size_t &rprvt, mach_vm_size_t &rsize, mach_vm_size_t &vprvt, mach_vm_size_t &vsize, mach_vm_size_t &dirty_size)
 {
-    static mach_port_t localHost = mach_host_self();
-    mach_msg_type_number_t count = HOST_VM_INFO_COUNT;
-    host_statistics(localHost, HOST_VM_INFO, (host_info_t)&vm_stats, &count);
-    vm_stats.wire_count += GetStolenPages();
-    physical_memory = GetPhysicalMemory();
-
-    // This uses vmmap strategy. We don't use the returned rsize for now. We prefer to match top's version since that's what we do for the rest of the metrics.
-    GetRegionSizes(task, rsize, dirty_size);
+    if (scanType & eProfileHostMemory)
+        physical_memory = GetPhysicalMemory();
     
-    GetMemorySizes(task, cputype, pid, rprvt, vprvt);
+    if (scanType & eProfileMemory)
+    {
+        static mach_port_t localHost = mach_host_self();
+        mach_msg_type_number_t count = HOST_VM_INFO_COUNT;
+        host_statistics(localHost, HOST_VM_INFO, (host_info_t)&vm_stats, &count);
+        vm_stats.wire_count += GetStolenPages();
     
-    rsize = ti.resident_size;
-    vsize = ti.virtual_size;
+        GetMemorySizes(task, cputype, pid, rprvt, vprvt);
+    
+        rsize = ti.resident_size;
+        vsize = ti.virtual_size;
+    }
+    
+    if (scanType & eProfileMemoryDirtyPage)
+    {
+        // This uses vmmap strategy. We don't use the returned rsize for now. We prefer to match top's version since that's what we do for the rest of the metrics.
+        GetRegionSizes(task, rsize, dirty_size);
+    }
     
     return true;
 }