title: How to print call stack in C/C++ more beautifully?
body: <p>I would like to print call stack with more information like in gdb.</p>
  
  <p>This is what I have so far.</p>
  
  <pre><code>void to_print_callstack()
  {
      void *buffer[100];
      int n = backtrace(buffer,10);
      char **str = backtrace_symbols(buffer, n);
  
      for (int i = 0; i &lt; n; i++)
      {
          printf("%d:  %s\n", i, str[i]);
      }
  }
  </code></pre>
  
  <p>When it runs, I get something as below.</p>
  
  <pre><code>0:  ./test-prog() [0x4466bf]
  1:  ./test-prog() [0x445e1d]
  2:  ./test-prog() [0x443fd5]
  3:  ./test-prog() [0x439a99]
  4:  ./test-prog() [0x43302f]
  5:  ./test-prog() [0x4322c9]
  6:  ./test-prog() [0x4320cd]
  7:  ./test-prog() [0x43e76b]
  8:  /lib/libc.so.6(__libc_start_main+0xfd) [0x7fc4de7d8c4d]
  9:  ./test-prog() [0x431569]
  </code></pre>
  
  <p>It is hard to read. With function names, it would be much better.
  Thanks a lot for the tip.</p>