Online GDB Pro

Tutorial · GDB online

How to use GDB online

To debug a C or C++ program online, paste it into Online GDB Pro, click the line numbers where you want to stop and press Debug. The program runs to the first breakpoint, and from there you move with next, step, finish and continue while every variable and the call stack update.

Open the debugger

In short

  • A breakpoint stops the program before that line runs.
  • next runs the current line and stops at the next one in the same function; step goes into the function being called.
  • finish runs until the current function returns to its caller.
  • continue runs to the next breakpoint, or to the end of the program.
  • Online GDB Pro records the run, so reverse-next and reverse-step go back in time.

Step by step

  1. Paste your program Open the IDE on the home page, choose C or C++ and paste your code. If it reads input with scanf or cin, type that input in the Input box.
  2. Set breakpoints Click the line number next to the first line you want to inspect. A red dot appears. You can also type break 12 or break main in the GDB console.
  3. Start the debugger Press Debug. Online GDB Pro compiles the program with Clang, runs it and stops at the first breakpoint. The current line is highlighted.
  4. Move through the code Use Next to run one line, Step to enter a function call, Finish to leave the current function and Continue to jump to the next breakpoint. The same commands work in the console as n, s, finish and c.
  5. Inspect the state The Variables panel lists the locals of the selected frame; values that just changed are highlighted. The Call stack panel shows how you got here; click a frame to see its variables. In the console, print x, print p.x or print v[2] shows one value.
  6. Go back when you overshoot Press Back or type reverse-next to return to the previous line, reverse-step to step back into a call and reverse-continue to go back to the previous breakpoint.

Finding common bugs

  • Wrong result: put a breakpoint inside the loop and watch the variable with watch total; the debugger stops every time it changes.
  • Crash (segmentation fault): debug the program; it stops at the line that read or wrote invalid memory, with the call stack that led there.
  • Infinite loop: the debugger stops at its step limit. Step back a few lines to see which condition never becomes false.
  • Recursion: Step into the function and look at the Call stack panel; each call is its own frame with its own n.

How it differs from GDB in a terminal

Online GDB Pro is not the GNU GDB program: it is a browser debugger that follows GDB’s commands. It records the program as it runs and then lets you move through that recording, which is why stepping backwards is always available. The run is recorded up to 20,000 line steps (300,000 with VIP), and input comes from the Input box rather than being typed while the program waits.

Frequently asked questions

Do I need to compile with -g?

No. Online GDB Pro prepares debugging information automatically when you press Debug. Run uses an optimized build; Debug uses an unoptimized one so every variable keeps its value.

What is the difference between next and step?

Both run one line. If the line calls a function, next runs the whole call and stops at the following line, while step stops at the first line inside the function.

Can I see the value of an array or a struct?

Yes. Arrays show their elements, structs show their fields by name and C++ containers such as vector, map and string show their contents.

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.

Is my code uploaded to a server?

No. Online GDB Pro compiles and runs your program in your browser, on your own device.

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.