Debugging:Hints,tricks and tools

You've written the program and it doesn't work.

Check out the list of common programming errors

Print

Use print statements to follow program executation and to examine variables. This is the easiest and most popular tool for debugging. However, it does require recompiling every time you want to change something. Additionally, printing inside a loop can generate many screens of output.

Debuggers

The "standard" unix debugger is called dbx. However, the commands and usage vary from vendor to vendor. Also, many vendors have a graphical debugging and performance system. The GNU debugger is called gdb

Debuggers are especially useful for tracing segmentation faults and bus errors. They will pinpoint exactly where the program has stopped.

One can run the program under the debugger, or use the debugger to examine a core file after a program has crashed.

Miscellanous

Sometimes useful is a compiler switch to turn on checking of array bounds (overwriting array bounds is a very common source/symptom of trouble)


Back to Computer Information