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

Unified Diff: base/debug/trace_memory.h

Issue 15418002: Record Chrome trace events in tcmalloc heap profiles (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup, run in all renderers Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/debug/trace_event_impl.cc ('k') | base/debug/trace_memory.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/trace_memory.h
diff --git a/base/debug/trace_memory.h b/base/debug/trace_memory.h
new file mode 100644
index 0000000000000000000000000000000000000000..7792e7aef31c4e5162663b9dad8a8e19fb07fcc2
--- /dev/null
+++ b/base/debug/trace_memory.h
@@ -0,0 +1,44 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BASE_DEBUG_TRACE_MEMORY_H_
+#define BASE_DEBUG_TRACE_MEMORY_H_
+
+#include "base/base_export.h"
+
+namespace base {
+
+class BASE_EXPORT ScopedTraceMemory {
+ public:
+ ScopedTraceMemory(const char* category);
+ ~ScopedTraceMemory();
+
+ static int GetStackIndexForTest();
+};
+
+BASE_EXPORT void TraceMemoryStart();
+BASE_EXPORT void TraceMemoryDump();
+// Caller owns the char* and must release it with free().
+BASE_EXPORT char* TraceMemoryDumpAsString();
+BASE_EXPORT void TraceMemoryStop();
+
+} // namespace base
+
+// Make local variables with unique names based on the line number. Note that
+// the extra level of redirection is needed.
+#define INTERNAL_TRACE_MEMORY_ID3(line) trace_memory_unique_##line
+#define INTERNAL_TRACE_MEMORY_ID2(line) INTERNAL_TRACE_MEMORY_ID3(line)
+#define INTERNAL_TRACE_MEMORY_ID INTERNAL_TRACE_MEMORY_ID2(__LINE__)
+
+// Generates a unique local variable name.
+// TODO(jamescook): Make it record both category and name.
+#define TRACE_MEMORY(category, name) \
+ base::ScopedTraceMemory INTERNAL_TRACE_MEMORY_ID(name);
+
+// A special trace name that allows us to ignore memory allocations inside
+// the memory dump system itself. The allocations are recorded, but the
+// visualizer skips them. Must match the value in heap.js.
+#define TRACE_MEMORY_IGNORE "trace-memory-ignore"
+
+#endif // BASE_DEBUG_TRACE_MEMORY_H_
« no previous file with comments | « base/debug/trace_event_impl.cc ('k') | base/debug/trace_memory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698