GDB - The GNU Debugger

Channel:
Subscribers:
2,640
Published on ● Video Link: https://www.youtube.com/watch?v=x_z1_5HaIyY



Duration: 1:08:06
170 views
2


GDB is a great tpol to have in your toolchest. There's kind of three main ways of getting into it (compile with g++ -g main.cc):
1) If your program is crashing and core dumping: gdb a.out core
2) If your program is infinite looping: gdb a.out, then hit run, then while it's running in an infinite loop, hit ctrl-c and find out where it is
3) If your program is just giving bad output: gdb a.out, and then set a breakpoint on the area you're interested in (b 50 will set a breakpoint on line 50 for example), then run

When you're there, you can s to step into a line, n to step over, bt to backtrace, and print to print variables.







Tags:
csci 41
gdb
debugging