| 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 "base/trace_event/process_memory_dump.h" | 5 #include "base/trace_event/process_memory_dump.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" |
| 11 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 12 #include "base/process/process_metrics.h" | 13 #include "base/process/process_metrics.h" |
| 13 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 14 #include "base/trace_event/heap_profiler_heap_dump_writer.h" | 15 #include "base/trace_event/heap_profiler_heap_dump_writer.h" |
| 15 #include "base/trace_event/memory_infra_background_whitelist.h" | 16 #include "base/trace_event/memory_infra_background_whitelist.h" |
| 16 #include "base/trace_event/process_memory_totals.h" | 17 #include "base/trace_event/process_memory_totals.h" |
| 17 #include "base/trace_event/trace_event_argument.h" | 18 #include "base/trace_event/trace_event_argument.h" |
| 18 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 19 | 20 |
| 20 #if defined(OS_IOS) | 21 #if defined(OS_IOS) |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 for (size_t i = 0; i < page_count; i++) { | 109 for (size_t i = 0; i < page_count; i++) { |
| 109 vec[i].VirtualAddress = | 110 vec[i].VirtualAddress = |
| 110 reinterpret_cast<void*>(chunk_start + i * page_size); | 111 reinterpret_cast<void*>(chunk_start + i * page_size); |
| 111 } | 112 } |
| 112 DWORD vec_size = static_cast<DWORD>( | 113 DWORD vec_size = static_cast<DWORD>( |
| 113 page_count * sizeof(PSAPI_WORKING_SET_EX_INFORMATION)); | 114 page_count * sizeof(PSAPI_WORKING_SET_EX_INFORMATION)); |
| 114 failure = !QueryWorkingSetEx(GetCurrentProcess(), vec.get(), vec_size); | 115 failure = !QueryWorkingSetEx(GetCurrentProcess(), vec.get(), vec_size); |
| 115 | 116 |
| 116 for (size_t i = 0; i < page_count; i++) | 117 for (size_t i = 0; i < page_count; i++) |
| 117 resident_page_count += vec[i].VirtualAttributes.Valid; | 118 resident_page_count += vec[i].VirtualAttributes.Valid; |
| 119 #elif defined(OS_FUCHSIA) |
| 120 // TODO(scottmg): Port. |
| 121 ALLOW_UNUSED_LOCAL(chunk_start); |
| 122 ALLOW_UNUSED_LOCAL(page_count); |
| 118 #elif defined(OS_POSIX) | 123 #elif defined(OS_POSIX) |
| 119 int error_counter = 0; | 124 int error_counter = 0; |
| 120 int result = 0; | 125 int result = 0; |
| 121 // HANDLE_EINTR tries for 100 times. So following the same pattern. | 126 // HANDLE_EINTR tries for 100 times. So following the same pattern. |
| 122 do { | 127 do { |
| 123 result = | 128 result = |
| 124 mincore(reinterpret_cast<void*>(chunk_start), chunk_size, vec.get()); | 129 mincore(reinterpret_cast<void*>(chunk_start), chunk_size, vec.get()); |
| 125 } while (result == -1 && errno == EAGAIN && error_counter++ < 100); | 130 } while (result == -1 && errno == EAGAIN && error_counter++ < 100); |
| 126 failure = !!result; | 131 failure = !!result; |
| 127 | 132 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 | 363 |
| 359 MemoryAllocatorDump* ProcessMemoryDump::GetBlackHoleMad() { | 364 MemoryAllocatorDump* ProcessMemoryDump::GetBlackHoleMad() { |
| 360 DCHECK(is_black_hole_non_fatal_for_testing_); | 365 DCHECK(is_black_hole_non_fatal_for_testing_); |
| 361 if (!black_hole_mad_) | 366 if (!black_hole_mad_) |
| 362 black_hole_mad_.reset(new MemoryAllocatorDump("discarded", this)); | 367 black_hole_mad_.reset(new MemoryAllocatorDump("discarded", this)); |
| 363 return black_hole_mad_.get(); | 368 return black_hole_mad_.get(); |
| 364 } | 369 } |
| 365 | 370 |
| 366 } // namespace trace_event | 371 } // namespace trace_event |
| 367 } // namespace base | 372 } // namespace base |
| OLD | NEW |