How to debug a C/C++ program with GDB command-line debugger

While most people use the debugger included in their favorite IDE, Linux is famous for its powerful command line C/C++ debugger: GDB. Once our breakpoints are set, we can run the program with the run command, or simply: r [command line arguments if your program takes some] as most words can be abbreviated in just a letter with gdb . But here we can do: set var a = 0 And just like any good debugger, we can step with: step to run the next line and potentially step into a function. And to finish testing, you can delete a breakpoint with: delete [line number] Keep running the program from the current breakpoint with: continue and exit GDB with: quit To conclude, with GDB, no more praying to compile, no more blood offerings to run, no more printf(test) . What do you think of GDB?

Visit Link