1. Before use:
When compiling gcc, you need to add -g to generate an executable file, the format is as follows
$ gcc -g *.c -o *
2. Enter gdb:
After generating the compiled executable file, gdb has two debugging modes:
Normal mode:
$ gdb -tui *
Up and down split screen mode:
$ gdb *
3. gdb debugging basic shortcuts
1)list/l
List the current debug code
2)breakpiont/b
b line number/function name breakpoint (the current breakpoint points to the code that will be executed but not executed)
(gdb)b main (gdb)b 12
3)print/p
p variable name output the variable name to view
(gdb)p a
4)next/n
nNext step
(gdb) n
5)info
info b View current breakpoint information
(gdb) info b
6)quit/q
q quit gdb
(gdb) q