title: How to use debug version of libc
body: <p><strong>Short version of question:</strong>
  How can I get gdb to use the debugging symbols for <code>libc</code>?</p>
  <p><strong>Longer version:</strong>
  I am debugging a program with gdb and I want to see information about a futex used by <code>libc</code>. However, at some point during debugging I get output such as:</p>
  <pre><code>Catchpoint 2 (call to syscall futex), 0x00007ffff772b73e in ?? () from /lib/libc.so.6
  (gdb) bt
  #0  0x00007ffff772b73e in ?? () from /lib/libc.so.6
  #1  0x00007ffff767fb90 in ?? () from /lib/libc.so.6
  #2  0x00007ffff767a4c0 in vfprintf () from /lib/libc.so.6
  #3  0x00007ffff768565a in printf () from /lib/libc.so.6
  ....
  </code></pre>
  <p>When I run <code>info sharedlibrary</code> in gdb at the breakpoint I see:</p>
  <pre><code>(gdb) info sharedlibrary
  From                To                  Syms Read   Shared Object Library
  0x00007ffff7dddaf0  0x00007ffff7df6704  Yes (*)     /lib64/ld-linux-x86-64.so.2
  0x00007ffff7bc53e0  0x00007ffff7bd1388  Yes (*)     /lib/libpthread.so.0
  0x00007ffff79ba190  0x00007ffff79bd7d8  Yes (*)     /lib/librt.so.1
  0x00007ffff76538c0  0x00007ffff7766c60  Yes (*)     /lib/libc.so.6
  0x00007ffff6c1fd80  0x00007ffff6c303c8  Yes (*)     /lib/libgcc_s.so.1
  (*): Shared library is missing debugging information.
  </code></pre>
  <p>And when I run <code>ldd</code> I see:</p>
  <pre><code>linux-vdso.so.1 =&gt;  (0x00007ffff7fde000)
  libpthread.so.0 =&gt; /lib/libpthread.so.0 (0x00007ffff7dbf000)
  librt.so.1 =&gt; /lib/librt.so.1 (0x00007ffff7bb6000)
  libc.so.6 =&gt; /lib/libc.so.6 (0x00007ffff7833000)
  /lib64/ld-linux-x86-64.so.2 (0x00007ffff7fdf000)
  </code></pre>
  <p>I am using Ubuntu 10.04 and I think that the version of <code>libc</code> with debug symbols is in <code>/usr/lib/debug/lib</code>.  I tried setting my <code>LD_LIBRARY_PATH</code> variable to have this at the front of the path but that did not seem to make a difference.</p>
  <p>I'm not completely clear on how the program chooses which shared libraries to load, whether this is set at runtime or compile time (I sort of assumed runtime but now I'm not sure).  So information on how to get gdb to use the debug version of <code>libc</code> is appreciated.</p>