01 什么是GDB

1.13~1.16 GDB调试_后端

02 准备工作

1.13~1.16 GDB调试_后端_02

03 GDB命令

1.13~1.16 GDB调试_gdb_03

zdb@zdb-virtual-machine:~/linux/lession08$ gcc test.c -o test -g
zdb@zdb-virtual-machine:~/linux/lession08$ gdb test
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from test...done.
(gdb) set args 10 20
(gdb) show args
Argument list to give program being debugged when it is started is "10 20".
(gdb) quit

1.13~1.16 GDB调试_GDB_04


1.13~1.16 GDB调试_GDB_05


list指令

1.13~1.16 GDB调试_linux_06


指定行号:

1.13~1.16 GDB调试_linux_07


指定查看的函数:

1.13~1.16 GDB调试_linux_08


显示其他文件的代码:

1.13~1.16 GDB调试_C++_09


设置显示的行数:

show list         # 查看显示的行数size
show listsize # 查看显示的行数size
set listsize 20 # 设置行数size

1.13~1.16 GDB调试_C++_10

04 GDB命令–断点调试

1.13~1.16 GDB调试_linux_11

  1. 设置断点
  2. 1.13~1.16 GDB调试_gdb_12


  3. 1.13~1.16 GDB调试_gdb_13

  4. 删除断点
  5. 1.13~1.16 GDB调试_GDB_14

  6. disable和enable
  7. 1.13~1.16 GDB调试_linux_15


05 GDB命令—调试命令

1.13~1.16 GDB调试_C++_16