blob: d553ee88e8041d92c525dd77554179b889721c39 [file] [log] [blame]
Benjamin Lerman507bb1a2015-02-26 13:15:17 +01001// 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.
4
5#include "base/trace_event/process_memory_maps.h"
6
Alhaad Gokhale4f513072015-03-24 10:49:34 -07007#include "base/format_macros.h"
8#include "base/strings/stringprintf.h"
Benjamin Lerman507bb1a2015-02-26 13:15:17 +01009#include "base/trace_event/trace_event_argument.h"
10
11namespace base {
12namespace trace_event {
13
14// static
15const uint32 ProcessMemoryMaps::VMRegion::kProtectionFlagsRead = 4;
16const uint32 ProcessMemoryMaps::VMRegion::kProtectionFlagsWrite = 2;
17const uint32 ProcessMemoryMaps::VMRegion::kProtectionFlagsExec = 1;
18
19ProcessMemoryMaps::ProcessMemoryMaps() {
20}
21
22ProcessMemoryMaps::~ProcessMemoryMaps() {
23}
24
25void ProcessMemoryMaps::AsValueInto(TracedValue* value) const {
Alhaad Gokhale4f513072015-03-24 10:49:34 -070026 static const char kHexFmt[] = "%" PRIx64;
27
28 // Refer to the design doc goo.gl/sxfFY8 for the semantic of these fields.
Benjamin Lerman507bb1a2015-02-26 13:15:17 +010029 value->BeginArray("vm_regions");
30 for (const auto& region : vm_regions_) {
31 value->BeginDictionary();
32
Alhaad Gokhale4f513072015-03-24 10:49:34 -070033 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);
Benjamin Lerman507bb1a2015-02-26 13:15:17 +010037
Alhaad Gokhale4f513072015-03-24 10:49:34 -070038 value->BeginDictionary("bs"); // byte stats
39 value->SetString(
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));
Benjamin Lerman507bb1a2015-02-26 13:15:17 +010045 value->EndDictionary();
46
47 value->EndDictionary();
48 }
49 value->EndArray();
50}
51
52} // namespace trace_event
53} // namespace base