Chromium Code Reviews| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 | 162 |
| 163 void MemoryDumpManager::EnableHeapProfilingIfNeeded() { | 163 void MemoryDumpManager::EnableHeapProfilingIfNeeded() { |
| 164 if (heap_profiling_enabled_) | 164 if (heap_profiling_enabled_) |
| 165 return; | 165 return; |
| 166 | 166 |
| 167 if (!CommandLine::InitializedForCurrentProcess() || | 167 if (!CommandLine::InitializedForCurrentProcess() || |
| 168 !CommandLine::ForCurrentProcess()->HasSwitch( | 168 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 169 switches::kEnableHeapProfiling)) | 169 switches::kEnableHeapProfiling)) |
| 170 return; | 170 return; |
| 171 | 171 |
| 172 AllocationContextTracker::SetCaptureEnabled(true); | 172 std::string profiling_mode = CommandLine::ForCurrentProcess() |
| 173 ->GetSwitchValueASCII(switches::kEnableHeapProfiling); | |
| 174 if (profiling_mode == "") { | |
| 175 AllocationContextTracker::SetCaptureMode( | |
| 176 AllocationContextTracker::CaptureMode::PSEUDO_STACK); | |
| 177 } | |
| 178 else if (profiling_mode == switches::kEnableHeapProfilingModeNative) { | |
| 179 #if ENABLE_NATIVE_ALLOCATION_TRACES | |
| 180 AllocationContextTracker::SetCaptureMode( | |
| 181 AllocationContextTracker::CaptureMode::NATIVE_STACK); | |
| 182 #else | |
| 183 CHECK(false) << "'" << profiling_mode << "' mode for " | |
| 184 << switches::kEnableHeapProfiling << " flag is not supported " | |
| 185 << "for this platform / build type."; | |
| 186 #endif | |
| 187 } else { | |
| 188 CHECK(false) << "Invalid mode '" << profiling_mode << "' for " | |
| 189 << switches::kEnableHeapProfiling << " flag."; | |
| 190 | |
| 191 // If the above didn't crash, use some default | |
|
Primiano Tucci (use gerrit)
2016/04/21 20:08:21
uh wat?
If the above didn't crash we have some ser
Dmitry Skiba
2016/04/22 06:31:15
Done.
| |
| 192 AllocationContextTracker::SetCaptureMode( | |
| 193 AllocationContextTracker::CaptureMode::PSEUDO_STACK); | |
| 194 } | |
| 195 | |
| 173 for (auto mdp : dump_providers_) | 196 for (auto mdp : dump_providers_) |
| 174 mdp->dump_provider->OnHeapProfilingEnabled(true); | 197 mdp->dump_provider->OnHeapProfilingEnabled(true); |
| 175 heap_profiling_enabled_ = true; | 198 heap_profiling_enabled_ = true; |
| 176 } | 199 } |
| 177 | 200 |
| 178 void MemoryDumpManager::Initialize(MemoryDumpManagerDelegate* delegate, | 201 void MemoryDumpManager::Initialize(MemoryDumpManagerDelegate* delegate, |
| 179 bool is_coordinator) { | 202 bool is_coordinator) { |
| 180 { | 203 { |
| 181 AutoLock lock(lock_); | 204 AutoLock lock(lock_); |
| 182 DCHECK(delegate); | 205 DCHECK(delegate); |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 751 if (iter == process_dumps.end()) { | 774 if (iter == process_dumps.end()) { |
| 752 std::unique_ptr<ProcessMemoryDump> new_pmd( | 775 std::unique_ptr<ProcessMemoryDump> new_pmd( |
| 753 new ProcessMemoryDump(session_state)); | 776 new ProcessMemoryDump(session_state)); |
| 754 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; |
| 755 } | 778 } |
| 756 return iter->second.get(); | 779 return iter->second.get(); |
| 757 } | 780 } |
| 758 | 781 |
| 759 } // namespace trace_event | 782 } // namespace trace_event |
| 760 } // namespace base | 783 } // namespace base |
| OLD | NEW |