7.5 — Using a debugger

📘 Chapter 7⏱ about 1 min read✍️ Beginner friendly
Read one box at a time. No rush.

What is a debugger?#

A debugger lets you pause your program and look inside it while it runs. It's like a slow-motion replay.

Every IDE has one: Visual Studio, VS Code, CLion, Xcode.

Breakpoints#

A breakpoint is a stop sign on a line. Click in the margin next to a line number (a red dot appears). Then start with debugging (F5 in most IDEs).

The program runs until it reaches that line, then pauses.

Stepping#

While paused, you can move one line at a time:

ActionUsual keyWhat it does
Step overF10Run this line, go to the next one.
Step intoF11If this line calls a function, go inside it.
Step outShift + F11Finish this function, go back to the caller.
ContinueF5Run until the next breakpoint.

Watching values#

While paused, hover your mouse over a variable to see its value. Or use the Watch / Locals window to see all of them at once.

Key idea

The debugger shows you what your program is actually doing, not what you think it's doing. That gap is where the bug lives.

Finished reading? Tick it off. Your progress is saved in this browser.

Tip: press ← / → to move between lessons, / to search.