OLD | NEW |
1 // Copyright (c) 2012 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 |
12 #import <objc/objc-class.h> | 12 #import <objc/objc-class.h> |
13 | 13 |
14 #include <algorithm> | 14 #include <algorithm> |
15 | 15 |
16 #include "base/debug/stack_trace.h" | 16 #include "base/debug/stack_trace.h" |
17 #include "base/lazy_instance.h" | 17 #include "base/lazy_instance.h" |
18 #include "base/logging.h" | 18 #include "base/logging.h" |
19 #include "base/mac/crash_logging.h" | 19 #include "base/mac/crash_logging.h" |
20 #include "base/mac/mac_util.h" | 20 #include "base/mac/mac_util.h" |
21 #include "base/metrics/histogram.h" | 21 #include "base/metrics/histogram.h" |
22 #include "base/synchronization/lock.h" | 22 #include "base/synchronization/lock.h" |
23 #import "chrome/common/mac/objc_method_swizzle.h" | 23 #import "chrome/common/mac/objc_method_swizzle.h" |
24 | 24 |
25 // Deallocated objects are re-classed as |CrZombie|. No superclass | 25 // Deallocated objects are re-classed as |CrZombie|. No superclass |
26 // because then the class would have to override many/most of the | 26 // because then the class would have to override many/most of the |
27 // inherited methods (|NSObject| is like a category magnet!). | 27 // inherited methods (|NSObject| is like a category magnet!). |
28 @interface CrZombie { | 28 // Without the __attribute__, clang's -Wobjc-root-class warns on the missing |
| 29 // superclass. |
| 30 __attribute__((objc_root_class)) |
| 31 @interface CrZombie { |
29 Class isa; | 32 Class isa; |
30 } | 33 } |
31 @end | 34 @end |
32 | 35 |
33 // Objects with enough space are made into "fat" zombies, which | 36 // Objects with enough space are made into "fat" zombies, which |
34 // directly remember which class they were until reallocated. | 37 // directly remember which class they were until reallocated. |
35 @interface CrFatZombie : CrZombie { | 38 @interface CrFatZombie : CrZombie { |
36 @public | 39 @public |
37 Class wasa; | 40 Class wasa; |
38 } | 41 } |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 if (oldZombies) { | 547 if (oldZombies) { |
545 for (size_t i = 0; i < oldCount; ++i) { | 548 for (size_t i = 0; i < oldCount; ++i) { |
546 if (oldZombies[i].object) | 549 if (oldZombies[i].object) |
547 object_dispose(oldZombies[i].object); | 550 object_dispose(oldZombies[i].object); |
548 } | 551 } |
549 free(oldZombies); | 552 free(oldZombies); |
550 } | 553 } |
551 } | 554 } |
552 | 555 |
553 } // namespace ObjcEvilDoers | 556 } // namespace ObjcEvilDoers |
OLD | NEW |