• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef BASE_TRACE_EVENT_PROCESS_MEMORY_MAPS_H_
6 #define BASE_TRACE_EVENT_PROCESS_MEMORY_MAPS_H_
7 
8 #include <stdint.h>
9 
10 #include <string>
11 #include <vector>
12 
13 #include "base/base_export.h"
14 #include "base/macros.h"
15 
16 namespace base {
17 namespace trace_event {
18 
19 class TracedValue;
20 
21 // Data model for process-wide memory stats.
22 class BASE_EXPORT ProcessMemoryMaps {
23  public:
24   struct BASE_EXPORT VMRegion {
25     static const uint32_t kProtectionFlagsRead;
26     static const uint32_t kProtectionFlagsWrite;
27     static const uint32_t kProtectionFlagsExec;
28     static const uint32_t kProtectionFlagsMayshare;
29 
30     VMRegion();
31     VMRegion(const VMRegion& other);
32 
33     uint64_t start_address;
34     uint64_t size_in_bytes;
35     uint32_t protection_flags;
36     std::string mapped_file;
37 
38     // private_dirty_resident + private_clean_resident + shared_dirty_resident +
39     // shared_clean_resident = resident set size.
40     uint64_t byte_stats_private_dirty_resident;
41     uint64_t byte_stats_private_clean_resident;
42     uint64_t byte_stats_shared_dirty_resident;
43     uint64_t byte_stats_shared_clean_resident;
44 
45     uint64_t byte_stats_swapped;
46 
47     // For multiprocess accounting.
48     uint64_t byte_stats_proportional_resident;
49   };
50 
51   ProcessMemoryMaps();
52   ~ProcessMemoryMaps();
53 
AddVMRegion(const VMRegion & region)54   void AddVMRegion(const VMRegion& region) { vm_regions_.push_back(region); }
vm_regions()55   const std::vector<VMRegion>& vm_regions() const { return vm_regions_; }
56 
57   // Called at trace generation time to populate the TracedValue.
58   void AsValueInto(TracedValue* value) const;
59 
60   // Clears up all the VMRegion(s) stored.
61   void Clear();
62 
63  private:
64   std::vector<VMRegion> vm_regions_;
65 
66   DISALLOW_COPY_AND_ASSIGN(ProcessMemoryMaps);
67 };
68 
69 }  // namespace trace_event
70 }  // namespace base
71 
72 #endif  // BASE_TRACE_EVENT_PROCESS_MEMORY_MAPS_H_
73