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

Side by Side Diff: third_party/tcmalloc/chromium/src/heap-checker-bcad.cc

Issue 10384117: Add a chromium version abort function for tcmalloc: Abort(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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
1 // Copyright (c) 2005, Google Inc. 1 // Copyright (c) 2005, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 26 matching lines...) Expand all
37 // destructors. 37 // destructors.
38 // 38 //
39 // This file must be the last library any binary links against. 39 // This file must be the last library any binary links against.
40 // Otherwise, the heap checker may not be able to run early enough to 40 // Otherwise, the heap checker may not be able to run early enough to
41 // catalog all the global objects in your program. If this happens, 41 // catalog all the global objects in your program. If this happens,
42 // and later in the program you allocate memory and have one of these 42 // and later in the program you allocate memory and have one of these
43 // "uncataloged" global objects point to it, the heap checker will 43 // "uncataloged" global objects point to it, the heap checker will
44 // consider that allocation to be a leak, even though it's not (since 44 // consider that allocation to be a leak, even though it's not (since
45 // the allocated object is reachable from global data and hence "live"). 45 // the allocated object is reachable from global data and hence "live").
46 46
47 #include <stdlib.h> // for abort()
48 #include <gperftools/malloc_extension.h> 47 #include <gperftools/malloc_extension.h>
48 #include "base/abort.h"
49 49
50 // A dummy variable to refer from heap-checker.cc. This is to make 50 // A dummy variable to refer from heap-checker.cc. This is to make
51 // sure this file is not optimized out by the linker. 51 // sure this file is not optimized out by the linker.
52 bool heap_leak_checker_bcad_variable; 52 bool heap_leak_checker_bcad_variable;
53 53
54 extern void HeapLeakChecker_AfterDestructors(); // in heap-checker.cc 54 extern void HeapLeakChecker_AfterDestructors(); // in heap-checker.cc
55 55
56 // A helper class to ensure that some components of heap leak checking 56 // A helper class to ensure that some components of heap leak checking
57 // can happen before construction and after destruction 57 // can happen before construction and after destruction
58 // of all global/static objects. 58 // of all global/static objects.
(...skipping 10 matching lines...) Expand all
69 // This needs to be called before the first allocation of an STL 69 // This needs to be called before the first allocation of an STL
70 // object, but after libc is done setting up threads (because it 70 // object, but after libc is done setting up threads (because it
71 // calls setenv, which requires a thread-aware errno). By 71 // calls setenv, which requires a thread-aware errno). By
72 // putting it here, we hope it's the first bit of code executed 72 // putting it here, we hope it's the first bit of code executed
73 // after the libc global-constructor code. 73 // after the libc global-constructor code.
74 MallocExtension::Initialize(); 74 MallocExtension::Initialize();
75 } 75 }
76 ++count_; 76 ++count_;
77 } 77 }
78 ~HeapLeakCheckerGlobalPrePost() { 78 ~HeapLeakCheckerGlobalPrePost() {
79 if (count_ <= 0) abort(); 79 if (count_ <= 0) tcmalloc::Abort();
80 --count_; 80 --count_;
81 if (count_ == 0) HeapLeakChecker_AfterDestructors(); 81 if (count_ == 0) HeapLeakChecker_AfterDestructors();
82 } 82 }
83 private: 83 private:
84 // Counter of constructions/destructions of objects of this class 84 // Counter of constructions/destructions of objects of this class
85 // (just in case there are more than one of them). 85 // (just in case there are more than one of them).
86 static int count_; 86 static int count_;
87 }; 87 };
88 88
89 int HeapLeakCheckerGlobalPrePost::count_ = 0; 89 int HeapLeakCheckerGlobalPrePost::count_ = 0;
90 90
91 // The early-construction/late-destruction global object. 91 // The early-construction/late-destruction global object.
92 static const HeapLeakCheckerGlobalPrePost heap_leak_checker_global_pre_post; 92 static const HeapLeakCheckerGlobalPrePost heap_leak_checker_global_pre_post;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698