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 #include <iostream> | |
16 | 15 |
17 #include "base/debug/stack_trace.h" | 16 #include "base/debug/stack_trace.h" |
18 #include "base/lazy_instance.h" | 17 #include "base/lazy_instance.h" |
19 #include "base/logging.h" | 18 #include "base/logging.h" |
20 #include "base/mac/crash_logging.h" | 19 #include "base/mac/crash_logging.h" |
21 #include "base/mac/mac_util.h" | 20 #include "base/mac/mac_util.h" |
22 #include "base/metrics/histogram.h" | 21 #include "base/metrics/histogram.h" |
23 #include "base/synchronization/lock.h" | 22 #include "base/synchronization/lock.h" |
24 #import "chrome/common/mac/objc_method_swizzle.h" | 23 #import "chrome/common/mac/objc_method_swizzle.h" |
25 | 24 |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 *record = g_zombies[i]; | 245 *record = g_zombies[i]; |
247 return YES; | 246 return YES; |
248 } | 247 } |
249 } | 248 } |
250 return NO; | 249 return NO; |
251 } | 250 } |
252 | 251 |
253 // Dump the symbols. This is pulled out into a function to make it | 252 // Dump the symbols. This is pulled out into a function to make it |
254 // easy to use DCHECK to dump only in debug builds. | 253 // easy to use DCHECK to dump only in debug builds. |
255 BOOL DumpDeallocTrace(const void* const* array, int size) { | 254 BOOL DumpDeallocTrace(const void* const* array, int size) { |
256 // |cerr| because that's where PrintBacktrace() sends output. | 255 // |cerr| because that's where PrintBacktrace() sends output. |
Nico
2012/07/29 05:50:32
I deleted this comment. It's not true (anymore?),
| |
257 std::cerr << "Backtrace from -dealloc:\n"; | 256 fprintf(stderr, "Backtrace from -dealloc:\n"); |
258 base::debug::StackTrace(array, size).PrintBacktrace(); | 257 base::debug::StackTrace(array, size).PrintBacktrace(); |
259 | 258 |
260 return YES; | 259 return YES; |
261 } | 260 } |
262 | 261 |
263 // Log a message to a freed object. |wasa| is the object's original | 262 // Log a message to a freed object. |wasa| is the object's original |
264 // class. |aSelector| is the selector which the calling code was | 263 // class. |aSelector| is the selector which the calling code was |
265 // attempting to send. |viaSelector| is the selector of the | 264 // attempting to send. |viaSelector| is the selector of the |
266 // dispatch-related method which is being invoked to send |aSelector| | 265 // dispatch-related method which is being invoked to send |aSelector| |
267 // (for instance, -respondsToSelector:). | 266 // (for instance, -respondsToSelector:). |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
546 if (oldZombies) { | 545 if (oldZombies) { |
547 for (size_t i = 0; i < oldCount; ++i) { | 546 for (size_t i = 0; i < oldCount; ++i) { |
548 if (oldZombies[i].object) | 547 if (oldZombies[i].object) |
549 object_dispose(oldZombies[i].object); | 548 object_dispose(oldZombies[i].object); |
550 } | 549 } |
551 free(oldZombies); | 550 free(oldZombies); |
552 } | 551 } |
553 } | 552 } |
554 | 553 |
555 } // namespace ObjcEvilDoers | 554 } // namespace ObjcEvilDoers |
OLD | NEW |