Debugging

Learning Objectives

(See p. 79) Be able to:

Notes

Understanding Computer Errors

(p. 156) Computers do what we say, not what we mean.

(p 157–160) Pay attention to feedback from the system

Possible sources of errors that occur when we use software (developed by competent programmers):

  1. Wrong data input
  2. Wrong command input
  3. “Broken system” i.e., error in the software

Of these, #1 and 2 are our responsibility and the most common.

Six-Step Strategy for Debugging

(p. 160)

  1. Try to reproduce the error.
  2. Be sure you know exactly what the problem is.
  3. Eliminate obvious causes.
  4. Divide parts that work from parts that do not.
  5. If you reach a dead end, reassess your assumptions and inferences; back up.
  6. Make predictions; test them.

Not guaranteed to work, but a useful framework.

Applications of the Strategy

(pp. 164–175) Debugging a web page:

What steps didn’t seem to fit in the framework?

(pp. 175–178) Debugging a printing problem; discovering the print queue.

Software Reliability

It is hard to make software completely correct. It is impossible to make complex software correct. Much of the software we use today is incredibly complex.

[Why is it complex? Remember in Principles of Computer Operation we stepped through a program that added 5 numbers, using a counter, comparing it to a limit, and branching back to a certain instruction if the counter is not over the limit? It’s these conditional branches that are the culprit. Consider a series of branches:

Nobody can test this many situations.]

Careful testing helps, but does not eliminate bugs. Why?

Can we prove, mathematically, that the software meets the specification — does what it’s supposed to do?

Examples of really, really bad software errors:

More

(Not in the textbook)

Summary

Resources