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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 if (!CommandLine::InitializedForCurrentProcess() || | 188 if (!CommandLine::InitializedForCurrentProcess() || |
189 !CommandLine::ForCurrentProcess()->HasSwitch( | 189 !CommandLine::ForCurrentProcess()->HasSwitch( |
190 switches::kEnableHeapProfiling)) | 190 switches::kEnableHeapProfiling)) |
191 return; | 191 return; |
192 | 192 |
193 std::string profiling_mode = CommandLine::ForCurrentProcess() | 193 std::string profiling_mode = CommandLine::ForCurrentProcess() |
194 ->GetSwitchValueASCII(switches::kEnableHeapProfiling); | 194 ->GetSwitchValueASCII(switches::kEnableHeapProfiling); |
195 if (profiling_mode == "") { | 195 if (profiling_mode == "") { |
196 AllocationContextTracker::SetCaptureMode( | 196 AllocationContextTracker::SetCaptureMode( |
197 AllocationContextTracker::CaptureMode::PSEUDO_STACK); | 197 AllocationContextTracker::CaptureMode::PSEUDO_STACK); |
198 #if (BUILDFLAG(CAN_UNWIND_WITH_FRAME_POINTERS) || !defined(NDEBUG)) | |
199 } else if (profiling_mode == switches::kEnableHeapProfilingModeNative) { | 198 } else if (profiling_mode == switches::kEnableHeapProfilingModeNative) { |
200 // We need frame pointers for native tracing to work, and they are | 199 // If we don't have frame pointers then native tracing falls-back to |
201 // enabled in profiling and debug builds. | 200 // using base::debug::StackTrace, which may be slow. |
202 AllocationContextTracker::SetCaptureMode( | 201 AllocationContextTracker::SetCaptureMode( |
203 AllocationContextTracker::CaptureMode::NATIVE_STACK); | 202 AllocationContextTracker::CaptureMode::NATIVE_STACK); |
204 #endif | |
205 #if BUILDFLAG(ENABLE_MEMORY_TASK_PROFILER) | 203 #if BUILDFLAG(ENABLE_MEMORY_TASK_PROFILER) |
206 } else if (profiling_mode == switches::kEnableHeapProfilingTaskProfiler) { | 204 } else if (profiling_mode == switches::kEnableHeapProfilingTaskProfiler) { |
207 // Enable heap tracking, which in turn enables capture of heap usage | 205 // Enable heap tracking, which in turn enables capture of heap usage |
208 // tracking in tracked_objects.cc. | 206 // tracking in tracked_objects.cc. |
209 if (!base::debug::ThreadHeapUsageTracker::IsHeapTrackingEnabled()) | 207 if (!base::debug::ThreadHeapUsageTracker::IsHeapTrackingEnabled()) |
210 base::debug::ThreadHeapUsageTracker::EnableHeapTracking(); | 208 base::debug::ThreadHeapUsageTracker::EnableHeapTracking(); |
211 #endif | 209 #endif |
212 } else { | 210 } else { |
213 CHECK(false) << "Invalid mode '" << profiling_mode << "' for " | 211 CHECK(false) << "Invalid mode '" << profiling_mode << "' for " |
214 << switches::kEnableHeapProfiling << " flag."; | 212 << switches::kEnableHeapProfiling << " flag."; |
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 if (iter == process_dumps.end()) { | 979 if (iter == process_dumps.end()) { |
982 std::unique_ptr<ProcessMemoryDump> new_pmd( | 980 std::unique_ptr<ProcessMemoryDump> new_pmd( |
983 new ProcessMemoryDump(session_state, dump_args)); | 981 new ProcessMemoryDump(session_state, dump_args)); |
984 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; | 982 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; |
985 } | 983 } |
986 return iter->second.get(); | 984 return iter->second.get(); |
987 } | 985 } |
988 | 986 |
989 } // namespace trace_event | 987 } // namespace trace_event |
990 } // namespace base | 988 } // namespace base |
OLD | NEW |