Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

printing a stack trace to the console



Does anyone know the magic incantation to create a string of a stack
trace? I'd like to "instrument" my code to print a stack trace to the
console at a particular point in my code. I want to who is calling it
-- there are an ungodly number of suspects. Gdb isn't a good candidate
because I need to send this code to a client, upon whom I'd prefer not
to foist gdb's learning curve.

I've looked into "defaults write NSGlobalDomain NSExceptionHandlingMask
63" but defaults apparently doesn't work quite that way anymore. If it
did, I could write the following objective-C method:

- (void)printStackTrace {
NS_DURING
[NSException raise:0 format:@"stack trace requested!"];
NS_HANDLER
NSLog(@"%@", [localException userInfo]);
NS_ENDHANDLER
}

This would be a rather nifty thing -- if the defaults exception
handling mask could be set, says the Apple Developer documentation, the
userInfo would contain a stack trace.

Jonathan Sand
(: enlightenment would be nice :)
email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.