Update V8 to version 4.7.21.
[chromium-blink-merge.git] / base / trace_event / process_memory_maps.cc
blobbb400de1743c851edb7435a123ef3e6c705841a1
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
3 // found in the LICENSE file.
5 #include "base/trace_event/process_memory_maps.h"
7 #include "base/format_macros.h"
8 #include "base/strings/stringprintf.h"
9 #include "base/trace_event/trace_event_argument.h"
11 namespace base {
12 namespace trace_event {
14 // static
15 const uint32 ProcessMemoryMaps::VMRegion::kProtectionFlagsRead = 4;
16 const uint32 ProcessMemoryMaps::VMRegion::kProtectionFlagsWrite = 2;
17 const uint32 ProcessMemoryMaps::VMRegion::kProtectionFlagsExec = 1;
19 ProcessMemoryMaps::VMRegion::VMRegion()
20 : start_address(0),
21 size_in_bytes(0),
22 protection_flags(0),
23 byte_stats_private_dirty_resident(0),
24 byte_stats_private_clean_resident(0),
25 byte_stats_shared_dirty_resident(0),
26 byte_stats_shared_clean_resident(0),
27 byte_stats_swapped(0),
28 byte_stats_proportional_resident(0) {
31 ProcessMemoryMaps::ProcessMemoryMaps() {
34 ProcessMemoryMaps::~ProcessMemoryMaps() {
37 void ProcessMemoryMaps::AsValueInto(TracedValue* value) const {
38 static const char kHexFmt[] = "%" PRIx64;
40 // Refer to the design doc goo.gl/sxfFY8 for the semantic of these fields.
41 value->BeginArray("vm_regions");
42 for (const auto& region : vm_regions_) {
43 value->BeginDictionary();
45 value->SetString("sa", StringPrintf(kHexFmt, region.start_address));
46 value->SetString("sz", StringPrintf(kHexFmt, region.size_in_bytes));
47 value->SetInteger("pf", region.protection_flags);
48 value->SetString("mf", region.mapped_file);
50 value->BeginDictionary("bs"); // byte stats
51 value->SetString(
52 "pss", StringPrintf(kHexFmt, region.byte_stats_proportional_resident));
53 value->SetString(
54 "pd", StringPrintf(kHexFmt, region.byte_stats_private_dirty_resident));
55 value->SetString(
56 "pc", StringPrintf(kHexFmt, region.byte_stats_private_clean_resident));
57 value->SetString(
58 "sd", StringPrintf(kHexFmt, region.byte_stats_shared_dirty_resident));
59 value->SetString(
60 "sc", StringPrintf(kHexFmt, region.byte_stats_shared_clean_resident));
61 value->SetString("sw", StringPrintf(kHexFmt, region.byte_stats_swapped));
62 value->EndDictionary();
64 value->EndDictionary();
66 value->EndArray();
69 void ProcessMemoryMaps::Clear() {
70 vm_regions_.clear();
73 } // namespace trace_event
74 } // namespace base