Tools and Process
What Is Debugging?
Debugging is the process of finding the cause of a bug, an error or unexpected behaviour in a program, and fixing it.
Definition
Debugging means finding out why a program does not do what it should, and fixing the cause. A bug can crash the program, give a wrong result or fail only for certain inputs.
Engineers called faults "bugs" long before computers. A well-known 1947 log entry from the Harvard Mark II team records a real moth found stuck in a relay.
How it works
A reliable routine: reproduce the bug, read the error message and stack trace, guess the cause, test the guess with print statements or a debugger, fix it, then run again to confirm.
A debugger lets you pause the program at a breakpoint, step through it line by line and inspect variables while it runs.