| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // Parts of this module come from: | 5 // Parts of this module come from: |
| 6 // http://www.codeproject.com/KB/applications/visualleakdetector.aspx | 6 // http://www.codeproject.com/KB/applications/visualleakdetector.aspx |
| 7 // by Dan Moulding. | 7 // by Dan Moulding. |
| 8 // http://www.codeproject.com/KB/threads/StackWalker.aspx | 8 // http://www.codeproject.com/KB/threads/StackWalker.aspx |
| 9 // by Jochen Kalmbach | 9 // by Jochen Kalmbach |
| 10 | 10 |
| 11 #ifndef MEMORY_WATCHER_CALL_STACK_H_ | 11 #ifndef MEMORY_WATCHER_CALL_STACK_H_ |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 // Indicate is this is a valid stack. | 131 // Indicate is this is a valid stack. |
| 132 // This is false if recursion precluded a real stack generation. | 132 // This is false if recursion precluded a real stack generation. |
| 133 bool valid_; | 133 bool valid_; |
| 134 | 134 |
| 135 // Cache ProgramCounter -> Symbol lookups. | 135 // Cache ProgramCounter -> Symbol lookups. |
| 136 // This cache is not thread safe. | 136 // This cache is not thread safe. |
| 137 typedef std::map<int32, PrivateAllocatorString, std::less<int32>, | 137 typedef std::map<int32, PrivateAllocatorString, std::less<int32>, |
| 138 PrivateHookAllocator<int32> > SymbolCache; | 138 PrivateHookAllocator<int32> > SymbolCache; |
| 139 static SymbolCache* symbol_cache_; | 139 static SymbolCache* symbol_cache_; |
| 140 | 140 |
| 141 DISALLOW_EVIL_CONSTRUCTORS(CallStack); | 141 DISALLOW_COPY_AND_ASSIGN(CallStack); |
| 142 }; | 142 }; |
| 143 | 143 |
| 144 // An AllocationStack is a type of CallStack which represents a CallStack where | 144 // An AllocationStack is a type of CallStack which represents a CallStack where |
| 145 // memory has been allocated. This class is also a list item, so that it can | 145 // memory has been allocated. This class is also a list item, so that it can |
| 146 // be easilly allocated and deallocated from its static singly-linked-list of | 146 // be easilly allocated and deallocated from its static singly-linked-list of |
| 147 // free instances. | 147 // free instances. |
| 148 class AllocationStack : public CallStack { | 148 class AllocationStack : public CallStack { |
| 149 public: | 149 public: |
| 150 explicit AllocationStack(int32 size) | 150 explicit AllocationStack(int32 size) |
| 151 : next_(NULL), size_(size), CallStack() {} | 151 : next_(NULL), size_(size), CallStack() {} |
| 152 | 152 |
| 153 // We maintain a freelist of the AllocationStacks. | 153 // We maintain a freelist of the AllocationStacks. |
| 154 void* operator new(size_t s); | 154 void* operator new(size_t s); |
| 155 void operator delete(void*p); | 155 void operator delete(void*p); |
| 156 | 156 |
| 157 int32 size() const { return size_; } | 157 int32 size() const { return size_; } |
| 158 | 158 |
| 159 private: | 159 private: |
| 160 AllocationStack* next_; // Pointer used when on the freelist. | 160 AllocationStack* next_; // Pointer used when on the freelist. |
| 161 int32 size_; // Size of block allocated. | 161 int32 size_; // Size of block allocated. |
| 162 static AllocationStack* freelist_; | 162 static AllocationStack* freelist_; |
| 163 static Lock freelist_lock_; | 163 static Lock freelist_lock_; |
| 164 | 164 |
| 165 DISALLOW_EVIL_CONSTRUCTORS(AllocationStack); | 165 DISALLOW_COPY_AND_ASSIGN(AllocationStack); |
| 166 }; | 166 }; |
| 167 | 167 |
| 168 #endif // MEMORY_WATCHER_CALL_STACK_H_ | 168 #endif // MEMORY_WATCHER_CALL_STACK_H_ |
| OLD | NEW |