code profiling

Discussion in 'Mac Programming' started by Zortrium, Dec 2, 2008.

  1. Zortrium macrumors 6502

    Joined:
    Jun 23, 2003
    #1
    I'm trying to get gprof working and am having absolutely no luck in getting a gmon.out file to be generated - I compile my program with the -pg flag, then execute it, but nothing gets generated. The flag is doing SOMETHING, since the size of the binary increases very slightly when I compile with -pg versus without, but it's definitely not creating any file - I've made sure permissions are set correctly, looked around in all possible directories. The exact same series of steps correctly creates the gmon.out file on a FreeBSD machine I tried it on, so I have absolutely no idea why it seems to do nothing on my Mac. Any ideas?

    EDIT: I tried it on another Mac (almost the exact same system as mine, both C2D iMacs with Leopard) and it works...which is even weirder. I've tried both gcc 4.0 and 4.2 on my machine and neither works.
     
  2. Catfish_Man macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #2
    Not sure on the answer to the question, but have you considered using Shark rather than gprof?
     
  3. szymczyk macrumors regular

    Joined:
    Mar 5, 2006
    #3
    gprof doesn't work on Intel Macs. Your alternatives are to use Shark, Instruments, or Saturn. If you use Saturn you have to build your program using the compiler flag -finstrument-functions and the linker flag -lSaturn.
     

Share This Page