| 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/heap_profiler_serialization_state.h" | 16 #include "base/trace_event/heap_profiler_serialization_state.h" |
| 16 #include "base/trace_event/memory_infra_background_whitelist.h" | 17 #include "base/trace_event/memory_infra_background_whitelist.h" |
| 17 #include "base/trace_event/process_memory_totals.h" | 18 #include "base/trace_event/process_memory_totals.h" |
| 18 #include "base/trace_event/trace_event_argument.h" | 19 #include "base/trace_event/trace_event_argument.h" |
| 19 #include "build/build_config.h" | 20 #include "build/build_config.h" |
| 20 | 21 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 for (size_t i = 0; i < page_count; i++) { | 110 for (size_t i = 0; i < page_count; i++) { |
| 110 vec[i].VirtualAddress = | 111 vec[i].VirtualAddress = |
| 111 reinterpret_cast<void*>(chunk_start + i * page_size); | 112 reinterpret_cast<void*>(chunk_start + i * page_size); |
| 112 } | 113 } |
| 113 DWORD vec_size = static_cast<DWORD>( | 114 DWORD vec_size = static_cast<DWORD>( |
| 114 page_count * sizeof(PSAPI_WORKING_SET_EX_INFORMATION)); | 115 page_count * sizeof(PSAPI_WORKING_SET_EX_INFORMATION)); |
| 115 failure = !QueryWorkingSetEx(GetCurrentProcess(), vec.get(), vec_size); | 116 failure = !QueryWorkingSetEx(GetCurrentProcess(), vec.get(), vec_size); |
| 116 | 117 |
| 117 for (size_t i = 0; i < page_count; i++) | 118 for (size_t i = 0; i < page_count; i++) |
| 118 resident_page_count += vec[i].VirtualAttributes.Valid; | 119 resident_page_count += vec[i].VirtualAttributes.Valid; |
| 120 #elif defined(OS_FUCHSIA) |
| 121 // TODO(scottmg): Port. |
| 122 ALLOW_UNUSED_LOCAL(chunk_start); |
| 123 ALLOW_UNUSED_LOCAL(page_count); |
| 119 #elif defined(OS_POSIX) | 124 #elif defined(OS_POSIX) |
| 120 int error_counter = 0; | 125 int error_counter = 0; |
| 121 int result = 0; | 126 int result = 0; |
| 122 // HANDLE_EINTR tries for 100 times. So following the same pattern. | 127 // HANDLE_EINTR tries for 100 times. So following the same pattern. |
| 123 do { | 128 do { |
| 124 result = | 129 result = |
| 125 #if defined(OS_AIX) | 130 #if defined(OS_AIX) |
| 126 mincore(reinterpret_cast<char*>(chunk_start), chunk_size, | 131 mincore(reinterpret_cast<char*>(chunk_start), chunk_size, |
| 127 reinterpret_cast<char*>(vec.get())); | 132 reinterpret_cast<char*>(vec.get())); |
| 128 #else | 133 #else |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 | 379 |
| 375 MemoryAllocatorDump* ProcessMemoryDump::GetBlackHoleMad() { | 380 MemoryAllocatorDump* ProcessMemoryDump::GetBlackHoleMad() { |
| 376 DCHECK(is_black_hole_non_fatal_for_testing_); | 381 DCHECK(is_black_hole_non_fatal_for_testing_); |
| 377 if (!black_hole_mad_) | 382 if (!black_hole_mad_) |
| 378 black_hole_mad_.reset(new MemoryAllocatorDump("discarded", this)); | 383 black_hole_mad_.reset(new MemoryAllocatorDump("discarded", this)); |
| 379 return black_hole_mad_.get(); | 384 return black_hole_mad_.get(); |
| 380 } | 385 } |
| 381 | 386 |
| 382 } // namespace trace_event | 387 } // namespace trace_event |
| 383 } // namespace base | 388 } // namespace base |
| OLD | NEW |