当前位置:Gxlcms > 数据库问题 > gdb的常见命令

gdb的常见命令

时间:2021-07-01 10:21:17 帮助过:2人阅读

1、定位到你想调试的可执行程序的文件夹下,假设你想调试hello,这个文件类型是Unix Executable File;


2、输入"gdb hello";
屏幕上应该会出现类似:最后出现done字样,表示可以使用gdb调试;
 gdb hello
GNU gdb (GDB) 7.7.1
Copyright (C) 2014 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-apple-darwin12.4.0".
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 hello...Reading symbols from /Users/chenchen/Desktop/Retail/sus/gcc/hello.dSYM/Contents/Resources/DWARF/hello...done.
done.
(gdb) 


3、输入“r”,表示run;


4、输入“b main”,表示在main函数处设一个breakpoint;


5、输入“n”,表示next,走到下一行;


6、输入“l”,可以看到当前行下面的10行代码,再输入一次"l",可以再往后的10行代码;


7、输入“b 20”,其中20是行号,可以在第20行加一个断点;


8、输入“c”,表示continue,从断点处继续往下走;


9、输入“r 20”,可以移除第20行的breakpoint;


10、输入“s”,表示step into,进入函数体;


11、输入“quit”,退出gdb调试状态。

gdb的常见命令

标签:

人气教程排行