| 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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/atomic_sequence_num.h" | 10 #include "base/atomic_sequence_num.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 163 |
| 164 void MemoryDumpManager::EnableHeapProfilingIfNeeded() { | 164 void MemoryDumpManager::EnableHeapProfilingIfNeeded() { |
| 165 if (heap_profiling_enabled_) | 165 if (heap_profiling_enabled_) |
| 166 return; | 166 return; |
| 167 | 167 |
| 168 if (!CommandLine::InitializedForCurrentProcess() || | 168 if (!CommandLine::InitializedForCurrentProcess() || |
| 169 !CommandLine::ForCurrentProcess()->HasSwitch( | 169 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 170 switches::kEnableHeapProfiling)) | 170 switches::kEnableHeapProfiling)) |
| 171 return; | 171 return; |
| 172 | 172 |
| 173 std::string profiling_mode = CommandLine::ForCurrentProcess() | 173 AllocationContextTracker::SetCaptureEnabled(true); |
| 174 ->GetSwitchValueASCII(switches::kEnableHeapProfiling); | |
| 175 if (profiling_mode == "") { | |
| 176 AllocationContextTracker::SetCaptureMode( | |
| 177 AllocationContextTracker::CaptureMode::PSEUDO_STACK); | |
| 178 } | |
| 179 else if (profiling_mode == switches::kEnableHeapProfilingModeNative) { | |
| 180 #if ENABLE_NATIVE_ALLOCATION_TRACES | |
| 181 AllocationContextTracker::SetCaptureMode( | |
| 182 AllocationContextTracker::CaptureMode::NATIVE_STACK); | |
| 183 #else | |
| 184 CHECK(false) << "'" << profiling_mode << "' mode for " | |
| 185 << switches::kEnableHeapProfiling << " flag is not supported " | |
| 186 << "for this platform / build type."; | |
| 187 #endif | |
| 188 } else { | |
| 189 CHECK(false) << "Invalid mode '" << profiling_mode << "' for " | |
| 190 << switches::kEnableHeapProfiling << " flag."; | |
| 191 } | |
| 192 | |
| 193 for (auto mdp : dump_providers_) | 174 for (auto mdp : dump_providers_) |
| 194 mdp->dump_provider->OnHeapProfilingEnabled(true); | 175 mdp->dump_provider->OnHeapProfilingEnabled(true); |
| 195 heap_profiling_enabled_ = true; | 176 heap_profiling_enabled_ = true; |
| 196 } | 177 } |
| 197 | 178 |
| 198 void MemoryDumpManager::Initialize(MemoryDumpManagerDelegate* delegate, | 179 void MemoryDumpManager::Initialize(MemoryDumpManagerDelegate* delegate, |
| 199 bool is_coordinator) { | 180 bool is_coordinator) { |
| 200 { | 181 { |
| 201 AutoLock lock(lock_); | 182 AutoLock lock(lock_); |
| 202 DCHECK(delegate); | 183 DCHECK(delegate); |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 if (iter == process_dumps.end()) { | 755 if (iter == process_dumps.end()) { |
| 775 std::unique_ptr<ProcessMemoryDump> new_pmd( | 756 std::unique_ptr<ProcessMemoryDump> new_pmd( |
| 776 new ProcessMemoryDump(session_state)); | 757 new ProcessMemoryDump(session_state)); |
| 777 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; | 758 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; |
| 778 } | 759 } |
| 779 return iter->second.get(); | 760 return iter->second.get(); |
| 780 } | 761 } |
| 781 | 762 |
| 782 } // namespace trace_event | 763 } // namespace trace_event |
| 783 } // namespace base | 764 } // namespace base |
| OLD | NEW |