• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Get the name of the method that called a method
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Get the name of the method that called a method (From: Alex Kac <email@hidden>)

  • Prev by Date: Re: Get the name of the method that called a method
  • Next by Date: Re: Get the name of the method that called a method
  • Previous by thread: Re: Get the name of the method that called a method
  • Next by thread: How to play a sound file by Double-click in a tableview?
  • Index(es):
    • Date
    • Thread