Chromium Code Reviews| 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 <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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 // Enable the core dump providers. | 194 // Enable the core dump providers. |
| 195 #if defined(MALLOC_MEMORY_TRACING_SUPPORTED) | 195 #if defined(MALLOC_MEMORY_TRACING_SUPPORTED) |
| 196 RegisterDumpProvider(MallocDumpProvider::GetInstance(), "Malloc", nullptr); | 196 RegisterDumpProvider(MallocDumpProvider::GetInstance(), "Malloc", nullptr); |
| 197 #endif | 197 #endif |
| 198 | 198 |
| 199 #if defined(OS_ANDROID) | 199 #if defined(OS_ANDROID) |
| 200 RegisterDumpProvider(JavaHeapDumpProvider::GetInstance(), "JavaHeap", | 200 RegisterDumpProvider(JavaHeapDumpProvider::GetInstance(), "JavaHeap", |
| 201 nullptr); | 201 nullptr); |
| 202 #endif | 202 #endif |
| 203 | 203 |
| 204 TRACE_EVENT0(kTraceCategory, "init"); // Add to trace-viewer category list. | |
|
Primiano Tucci (use gerrit)
2016/10/12 17:50:17
I learned only recently that there is a macro for
ssid
2016/10/12 19:04:43
Done.
| |
| 205 | |
| 206 // TODO(ssid): This should be done in EnableHeapProfiling so that we capture | |
| 207 // more allocations (crbug.com/625170). | |
| 208 // Adding filters if filtering was already enabled is not supported by | |
| 209 // TraceLog. So, in case of startup tracing filtering mode is not enabled. | |
|
Primiano Tucci (use gerrit)
2016/10/12 17:50:17
s/startup/background/ I think?
ssid
2016/10/12 19:04:43
Actually this is not true. The first comment takes
| |
| 210 if (heap_profiling_enabled_ && | |
| 211 !(TraceLog::GetInstance()->enabled_modes() & TraceLog::FILTERING_MODE)) { | |
|
Primiano Tucci (use gerrit)
2016/10/12 17:50:17
shouldn't you do all this only if enabled for pseu
ssid
2016/10/12 19:04:43
Sorry this was mistake. That will be different pat
| |
| 212 TraceConfig::EventFilterConfig heap_profiler_filter_config( | |
| 213 TraceLog::TraceEventFilter::kHeapProfilerPredicate); | |
| 214 heap_profiler_filter_config.AddIncludedCategory("*"); | |
|
Primiano Tucci (use gerrit)
2016/10/12 17:50:17
should you also include here disabled-by-default-*
ssid
2016/10/12 19:04:43
Currently we enable disabled-by-default categories
| |
| 215 heap_profiler_filter_config.AddIncludedCategory( | |
| 216 MemoryDumpManager::kTraceCategory); | |
|
Primiano Tucci (use gerrit)
2016/10/12 17:50:17
out of curiosity why do yo need to add memory-infr
ssid
2016/10/12 19:04:43
In case in future we decide to have enabled-catego
oystein (OOO til 10th of July)
2016/10/13 00:34:29
If this is just in-case we change this in the futu
| |
| 217 TraceConfig::EventFilters filters; | |
| 218 filters.push_back(heap_profiler_filter_config); | |
| 219 TraceConfig filtering_trace_config; | |
| 220 filtering_trace_config.SetEventFilterConfigs(filters); | |
| 221 TraceLog::GetInstance()->SetEnabled(filtering_trace_config, | |
| 222 TraceLog::FILTERING_MODE); | |
| 223 } | |
| 224 | |
| 204 // If tracing was enabled before initializing MemoryDumpManager, we missed the | 225 // If tracing was enabled before initializing MemoryDumpManager, we missed the |
| 205 // OnTraceLogEnabled() event. Synthetize it so we can late-join the party. | 226 // OnTraceLogEnabled() event. Synthetize it so we can late-join the party. |
| 206 bool is_tracing_already_enabled = TraceLog::GetInstance()->IsEnabled(); | 227 bool tracing_already_enabled = TraceLog::GetInstance()->IsEnabled(); |
| 207 TRACE_EVENT0(kTraceCategory, "init"); // Add to trace-viewer category list. | |
| 208 TraceLog::GetInstance()->AddEnabledStateObserver(this); | 228 TraceLog::GetInstance()->AddEnabledStateObserver(this); |
| 209 if (is_tracing_already_enabled) | 229 if (tracing_already_enabled) |
| 210 OnTraceLogEnabled(); | 230 OnTraceLogEnabled(); |
| 211 } | 231 } |
| 212 | 232 |
| 213 void MemoryDumpManager::RegisterDumpProvider( | 233 void MemoryDumpManager::RegisterDumpProvider( |
| 214 MemoryDumpProvider* mdp, | 234 MemoryDumpProvider* mdp, |
| 215 const char* name, | 235 const char* name, |
| 216 scoped_refptr<SingleThreadTaskRunner> task_runner, | 236 scoped_refptr<SingleThreadTaskRunner> task_runner, |
| 217 MemoryDumpProvider::Options options) { | 237 MemoryDumpProvider::Options options) { |
| 218 options.dumps_on_single_thread_task_runner = true; | 238 options.dumps_on_single_thread_task_runner = true; |
| 219 RegisterDumpProviderInternal(mdp, name, std::move(task_runner), options); | 239 RegisterDumpProviderInternal(mdp, name, std::move(task_runner), options); |
| (...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 865 if (heavy_dump_rate_ > 0 && periodic_dumps_count_ % heavy_dump_rate_ == 0) | 885 if (heavy_dump_rate_ > 0 && periodic_dumps_count_ % heavy_dump_rate_ == 0) |
| 866 level_of_detail = MemoryDumpLevelOfDetail::DETAILED; | 886 level_of_detail = MemoryDumpLevelOfDetail::DETAILED; |
| 867 ++periodic_dumps_count_; | 887 ++periodic_dumps_count_; |
| 868 | 888 |
| 869 MemoryDumpManager::GetInstance()->RequestGlobalDump( | 889 MemoryDumpManager::GetInstance()->RequestGlobalDump( |
| 870 MemoryDumpType::PERIODIC_INTERVAL, level_of_detail); | 890 MemoryDumpType::PERIODIC_INTERVAL, level_of_detail); |
| 871 } | 891 } |
| 872 | 892 |
| 873 } // namespace trace_event | 893 } // namespace trace_event |
| 874 } // namespace base | 894 } // namespace base |
| OLD | NEW |