Thread: Profiling with GPROF

  1. #1
    char main() RoshanX's Avatar
    Join Date
    Mar 2003
    Posts
    68

    Profiling with GPROF

    hi all,

    I am trying to instrument a DLL, which will be loaded by a third party program.
    So I compiled and linked the DLL with -pg flag. But when I ran the program, the profile data does not get generated ( the gmon file does not get created ).

    Is it not possible to profile a dll like this ?

    Thank you.
    First there was God. He was quite lonely, so he created Dennis.
    Dennis was unimpressed with God.
    So, . . . God created Brian..........Khan Klatt
    http://www.clifford.at/fun/GOD

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    I have not used gprof but there are 2 possible reasons (from general point of view)
    1. You may need recompile also the calling exe the same way
    2. You may need to specify module of interest for the gmon before you start the application
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    I have used gprof . . .
    I have not used gprof but there are 2 possible reasons (from general point of view)
    1. You may need recompile also the calling exe the same way
    Yes, I think you need to, though I've never tried profiling DLLs either.
    2. You may need to specify module of interest for the gmon before you start the application
    No, you don't need to do this. Once a program is compiled with -pg, when run it generates the GPROF file. This can then be parsed with
    Code:
    $ gprof gmon.out
    into stdout.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can gprof go into each self-defined function?
    By lehe in forum C Programming
    Replies: 3
    Last Post: 03-26-2009, 10:30 PM
  2. Question about Gprof
    By PetrolMan in forum C++ Programming
    Replies: 1
    Last Post: 03-23-2009, 10:18 AM
  3. Profiling for c code in eclipse
    By hai12345 in forum C Programming
    Replies: 2
    Last Post: 10-10-2008, 04:46 PM
  4. Gprof under windows
    By Kempelen in forum C Programming
    Replies: 7
    Last Post: 05-23-2008, 05:49 PM
  5. I can't get profiling to work with Visual Studio 6
    By Darkness in forum C++ Programming
    Replies: 7
    Last Post: 12-30-2004, 10:37 PM