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

Unified Diff: base/trace_event/process_memory_dump.cc

Issue 987043003: [tracing] Introduce support for userland memory allocators dumps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mmaps_en
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: base/trace_event/process_memory_dump.cc
diff --git a/base/trace_event/process_memory_dump.cc b/base/trace_event/process_memory_dump.cc
index 5363db559c32151712dc128e74d44f1933bbec00..131494e9856c822468e474647d16b68315363a4c 100644
--- a/base/trace_event/process_memory_dump.cc
+++ b/base/trace_event/process_memory_dump.cc
@@ -17,6 +17,27 @@ ProcessMemoryDump::ProcessMemoryDump()
ProcessMemoryDump::~ProcessMemoryDump() {
}
+MemoryAllocatorDump* ProcessMemoryDump::AddAllocatorDump(
+ const std::string& name) {
+ return AddAllocatorDump(name, nullptr);
+}
+
+MemoryAllocatorDump* ProcessMemoryDump::AddAllocatorDump(
+ const std::string& name,
+ MemoryAllocatorDump* parent) {
+ DCHECK_EQ(0ul, allocator_dumps_.count(name));
+ MemoryAllocatorDump* mad = new MemoryAllocatorDump(name, parent);
+ allocator_dumps_storage_.push_back(mad);
+ allocator_dumps_[name] = mad;
+ return mad;
+}
+
+MemoryAllocatorDump* ProcessMemoryDump::GetAllocatorDump(
+ const std::string& name) const {
+ auto it = allocator_dumps_.find(name);
+ return it == allocator_dumps_.end() ? nullptr : it->second;
+}
+
void ProcessMemoryDump::AsValueInto(TracedValue* value) const {
// Build up the [dumper name] -> [value] dictionary.
if (has_process_totals_) {
@@ -29,6 +50,12 @@ void ProcessMemoryDump::AsValueInto(TracedValue* value) const {
process_mmaps_.AsValueInto(value);
value->EndDictionary();
}
+ if (allocator_dumps_storage_.size() > 0) {
+ value->BeginDictionary("allocators");
+ for (const MemoryAllocatorDump* allocator_dump : allocator_dumps_storage_)
+ allocator_dump->AsValueInto(value);
+ value->EndDictionary();
+ }
}
} // namespace trace_event
« base/trace_event/process_memory_dump.h ('K') | « base/trace_event/process_memory_dump.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698