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

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

Issue 2273703003: Hook memory tracing into Windows heap shim. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Primiano's nits. Created 4 years, 3 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
« no previous file with comments | « base/trace_event/malloc_dump_provider.cc ('k') | base/trace_event/winheap_dump_provider_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/atomic_sequence_num.h" 11 #include "base/atomic_sequence_num.h"
11 #include "base/base_switches.h" 12 #include "base/base_switches.h"
12 #include "base/command_line.h" 13 #include "base/command_line.h"
13 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
14 #include "base/debug/debugging_flags.h" 15 #include "base/debug/debugging_flags.h"
15 #include "base/debug/stack_trace.h" 16 #include "base/debug/stack_trace.h"
16 #include "base/memory/ptr_util.h" 17 #include "base/memory/ptr_util.h"
17 #include "base/threading/thread.h" 18 #include "base/threading/thread.h"
18 #include "base/threading/thread_task_runner_handle.h" 19 #include "base/threading/thread_task_runner_handle.h"
19 #include "base/trace_event/heap_profiler.h" 20 #include "base/trace_event/heap_profiler.h"
20 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" 21 #include "base/trace_event/heap_profiler_allocation_context_tracker.h"
21 #include "base/trace_event/heap_profiler_stack_frame_deduplicator.h" 22 #include "base/trace_event/heap_profiler_stack_frame_deduplicator.h"
22 #include "base/trace_event/heap_profiler_type_name_deduplicator.h" 23 #include "base/trace_event/heap_profiler_type_name_deduplicator.h"
23 #include "base/trace_event/malloc_dump_provider.h" 24 #include "base/trace_event/malloc_dump_provider.h"
24 #include "base/trace_event/memory_dump_provider.h" 25 #include "base/trace_event/memory_dump_provider.h"
25 #include "base/trace_event/memory_dump_session_state.h" 26 #include "base/trace_event/memory_dump_session_state.h"
26 #include "base/trace_event/memory_infra_background_whitelist.h" 27 #include "base/trace_event/memory_infra_background_whitelist.h"
27 #include "base/trace_event/process_memory_dump.h" 28 #include "base/trace_event/process_memory_dump.h"
28 #include "base/trace_event/trace_event.h" 29 #include "base/trace_event/trace_event.h"
29 #include "base/trace_event/trace_event_argument.h" 30 #include "base/trace_event/trace_event_argument.h"
30 #include "build/build_config.h" 31 #include "build/build_config.h"
31 32
32 #if defined(OS_ANDROID) 33 #if defined(OS_ANDROID)
33 #include "base/trace_event/java_heap_dump_provider_android.h" 34 #include "base/trace_event/java_heap_dump_provider_android.h"
34 #endif 35 #endif
35 36
36 #if defined(OS_WIN)
37 #include "base/trace_event/winheap_dump_provider_win.h"
38 #endif
39
40 namespace base { 37 namespace base {
41 namespace trace_event { 38 namespace trace_event {
42 39
43 namespace { 40 namespace {
44 41
45 const int kTraceEventNumArgs = 1; 42 const int kTraceEventNumArgs = 1;
46 const char* kTraceEventArgNames[] = {"dumps"}; 43 const char* kTraceEventArgNames[] = {"dumps"};
47 const unsigned char kTraceEventArgTypes[] = {TRACE_VALUE_TYPE_CONVERTABLE}; 44 const unsigned char kTraceEventArgTypes[] = {TRACE_VALUE_TYPE_CONVERTABLE};
48 45
49 StaticAtomicSequenceNumber g_next_guid; 46 StaticAtomicSequenceNumber g_next_guid;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // static 100 // static
104 const int MemoryDumpManager::kMaxConsecutiveFailuresCount = 3; 101 const int MemoryDumpManager::kMaxConsecutiveFailuresCount = 3;
105 102
106 // static 103 // static
107 const uint64_t MemoryDumpManager::kInvalidTracingProcessId = 0; 104 const uint64_t MemoryDumpManager::kInvalidTracingProcessId = 0;
108 105
109 // static 106 // static
110 const char* const MemoryDumpManager::kSystemAllocatorPoolName = 107 const char* const MemoryDumpManager::kSystemAllocatorPoolName =
111 #if defined(MALLOC_MEMORY_TRACING_SUPPORTED) 108 #if defined(MALLOC_MEMORY_TRACING_SUPPORTED)
112 MallocDumpProvider::kAllocatedObjects; 109 MallocDumpProvider::kAllocatedObjects;
113 #elif defined(OS_WIN)
114 WinHeapDumpProvider::kAllocatedObjects;
115 #else 110 #else
116 nullptr; 111 nullptr;
117 #endif 112 #endif
118 113
119 // static 114 // static
120 MemoryDumpManager* MemoryDumpManager::GetInstance() { 115 MemoryDumpManager* MemoryDumpManager::GetInstance() {
121 if (g_instance_for_testing) 116 if (g_instance_for_testing)
122 return g_instance_for_testing; 117 return g_instance_for_testing;
123 118
124 return Singleton<MemoryDumpManager, 119 return Singleton<MemoryDumpManager,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 // Enable the core dump providers. 194 // Enable the core dump providers.
200 #if defined(MALLOC_MEMORY_TRACING_SUPPORTED) 195 #if defined(MALLOC_MEMORY_TRACING_SUPPORTED)
201 RegisterDumpProvider(MallocDumpProvider::GetInstance(), "Malloc", nullptr); 196 RegisterDumpProvider(MallocDumpProvider::GetInstance(), "Malloc", nullptr);
202 #endif 197 #endif
203 198
204 #if defined(OS_ANDROID) 199 #if defined(OS_ANDROID)
205 RegisterDumpProvider(JavaHeapDumpProvider::GetInstance(), "JavaHeap", 200 RegisterDumpProvider(JavaHeapDumpProvider::GetInstance(), "JavaHeap",
206 nullptr); 201 nullptr);
207 #endif 202 #endif
208 203
209 #if defined(OS_WIN)
210 RegisterDumpProvider(WinHeapDumpProvider::GetInstance(), "WinHeap", nullptr);
211 #endif
212
213 // If tracing was enabled before initializing MemoryDumpManager, we missed the 204 // If tracing was enabled before initializing MemoryDumpManager, we missed the
214 // OnTraceLogEnabled() event. Synthetize it so we can late-join the party. 205 // OnTraceLogEnabled() event. Synthetize it so we can late-join the party.
215 bool is_tracing_already_enabled = TraceLog::GetInstance()->IsEnabled(); 206 bool is_tracing_already_enabled = TraceLog::GetInstance()->IsEnabled();
216 TRACE_EVENT0(kTraceCategory, "init"); // Add to trace-viewer category list. 207 TRACE_EVENT0(kTraceCategory, "init"); // Add to trace-viewer category list.
217 TraceLog::GetInstance()->AddEnabledStateObserver(this); 208 TraceLog::GetInstance()->AddEnabledStateObserver(this);
218 if (is_tracing_already_enabled) 209 if (is_tracing_already_enabled)
219 OnTraceLogEnabled(); 210 OnTraceLogEnabled();
220 } 211 }
221 212
222 void MemoryDumpManager::RegisterDumpProvider( 213 void MemoryDumpManager::RegisterDumpProvider(
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 if (heavy_dump_rate_ > 0 && periodic_dumps_count_ % heavy_dump_rate_ == 0) 865 if (heavy_dump_rate_ > 0 && periodic_dumps_count_ % heavy_dump_rate_ == 0)
875 level_of_detail = MemoryDumpLevelOfDetail::DETAILED; 866 level_of_detail = MemoryDumpLevelOfDetail::DETAILED;
876 ++periodic_dumps_count_; 867 ++periodic_dumps_count_;
877 868
878 MemoryDumpManager::GetInstance()->RequestGlobalDump( 869 MemoryDumpManager::GetInstance()->RequestGlobalDump(
879 MemoryDumpType::PERIODIC_INTERVAL, level_of_detail); 870 MemoryDumpType::PERIODIC_INTERVAL, level_of_detail);
880 } 871 }
881 872
882 } // namespace trace_event 873 } // namespace trace_event
883 } // namespace base 874 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/malloc_dump_provider.cc ('k') | base/trace_event/winheap_dump_provider_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698