Commit ab614721 authored by Dominik Lang's avatar Dominik Lang Committed by Commit Bot

Fix units comparison in MemoryAllocatorDump

Calling MemoryAllocatorDump::AsProtoInto was causing a DCHECK failure.

Bug: 1098746
Change-Id: Iac11e583b7888dfe7e0b673bf47894f3ad038df8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2501481Reviewed-by: default avatarEric Seckler <eseckler@chromium.org>
Reviewed-by: default avatarssid <ssid@chromium.org>
Commit-Queue: Eric Seckler <eseckler@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821716}
parent a444094d
...@@ -104,7 +104,7 @@ void MemoryAllocatorDump::AsProtoInto( ...@@ -104,7 +104,7 @@ void MemoryAllocatorDump::AsProtoInto(
for (const Entry& entry : entries_) { for (const Entry& entry : entries_) {
if (entry.name == "size") { if (entry.name == "size") {
DCHECK_EQ(entry.entry_type, Entry::EntryType::kUint64); DCHECK_EQ(entry.entry_type, Entry::EntryType::kUint64);
DCHECK_EQ(entry.units, "kBytes"); DCHECK_EQ(entry.units, kUnitsBytes);
memory_node->set_size_bytes(entry.value_uint64); memory_node->set_size_bytes(entry.value_uint64);
continue; continue;
} }
...@@ -122,11 +122,11 @@ void MemoryAllocatorDump::AsProtoInto( ...@@ -122,11 +122,11 @@ void MemoryAllocatorDump::AsProtoInto(
proto_memory_node_entry->set_value_string(entry.value_string); proto_memory_node_entry->set_value_string(entry.value_string);
break; break;
} }
if (entry.units == "kBytes") { if (entry.units == kUnitsBytes) {
proto_memory_node_entry->set_units( proto_memory_node_entry->set_units(
perfetto::protos::pbzero::MemoryTrackerSnapshot::ProcessSnapshot:: perfetto::protos::pbzero::MemoryTrackerSnapshot::ProcessSnapshot::
MemoryNode::MemoryNodeEntry::BYTES); MemoryNode::MemoryNodeEntry::BYTES);
} else if (entry.units == "kObjects") { } else if (entry.units == kUnitsObjects) {
proto_memory_node_entry->set_units( proto_memory_node_entry->set_units(
perfetto::protos::pbzero::MemoryTrackerSnapshot::ProcessSnapshot:: perfetto::protos::pbzero::MemoryTrackerSnapshot::ProcessSnapshot::
MemoryNode::MemoryNodeEntry::COUNT); MemoryNode::MemoryNodeEntry::COUNT);
......
...@@ -371,11 +371,13 @@ TEST_F(TracingObserverProtoTest, AsProtoInto) { ...@@ -371,11 +371,13 @@ TEST_F(TracingObserverProtoTest, AsProtoInto) {
base::trace_event::ProcessMemoryDump pmd = base::trace_event::ProcessMemoryDump pmd =
base::trace_event::ProcessMemoryDump(dump_args); base::trace_event::ProcessMemoryDump(dump_args);
base::trace_event::MemoryAllocatorDump* dump = pmd.CreateAllocatorDump( using MemoryAllocatorDump = base::trace_event::MemoryAllocatorDump;
MemoryAllocatorDump* dump = pmd.CreateAllocatorDump(
"mad1", base::trace_event::MemoryAllocatorDumpGuid(421)); "mad1", base::trace_event::MemoryAllocatorDumpGuid(421));
dump->AddScalar("size", "kBytes", 10); dump->AddScalar("size", MemoryAllocatorDump::kUnitsBytes, 10);
dump->AddScalar("one", "kBytes", 1); dump->AddScalar("one", MemoryAllocatorDump::kUnitsBytes, 1);
dump->AddString("two", "kObjects", "one"); dump->AddString("two", MemoryAllocatorDump::kUnitsObjects, "one");
perfetto::TraceWriter::TracePacketHandle handle = perfetto::TraceWriter::TracePacketHandle handle =
trace_writer->NewTracePacket(); trace_writer->NewTracePacket();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment