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 AllocationContextTracker::SetCaptureEnabled(true); | 173 std::string profiling_mode = CommandLine::ForCurrentProcess() |
| 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 |
174 for (auto mdp : dump_providers_) | 193 for (auto mdp : dump_providers_) |
175 mdp->dump_provider->OnHeapProfilingEnabled(true); | 194 mdp->dump_provider->OnHeapProfilingEnabled(true); |
176 heap_profiling_enabled_ = true; | 195 heap_profiling_enabled_ = true; |
177 } | 196 } |
178 | 197 |
179 void MemoryDumpManager::Initialize(MemoryDumpManagerDelegate* delegate, | 198 void MemoryDumpManager::Initialize(MemoryDumpManagerDelegate* delegate, |
180 bool is_coordinator) { | 199 bool is_coordinator) { |
181 { | 200 { |
182 AutoLock lock(lock_); | 201 AutoLock lock(lock_); |
183 DCHECK(delegate); | 202 DCHECK(delegate); |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 if (iter == process_dumps.end()) { | 774 if (iter == process_dumps.end()) { |
756 std::unique_ptr<ProcessMemoryDump> new_pmd( | 775 std::unique_ptr<ProcessMemoryDump> new_pmd( |
757 new ProcessMemoryDump(session_state)); | 776 new ProcessMemoryDump(session_state)); |
758 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; | 777 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; |
759 } | 778 } |
760 return iter->second.get(); | 779 return iter->second.get(); |
761 } | 780 } |
762 | 781 |
763 } // namespace trace_event | 782 } // namespace trace_event |
764 } // namespace base | 783 } // namespace base |
OLD | NEW |