OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 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_DEBUG_TRACE_MEMORY_H_ |
| 6 #define BASE_DEBUG_TRACE_MEMORY_H_ |
| 7 |
| 8 #include "base/base_export.h" |
| 9 |
| 10 namespace base { |
| 11 |
| 12 class BASE_EXPORT ScopedTraceMemory { |
| 13 public: |
| 14 ScopedTraceMemory(const char* category); |
| 15 ~ScopedTraceMemory(); |
| 16 |
| 17 static int GetStackIndexForTest(); |
| 18 }; |
| 19 |
| 20 BASE_EXPORT void TraceMemoryStart(); |
| 21 BASE_EXPORT void TraceMemoryDump(); |
| 22 // Caller owns the char* and must release it with free(). |
| 23 BASE_EXPORT char* TraceMemoryDumpAsString(); |
| 24 BASE_EXPORT void TraceMemoryStop(); |
| 25 |
| 26 } // namespace base |
| 27 |
| 28 // Make local variables with unique names based on the line number. Note that |
| 29 // the extra level of redirection is needed. |
| 30 #define INTERNAL_TRACE_MEMORY_ID3(line) trace_memory_unique_##line |
| 31 #define INTERNAL_TRACE_MEMORY_ID2(line) INTERNAL_TRACE_MEMORY_ID3(line) |
| 32 #define INTERNAL_TRACE_MEMORY_ID INTERNAL_TRACE_MEMORY_ID2(__LINE__) |
| 33 |
| 34 // Generates a unique local variable name. |
| 35 // TODO(jamescook): Make it record both category and name. |
| 36 #define TRACE_MEMORY(category, name) \ |
| 37 base::ScopedTraceMemory INTERNAL_TRACE_MEMORY_ID(name); |
| 38 |
| 39 // A special trace name that allows us to ignore memory allocations inside |
| 40 // the memory dump system itself. The allocations are recorded, but the |
| 41 // visualizer skips them. Must match the value in heap.js. |
| 42 #define TRACE_MEMORY_IGNORE "trace-memory-ignore" |
| 43 |
| 44 #endif // BASE_DEBUG_TRACE_MEMORY_H_ |
OLD | NEW |