diff options
| author | Han Ming Ong <hanming@apple.com> | 2013-03-25 20:44:40 +0000 |
|---|---|---|
| committer | Han Ming Ong <hanming@apple.com> | 2013-03-25 20:44:40 +0000 |
| commit | 6f7237d1f19725716e896cdb73f992d8c7d5d3f6 (patch) | |
| tree | e4e862da652a161bf4d9a09ded9f4bf9b7a2b689 | |
| parent | 389ed4b8f74e02cf36b2b1a9e5f346a32150e0b6 (diff) | |
| download | bcm5719-llvm-6f7237d1f19725716e896cdb73f992d8c7d5d3f6.tar.gz bcm5719-llvm-6f7237d1f19725716e896cdb73f992d8c7d5d3f6.zip | |
<rdar://problem/13498504>
Don't hard code vm page size in profiling code
llvm-svn: 177907
| -rw-r--r-- | lldb/tools/debugserver/source/MacOSX/MachTask.cpp | 18 | ||||
| -rw-r--r-- | lldb/tools/debugserver/source/MacOSX/MachVMMemory.cpp | 29 |
2 files changed, 36 insertions, 11 deletions
diff --git a/lldb/tools/debugserver/source/MacOSX/MachTask.cpp b/lldb/tools/debugserver/source/MacOSX/MachTask.cpp index 21c10dde077..783a751f880 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachTask.cpp +++ b/lldb/tools/debugserver/source/MacOSX/MachTask.cpp @@ -417,12 +417,20 @@ MachTask::GetProfileData (DNBProfileDataScanType scanType) if (scanType & eProfileMemory) { - profile_data_stream << "wired:" << vm_stats.wire_count * vm_page_size << ';'; - profile_data_stream << "active:" << vm_stats.active_count * vm_page_size << ';'; - profile_data_stream << "inactive:" << vm_stats.inactive_count * vm_page_size << ';'; + static vm_size_t pagesize; + static bool calculated = false; + if (!calculated) + { + calculated = true; + host_page_size(mach_host_self(), &pagesize); + } + + profile_data_stream << "wired:" << vm_stats.wire_count * pagesize << ';'; + profile_data_stream << "active:" << vm_stats.active_count * pagesize << ';'; + profile_data_stream << "inactive:" << vm_stats.inactive_count * pagesize << ';'; uint64_t total_used_count = vm_stats.wire_count + vm_stats.inactive_count + vm_stats.active_count; - profile_data_stream << "used:" << total_used_count * vm_page_size << ';'; - profile_data_stream << "free:" << vm_stats.free_count * vm_page_size << ';'; + profile_data_stream << "used:" << total_used_count * pagesize << ';'; + profile_data_stream << "free:" << vm_stats.free_count * pagesize << ';'; profile_data_stream << "rprvt:" << rprvt << ';'; profile_data_stream << "rsize:" << rsize << ';'; diff --git a/lldb/tools/debugserver/source/MacOSX/MachVMMemory.cpp b/lldb/tools/debugserver/source/MacOSX/MachVMMemory.cpp index 6ef43424c5d..56d79fa39e0 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachVMMemory.cpp +++ b/lldb/tools/debugserver/source/MacOSX/MachVMMemory.cpp @@ -186,7 +186,9 @@ static uint64_t GetStolenPages() if(stolen >= mb128) { stolen = (stolen & ~((128 * 1024 * 1024ULL) - 1)); // rounding down - stolenPages = stolen/vm_page_size; + vm_size_t pagesize = vm_page_size; + host_page_size(mach_host_self(), &pagesize); + stolenPages = stolen/pagesize; } } } @@ -222,7 +224,7 @@ static void GetRegionSizes(task_t task, mach_vm_size_t &rsize, mach_vm_size_t &d while (1) { - mach_msg_type_number_t count; + mach_msg_type_number_t count; struct vm_region_submap_info_64 info; count = VM_REGION_SUBMAP_INFO_COUNT_64; @@ -260,8 +262,16 @@ static void GetRegionSizes(task_t task, mach_vm_size_t &rsize, mach_vm_size_t &d } } - rsize = pages_resident * vm_page_size; - dirty_size = pages_dirtied * vm_page_size; + static vm_size_t pagesize; + static bool calculated = false; + if (!calculated) + { + calculated = true; + host_page_size(mach_host_self(), &pagesize); + } + + rsize = pages_resident * pagesize; + dirty_size = pages_dirtied * pagesize; } // Test whether the virtual address is within the architecture's shared region. @@ -302,9 +312,16 @@ static void GetMemorySizes(task_t task, cpu_type_t cputype, nub_process_t pid, m mach_vm_size_t fw_private = 0; mach_vm_size_t aliased = 0; - mach_vm_size_t pagesize = vm_page_size; bool global_shared_text_data_mapped = false; + static vm_size_t pagesize; + static bool calculated = false; + if (!calculated) + { + calculated = true; + host_page_size(mach_host_self(), &pagesize); + } + for (mach_vm_address_t addr=0, size=0; ; addr += size) { vm_region_top_info_data_t info; @@ -321,7 +338,7 @@ static void GetMemorySizes(task_t task, cpu_type_t cputype, nub_process_t pid, m // Check if this process has the globally shared text and data regions mapped in. If so, set global_shared_text_data_mapped to TRUE and avoid checking again. if (global_shared_text_data_mapped == FALSE && info.share_mode == SM_EMPTY) { - vm_region_basic_info_data_64_t b_info; + vm_region_basic_info_data_64_t b_info; mach_vm_address_t b_addr = addr; mach_vm_size_t b_size = size; count = VM_REGION_BASIC_INFO_COUNT_64; |

