Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Side by Side Diff: components/tracing/common/process_metrics_memory_dump_provider.cc

Issue 2788453002: Revert of macOS: Fix a bug in logic to get all memory regions. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 mach_vm_address_t address = MACH_VM_MIN_ADDRESS; 433 for (mach_vm_address_t address = MACH_VM_MIN_ADDRESS;; address += size) {
434 while (true) {
435 memset(&info, 0, sizeof(info)); 434 memset(&info, 0, sizeof(info));
436 kern_return_t kr = mach_vm_region_recurse( 435 kern_return_t kr = mach_vm_region_recurse(
437 task, &address, &size, &depth, 436 task, &address, &size, &depth,
438 reinterpret_cast<vm_region_info_t>(&info), &count); 437 reinterpret_cast<vm_region_info_t>(&info), &count);
439 if (kr == KERN_INVALID_ADDRESS) // nothing else left 438 if (kr == KERN_INVALID_ADDRESS) // nothing else left
440 break; 439 break;
441 if (kr != KERN_SUCCESS) // something bad 440 if (kr != KERN_SUCCESS) // something bad
442 return false; 441 return false;
443 if (info.is_submap) { 442 if (info.is_submap) {
444 size = 0; 443 size = 0;
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 #endif 704 #endif
706 } 705 }
707 706
708 void ProcessMetricsMemoryDumpProvider::SuspendFastMemoryPolling() { 707 void ProcessMetricsMemoryDumpProvider::SuspendFastMemoryPolling() {
709 #if defined(OS_LINUX) || defined(OS_ANDROID) 708 #if defined(OS_LINUX) || defined(OS_ANDROID)
710 fast_polling_statm_fd_.reset(); 709 fast_polling_statm_fd_.reset();
711 #endif 710 #endif
712 } 711 }
713 712
714 } // namespace tracing 713 } // namespace tracing
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698