gdb - GNU debugger

Start gdb:

gdb program_name

Set the screen width for gdb:

(gdb) set width 70

Set a breakpoint:

(gdb) break m4_changequote

Using the run command, we start running the program under gdb control; as long as control does not reach the m4_changequote subroutine, the program runs as usual:

(gdb) run

Advance to the next line:

(gdb) n

Step into:

(gdb) s

Display the stack:

(gdb) bt

Display the value of a variable:

(gdb) p varname

To look at some context, we can display ten lines of source surrounding the current line with the l (list) command:

(gdb) l

To change the value of a variable:

(gdb) p len_lquote=strlen(lquote)

To continue:

(gdb) c

To quit gdb:

(gdb) quit

To start gdb with a program and its core file:

gdb program_name core_file

To debug a running process:

gdb program_name PID

To debug a program that takes command-line parameters:

gdb /home/ec2-user/submitter-express/testmsg
r -f /tmp/testmsg8989_1506449271.txt -cf /home/ec2-user/submitter-express/submitter-express.cfg
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License