Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Side by Side Diff: base/trace_event/process_memory_dump.h

Issue 2861133002: memory-infra: Move dump level check to observer and rename session state (Closed)
Patch Set: move comment Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_ 5 #ifndef BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_
6 #define BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_ 6 #define BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <unordered_map> 10 #include <unordered_map>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/base_export.h" 13 #include "base/base_export.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_vector.h" 16 #include "base/memory/scoped_vector.h"
17 #include "base/trace_event/heap_profiler_serialization_state.h"
17 #include "base/trace_event/memory_allocator_dump.h" 18 #include "base/trace_event/memory_allocator_dump.h"
18 #include "base/trace_event/memory_allocator_dump_guid.h" 19 #include "base/trace_event/memory_allocator_dump_guid.h"
19 #include "base/trace_event/memory_dump_request_args.h" 20 #include "base/trace_event/memory_dump_request_args.h"
20 #include "base/trace_event/memory_dump_session_state.h"
21 #include "base/trace_event/process_memory_maps.h" 21 #include "base/trace_event/process_memory_maps.h"
22 #include "base/trace_event/process_memory_totals.h" 22 #include "base/trace_event/process_memory_totals.h"
23 #include "build/build_config.h" 23 #include "build/build_config.h"
24 24
25 // Define COUNT_RESIDENT_BYTES_SUPPORTED if platform supports counting of the 25 // Define COUNT_RESIDENT_BYTES_SUPPORTED if platform supports counting of the
26 // resident memory. 26 // resident memory.
27 #if (defined(OS_POSIX) && !defined(OS_NACL)) || defined(OS_WIN) 27 #if (defined(OS_POSIX) && !defined(OS_NACL)) || defined(OS_WIN)
28 #define COUNT_RESIDENT_BYTES_SUPPORTED 28 #define COUNT_RESIDENT_BYTES_SUPPORTED
29 #endif 29 #endif
30 30
31 namespace base { 31 namespace base {
32 namespace trace_event { 32 namespace trace_event {
33 33
34 class MemoryDumpSessionState; 34 class HeapProfilerSerializationState;
35 class TracedValue; 35 class TracedValue;
36 36
37 // ProcessMemoryDump is as a strongly typed container which holds the dumps 37 // ProcessMemoryDump is as a strongly typed container which holds the dumps
38 // produced by the MemoryDumpProvider(s) for a specific process. 38 // produced by the MemoryDumpProvider(s) for a specific process.
39 class BASE_EXPORT ProcessMemoryDump { 39 class BASE_EXPORT ProcessMemoryDump {
40 public: 40 public:
41 struct MemoryAllocatorDumpEdge { 41 struct MemoryAllocatorDumpEdge {
42 MemoryAllocatorDumpGuid source; 42 MemoryAllocatorDumpGuid source;
43 MemoryAllocatorDumpGuid target; 43 MemoryAllocatorDumpGuid target;
44 int importance; 44 int importance;
(...skipping 15 matching lines...) Expand all
60 // In most cases, the two are the same. 60 // In most cases, the two are the same.
61 static size_t GetSystemPageSize(); 61 static size_t GetSystemPageSize();
62 62
63 // Returns the total bytes resident for a virtual address range, with given 63 // Returns the total bytes resident for a virtual address range, with given
64 // |start_address| and |mapped_size|. |mapped_size| is specified in bytes. The 64 // |start_address| and |mapped_size|. |mapped_size| is specified in bytes. The
65 // value returned is valid only if the given range is currently mmapped by the 65 // value returned is valid only if the given range is currently mmapped by the
66 // process. The |start_address| must be page-aligned. 66 // process. The |start_address| must be page-aligned.
67 static size_t CountResidentBytes(void* start_address, size_t mapped_size); 67 static size_t CountResidentBytes(void* start_address, size_t mapped_size);
68 #endif 68 #endif
69 69
70 ProcessMemoryDump(scoped_refptr<MemoryDumpSessionState> session_state, 70 ProcessMemoryDump(scoped_refptr<HeapProfilerSerializationState>
71 heap_profiler_serialization_state,
71 const MemoryDumpArgs& dump_args); 72 const MemoryDumpArgs& dump_args);
72 ~ProcessMemoryDump(); 73 ~ProcessMemoryDump();
73 74
74 // Creates a new MemoryAllocatorDump with the given name and returns the 75 // Creates a new MemoryAllocatorDump with the given name and returns the
75 // empty object back to the caller. 76 // empty object back to the caller.
76 // Arguments: 77 // Arguments:
77 // absolute_name: a name that uniquely identifies allocator dumps produced 78 // absolute_name: a name that uniquely identifies allocator dumps produced
78 // by this provider. It is possible to specify nesting by using a 79 // by this provider. It is possible to specify nesting by using a
79 // path-like string (e.g., v8/isolate1/heap1, v8/isolate1/heap2). 80 // path-like string (e.g., v8/isolate1/heap1, v8/isolate1/heap2).
80 // Leading or trailing slashes are not allowed. 81 // Leading or trailing slashes are not allowed.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 142 }
142 143
143 // Utility method to add a suballocation relationship with the following 144 // Utility method to add a suballocation relationship with the following
144 // semantics: |source| is suballocated from |target_node_name|. 145 // semantics: |source| is suballocated from |target_node_name|.
145 // This creates a child node of |target_node_name| and adds an ownership edge 146 // This creates a child node of |target_node_name| and adds an ownership edge
146 // between |source| and the new child node. As a result, the UI will not 147 // between |source| and the new child node. As a result, the UI will not
147 // account the memory of |source| in the target node. 148 // account the memory of |source| in the target node.
148 void AddSuballocation(const MemoryAllocatorDumpGuid& source, 149 void AddSuballocation(const MemoryAllocatorDumpGuid& source,
149 const std::string& target_node_name); 150 const std::string& target_node_name);
150 151
151 const scoped_refptr<MemoryDumpSessionState>& session_state() const { 152 const scoped_refptr<HeapProfilerSerializationState>&
152 return session_state_; 153 heap_profiler_serialization_state() const {
154 return heap_profiler_serialization_state_;
153 } 155 }
154 156
155 // Removes all the MemoryAllocatorDump(s) contained in this instance. This 157 // Removes all the MemoryAllocatorDump(s) contained in this instance. This
156 // ProcessMemoryDump can be safely reused as if it was new once this returns. 158 // ProcessMemoryDump can be safely reused as if it was new once this returns.
157 void Clear(); 159 void Clear();
158 160
159 // Merges all MemoryAllocatorDump(s) contained in |other| inside this 161 // Merges all MemoryAllocatorDump(s) contained in |other| inside this
160 // ProcessMemoryDump, transferring their ownership to this instance. 162 // ProcessMemoryDump, transferring their ownership to this instance.
161 // |other| will be an empty ProcessMemoryDump after this method returns. 163 // |other| will be an empty ProcessMemoryDump after this method returns.
162 // This is to allow dump providers to pre-populate ProcessMemoryDump instances 164 // This is to allow dump providers to pre-populate ProcessMemoryDump instances
(...skipping 28 matching lines...) Expand all
191 ProcessMemoryTotals process_totals_; 193 ProcessMemoryTotals process_totals_;
192 bool has_process_totals_; 194 bool has_process_totals_;
193 195
194 ProcessMemoryMaps process_mmaps_; 196 ProcessMemoryMaps process_mmaps_;
195 bool has_process_mmaps_; 197 bool has_process_mmaps_;
196 198
197 AllocatorDumpsMap allocator_dumps_; 199 AllocatorDumpsMap allocator_dumps_;
198 HeapDumpsMap heap_dumps_; 200 HeapDumpsMap heap_dumps_;
199 201
200 // State shared among all PMDs instances created in a given trace session. 202 // State shared among all PMDs instances created in a given trace session.
201 scoped_refptr<MemoryDumpSessionState> session_state_; 203 scoped_refptr<HeapProfilerSerializationState>
204 heap_profiler_serialization_state_;
202 205
203 // Keeps track of relationships between MemoryAllocatorDump(s). 206 // Keeps track of relationships between MemoryAllocatorDump(s).
204 std::vector<MemoryAllocatorDumpEdge> allocator_dumps_edges_; 207 std::vector<MemoryAllocatorDumpEdge> allocator_dumps_edges_;
205 208
206 // Level of detail of the current dump. 209 // Level of detail of the current dump.
207 const MemoryDumpArgs dump_args_; 210 const MemoryDumpArgs dump_args_;
208 211
209 // This allocator dump is returned when an invalid dump is created in 212 // This allocator dump is returned when an invalid dump is created in
210 // background mode. The attributes of the dump are ignored and not added to 213 // background mode. The attributes of the dump are ignored and not added to
211 // the trace. 214 // the trace.
212 std::unique_ptr<MemoryAllocatorDump> black_hole_mad_; 215 std::unique_ptr<MemoryAllocatorDump> black_hole_mad_;
213 216
214 // When set to true, the DCHECK(s) for invalid dump creations on the 217 // When set to true, the DCHECK(s) for invalid dump creations on the
215 // background mode are disabled for testing. 218 // background mode are disabled for testing.
216 static bool is_black_hole_non_fatal_for_testing_; 219 static bool is_black_hole_non_fatal_for_testing_;
217 220
218 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDump); 221 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDump);
219 }; 222 };
220 223
221 } // namespace trace_event 224 } // namespace trace_event
222 } // namespace base 225 } // namespace base
223 226
224 #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_ 227 #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698