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

Unified Diff: base/trace_event/process_memory_dump.cc

Issue 2911263003: [memory-infra] Add method to override importance of ownership edges (Closed)
Patch Set: Make it public. Created 3 years, 6 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 9f710936e1405f2b4215761ab0d357d75b7dbd8d..023deea8b539527285e24ebbfe12ede0a7710b48 100644
--- a/base/trace_event/process_memory_dump.cc
+++ b/base/trace_event/process_memory_dump.cc
@@ -286,8 +286,7 @@ void ProcessMemoryDump::TakeAllDumpsFrom(ProcessMemoryDump* other) {
other->allocator_dumps_.clear();
// Move all the edges.
- allocator_dumps_edges_.insert(allocator_dumps_edges_.end(),
- other->allocator_dumps_edges_.begin(),
+ allocator_dumps_edges_.insert(other->allocator_dumps_edges_.begin(),
other->allocator_dumps_edges_.end());
other->allocator_dumps_edges_.clear();
@@ -326,7 +325,8 @@ void ProcessMemoryDump::AsValueInto(TracedValue* value) const {
}
value->BeginArray("allocators_graph");
- for (const MemoryAllocatorDumpEdge& edge : allocator_dumps_edges_) {
+ for (const auto& it : allocator_dumps_edges_) {
+ const MemoryAllocatorDumpEdge& edge = it.second;
value->BeginDictionary();
value->SetString("source", edge.source.ToString());
value->SetString("target", edge.target.ToString());
@@ -340,8 +340,11 @@ void ProcessMemoryDump::AsValueInto(TracedValue* value) const {
void ProcessMemoryDump::AddOwnershipEdge(const MemoryAllocatorDumpGuid& source,
const MemoryAllocatorDumpGuid& target,
int importance) {
- allocator_dumps_edges_.push_back(
- {source, target, importance, kEdgeTypeOwnership});
+ DCHECK(allocator_dumps_edges_.count(source) == 0 ||
+ allocator_dumps_edges_[source].overridable)
+ << "Cannot add multiple ownership edges between same allocator dumps";
Primiano Tucci (use gerrit) 2017/06/06 18:50:50 I think the dcheck itself is quite self-explicativ
ssid 2017/06/07 01:16:32 removed.
+ allocator_dumps_edges_[source] = {
+ source, target, importance, kEdgeTypeOwnership, false /* overridable */};
}
void ProcessMemoryDump::AddOwnershipEdge(
@@ -350,6 +353,21 @@ void ProcessMemoryDump::AddOwnershipEdge(
AddOwnershipEdge(source, target, 0 /* importance */);
}
+void ProcessMemoryDump::AddOverridableOwnershipEdge(
+ const MemoryAllocatorDumpGuid& source,
+ const MemoryAllocatorDumpGuid& target,
+ int importance) {
+ if (allocator_dumps_edges_.find(source) == allocator_dumps_edges_.end()) {
Primiano Tucci (use gerrit) 2017/06/06 18:50:49 count()
ssid 2017/06/07 01:16:32 ouch, sorry.
+ allocator_dumps_edges_[source] = {
+ source, target, importance, kEdgeTypeOwnership, true /* overridable */};
+ } else {
+ // An edge between the source and target already exits. So, do nothing here
+ // since the new overridable edge is implicitly overridden by a strong edge
+ // which was created earlier.
+ DCHECK(!allocator_dumps_edges_[source].overridable);
+ }
+}
+
void ProcessMemoryDump::AddSuballocation(const MemoryAllocatorDumpGuid& source,
const std::string& target_node_name) {
// Do not create new dumps for suballocations in background mode.

Powered by Google App Engine
This is Rietveld 408576698