Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: base/trace_event/memory_dump_manager.cc

Issue 2757123002: Cleaner fall-back stack capture for --enable-heap-profiling=native. (Closed)
Patch Set: Fix comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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)) 198 #if !defined(OS_NACL)
199 } else if (profiling_mode == switches::kEnableHeapProfilingModeNative) { 199 } else if (profiling_mode == switches::kEnableHeapProfilingModeNative) {
200 // We need frame pointers for native tracing to work, and they are 200 // If we don't have frame pointers then native tracing falls-back to
201 // enabled in profiling and debug builds. 201 // using base::debug::StackTrace, which may be slow.
202 AllocationContextTracker::SetCaptureMode( 202 AllocationContextTracker::SetCaptureMode(
203 AllocationContextTracker::CaptureMode::NATIVE_STACK); 203 AllocationContextTracker::CaptureMode::NATIVE_STACK);
204 #endif 204 #endif // !defined(OS_NACL)
205 #if BUILDFLAG(ENABLE_MEMORY_TASK_PROFILER) 205 #if BUILDFLAG(ENABLE_MEMORY_TASK_PROFILER)
206 } else if (profiling_mode == switches::kEnableHeapProfilingTaskProfiler) { 206 } else if (profiling_mode == switches::kEnableHeapProfilingTaskProfiler) {
207 // Enable heap tracking, which in turn enables capture of heap usage 207 // Enable heap tracking, which in turn enables capture of heap usage
208 // tracking in tracked_objects.cc. 208 // tracking in tracked_objects.cc.
209 if (!base::debug::ThreadHeapUsageTracker::IsHeapTrackingEnabled()) 209 if (!base::debug::ThreadHeapUsageTracker::IsHeapTrackingEnabled())
210 base::debug::ThreadHeapUsageTracker::EnableHeapTracking(); 210 base::debug::ThreadHeapUsageTracker::EnableHeapTracking();
211 #endif 211 #endif // BUILDFLAG(ENABLE_MEMORY_TASK_PROFILER)
212 } else { 212 } else {
213 CHECK(false) << "Invalid mode '" << profiling_mode << "' for " 213 CHECK(false) << "Invalid mode '" << profiling_mode << "' for "
214 << switches::kEnableHeapProfiling << " flag."; 214 << switches::kEnableHeapProfiling << " flag.";
215 } 215 }
216 216
217 for (auto mdp : dump_providers_) 217 for (auto mdp : dump_providers_)
218 mdp->dump_provider->OnHeapProfilingEnabled(true); 218 mdp->dump_provider->OnHeapProfilingEnabled(true);
219 heap_profiling_enabled_ = true; 219 heap_profiling_enabled_ = true;
220 } 220 }
221 221
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 if (iter == process_dumps.end()) { 981 if (iter == process_dumps.end()) {
982 std::unique_ptr<ProcessMemoryDump> new_pmd( 982 std::unique_ptr<ProcessMemoryDump> new_pmd(
983 new ProcessMemoryDump(session_state, dump_args)); 983 new ProcessMemoryDump(session_state, dump_args));
984 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; 984 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first;
985 } 985 }
986 return iter->second.get(); 986 return iter->second.get();
987 } 987 }
988 988
989 } // namespace trace_event 989 } // namespace trace_event
990 } // namespace base 990 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/heap_profiler_allocation_context_tracker.cc ('k') | build/config/compiler/compiler.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698