• 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: Discovering where a method was called from within the method
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Discovering where a method was called from within the method


  • Subject: Re: Discovering where a method was called from within the method
  • From: Nicko van Someren <email@hidden>
  • Date: Thu, 20 Apr 2006 16:00:34 +0100

On 20 Apr 2006, at 09:34, Philip Dow wrote:

I imagine something like this has been addressed before, but I don't know what to search for as I'm not sure what this is called. Maybe a stack trace? The scenario is as follows:

I am changing a custom object's variable from an NSData object to an NSAttributedString object. I have accessors and setters for both. Everywhere else in the program, I need to update the code to access the new attributed string methods rather than those for the data object.

Because I can convert an attributed string to rtfd data, I can still call the methods that had been using the data object and just convert from the string on the fly. This makes it possible to update my code slowly and carefully. However, I need to know when the data accessors and setters are being called. Knowing where they are used, I can eventually fade them out completely.

Is it possible from within those methods find out what other objects and methods are calling them? I need something similar to a crash report.

Yes, it is. GCC has an extension built in function called __builtin_return_address (see [1] for details). You could add some code to your application which called this accumulated each time your method was called and stuffed the value into a set and have some debug trigger which would dump out the values in the set. Run the application for a while until you think that most paths through your code have been exercised and then extract the list of addresses. You can then use the debugger to visit each address and find out in what function that address sits (the alternative would be to try to parse the debug symbol yourself, but that seems like hard work).


I hope this helps,

	Nicko

[1] http://developer.apple.com/documentation/DeveloperTools/gcc-4.0.1/ gcc/Return-Address.html


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Discovering where a method was called from within the method (From: Philip Dow <email@hidden>)

  • Prev by Date: RE: Simple Open Window Close Window
  • Next by Date: Simple Open Window Close Window
  • Previous by thread: Re: Discovering where a method was called from within the method
  • Next by thread: Creating custom core image transitions for Keynote
  • Index(es):
    • Date
    • Thread