Re: -[_NSZombie methodSignatureForSelector:] not working
Re: -[_NSZombie methodSignatureForSelector:] not working
- Subject: Re: -[_NSZombie methodSignatureForSelector:] not working
- From: Chris Kane <email@hidden>
- Date: Thu, 30 Oct 2008 10:41:18 -0700
As long as you don't foolishly have a signal handler for SIGTRAP setup
to ignore it, the zombie mechanism causes its own debugger trap for
you in 10.5 and later. For stopping in the debugger purposes, no
breakpoint is needed. If you have a SIGTRAP handler, it will get
called instead of a debugger trap, and you can break on your handler.
#import <Foundation/Foundation.h>
int main( int argc, char **argv ) {
id dead = [NSObject new];
[dead release];
[dead self];
return 0;
}
% cc test.m -framework Foundation -o dead
% ./dead
objc[12320]: FREED(id): message self sent to freed object=0xc04850
zsh: illegal hardware instruction dead
%
% NSZombieEnabled=YES ./dead
2008-10-30 10:39:35.736 dead[12323:10b] *** -[NSObject self]: message
sent to deallocated instance 0xc048b0
zsh: trace trap NSZombieEnabled=YES dead
Chris Kane
Cocoa Frameworks, Apple
On Oct 30, 2008, at 10:03, Michael Ash wrote:
The famous TN2124
(http://developer.apple.com/technotes/tn2004/tn2124.html) has this to
say about debugging using zombies:
"You can use GDB to set a breakpoint on -[_NSZombie
methodSignatureForSelector:] to further debug this sort of problem."
However this does not appear to work. GDB cannot resolve this
breakpoint, and indeed the _NSZombie class no longer appears to exist
on 10.5.5 (and presumably all of 10.5). This test program illustrates:
#import <Foundation/Foundation.h>
int main( int argc, char **argv )
{
[NSAutoreleasePool new];
id obj = [[NSObject alloc] init];
[obj release];
NSLog(@"Class of released object is %@, _NSZombie is %@",
NSStringFromClass(obj->isa), NSClassFromString(@"_NSZombie"));
return 0;
}
This is the output I get on my machine when the above is run with
NSZombieEnabled=YES:
2008-10-30 12:54:42.810 a.out[28706:10b] Class of released object is
_NSZombie_NSObject, _NSZombie is (null)
So it would appear that NSZombieEnabled has gone to creating dynamic
zombie classes rather than simply using a single _NSZombie class as in
days past. Which is fine. Except that I no longer know where to set my
breakpoint. Am I doing something wrong, or what's the substitute for
-[_NSZombie methodSignatureForSelector:]?
Mike
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden