I am running my program with the -pg option. When I open the output gmon.out it only cumulative list and not call graphs. How do I fix that?
I know this was asked before here: gprof - File is missing call-graph data But no one actually answered the question, only gave suggestions for alternatives to gprof.
I, too, had a disappointing experience looking for answers.
Specifically: The following helped for me (up-to-date Ubuntu May 2013). Try both -fno-reorder-functions
and -fno-inline
. For example, under cmake, this worked:
if(CMAKE_COMPILER_IS_GNUCXX)
add_definitions(${CMAKE_CXX_FLAGS} "-Ofast")
add_definitions(${CMAKE_CXX_FLAGS} "-fno-reorder-functions")
add_definitions(${CMAKE_CXX_FLAGS} "-fno-inline")
endif()
Generally: Try looking at the compiler optimization docs. Find an optimization level that works, and then add all the listed options for the next level. Try adding and removing with, say, bisection. Again, in cmake something like:
add_definitions(${CMAKE_CXX_FLAGS} "-O1")
add_definitions(${CMAKE_CXX_FLAGS} "-fthread-jumps")
add_definitions(${CMAKE_CXX_FLAGS} "-falign-functions -falign-jumps")
add_definitions(${CMAKE_CXX_FLAGS} "-falign-loops -falign-labels")
# add_definitions(${CMAKE_CXX_FLAGS} "-fcaller-saves")
# add_definitions(${CMAKE_CXX_FLAGS} "-fcrossjumping")
# add_definitions(${CMAKE_CXX_FLAGS} "-fcse-follow-jumps -fcse-skip-blocks")
# add_definitions(${CMAKE_CXX_FLAGS} "-fdelete-null-pointer-checks")
It may well be that one or two optimization options are causing all the problems.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With