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

Unified Diff: base/trace_event/process_memory_dump.cc

Issue 2911263003: [memory-infra] Add method to override importance of ownership edges (Closed)
Patch Set: Fixes. 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
« no previous file with comments | « base/trace_event/process_memory_dump.h ('k') | base/trace_event/process_memory_dump_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..13b3835f9a48855e7c7899e0fd52b410e7d9be36 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,10 @@ 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);
+ allocator_dumps_edges_[source] = {
+ source, target, importance, kEdgeTypeOwnership, false /* overridable */};
}
void ProcessMemoryDump::AddOwnershipEdge(
@@ -350,6 +352,21 @@ void ProcessMemoryDump::AddOwnershipEdge(
AddOwnershipEdge(source, target, 0 /* importance */);
}
+void ProcessMemoryDump::AddOverridableOwnershipEdge(
+ const MemoryAllocatorDumpGuid& source,
+ const MemoryAllocatorDumpGuid& target,
+ int importance) {
+ if (allocator_dumps_edges_.count(source) == 0) {
+ 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.
« no previous file with comments | « base/trace_event/process_memory_dump.h ('k') | base/trace_event/process_memory_dump_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698