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

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: Revert to non-function-style macro Created 3 years, 9 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 <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/allocator/features.h" 10 #include "base/allocator/features.h"
(...skipping 17 matching lines...) Expand all
28 #include "base/trace_event/heap_profiler_type_name_deduplicator.h" 28 #include "base/trace_event/heap_profiler_type_name_deduplicator.h"
29 #include "base/trace_event/malloc_dump_provider.h" 29 #include "base/trace_event/malloc_dump_provider.h"
30 #include "base/trace_event/memory_dump_provider.h" 30 #include "base/trace_event/memory_dump_provider.h"
31 #include "base/trace_event/memory_dump_scheduler.h" 31 #include "base/trace_event/memory_dump_scheduler.h"
32 #include "base/trace_event/memory_dump_session_state.h" 32 #include "base/trace_event/memory_dump_session_state.h"
33 #include "base/trace_event/memory_infra_background_whitelist.h" 33 #include "base/trace_event/memory_infra_background_whitelist.h"
34 #include "base/trace_event/process_memory_dump.h" 34 #include "base/trace_event/process_memory_dump.h"
35 #include "base/trace_event/trace_event.h" 35 #include "base/trace_event/trace_event.h"
36 #include "base/trace_event/trace_event_argument.h" 36 #include "base/trace_event/trace_event_argument.h"
37 #include "build/build_config.h" 37 #include "build/build_config.h"
38 #include "build/buildflag.h"
38 39
39 #if defined(OS_ANDROID) 40 #if defined(OS_ANDROID)
40 #include "base/trace_event/java_heap_dump_provider_android.h" 41 #include "base/trace_event/java_heap_dump_provider_android.h"
41 #endif 42 #endif
42 43
43 namespace base { 44 namespace base {
44 namespace trace_event { 45 namespace trace_event {
45 46
46 namespace { 47 namespace {
47 48
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 if (!CommandLine::InitializedForCurrentProcess() || 183 if (!CommandLine::InitializedForCurrentProcess() ||
183 !CommandLine::ForCurrentProcess()->HasSwitch( 184 !CommandLine::ForCurrentProcess()->HasSwitch(
184 switches::kEnableHeapProfiling)) 185 switches::kEnableHeapProfiling))
185 return; 186 return;
186 187
187 std::string profiling_mode = CommandLine::ForCurrentProcess() 188 std::string profiling_mode = CommandLine::ForCurrentProcess()
188 ->GetSwitchValueASCII(switches::kEnableHeapProfiling); 189 ->GetSwitchValueASCII(switches::kEnableHeapProfiling);
189 if (profiling_mode == "") { 190 if (profiling_mode == "") {
190 AllocationContextTracker::SetCaptureMode( 191 AllocationContextTracker::SetCaptureMode(
191 AllocationContextTracker::CaptureMode::PSEUDO_STACK); 192 AllocationContextTracker::CaptureMode::PSEUDO_STACK);
192 #if HAVE_TRACE_STACK_FRAME_POINTERS && \
193 (BUILDFLAG(ENABLE_PROFILING) || !defined(NDEBUG))
194 } else if (profiling_mode == switches::kEnableHeapProfilingModeNative) { 193 } else if (profiling_mode == switches::kEnableHeapProfilingModeNative) {
195 // We need frame pointers for native tracing to work, and they are 194 // If we don't have frame pointers then native tracing falls-back to
196 // enabled in profiling and debug builds. 195 // using base::debug::StackTrace, which may be slow.
197 AllocationContextTracker::SetCaptureMode( 196 AllocationContextTracker::SetCaptureMode(
198 AllocationContextTracker::CaptureMode::NATIVE_STACK); 197 AllocationContextTracker::CaptureMode::NATIVE_STACK);
199 #endif
200 #if BUILDFLAG(ENABLE_MEMORY_TASK_PROFILER) 198 #if BUILDFLAG(ENABLE_MEMORY_TASK_PROFILER)
201 } else if (profiling_mode == switches::kEnableHeapProfilingTaskProfiler) { 199 } else if (profiling_mode == switches::kEnableHeapProfilingTaskProfiler) {
202 // Enable heap tracking, which in turn enables capture of heap usage 200 // Enable heap tracking, which in turn enables capture of heap usage
203 // tracking in tracked_objects.cc. 201 // tracking in tracked_objects.cc.
204 if (!base::debug::ThreadHeapUsageTracker::IsHeapTrackingEnabled()) 202 if (!base::debug::ThreadHeapUsageTracker::IsHeapTrackingEnabled())
205 base::debug::ThreadHeapUsageTracker::EnableHeapTracking(); 203 base::debug::ThreadHeapUsageTracker::EnableHeapTracking();
206 #endif 204 #endif
207 } else { 205 } else {
208 CHECK(false) << "Invalid mode '" << profiling_mode << "' for " 206 CHECK(false) << "Invalid mode '" << profiling_mode << "' for "
209 << switches::kEnableHeapProfiling << " flag."; 207 << switches::kEnableHeapProfiling << " flag.";
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 if (iter == process_dumps.end()) { 1006 if (iter == process_dumps.end()) {
1009 std::unique_ptr<ProcessMemoryDump> new_pmd( 1007 std::unique_ptr<ProcessMemoryDump> new_pmd(
1010 new ProcessMemoryDump(session_state, dump_args)); 1008 new ProcessMemoryDump(session_state, dump_args));
1011 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; 1009 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first;
1012 } 1010 }
1013 return iter->second.get(); 1011 return iter->second.get();
1014 } 1012 }
1015 1013
1016 } // namespace trace_event 1014 } // namespace trace_event
1017 } // namespace base 1015 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698