On Apr 20, 2009, at 23:09 , Alex Kac wrote:

I am trying to log some specific error conditions in a fairly dynamic environment (of course Obj-C's forté), and would like to log some sort of backtrace of method calls that reached a specific method.

What is the best way to get that info? This is using Objective-C 2.0 on the iPhone.

One alternative to stack-munging would be for all your methods to set up logging information in a temporary buffer, which is then output from your specific method and otherwise flushed or ignored.

For example:

#define  MAXCALLINFO  200
char *call_info[MAXCALLINFO+10];
int curCallInfo=0;

#define ENTER call_info[ MAX(MIN( curCallInfo++, MAXCALLINFO),0) ] = __PRETTY_FUNCTION__
#define LEAVE      curCallInfo--



Pros: Should always work, independent of code generation, symbol availability etc.
Cons:   Potentially a lot of work.

Marcel





_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to