UMBC CMSC 201 Fall '05
CSEE | 201 | 201 F'05 | lectures | news | help

Debugging Techniques

If debugging is the process of removing bugs,
then programming must be the process of putting them in...


We've talked about a little already about how to use printf() statements to debug your programs, and by now all of you realize that it usually takes more time to debug a program than it does to write it.

The good news is, as you gain more experience you'll make fewer logic and syntax errors. You'll also get better at debugging your own code.

The bad news is, it's going to take a lot of experience.

Today we're going to discuss some basic debugging techniques, including the use of a symbolic debugger to help you find and fix errors in your code.

Basic steps to debugging

The basic steps in debugging are the same for debugging computer programs, hardware, social systems, etc.:

Compile time vs. runtime

Compile time errors

The compiler identifies several kinds of errors:

Linker errors

Linker errors tend to be simple and are usually caused be forgetting to include an object file or failing to define a function in one of them.

% gcc -Wall -ansi proj3.o students.o 
proj3.o: In function `main':
proj3.o(.text+0x121): undefined reference to `CalculateStats'
collect2: ld returned 1 exit status

Runtime errors

CSEE | 201 | 201 F'05 | lectures | news | help

Monday, 14-Nov-2005 11:30:45 EST