Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/trace_event/process_memory_maps.h" | 5 #include "base/trace_event/process_memory_maps.h" |
| 6 | 6 |
| 7 #include "base/format_macros.h" | |
| 8 #include "base/strings/stringprintf.h" | |
| 7 #include "base/trace_event/trace_event_argument.h" | 9 #include "base/trace_event/trace_event_argument.h" |
| 8 | 10 |
| 11 namespace { | |
| 12 const int kDumpVersion = 1; // For tracing backwards compatibility, | |
|
dsinclair
2015/02/26 18:00:01
Named keys would get rid of the need for this vers
| |
| 13 } | |
| 14 | |
| 9 namespace base { | 15 namespace base { |
| 10 namespace trace_event { | 16 namespace trace_event { |
| 11 | 17 |
| 12 // static | 18 // static |
| 13 const uint32 ProcessMemoryMaps::VMRegion::kProtectionFlagsRead = 4; | 19 const uint32 ProcessMemoryMaps::VMRegion::kProtectionFlagsRead = 4; |
| 14 const uint32 ProcessMemoryMaps::VMRegion::kProtectionFlagsWrite = 2; | 20 const uint32 ProcessMemoryMaps::VMRegion::kProtectionFlagsWrite = 2; |
| 15 const uint32 ProcessMemoryMaps::VMRegion::kProtectionFlagsExec = 1; | 21 const uint32 ProcessMemoryMaps::VMRegion::kProtectionFlagsExec = 1; |
| 16 | 22 |
| 17 ProcessMemoryMaps::ProcessMemoryMaps() { | 23 ProcessMemoryMaps::ProcessMemoryMaps() { |
| 18 } | 24 } |
| 19 | 25 |
| 20 ProcessMemoryMaps::~ProcessMemoryMaps() { | 26 ProcessMemoryMaps::~ProcessMemoryMaps() { |
| 21 } | 27 } |
| 22 | 28 |
| 23 void ProcessMemoryMaps::AsValueInto(TracedValue* value) const { | 29 void ProcessMemoryMaps::AsValueInto(TracedValue* value) const { |
| 30 value->SetInteger("v", kDumpVersion); | |
| 31 | |
| 32 value->BeginArray("vm_regions_headers"); | |
| 33 value->AppendString("start_address"), | |
| 34 value->AppendString("size_in_bytes"), | |
| 35 value->AppendString("protection_flags"), | |
| 36 value->AppendString("mapped_file"), | |
| 37 value->AppendString("mapped_offset"), | |
| 38 value->AppendString("byte_stats_resident"), | |
| 39 value->AppendString("byte_stats_anonymous"), | |
| 40 value->EndArray(); | |
| 41 | |
| 24 value->BeginArray("vm_regions"); | 42 value->BeginArray("vm_regions"); |
| 25 for (const auto& region : vm_regions_) { | 43 for (const auto& region : vm_regions_) { |
| 26 value->BeginDictionary(); | 44 value->BeginArray(); |
| 27 | 45 value->AppendString(StringPrintf("%" PRIx64, region.start_address)); |
| 28 value->SetDouble("start_address", region.start_address); | 46 value->AppendString(StringPrintf("%" PRIx64, region.size_in_bytes)); |
| 29 value->SetDouble("size_in_bytes", region.size_in_bytes); | 47 value->AppendInteger(region.protection_flags); |
| 30 value->SetInteger("protection_flags", region.protection_flags); | 48 value->AppendString(region.mapped_file); |
| 31 value->SetString("mapped_file", region.mapped_file); | 49 value->AppendString(StringPrintf("%" PRIx64, region.mapped_file_offset)); |
| 32 value->SetDouble("mapped_file_offset", region.mapped_file_offset); | 50 value->AppendString(StringPrintf("%" PRIx64, region.byte_stats_resident)); |
| 33 | 51 value->AppendString(StringPrintf("%" PRIx64, region.byte_stats_anonymous)); |
| 34 value->BeginDictionary("byte_stats"); | 52 value->EndArray(); |
| 35 value->SetDouble("resident", region.byte_stats_resident); | |
| 36 value->SetDouble("anonymous", region.byte_stats_anonymous); | |
| 37 value->EndDictionary(); | |
| 38 | |
| 39 value->EndDictionary(); | |
| 40 } | 53 } |
| 41 value->EndArray(); | 54 value->EndArray(); |
| 42 } | 55 } |
| 43 | 56 |
| 44 } // namespace trace_event | 57 } // namespace trace_event |
| 45 } // namespace base | 58 } // namespace base |
| OLD | NEW |