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

Unified Diff: base/allocator/type_profiler.cc

Issue 10411047: Type profiler by intercepting 'new' and 'delete' expressions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed Created 8 years, 3 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/allocator/type_profiler.h ('k') | base/allocator/type_profiler_control.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/allocator/type_profiler.cc
diff --git a/base/allocator/type_profiler.cc b/base/allocator/type_profiler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..635fbcf5ed95582f872c049a8950df6ea26ed266
--- /dev/null
+++ b/base/allocator/type_profiler.cc
@@ -0,0 +1,63 @@
+// Copyright 2012 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.
+
+#if defined(TYPE_PROFILING)
+
+#include "base/allocator/type_profiler.h"
+
+#include <assert.h>
+
+namespace {
+
+void* NopIntercept(void* ptr, size_t size, const std::type_info& type) {
+ return ptr;
+}
+
+base::type_profiler::InterceptFunction* g_new_intercept = NopIntercept;
+base::type_profiler::InterceptFunction* g_delete_intercept = NopIntercept;
+
+}
+
+void* __op_new_intercept__(void* ptr,
+ size_t size,
+ const std::type_info& type) {
+ return g_new_intercept(ptr, size, type);
+}
+
+void* __op_delete_intercept__(void* ptr,
+ size_t size,
+ const std::type_info& type) {
+ return g_delete_intercept(ptr, size, type);
+}
+
+namespace base {
+namespace type_profiler {
+
+// static
+void InterceptFunctions::SetFunctions(InterceptFunction* new_intercept,
+ InterceptFunction* delete_intercept) {
+ // Don't use DCHECK, as this file is injected into targets
+ // that do not and should not depend on base/base.gyp:base
+ assert(g_new_intercept == NopIntercept);
+ assert(g_delete_intercept == NopIntercept);
+
+ g_new_intercept = new_intercept;
+ g_delete_intercept = delete_intercept;
+}
+
+// static
+void InterceptFunctions::ResetFunctions() {
+ g_new_intercept = NopIntercept;
+ g_delete_intercept = NopIntercept;
+}
+
+// static
+bool InterceptFunctions::IsAvailable() {
+ return g_new_intercept != NopIntercept || g_delete_intercept != NopIntercept;
+}
+
+} // namespace type_profiler
+} // namespace base
+
+#endif // defined(TYPE_PROFILING)
« no previous file with comments | « base/allocator/type_profiler.h ('k') | base/allocator/type_profiler_control.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698