OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/tracing/common/process_metrics_memory_dump_provider.h" | 5 #include "components/tracing/common/process_metrics_memory_dump_provider.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 | 423 |
424 // Creates VMRegions from mach_vm_region_recurse. Returns whether the operation | 424 // Creates VMRegions from mach_vm_region_recurse. Returns whether the operation |
425 // succeeded. | 425 // succeeded. |
426 bool GetAllRegions(std::vector<VMRegion>* regions) { | 426 bool GetAllRegions(std::vector<VMRegion>* regions) { |
427 const int pid = getpid(); | 427 const int pid = getpid(); |
428 task_t task = mach_task_self(); | 428 task_t task = mach_task_self(); |
429 mach_vm_size_t size = 0; | 429 mach_vm_size_t size = 0; |
430 vm_region_submap_info_64 info; | 430 vm_region_submap_info_64 info; |
431 natural_t depth = 1; | 431 natural_t depth = 1; |
432 mach_msg_type_number_t count = sizeof(info); | 432 mach_msg_type_number_t count = sizeof(info); |
433 for (mach_vm_address_t address = MACH_VM_MIN_ADDRESS;; address += size) { | 433 mach_vm_address_t address = MACH_VM_MIN_ADDRESS; |
| 434 while (true) { |
434 memset(&info, 0, sizeof(info)); | 435 memset(&info, 0, sizeof(info)); |
435 kern_return_t kr = mach_vm_region_recurse( | 436 kern_return_t kr = mach_vm_region_recurse( |
436 task, &address, &size, &depth, | 437 task, &address, &size, &depth, |
437 reinterpret_cast<vm_region_info_t>(&info), &count); | 438 reinterpret_cast<vm_region_info_t>(&info), &count); |
438 if (kr == KERN_INVALID_ADDRESS) // nothing else left | 439 if (kr == KERN_INVALID_ADDRESS) // nothing else left |
439 break; | 440 break; |
440 if (kr != KERN_SUCCESS) // something bad | 441 if (kr != KERN_SUCCESS) // something bad |
441 return false; | 442 return false; |
442 if (info.is_submap) { | 443 if (info.is_submap) { |
443 size = 0; | 444 size = 0; |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 #endif | 705 #endif |
705 } | 706 } |
706 | 707 |
707 void ProcessMetricsMemoryDumpProvider::SuspendFastMemoryPolling() { | 708 void ProcessMetricsMemoryDumpProvider::SuspendFastMemoryPolling() { |
708 #if defined(OS_LINUX) || defined(OS_ANDROID) | 709 #if defined(OS_LINUX) || defined(OS_ANDROID) |
709 fast_polling_statm_fd_.reset(); | 710 fast_polling_statm_fd_.reset(); |
710 #endif | 711 #endif |
711 } | 712 } |
712 | 713 |
713 } // namespace tracing | 714 } // namespace tracing |
OLD | NEW |