OLD | NEW |
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/memory_allocator_dump.h" | 17 #include "base/trace_event/memory_allocator_dump.h" |
18 #include "base/trace_event/memory_allocator_dump_guid.h" | 18 #include "base/trace_event/memory_allocator_dump_guid.h" |
| 19 #include "base/trace_event/memory_dump_request_args.h" |
19 #include "base/trace_event/memory_dump_session_state.h" | 20 #include "base/trace_event/memory_dump_session_state.h" |
20 #include "base/trace_event/process_memory_maps.h" | 21 #include "base/trace_event/process_memory_maps.h" |
21 #include "base/trace_event/process_memory_totals.h" | 22 #include "base/trace_event/process_memory_totals.h" |
22 #include "build/build_config.h" | 23 #include "build/build_config.h" |
23 | 24 |
24 // Define COUNT_RESIDENT_BYTES_SUPPORTED if platform supports counting of the | 25 // Define COUNT_RESIDENT_BYTES_SUPPORTED if platform supports counting of the |
25 // resident memory. | 26 // resident memory. |
26 #if (defined(OS_POSIX) && !defined(OS_NACL)) || defined(OS_WIN) | 27 #if (defined(OS_POSIX) && !defined(OS_NACL)) || defined(OS_WIN) |
27 #define COUNT_RESIDENT_BYTES_SUPPORTED | 28 #define COUNT_RESIDENT_BYTES_SUPPORTED |
28 #endif | 29 #endif |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // In most cases, the two are the same. | 61 // In most cases, the two are the same. |
61 static size_t GetSystemPageSize(); | 62 static size_t GetSystemPageSize(); |
62 | 63 |
63 // Returns the total bytes resident for a virtual address range, with given | 64 // 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 | 65 // |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 | 66 // value returned is valid only if the given range is currently mmapped by the |
66 // process. The |start_address| must be page-aligned. | 67 // process. The |start_address| must be page-aligned. |
67 static size_t CountResidentBytes(void* start_address, size_t mapped_size); | 68 static size_t CountResidentBytes(void* start_address, size_t mapped_size); |
68 #endif | 69 #endif |
69 | 70 |
70 ProcessMemoryDump(scoped_refptr<MemoryDumpSessionState> session_state); | 71 ProcessMemoryDump(scoped_refptr<MemoryDumpSessionState> session_state, |
| 72 const MemoryDumpArgs& dump_args); |
71 ~ProcessMemoryDump(); | 73 ~ProcessMemoryDump(); |
72 | 74 |
73 // Creates a new MemoryAllocatorDump with the given name and returns the | 75 // Creates a new MemoryAllocatorDump with the given name and returns the |
74 // empty object back to the caller. | 76 // empty object back to the caller. |
75 // Arguments: | 77 // Arguments: |
76 // absolute_name: a name that uniquely identifies allocator dumps produced | 78 // absolute_name: a name that uniquely identifies allocator dumps produced |
77 // 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 |
78 // path-like string (e.g., v8/isolate1/heap1, v8/isolate1/heap2). | 80 // path-like string (e.g., v8/isolate1/heap1, v8/isolate1/heap2). |
79 // Leading or trailing slashes are not allowed. | 81 // Leading or trailing slashes are not allowed. |
80 // guid: an optional identifier, unique among all processes within the | 82 // guid: an optional identifier, unique among all processes within the |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 ProcessMemoryTotals* process_totals() { return &process_totals_; } | 170 ProcessMemoryTotals* process_totals() { return &process_totals_; } |
169 bool has_process_totals() const { return has_process_totals_; } | 171 bool has_process_totals() const { return has_process_totals_; } |
170 void set_has_process_totals() { has_process_totals_ = true; } | 172 void set_has_process_totals() { has_process_totals_ = true; } |
171 | 173 |
172 ProcessMemoryMaps* process_mmaps() { return &process_mmaps_; } | 174 ProcessMemoryMaps* process_mmaps() { return &process_mmaps_; } |
173 bool has_process_mmaps() const { return has_process_mmaps_; } | 175 bool has_process_mmaps() const { return has_process_mmaps_; } |
174 void set_has_process_mmaps() { has_process_mmaps_ = true; } | 176 void set_has_process_mmaps() { has_process_mmaps_ = true; } |
175 | 177 |
176 const HeapDumpsMap& heap_dumps() const { return heap_dumps_; } | 178 const HeapDumpsMap& heap_dumps() const { return heap_dumps_; } |
177 | 179 |
| 180 const MemoryDumpArgs& dump_args() const { return dump_args_; } |
| 181 |
178 private: | 182 private: |
| 183 FRIEND_TEST_ALL_PREFIXES(ProcessMemoryDumpTest, BackgroundModeTest); |
| 184 |
179 MemoryAllocatorDump* AddAllocatorDumpInternal( | 185 MemoryAllocatorDump* AddAllocatorDumpInternal( |
180 std::unique_ptr<MemoryAllocatorDump> mad); | 186 std::unique_ptr<MemoryAllocatorDump> mad); |
181 | 187 |
| 188 MemoryAllocatorDump* GetBlackHoleMad(); |
| 189 |
182 ProcessMemoryTotals process_totals_; | 190 ProcessMemoryTotals process_totals_; |
183 bool has_process_totals_; | 191 bool has_process_totals_; |
184 | 192 |
185 ProcessMemoryMaps process_mmaps_; | 193 ProcessMemoryMaps process_mmaps_; |
186 bool has_process_mmaps_; | 194 bool has_process_mmaps_; |
187 | 195 |
188 AllocatorDumpsMap allocator_dumps_; | 196 AllocatorDumpsMap allocator_dumps_; |
189 HeapDumpsMap heap_dumps_; | 197 HeapDumpsMap heap_dumps_; |
190 | 198 |
191 // State shared among all PMDs instances created in a given trace session. | 199 // State shared among all PMDs instances created in a given trace session. |
192 scoped_refptr<MemoryDumpSessionState> session_state_; | 200 scoped_refptr<MemoryDumpSessionState> session_state_; |
193 | 201 |
194 // Keeps track of relationships between MemoryAllocatorDump(s). | 202 // Keeps track of relationships between MemoryAllocatorDump(s). |
195 std::vector<MemoryAllocatorDumpEdge> allocator_dumps_edges_; | 203 std::vector<MemoryAllocatorDumpEdge> allocator_dumps_edges_; |
196 | 204 |
| 205 // Level of detail of the current dump. |
| 206 const MemoryDumpArgs dump_args_; |
| 207 |
| 208 // This allocator dump is returned when an invalid dump is created in |
| 209 // background mode. The attributes of the dump are ignored and not added to |
| 210 // the trace. |
| 211 std::unique_ptr<MemoryAllocatorDump> black_hole_mad_; |
| 212 |
| 213 // When set to true, the DCHECK(s) for invalid dump creations on the |
| 214 // background mode are disabled for testing. |
| 215 static bool is_black_hole_non_fatal_for_testing_; |
| 216 |
197 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDump); | 217 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDump); |
198 }; | 218 }; |
199 | 219 |
200 } // namespace trace_event | 220 } // namespace trace_event |
201 } // namespace base | 221 } // namespace base |
202 | 222 |
203 #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_ | 223 #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_ |
OLD | NEW |