| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #import "chrome/common/mac/objc_zombie.h" | 5 #import "chrome/common/mac/objc_zombie.h" |
| 6 | 6 |
| 7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
| 8 #include <execinfo.h> | 8 #include <execinfo.h> |
| 9 #include <mach-o/dyld.h> | 9 #include <mach-o/dyld.h> |
| 10 #include <mach-o/nlist.h> | 10 #include <mach-o/nlist.h> |
| 11 | 11 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 // treadmill). | 69 // treadmill). |
| 70 Class g_zombieClass = Nil; // cached [CrZombie class] | 70 Class g_zombieClass = Nil; // cached [CrZombie class] |
| 71 Class g_fatZombieClass = Nil; // cached [CrFatZombie class] | 71 Class g_fatZombieClass = Nil; // cached [CrFatZombie class] |
| 72 size_t g_fatZombieSize = 0; | 72 size_t g_fatZombieSize = 0; |
| 73 | 73 |
| 74 // Whether to zombie all freed objects, or only those which return YES | 74 // Whether to zombie all freed objects, or only those which return YES |
| 75 // from |-shouldBecomeCrZombie|. | 75 // from |-shouldBecomeCrZombie|. |
| 76 BOOL g_zombieAllObjects = NO; | 76 BOOL g_zombieAllObjects = NO; |
| 77 | 77 |
| 78 // Protects |g_zombieCount|, |g_zombieIndex|, and |g_zombies|. | 78 // Protects |g_zombieCount|, |g_zombieIndex|, and |g_zombies|. |
| 79 base::LazyInstance<base::Lock, base::LeakyLazyInstanceTraits<base::Lock> > | 79 base::LazyInstance<base::Lock>::Leaky g_lock = LAZY_INSTANCE_INITIALIZER; |
| 80 g_lock = LAZY_INSTANCE_INITIALIZER; | |
| 81 | 80 |
| 82 // How many zombies to keep before freeing, and the current head of | 81 // How many zombies to keep before freeing, and the current head of |
| 83 // the circular buffer. | 82 // the circular buffer. |
| 84 size_t g_zombieCount = 0; | 83 size_t g_zombieCount = 0; |
| 85 size_t g_zombieIndex = 0; | 84 size_t g_zombieIndex = 0; |
| 86 | 85 |
| 87 typedef struct { | 86 typedef struct { |
| 88 id object; // The zombied object. | 87 id object; // The zombied object. |
| 89 Class wasa; // Value of |object->isa| before we replaced it. | 88 Class wasa; // Value of |object->isa| before we replaced it. |
| 90 void* trace[kBacktraceDepth]; // Backtrace at point of deallocation. | 89 void* trace[kBacktraceDepth]; // Backtrace at point of deallocation. |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 if (oldZombies) { | 553 if (oldZombies) { |
| 555 for (size_t i = 0; i < oldCount; ++i) { | 554 for (size_t i = 0; i < oldCount; ++i) { |
| 556 if (oldZombies[i].object) | 555 if (oldZombies[i].object) |
| 557 object_dispose(oldZombies[i].object); | 556 object_dispose(oldZombies[i].object); |
| 558 } | 557 } |
| 559 free(oldZombies); | 558 free(oldZombies); |
| 560 } | 559 } |
| 561 } | 560 } |
| 562 | 561 |
| 563 } // namespace ObjcEvilDoers | 562 } // namespace ObjcEvilDoers |
| OLD | NEW |