title: Why doesn't GDB show line numbers or function names?
body: <p>I was trying to use GDB to troubleshoot a segfault in code I'm writing.  GDB does not show line numbers or function names when I use the <code>backtrace</code> command.  Here's a short sample program that illustrates my problem:</p>
  
  <pre><code>void segfault(int *b) {
      // This causes a segfault on CentOS7 Intel 64-bit
      b[-1] = 5;
  }
  
  void main() {
      int a[10];
      segfault(a);
  }
  </code></pre>
  
  <p>However when I compile with</p>
  
  <pre><code>gcc -ggdb -O0 test.c -o segfaulttest
  </code></pre>
  
  <p>And use <code>gdb segfaulttest</code> to run it, when I use gdb's backtrace command I don't get any line numbers or function names.  I would expect it to list <code>main()</code> and <code>segfault()</code> in the trace.</p>
  
  <p>Sample output</p>
  
  <pre><code>Reading symbols from /home/user/test/segfaulttest...done.
  (gdb) run
  Starting program: /home/user/test/segfaulttest 
  
  Program received signal SIGSEGV, Segmentation fault.
  0x000000050040051c in ?? ()
  (gdb) bt
  #0  0x000000050040051c in ?? ()
  #1  0x0000000000000000 in ?? ()
  (gdb) 
  </code></pre>
  
  <p>I'm using:</p>
  
  <ul>
  <li>CentOS 7 (64 bit)</li>
  <li>GCC: <code>gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4)</code></li>
  <li>GDB is <code>gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4)</code></li>
  </ul>
  
  <p>(Aside: I fixed the actual bug in my code, I just don't understand why gdb backtrace doesn't show me more information).</p>