Online GDB Pro

Reference · GDB commands

GDB commands cheat sheet

Most debugging sessions need about a dozen GDB commands: break to stop, run to start, next and step to move, print to look at values and backtrace to see the call stack. Every command below also works in the Online GDB Pro console, with the same short forms.

Try the commands

In short

  • break N (b) sets a breakpoint at line N; break name sets one at a function.
  • next (n) steps over calls, step (s) steps into them, finish leaves the current function.
  • continue (c) runs to the next breakpoint.
  • print x (p) shows a value; backtrace (bt) shows the call stack.
  • Pressing Enter on an empty line repeats the last command.

Starting and stopping

  • run (r): start the program and stop at the first breakpoint.
  • start: start the program and stop at the first line of main.
  • break 12 / break main (b): stop before line 12, or when main is entered.
  • info breakpoints (i b): list breakpoints with their numbers.
  • delete 2 / delete (d): remove breakpoint 2, or all breakpoints.
  • kill (k): stop debugging.

Moving through the program

  • next (n): run the current line, stepping over function calls. next 5 repeats it five times.
  • step (s): run the current line, stopping inside a called function.
  • finish: run until the current function returns.
  • continue (c): run until the next breakpoint.
  • watch total: run until the value of total changes.
  • reverse-next (rn), reverse-step (rs), reverse-continue (rc), reverse-finish: the same moves, backwards in time.

Looking at data

  • print x (p): show a variable; print p.x, print v[2] show a field or element.
  • display x: show x again at every stop.
  • ptype x / whatis x: show the type of x.
  • info locals: list all local variables of the current frame.
  • backtrace (bt): list the active function calls, innermost first.
  • frame 1 (f), up, down: select another frame of the call stack to inspect its variables.
  • list (l): show the source around the current line.

Frequently asked questions

How do I set a breakpoint in GDB?

Type break followed by a line number or a function name, for example break 25 or break main. In Online GDB Pro you can also click the line number in the editor.

What does bt mean in GDB?

bt is short for backtrace. It prints the chain of function calls that led to the current line, innermost first, with the line each call is on.

How do I go back a step in GDB?

Use reverse-next or reverse-step. In a terminal GDB this needs recording to be switched on first; in Online GDB Pro every debug run is recorded, so they always work.

Is Online GDB Pro free?

Yes. Running, debugging and the lessons are free with no sign-up. VIP removes ads and raises the run-time and debugger limits.

Sources

Updated 2026-11-28. Online GDB Pro is an independent tool. It is not affiliated with, endorsed by or sponsored by the GNU Project, the Free Software Foundation or OnlineGDB. GDB is a GNU Project debugger.