Both advance execution by one source line, but they differ on function calls. next (n) executes the current line and, if it contains a function call, runs that entire call to completion and stops at the next line in the current function, it "steps over" the call, treating it as a single step. step (s) executes the current line but, if it contains a function call, descends into that function and stops at its first line, it "steps into" the call. You use next when you trust a called function and just want to proceed in the current function, and step when you want to investigate inside the call. The classic time-waster is accidentally stepping into a library or runtime function (like a printf or a memcpy) and getting lost deep in code you don't care about, the recovery is finish (run until the current function returns) to climb back out, or you simply use next by default and only step when you intend to descend. There's also stepi/nexti for instruction-level granularity (useful in optimized or assembly debugging) and finish to run out of the current frame. So the mnemonic is next = over, step = into, and defaulting to next avoids the descend-into-libraries trap.
Debugging & Toolchain · Interview question
What's the difference between next and step in GDB?
A strong answer
What a weak answer sounds like
You know the answer. Do you know what gets you dinged?
Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.
From the lesson
Debugging with GDB
Pause, inspect, and step through a running program: GDB's core commands (break/continue/step, print, backtrace), connecting to an embedded target over a gdbserver, and the optimization gotcha.