Noeud:An example debugging session using gdb, Noeud « Next »:, Noeud « Previous »:How to Use a Debugger, Noeud « Up »:Debugging with gdb and DDD



An example debugging session using gdb

The program was compiled with the '-g' flag set, so you can run it under control of the debugger. The easiest way to do this is to start the debugger with the name of the program as an argument. I will be describing 'gdb', the GNU debugger, so for the example program you would use gdb ecount1.

This makes the debugger start up, load the executable and all of it's source code and variable names into memory, then wait for your command. At this point the program is not yet running, but the debugger knows everything it needs to know about it.

     bash$ gdb ecount1
     GNU gdb 5.0
     Copyright 2000 Free Software Foundation, Inc.
     GDB is free software, covered by the GNU General Public License, and you are
     welcome to change it and/or distribute copies of it under certain conditions.
     Type "show copying" to see the conditions.
     There is absolutely no warranty for GDB.  Type "show warranty" for details.
     This GDB was configured as "i386-slackware-linux"...
     (gdb)
     

gdb is now ready to run the program.