Re: Get the name of the method that called a method
Re: Get the name of the method that called a method
- Subject: Re: Get the name of the method that called a method
- From: Marcel Weiher <email@hidden>
- Date: Tue, 21 Apr 2009 09:02:55 -0700
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 (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