| 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> |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #define COUNT_RESIDENT_BYTES_SUPPORTED | 27 #define COUNT_RESIDENT_BYTES_SUPPORTED |
| 28 #endif | 28 #endif |
| 29 | 29 |
| 30 namespace base { | 30 namespace base { |
| 31 namespace trace_event { | 31 namespace trace_event { |
| 32 | 32 |
| 33 class MemoryDumpManager; | 33 class MemoryDumpManager; |
| 34 class MemoryDumpSessionState; | 34 class MemoryDumpSessionState; |
| 35 class TracedValue; | 35 class TracedValue; |
| 36 | 36 |
| 37 // Args for ProcessMemoryDump. Dump providers are expected to read the args for |
| 38 // creating dumps. |
| 39 struct MemoryDumpArgs { |
| 40 // Specifies how detailed the dumps should be. |
| 41 MemoryDumpLevelOfDetail level_of_detail; |
| 42 }; |
| 43 |
| 37 // ProcessMemoryDump is as a strongly typed container which holds the dumps | 44 // ProcessMemoryDump is as a strongly typed container which holds the dumps |
| 38 // produced by the MemoryDumpProvider(s) for a specific process. | 45 // produced by the MemoryDumpProvider(s) for a specific process. |
| 39 class BASE_EXPORT ProcessMemoryDump { | 46 class BASE_EXPORT ProcessMemoryDump { |
| 40 public: | 47 public: |
| 41 struct MemoryAllocatorDumpEdge { | 48 struct MemoryAllocatorDumpEdge { |
| 42 MemoryAllocatorDumpGuid source; | 49 MemoryAllocatorDumpGuid source; |
| 43 MemoryAllocatorDumpGuid target; | 50 MemoryAllocatorDumpGuid target; |
| 44 int importance; | 51 int importance; |
| 45 const char* type; | 52 const char* type; |
| 46 }; | 53 }; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 60 // In most cases, the two are the same. | 67 // In most cases, the two are the same. |
| 61 static size_t GetSystemPageSize(); | 68 static size_t GetSystemPageSize(); |
| 62 | 69 |
| 63 // Returns the total bytes resident for a virtual address range, with given | 70 // 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 | 71 // |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 | 72 // value returned is valid only if the given range is currently mmapped by the |
| 66 // process. The |start_address| must be page-aligned. | 73 // process. The |start_address| must be page-aligned. |
| 67 static size_t CountResidentBytes(void* start_address, size_t mapped_size); | 74 static size_t CountResidentBytes(void* start_address, size_t mapped_size); |
| 68 #endif | 75 #endif |
| 69 | 76 |
| 70 ProcessMemoryDump(scoped_refptr<MemoryDumpSessionState> session_state); | 77 ProcessMemoryDump(scoped_refptr<MemoryDumpSessionState> session_state, |
| 78 const MemoryDumpArgs& dump_args); |
| 71 ~ProcessMemoryDump(); | 79 ~ProcessMemoryDump(); |
| 72 | 80 |
| 73 // Creates a new MemoryAllocatorDump with the given name and returns the | 81 // Creates a new MemoryAllocatorDump with the given name and returns the |
| 74 // empty object back to the caller. | 82 // empty object back to the caller. |
| 75 // Arguments: | 83 // Arguments: |
| 76 // absolute_name: a name that uniquely identifies allocator dumps produced | 84 // absolute_name: a name that uniquely identifies allocator dumps produced |
| 77 // by this provider. It is possible to specify nesting by using a | 85 // by this provider. It is possible to specify nesting by using a |
| 78 // path-like string (e.g., v8/isolate1/heap1, v8/isolate1/heap2). | 86 // path-like string (e.g., v8/isolate1/heap1, v8/isolate1/heap2). |
| 79 // Leading or trailing slashes are not allowed. | 87 // Leading or trailing slashes are not allowed. |
| 80 // guid: an optional identifier, unique among all processes within the | 88 // 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_; } | 176 ProcessMemoryTotals* process_totals() { return &process_totals_; } |
| 169 bool has_process_totals() const { return has_process_totals_; } | 177 bool has_process_totals() const { return has_process_totals_; } |
| 170 void set_has_process_totals() { has_process_totals_ = true; } | 178 void set_has_process_totals() { has_process_totals_ = true; } |
| 171 | 179 |
| 172 ProcessMemoryMaps* process_mmaps() { return &process_mmaps_; } | 180 ProcessMemoryMaps* process_mmaps() { return &process_mmaps_; } |
| 173 bool has_process_mmaps() const { return has_process_mmaps_; } | 181 bool has_process_mmaps() const { return has_process_mmaps_; } |
| 174 void set_has_process_mmaps() { has_process_mmaps_ = true; } | 182 void set_has_process_mmaps() { has_process_mmaps_ = true; } |
| 175 | 183 |
| 176 const HeapDumpsMap& heap_dumps() const { return heap_dumps_; } | 184 const HeapDumpsMap& heap_dumps() const { return heap_dumps_; } |
| 177 | 185 |
| 186 const MemoryDumpArgs& dump_args() const { return dump_args_; } |
| 187 |
| 188 MemoryAllocatorDump* black_hole_mad_for_testing() { |
| 189 return black_hole_mad_.get(); |
| 190 } |
| 191 |
| 178 private: | 192 private: |
| 193 friend class ProcessMemoryDumpTest; |
| 194 FRIEND_TEST_ALL_PREFIXES(ProcessMemoryDumpTest, BackgroundModeTest); |
| 195 |
| 179 MemoryAllocatorDump* AddAllocatorDumpInternal( | 196 MemoryAllocatorDump* AddAllocatorDumpInternal( |
| 180 std::unique_ptr<MemoryAllocatorDump> mad); | 197 std::unique_ptr<MemoryAllocatorDump> mad); |
| 181 | 198 |
| 182 ProcessMemoryTotals process_totals_; | 199 ProcessMemoryTotals process_totals_; |
| 183 bool has_process_totals_; | 200 bool has_process_totals_; |
| 184 | 201 |
| 185 ProcessMemoryMaps process_mmaps_; | 202 ProcessMemoryMaps process_mmaps_; |
| 186 bool has_process_mmaps_; | 203 bool has_process_mmaps_; |
| 187 | 204 |
| 188 AllocatorDumpsMap allocator_dumps_; | 205 AllocatorDumpsMap allocator_dumps_; |
| 189 HeapDumpsMap heap_dumps_; | 206 HeapDumpsMap heap_dumps_; |
| 190 | 207 |
| 191 // State shared among all PMDs instances created in a given trace session. | 208 // State shared among all PMDs instances created in a given trace session. |
| 192 scoped_refptr<MemoryDumpSessionState> session_state_; | 209 scoped_refptr<MemoryDumpSessionState> session_state_; |
| 193 | 210 |
| 194 // Keeps track of relationships between MemoryAllocatorDump(s). | 211 // Keeps track of relationships between MemoryAllocatorDump(s). |
| 195 std::vector<MemoryAllocatorDumpEdge> allocator_dumps_edges_; | 212 std::vector<MemoryAllocatorDumpEdge> allocator_dumps_edges_; |
| 196 | 213 |
| 214 // Level of detail of the current dump. |
| 215 const MemoryDumpArgs dump_args_; |
| 216 |
| 217 // This allocator dump is returned when an invalid dump is created in |
| 218 // background mode. The attributes of the dump are ignored and not added to |
| 219 // the trace. |
| 220 std::unique_ptr<MemoryAllocatorDump> black_hole_mad_; |
| 221 |
| 197 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDump); | 222 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDump); |
| 198 }; | 223 }; |
| 199 | 224 |
| 200 } // namespace trace_event | 225 } // namespace trace_event |
| 201 } // namespace base | 226 } // namespace base |
| 202 | 227 |
| 203 #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_ | 228 #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_ |
| OLD | NEW |