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/process_memory_dump.h" | 5 #include "base/trace_event/process_memory_dump.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 return GetAllocatorDump(GetSharedGlobalAllocatorDumpName(guid)); | 246 return GetAllocatorDump(GetSharedGlobalAllocatorDumpName(guid)); |
247 } | 247 } |
248 | 248 |
249 void ProcessMemoryDump::DumpHeapUsage( | 249 void ProcessMemoryDump::DumpHeapUsage( |
250 const std::unordered_map<base::trace_event::AllocationContext, | 250 const std::unordered_map<base::trace_event::AllocationContext, |
251 base::trace_event::AllocationMetrics>& | 251 base::trace_event::AllocationMetrics>& |
252 metrics_by_context, | 252 metrics_by_context, |
253 base::trace_event::TraceEventMemoryOverhead& overhead, | 253 base::trace_event::TraceEventMemoryOverhead& overhead, |
254 const char* allocator_name) { | 254 const char* allocator_name) { |
255 if (!metrics_by_context.empty()) { | 255 if (!metrics_by_context.empty()) { |
| 256 // We shouldn't end up here unless we're doing a detailed dump with |
| 257 // heap profiling enabled and if that is the case tracing should be |
| 258 // enabled which sets up the heap profiler serialization state. |
| 259 if (!heap_profiler_serialization_state()) { |
| 260 NOTREACHED(); |
| 261 return; |
| 262 } |
256 DCHECK_EQ(0ul, heap_dumps_.count(allocator_name)); | 263 DCHECK_EQ(0ul, heap_dumps_.count(allocator_name)); |
257 std::unique_ptr<TracedValue> heap_dump = ExportHeapDump( | 264 std::unique_ptr<TracedValue> heap_dump = ExportHeapDump( |
258 metrics_by_context, *heap_profiler_serialization_state()); | 265 metrics_by_context, *heap_profiler_serialization_state()); |
259 heap_dumps_[allocator_name] = std::move(heap_dump); | 266 heap_dumps_[allocator_name] = std::move(heap_dump); |
260 } | 267 } |
261 | 268 |
262 std::string base_name = base::StringPrintf("tracing/heap_profiler_%s", | 269 std::string base_name = base::StringPrintf("tracing/heap_profiler_%s", |
263 allocator_name); | 270 allocator_name); |
264 overhead.DumpInto(base_name.c_str(), this); | 271 overhead.DumpInto(base_name.c_str(), this); |
265 } | 272 } |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 | 374 |
368 MemoryAllocatorDump* ProcessMemoryDump::GetBlackHoleMad() { | 375 MemoryAllocatorDump* ProcessMemoryDump::GetBlackHoleMad() { |
369 DCHECK(is_black_hole_non_fatal_for_testing_); | 376 DCHECK(is_black_hole_non_fatal_for_testing_); |
370 if (!black_hole_mad_) | 377 if (!black_hole_mad_) |
371 black_hole_mad_.reset(new MemoryAllocatorDump("discarded", this)); | 378 black_hole_mad_.reset(new MemoryAllocatorDump("discarded", this)); |
372 return black_hole_mad_.get(); | 379 return black_hole_mad_.get(); |
373 } | 380 } |
374 | 381 |
375 } // namespace trace_event | 382 } // namespace trace_event |
376 } // namespace base | 383 } // namespace base |
OLD | NEW |