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"
12 namespace trace_event
{
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()
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
52 "pss", StringPrintf(kHexFmt
, region
.byte_stats_proportional_resident
));
54 "pd", StringPrintf(kHexFmt
, region
.byte_stats_private_dirty_resident
));
56 "pc", StringPrintf(kHexFmt
, region
.byte_stats_private_clean_resident
));
58 "sd", StringPrintf(kHexFmt
, region
.byte_stats_shared_dirty_resident
));
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();
69 void ProcessMemoryMaps::Clear() {
73 } // namespace trace_event