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::ProcessMemoryMaps() {
22 ProcessMemoryMaps::~ProcessMemoryMaps() {
25 void ProcessMemoryMaps::AsValueInto(TracedValue
* value
) const {
26 static const char kHexFmt
[] = "%" PRIx64
;
28 // Refer to the design doc goo.gl/sxfFY8 for the semantic of these fields.
29 value
->BeginArray("vm_regions");
30 for (const auto& region
: vm_regions_
) {
31 value
->BeginDictionary();
33 value
->SetString("sa", StringPrintf(kHexFmt
, region
.start_address
));
34 value
->SetString("sz", StringPrintf(kHexFmt
, region
.size_in_bytes
));
35 value
->SetInteger("pf", region
.protection_flags
);
36 value
->SetString("mf", region
.mapped_file
);
38 value
->BeginDictionary("bs"); // byte stats
40 "pss", StringPrintf(kHexFmt
, region
.byte_stats_proportional_resident
));
41 value
->SetString("prv",
42 StringPrintf(kHexFmt
, region
.byte_stats_private_resident
));
43 value
->SetString("shr",
44 StringPrintf(kHexFmt
, region
.byte_stats_shared_resident
));
45 value
->EndDictionary();
47 value
->EndDictionary();
52 } // namespace trace_event