I am trying to view the annotated source using $ valgrind --tool=callgrind ./myProgram
followed by $ kcachegrind
using Ubuntu 12.04 (and I'm having the same problem with $ qcachegrind
using Mac OSX).
The C++ script myProgram.cpp
makes calls to functions that live in a .hpp
file (via #include "../include/myHeader.hpp"
, etc.). I compile myProgram.cpp
like this:
g++ -g -o myProgram myProgram.o -l<some third party lib>
where I don't care about viewing annotated source for that third party lib.
What I would like to see is annotated source for the functions in myHeader.hpp
and for myProgram.cpp
.
Instead, I see kcachegrind's Flat Profile window with a list of all the functions that get called, including the functions in myHeader.hpp
- this is great. Now, kcachegrind reports the location of functions from myHeader.hpp
as being from myProgram
- this is odd. And finally, when I select any function from the Flat Profile window and request to see Source Code, I am met with:
There is no source available for the following function
<name of the selected function>
This is because no debug information is present.
Recompile the source and redo the profile run.
The function is located in the ELF object:
<some location...>
What I've tried:
added the directory holding
myHeader.hpp
to the Annotations list using kcachegrind's GUI.compiled using -O0 to remove compiler optimizations
<some function>
at<some location>
. – Barefoot