Build & Tooling

debugger

A debugger is a tool that freezes your running program mid-stride so you can look inside it. Instead of guessing why something went wrong, you pause the code at a chosen line, then walk it forward one step at a time — watching exactly what each variable holds at each moment. It answers the real question: not 'what broke' but 'WHY'.

The trick is the breakpoint — a marker you drop on a line that says 'stop here'. When the program reaches it, everything halts and hands you the controls. You can peek at every value, step into a function to follow it deeper, or let it run on to the next breakpoint. It's like pausing a movie frame by frame to catch the exact moment a trick was done.

Before debuggers, people scattered print statements everywhere to spy on their code — and many still do for quick checks. A debugger is the grown-up version: no editing your code, no rerunning a dozen times. You stop time, look around, and the bug usually gives itself away.

function total(cart) {
  let sum = 0;
  for (const item of cart) {
    debugger;   // ← execution pauses here; inspect 'item' and 'sum'
    sum += item.price;
  }
  return sum;
}

Hit the breakpoint, then step the loop and watch 'sum' climb — or fail to.

If a program exits with a non-zero exit code and you can't see why, running it under a debugger is often the fastest way to catch the moment it goes wrong.

Also called
breakpointstep debuggergdbstep through