Setting up gdb in Fedora

gdb installation

gdb comes with the standard g++ install. However, many of the debugging symbols do not. Run gdb on one of your executables. Tell it to "start" and it will check to see if system debugging symbols are available. If they are not, it will tell you what command you need to execute to install the debugging symbols. On my Fedora install gdb gave this instruction (some output removed for clarity):

$ gdb graphlib_test
GNU gdb (GDB) Fedora (7.4.50.20120120-54.fc17)
Reading symbols from graphlib_test...(no debugging symbols found)...done.
(gdb) start
Temporary breakpoint 1 at 0x40522c
Missing separate debuginfos, use: debuginfo-install glibc-2.15-58.fc17.x86_64 libgcc-4.7.2-2.fc17.x86_64 libstdc++-4.7.2-2.fc17.x86_64
(gdb)

Run that command as root to install the debugging packages:

  $ sudo debuginfo-install glibc-2.15-58.fc17.x86_64 libgcc-4.7.2-2.fc17.x86_64 libstdc++-4.7.2-2.fc17.x86_64

You can verify the system debug symbol installation was completed by running gdb again. When you type "start" this time it should not complain about missing system symbols.

Compiling with debug symbols

Now that we have the system debug symbols installed, we need to get debugging symbols for our program. That's as simple as adding '-g' to the g++ command line.



  $ g++ -Wall -Werror -g graphlibd.o graphlib_test.c++ -o graphlib_test

Now when you run gdb on your executable it should be able to show you all of the symbolic information:

  $ gdb graphlib_test
  GNU gdb (GDB) Fedora (7.4.50.20120120-54.fc17)
  Reading symbols from graphlib_test...done.
  (gdb) start
  Temporary breakpoint 1 at 0x405241: file graphlib_test.c++, line 13.
  Starting program: graphlib_test 
  13  int i = 0;
  (gdb) n
  15  Graph g;
  (gdb) n
  17  assert( g.edgeCount() == 0, "edge count fail" );
  (gdb) n
  18  assert( g.vertexCount() == 0, "vertex count fail" );
  (gdb) 


Comments

Popular posts from this blog

Patching VMware Tools in Fedora 18

Programming language notes, links

Acronyms