How to examine a core file generated when program is running under valgrind
<p>I have a program <code>myprog</code> which I have been running under valgrind:</p>

<pre><code>/usr/bin/valgrind --tool=massif --tool=memcheck --leak-check=yes --track-origins=yes --log-file=/tmp/valgrind%p /opt/bin/myprog
</code></pre>

<p>I'm not exactly sure of the details of how valgrind works under the covers, but when run in this manner I see that <code>valgrind</code> has a pid, but <code>myprog</code> does not.  Thus I assume valgrind runs <code>myprog</code> in the same process space and uses some magic to load the target program.</p>

<p><code>myprog</code> appears to have hit an <code>assert()</code> and a corefile has been generated.  I would like to examine this corefile using GDB so I can dig into the cause of the <code>assert()</code>.  I'm trying to figure out how to load symbols from myprog necessary to use GDB.</p>

<p>If I use <code>file valgrind</code>, then this just loads valgrind symbols and nothing from <code>myprog</code></p>

<p>If I use <code>file myprog</code>, then the corefile (generated by valgrind) won't match the executable (myprog).</p>

<p>Is there some way I can tell GDB that even though the "host" process here is <code>valgrind</code>, that we also want to load the <code>myprog</code> symbols, as this is the program we are actually interested in?</p>

<p>Looking through the <a href="http://ftp.gnu.org/old-gnu/Manuals/gdb/html_chapter/gdb_14.html" rel="nofollow noreferrer">GDB documentation</a>, I'm guessing that I'd need something like <code>add-symbol-file filename address</code>, but I'm not sure how to figure out what the address would be.</p>