| 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/memory_dump_manager.h" | 5 #include "base/trace_event/memory_dump_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
| 10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
| 14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
| 15 #include "base/trace_event/malloc_dump_provider.h" | 15 #include "base/trace_event/malloc_dump_provider.h" |
| 16 #include "base/trace_event/memory_dump_provider.h" | 16 #include "base/trace_event/memory_dump_provider.h" |
| 17 #include "base/trace_event/memory_dump_session_state.h" | 17 #include "base/trace_event/memory_dump_session_state.h" |
| 18 #include "base/trace_event/memory_profiler_allocation_context.h" | 18 #include "base/trace_event/memory_profiler_allocation_context.h" |
| 19 #include "base/trace_event/process_memory_dump.h" | 19 #include "base/trace_event/process_memory_dump.h" |
| 20 #include "base/trace_event/trace_event_argument.h" | 20 #include "base/trace_event/trace_event_argument.h" |
| 21 #include "build/build_config.h" | 21 #include "build/build_config.h" |
| 22 | 22 |
| 23 #if !defined(OS_NACL) | |
| 24 #include "base/trace_event/process_memory_totals_dump_provider.h" | |
| 25 #endif | |
| 26 | |
| 27 #if defined(OS_LINUX) || defined(OS_ANDROID) | |
| 28 #include "base/trace_event/process_memory_maps_dump_provider.h" | |
| 29 #endif | |
| 30 | |
| 31 #if defined(OS_ANDROID) | 23 #if defined(OS_ANDROID) |
| 32 #include "base/trace_event/java_heap_dump_provider_android.h" | 24 #include "base/trace_event/java_heap_dump_provider_android.h" |
| 33 #endif | 25 #endif |
| 34 | 26 |
| 35 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
| 36 #include "base/trace_event/winheap_dump_provider_win.h" | 28 #include "base/trace_event/winheap_dump_provider_win.h" |
| 37 #endif | 29 #endif |
| 38 | 30 |
| 39 namespace base { | 31 namespace base { |
| 40 namespace trace_event { | 32 namespace trace_event { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 void MemoryDumpManager::Initialize(MemoryDumpManagerDelegate* delegate, | 138 void MemoryDumpManager::Initialize(MemoryDumpManagerDelegate* delegate, |
| 147 bool is_coordinator) { | 139 bool is_coordinator) { |
| 148 { | 140 { |
| 149 AutoLock lock(lock_); | 141 AutoLock lock(lock_); |
| 150 DCHECK(delegate); | 142 DCHECK(delegate); |
| 151 DCHECK(!delegate_); | 143 DCHECK(!delegate_); |
| 152 delegate_ = delegate; | 144 delegate_ = delegate; |
| 153 is_coordinator_ = is_coordinator; | 145 is_coordinator_ = is_coordinator; |
| 154 } | 146 } |
| 155 | 147 |
| 156 // Enable the core dump providers. | 148 // Enable the core dump providers. |
| 157 #if !defined(OS_NACL) | |
| 158 RegisterDumpProvider(ProcessMemoryTotalsDumpProvider::GetInstance(), | |
| 159 "ProcessMemoryTotals", nullptr); | |
| 160 #endif | |
| 161 | |
| 162 #if defined(MALLOC_MEMORY_TRACING_SUPPORTED) | 149 #if defined(MALLOC_MEMORY_TRACING_SUPPORTED) |
| 163 RegisterDumpProvider(MallocDumpProvider::GetInstance(), "Malloc", nullptr); | 150 RegisterDumpProvider(MallocDumpProvider::GetInstance(), "Malloc", nullptr); |
| 164 #endif | 151 #endif |
| 165 | 152 |
| 166 #if defined(OS_LINUX) || defined(OS_ANDROID) | |
| 167 RegisterDumpProvider(ProcessMemoryMapsDumpProvider::GetInstance(), | |
| 168 "ProcessMemoryMaps", nullptr); | |
| 169 #endif | |
| 170 | |
| 171 #if defined(OS_ANDROID) | 153 #if defined(OS_ANDROID) |
| 172 RegisterDumpProvider(JavaHeapDumpProvider::GetInstance(), "JavaHeap", | 154 RegisterDumpProvider(JavaHeapDumpProvider::GetInstance(), "JavaHeap", |
| 173 nullptr); | 155 nullptr); |
| 174 #endif | 156 #endif |
| 175 | 157 |
| 176 #if defined(OS_WIN) | 158 #if defined(OS_WIN) |
| 177 RegisterDumpProvider(WinHeapDumpProvider::GetInstance(), "WinHeap", nullptr); | 159 RegisterDumpProvider(WinHeapDumpProvider::GetInstance(), "WinHeap", nullptr); |
| 178 #endif | 160 #endif |
| 179 | 161 |
| 180 // If tracing was enabled before initializing MemoryDumpManager, we missed the | 162 // If tracing was enabled before initializing MemoryDumpManager, we missed the |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 auto iter = process_dumps.find(pid); | 652 auto iter = process_dumps.find(pid); |
| 671 if (iter == process_dumps.end()) { | 653 if (iter == process_dumps.end()) { |
| 672 scoped_ptr<ProcessMemoryDump> new_pmd(new ProcessMemoryDump(session_state)); | 654 scoped_ptr<ProcessMemoryDump> new_pmd(new ProcessMemoryDump(session_state)); |
| 673 iter = process_dumps.insert(pid, new_pmd.Pass()).first; | 655 iter = process_dumps.insert(pid, new_pmd.Pass()).first; |
| 674 } | 656 } |
| 675 return iter->second; | 657 return iter->second; |
| 676 } | 658 } |
| 677 | 659 |
| 678 } // namespace trace_event | 660 } // namespace trace_event |
| 679 } // namespace base | 661 } // namespace base |
| OLD | NEW |