Is there any hook to access the names of the functions being called at runtime?

Discussion in 'Mac Programming' started by thelonelysaint, Jul 29, 2010.

  1. thelonelysaint macrumors newbie

    Joined:
    Jul 29, 2010
    #1
    Is there any hook to access the names of the functions being called at runtime in Xcode?

    I'm just trying to log the names of all the functions that are called during the lifetime of the process. I have the necessary symbols for the application.

    I can do it easily in Visual Studio using _penter() and _pexit() functions. But can't find a way to do it on Xcode.

    It's a C++ project btw.

    I'm using Xcode 3.1.2 on 10.5.8.

    Any help is appreciated.

    Thanks.
     
  2. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
  3. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #3
    'man g++' provides '−finstrument−functions'

    Generate instrumentation calls for entry and exit to functions. Just after function entry and just before function exit, the following profiling functions will be called with the address of the current function and its call site. (On some platforms, __builtin_return_address does not work beyond the current function, so the call site information may not be available to the profiling functions otherwise.)
    void __cyg_profile_func_enter (void *this_fn, void *call_site);
    void __cyg_profile_func_exit (void *this_fn, void *call_site);

    And the g++ macro '__PRETTY_FUNCTION__' expands to the name of the current function.
     
  4. Detrius macrumors 68000

    Joined:
    Sep 10, 2008
    Location:
    Asheville, NC
    #4
    Last I checked, Shark samples at regular intervals, so there's the possibility a very short function could be missed, but, I concur that whatever the reasons are for needing this info, Shark probably gives you everything you actually need.
     

Share This Page