| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef COMPONENTS_CRASH_CORE_COMMON_OBJC_ZOMBIE_H_ | 5 #ifndef COMPONENTS_CRASH_CORE_COMMON_OBJC_ZOMBIE_H_ |
| 6 #define COMPONENTS_CRASH_CORE_COMMON_OBJC_ZOMBIE_H_ | 6 #define COMPONENTS_CRASH_CORE_COMMON_OBJC_ZOMBIE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "components/crash/core/common/crash_export.h" |
| 11 | 12 |
| 12 // You should think twice every single time you use anything from this | 13 // You should think twice every single time you use anything from this |
| 13 // namespace. | 14 // namespace. |
| 14 namespace ObjcEvilDoers { | 15 namespace ObjcEvilDoers { |
| 15 | 16 |
| 16 // Enable zombie object debugging. This implements a variant of Apple's | 17 // Enable zombie object debugging. This implements a variant of Apple's |
| 17 // NSZombieEnabled which can help expose use-after-free errors where messages | 18 // NSZombieEnabled which can help expose use-after-free errors where messages |
| 18 // are sent to freed Objective-C objects in production builds. | 19 // are sent to freed Objective-C objects in production builds. |
| 19 // | 20 // |
| 20 // Returns NO if it fails to enable. | 21 // Returns NO if it fails to enable. |
| 21 // | 22 // |
| 22 // When |zombieAllObjects| is YES, all objects inheriting from | 23 // When |zombieAllObjects| is YES, all objects inheriting from |
| 23 // NSObject become zombies on -dealloc. If NO, -shouldBecomeCrZombie | 24 // NSObject become zombies on -dealloc. If NO, -shouldBecomeCrZombie |
| 24 // is queried to determine whether to make the object a zombie. | 25 // is queried to determine whether to make the object a zombie. |
| 25 // | 26 // |
| 26 // |zombieCount| controls how many zombies to store before freeing the | 27 // |zombieCount| controls how many zombies to store before freeing the |
| 27 // oldest. Set to 0 to free objects immediately after making them | 28 // oldest. Set to 0 to free objects immediately after making them |
| 28 // zombies. | 29 // zombies. |
| 29 bool ZombieEnable(bool zombieAllObjects, size_t zombieCount); | 30 bool CRASH_EXPORT ZombieEnable(bool zombieAllObjects, size_t zombieCount); |
| 30 | 31 |
| 31 // Disable zombies. | 32 // Disable zombies. |
| 32 void ZombieDisable(); | 33 void CRASH_EXPORT ZombieDisable(); |
| 33 | 34 |
| 34 } // namespace ObjcEvilDoers | 35 } // namespace ObjcEvilDoers |
| 35 | 36 |
| 36 #if defined(OS_MACOSX) | 37 #if defined(OS_MACOSX) |
| 37 #if defined(__OBJC__) | 38 #if defined(__OBJC__) |
| 38 | 39 |
| 39 #import <Foundation/Foundation.h> | 40 #import <Foundation/Foundation.h> |
| 40 | 41 |
| 41 @interface NSObject (CrZombie) | 42 @interface NSObject (CrZombie) |
| 42 - (BOOL)shouldBecomeCrZombie; | 43 - (BOOL)shouldBecomeCrZombie; |
| 43 @end | 44 @end |
| 44 | 45 |
| 45 #endif // __OBJC__ | 46 #endif // __OBJC__ |
| 46 #endif // OS_MACOSX | 47 #endif // OS_MACOSX |
| 47 | 48 |
| 48 #endif // COMPONENTS_CRASH_CORE_COMMON_OBJC_ZOMBIE_H_ | 49 #endif // COMPONENTS_CRASH_CORE_COMMON_OBJC_ZOMBIE_H_ |
| OLD | NEW |