Definition
Debugging is the systematic process of locating, understanding, and correcting defects in software. It begins with a discrepancy between observed and expected behavior, proceeds through a sequence of hypotheses about which part of the system is responsible, and ends only when the corrected program produces the expected result reliably. The defining feature is that debugging is investigative rather than constructive — the code already exists; the problem is to understand why it behaves the way it does.
A debugger is the tool most associated with the practice, but debugging is broader: reading log output, inserting print statements, writing a failing test, bisecting a version-control history, examining a memory dump, or simply re-reading code carefully are all debugging techniques. The discipline is one of patient observation and falsifiable hypotheses, not random tinkering.
Why it matters
How it works
The disciplined loop has four steps. First, reproduce the bug reliably — find the smallest input or sequence of actions that triggers the wrong behavior every time. Second, isolate the failure to a specific subsystem by narrowing the suspect surface: comment out half the pipeline, disable a feature flag, run on a clean dataset, bisect commits since the last known-good version. Third, form a hypothesis about the cause that is specific enough to falsify with one experiment. Fourth, test the hypothesis — by reading code, inspecting state in a debugger, adding logging, or writing a unit test — and either confirm and fix, or discard and form a new hypothesis.
Tools matter but technique matters more. A debugger lets you set breakpoints, step line by line, and inspect variables; logging gives you a postmortem record of what happened in production where a debugger cannot reach; git bisect automates binary search across history; tracing tools surface latency outliers and rare error paths. The best debuggers — the people — learn to read code as if it were evidence, treat every assumption as suspect, and never stop investigating until they can explain not just what fixed it but why the original code was wrong.