User Tools

Site Tools


user:mgardne8:portfolio:debug

Table of Contents

Debugging with GDB

de·bug

/dēˈbəɡ/

verb identify and remove errors from (a computer program). [(http://dictionary.reference.com/browse/debug?s=t)]

Ouch!

GDB, the GNU Project debugger, allows you to see what is going on `inside' another program while it executes – or what another program was doing at the moment it crashed.[(http://www.gnu.org/software/gdb/)]

GDB can do four main kinds of things (plus other things in support of these) to help you catch bugs in the act:

  1. Start your program, specifying anything that might affect its behavior.
  2. Make your program stop on specified conditions.
  3. Examine what has happened, when your program has stopped.
  4. Change things in your program, so you can experiment with correcting the effects of one bug and go on to learn about another.

Debugging is something that can't be avoided. Every programmer will at one point in their programming career have to debug a section of code. There are many ways to go about debugging, from printing out messages to the screen, using a debugger, or just thinking about what the program is doing and making an educated guess as to what the problem is.

Before a bug can be fixed, the source of the bug must be located. For example, with segmentation faults, it is useful to know on which line of code the seg fault is occuring. Once the line of code in question has been found, it is useful to know about the values in that method, who called the method, and why (specifically) the error is occuring. Using a debugger makes finding all of this information very simple.[(http://www.cs.cmu.edu/~gilpin/tutorial/)]

2

a

b

3

a

b

4

~~REFNOTES~~

user/mgardne8/portfolio/debug.txt · Last modified: 2014/10/07 09:01 by mgardne8