This page (revision-5) was last changed on 25-Jul-2021 11:23 by BlakeMcBride

This page was created on 16-Oct-2015 08:50 by BlakeMcBride

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

Page revision history

Version Date Modified Size Author Changes ... Change note
5 25-Jul-2021 11:23 1 KB BlakeMcBride to previous
4 16-Oct-2015 09:50 1 KB BlakeMcBride to previous | to last
3 16-Oct-2015 09:28 940 bytes BlakeMcBride to previous | to last
2 16-Oct-2015 09:12 937 bytes BlakeMcBride to previous | to last
1 16-Oct-2015 08:50 915 bytes BlakeMcBride to last

Page References

Incoming links Outgoing links
GDB

Version management

Difference between version and

1!!GDB - GNU debugger
2
3gdb without any arguments automatically uses a.out
4
5Compile with -g
6C programs should be compiled with -g -Og
7
8
9To make a program produce a core file for debugging with gdb after-the-fact do:
10 {{{ulimit -c unlimited}}}
11
12{{{gdb myProgram core}}}
13{{{gdb myProgram [core]}}}
14
15
16| run [[args] | run the program
17| kill | stop program from running
18| quit | exit debugger
19| help |
20| ^C | stop / interrupt the program
21| continue | continue execution
22| list | show program code
23| next | go over next line
24| step | go into next line
25| print x | print value of x
26| backtrace | show stack
27| frame n | change to stack frame n
28| info frame |
29| info locals |
30| info args |
31| run [[args] | r | run the program
32| kill | k | stop program from running
33| quit | q | exit debugger
34| help | h |
35| ^C | | stop / interrupt the program
36| continue | c | continue execution
37| list | l | show program code
38| next | n | go __over__ next line
39| step | s | go __into__ next line
40| finish | fin | exit stack frame (go __up__)
41| print x | p | print value of x
42| backtrace | bt | show stack
43| frame n | f | change to stack frame n
44| info locals | i lo | display local variables
45| info args | i ar | display command line arguments
46| info frame | i f | stack frame information
47
48!Breakpoints
49
50| break file.c:45 | set breakpoint at line 45 of file.c
51| break myfun | set breakpoint at beginning of myfun()
52| info breakpoints | list breakpoints
53| disable 2 | disable breakpoint 2
54| clear XXXX | delete breakpoint
55| break file.c:45 | b | set breakpoint at line 45 of file.c
56| break myfun | b | set breakpoint at beginning of myfun()
57| info breakpoints | i br | list breakpoints
58| disable 2 | | disable breakpoint 2
59| clear XXXX | cl | delete breakpoint at location XXXX
60| delete nnn | d | delete breakpoint number nnn
61
62When lines are displayed, it is showing the line that is about to be executed, not the line that was just executed.
63