Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm trying to profile a C++ application with gprof on a machine running OSX 10.5.7. I compile with g++ in the usual way, but using -pg flags, run the application and try to view the call graph with gprof.

Unfortunately my call graph contains all zeroes for all time columns. The values in the "called" columns have reasonable values so it looks like something was profiled but I'm mystified about the lack of other data.

All my source files are compiled in a similar way:

g++ -pg -O2 -DNDEBUG -I./ -ansi -c -o  ScenarioLoader.o ScenarioLoader.cpp

I then run 'ar' to bundle all the object files into a library. Later, I link and run gprof as so:

g++ -pg -lm  -o vrpalone vrpalone.o ../src/atomicprof.a lastbuild.o
./vrpalone
gprof gmon.out | less

Any ideas?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
549 views
Welcome To Ask or Share your Answers For Others

1 Answer

If your program terminates in a non-clean manner then the profile data won't get written correctly - how is your program exiting?

Regardless, I'd strongly recommend using Shark instead of gprof - it's very easy to use and superior in pretty much every way to gprof - and doesn't require you to recompile your program.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...