Mailing Lists: Apple Mailing Lists

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

Re: printing a stack trace to the console



Read the headers for the ExceptionHandling.framework.
It's really easy to grab out backtraces on exceptions using this
framework.

j o a r

On 2004-03-31, at 10.44, Jonathan Sand wrote:

> 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.

[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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.


References: 
 >printing a stack trace to the console (From: Jonathan Sand <email@hidden>)



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.