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

Unified Diff: base/trace_event/process_memory_dump.cc

Issue 2911263003: [memory-infra] Add method to override importance of ownership edges (Closed)
Patch Set: Created 3 years, 7 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..14be09779b2486c2f0d9b0a589be1c761f9eb78b 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,12 +325,12 @@ void ProcessMemoryDump::AsValueInto(TracedValue* value) const {
}
value->BeginArray("allocators_graph");
- for (const MemoryAllocatorDumpEdge& edge : allocator_dumps_edges_) {
+ for (const auto& edge : allocator_dumps_edges_) {
value->BeginDictionary();
- value->SetString("source", edge.source.ToString());
- value->SetString("target", edge.target.ToString());
- value->SetInteger("importance", edge.importance);
- value->SetString("type", edge.type);
+ value->SetString("source", edge.first.ToString());
+ value->SetString("target", edge.second.target.ToString());
+ value->SetInteger("importance", edge.second.importance);
+ value->SetString("type", edge.second.type);
value->EndDictionary();
}
value->EndArray();
@@ -340,8 +339,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_.find(source) == allocator_dumps_edges_.end() ||
+ allocator_dumps_edges_[source].overridable)
+ << "Cannot add multiple ownership edges between same allocator dumps";
+ allocator_dumps_edges_[source] = {target, importance, kEdgeTypeOwnership,
+ false /* overridable */};
}
void ProcessMemoryDump::AddOwnershipEdge(
@@ -350,6 +352,43 @@ void ProcessMemoryDump::AddOwnershipEdge(
AddOwnershipEdge(source, target, 0 /* importance */);
}
+void ProcessMemoryDump::CreateSharedMemoryOwnershipEdge(
+ const MemoryAllocatorDumpGuid& client_dump_guid,
+ const MemoryAllocatorDumpGuid& client_global_dump_guid,
+ bool is_weak,
+ int importance,
+ uint64_t shm_unguessable_token) {
+ if (UseNewOwnershipEdges() && shared_memory_handle) {
+ base::SharedMemoryTracker::AddOwnershipEdge(pmd, dump->guid(),
+ shared_memory_handle);
+ AddOwnershipEdge(
+ SharedMemoryTracker::GetLocallDumpGUIDFromToken(shm_unguessable_token),
+ SharedMemoryTracker::GetGlobalDumpGUIDFromToken(shm_unguessable_token),
+ importance);
+ } else {
+ // Existing logic for ownership
+ if (is_weak)
+ pmd->CreateWeakSharedGlobalAllocatorDump(client_global_dump_guid);
+ else
+ pmd->CreateSharedGlobalAllocatorDump(client_global_dump_guid);
+ pmd->AddOwnershipEdge(client_dump_guid, client_global_dump_guid,
+ importance);
+ }
+}
+
+void ProcessMemoryDump::AddOverridableOwnershipEdge(
+ const MemoryAllocatorDumpGuid& source,
+ const MemoryAllocatorDumpGuid& target,
+ int importance) {
+ if (allocator_dumps_edges_.find(source) == allocator_dumps_edges_.end() ||
+ allocator_dumps_edges_[source].overridable) {
+ allocator_dumps_edges_[source] = {target, importance, kEdgeTypeOwnership,
+ true /* overridable */};
+ } else {
+ NOTREACHED();
+ }
+}
+
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