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 <inttypes.h> | 7 #include <inttypes.h> |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 | 194 |
| 195 void MemoryDumpManager::EnableHeapProfilingIfNeeded() { | 195 void MemoryDumpManager::EnableHeapProfilingIfNeeded() { |
| 196 if (heap_profiling_enabled_) | 196 if (heap_profiling_enabled_) |
| 197 return; | 197 return; |
| 198 | 198 |
| 199 if (!CommandLine::InitializedForCurrentProcess() || | 199 if (!CommandLine::InitializedForCurrentProcess() || |
| 200 !CommandLine::ForCurrentProcess()->HasSwitch( | 200 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 201 switches::kEnableHeapProfiling)) | 201 switches::kEnableHeapProfiling)) |
| 202 return; | 202 return; |
| 203 | 203 |
| 204 #if !BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM) | |
|
Wez
2017/05/24 21:29:25
Do we ever actually set this under Windows? The W
Primiano Tucci (use gerrit)
2017/05/25 10:46:51
I thought so:
From build/config/allocator.gni:
i
| |
| 205 #if defined(OS_WIN) | |
| 206 const char kExtraErrMsg[] = "On Windows it requires release + static builds."; | |
| 207 #else | |
| 208 const char kExtraErrMsg[] = ""; | |
| 209 #endif // defined(OS_WIN) | |
| 210 LOG(FATAL) << "--" << switches::kEnableHeapProfiling | |
| 211 << " requires building with use_experimental_allocator_shim=true " | |
| 212 "(on by default on the major platforms). " | |
| 213 << kExtraErrMsg; | |
| 214 #endif // BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM) | |
| 215 | |
| 204 std::string profiling_mode = CommandLine::ForCurrentProcess() | 216 std::string profiling_mode = CommandLine::ForCurrentProcess() |
| 205 ->GetSwitchValueASCII(switches::kEnableHeapProfiling); | 217 ->GetSwitchValueASCII(switches::kEnableHeapProfiling); |
| 206 if (profiling_mode == switches::kEnableHeapProfilingModePseudo) { | 218 if (profiling_mode == switches::kEnableHeapProfilingModePseudo) { |
| 207 AllocationContextTracker::SetCaptureMode( | 219 AllocationContextTracker::SetCaptureMode( |
| 208 AllocationContextTracker::CaptureMode::PSEUDO_STACK); | 220 AllocationContextTracker::CaptureMode::PSEUDO_STACK); |
| 209 #if !defined(OS_NACL) | 221 #if !defined(OS_NACL) |
| 210 } else if (profiling_mode == switches::kEnableHeapProfilingModeNative) { | 222 } else if (profiling_mode == switches::kEnableHeapProfilingModeNative) { |
| 211 // If we don't have frame pointers then native tracing falls-back to | 223 // If we don't have frame pointers then native tracing falls-back to |
| 212 // using base::debug::StackTrace, which may be slow. | 224 // using base::debug::StackTrace, which may be slow. |
| 213 AllocationContextTracker::SetCaptureMode( | 225 AllocationContextTracker::SetCaptureMode( |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 908 if (iter == process_dumps.end()) { | 920 if (iter == process_dumps.end()) { |
| 909 std::unique_ptr<ProcessMemoryDump> new_pmd( | 921 std::unique_ptr<ProcessMemoryDump> new_pmd( |
| 910 new ProcessMemoryDump(heap_profiler_serialization_state, dump_args)); | 922 new ProcessMemoryDump(heap_profiler_serialization_state, dump_args)); |
| 911 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; | 923 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; |
| 912 } | 924 } |
| 913 return iter->second.get(); | 925 return iter->second.get(); |
| 914 } | 926 } |
| 915 | 927 |
| 916 } // namespace trace_event | 928 } // namespace trace_event |
| 917 } // namespace base | 929 } // namespace base |
| OLD | NEW |