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