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

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 OS_NACL 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 15 matching lines...) Expand all
26 #include "base/trace_event/heap_profiler_type_name_deduplicator.h" 26 #include "base/trace_event/heap_profiler_type_name_deduplicator.h"
27 #include "base/trace_event/malloc_dump_provider.h" 27 #include "base/trace_event/malloc_dump_provider.h"
28 #include "base/trace_event/memory_dump_provider.h" 28 #include "base/trace_event/memory_dump_provider.h"
29 #include "base/trace_event/memory_dump_scheduler.h" 29 #include "base/trace_event/memory_dump_scheduler.h"
30 #include "base/trace_event/memory_dump_session_state.h" 30 #include "base/trace_event/memory_dump_session_state.h"
31 #include "base/trace_event/memory_infra_background_whitelist.h" 31 #include "base/trace_event/memory_infra_background_whitelist.h"
32 #include "base/trace_event/process_memory_dump.h" 32 #include "base/trace_event/process_memory_dump.h"
33 #include "base/trace_event/trace_event.h" 33 #include "base/trace_event/trace_event.h"
34 #include "base/trace_event/trace_event_argument.h" 34 #include "base/trace_event/trace_event_argument.h"
35 #include "build/build_config.h" 35 #include "build/build_config.h"
36 #include "build/buildflag.h"
36 37
37 #if defined(OS_ANDROID) 38 #if defined(OS_ANDROID)
38 #include "base/trace_event/java_heap_dump_provider_android.h" 39 #include "base/trace_event/java_heap_dump_provider_android.h"
39 #endif 40 #endif
40 41
41 namespace base { 42 namespace base {
42 namespace trace_event { 43 namespace trace_event {
43 44
44 namespace { 45 namespace {
45 46
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 if (!CommandLine::InitializedForCurrentProcess() || 181 if (!CommandLine::InitializedForCurrentProcess() ||
181 !CommandLine::ForCurrentProcess()->HasSwitch( 182 !CommandLine::ForCurrentProcess()->HasSwitch(
182 switches::kEnableHeapProfiling)) 183 switches::kEnableHeapProfiling))
183 return; 184 return;
184 185
185 std::string profiling_mode = CommandLine::ForCurrentProcess() 186 std::string profiling_mode = CommandLine::ForCurrentProcess()
186 ->GetSwitchValueASCII(switches::kEnableHeapProfiling); 187 ->GetSwitchValueASCII(switches::kEnableHeapProfiling);
187 if (profiling_mode == "") { 188 if (profiling_mode == "") {
188 AllocationContextTracker::SetCaptureMode( 189 AllocationContextTracker::SetCaptureMode(
189 AllocationContextTracker::CaptureMode::PSEUDO_STACK); 190 AllocationContextTracker::CaptureMode::PSEUDO_STACK);
190 #if HAVE_TRACE_STACK_FRAME_POINTERS && \
191 (BUILDFLAG(ENABLE_PROFILING) || !defined(NDEBUG))
192 } else if (profiling_mode == switches::kEnableHeapProfilingModeNative) { 191 } else if (profiling_mode == switches::kEnableHeapProfilingModeNative) {
Primiano Tucci (use gerrit) 2017/03/22 10:38:35 should we have an #if defined(COMPONENT_BUILD) her
DmitrySkiba 2017/03/23 19:10:24 Component builds *should* be working on Linux and
Wez 2017/03/27 03:59:37 That would equally apply to the pseudo-stack case,
Wez 2017/03/27 03:59:37 Definitely not on Windows, since the shim impl is
Primiano Tucci (use gerrit) 2017/03/27 09:42:47 Ah, I was thinking more to the "can this unwinder
193 // We need frame pointers for native tracing to work, and they are 192 // If we don't have frame pointers then native tracing falls-back to
194 // enabled in profiling and debug builds. 193 // using base::debug::StackTrace, which may be slow.
195 AllocationContextTracker::SetCaptureMode( 194 AllocationContextTracker::SetCaptureMode(
196 AllocationContextTracker::CaptureMode::NATIVE_STACK); 195 AllocationContextTracker::CaptureMode::NATIVE_STACK);
197 #endif
198 #if BUILDFLAG(ENABLE_MEMORY_TASK_PROFILER) 196 #if BUILDFLAG(ENABLE_MEMORY_TASK_PROFILER)
199 } else if (profiling_mode == switches::kEnableHeapProfilingTaskProfiler) { 197 } else if (profiling_mode == switches::kEnableHeapProfilingTaskProfiler) {
200 // Enable heap tracking, which in turn enables capture of heap usage 198 // Enable heap tracking, which in turn enables capture of heap usage
201 // tracking in tracked_objects.cc. 199 // tracking in tracked_objects.cc.
202 if (!base::debug::ThreadHeapUsageTracker::IsHeapTrackingEnabled()) 200 if (!base::debug::ThreadHeapUsageTracker::IsHeapTrackingEnabled())
203 base::debug::ThreadHeapUsageTracker::EnableHeapTracking(); 201 base::debug::ThreadHeapUsageTracker::EnableHeapTracking();
204 #endif 202 #endif
205 } else { 203 } else {
206 CHECK(false) << "Invalid mode '" << profiling_mode << "' for " 204 CHECK(false) << "Invalid mode '" << profiling_mode << "' for "
207 << switches::kEnableHeapProfiling << " flag."; 205 << switches::kEnableHeapProfiling << " flag.";
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 if (iter == process_dumps.end()) { 959 if (iter == process_dumps.end()) {
962 std::unique_ptr<ProcessMemoryDump> new_pmd( 960 std::unique_ptr<ProcessMemoryDump> new_pmd(
963 new ProcessMemoryDump(session_state, dump_args)); 961 new ProcessMemoryDump(session_state, dump_args));
964 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; 962 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first;
965 } 963 }
966 return iter->second.get(); 964 return iter->second.get();
967 } 965 }
968 966
969 } // namespace trace_event 967 } // namespace trace_event
970 } // namespace base 968 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698