Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gprof not showing call graph

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.

like image 291
postelrich Avatar asked Oct 05 '22 04:10

postelrich


1 Answers

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.

like image 192
Alex S Avatar answered Oct 10 '22 03:10

Alex S