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

Side by Side 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 for jar's comments #72 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2012 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 #include "base/allocator/type_profiler.h"
6
7 #include <assert.h>
8
9 #if defined(TYPE_PROFILING)
10
11 namespace {
12 void* NopIntercept(void* ptr, size_t size, const std::type_info& type) {
13 return ptr;
14 }
15 }
16
17 void* __op_new_intercept__(void* ptr,
18 size_t size,
19 const std::type_info& type) {
20 return base::type_profiler::InterceptFunctions::new_intercept_(
21 ptr, size, type);
22 }
23
24 void* __op_delete_intercept__(void* ptr,
25 size_t size,
26 const std::type_info& type) {
27 return base::type_profiler::InterceptFunctions::delete_intercept_(
28 ptr, size, type);
29 }
30
31 namespace base {
32 namespace type_profiler {
33
34 InterceptFunction* InterceptFunctions::new_intercept_ = NopIntercept;
35 InterceptFunction* InterceptFunctions::delete_intercept_ = NopIntercept;
36
37 // static
38 void InterceptFunctions::SetFunctions(InterceptFunction* new_intercept,
39 InterceptFunction* delete_intercept) {
40 // Don't use DCHECKs as this file is injected also to non-Chromium binaries.
41 // They don't link base/ files.
Ryan Sleevi 2012/09/12 19:13:34 nit: wording // Don't use DCHECK, as this file is
Dai Mikurube (NOT FULLTIME) 2012/09/13 04:00:12 Done.
42 assert(new_intercept_ == NopIntercept);
43 assert(delete_intercept_ == NopIntercept);
44
45 new_intercept_ = new_intercept;
46 delete_intercept_ = delete_intercept;
47 }
48
49 // static
50 void InterceptFunctions::ResetFunctions() {
51 new_intercept_ = NopIntercept;
52 delete_intercept_ = NopIntercept;
53 }
54
55 // static
56 bool InterceptFunctions::IsAvailable() {
57 return new_intercept_ != NopIntercept || delete_intercept_ != NopIntercept;
58 }
59
60 } // namespace type_profiler
61 } // namespace base
62
63 #endif // defined(TYPE_PROFILING)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698