gdb使用(1)
来源:互联网 发布:ubuntu内核源码目录 编辑:程序博客网 时间:2024/06/05 11:03
简单的使用
1.进入gdb
[mason@cyhongLinuxT510Node download]$ gdb
2.gdb中的大类命令列表
(gdb) help
List of classes of commands:
aliases -- Aliases of other commands
breakpoints -- Making program stop at certain points
data -- Examining data
files -- Specifying and examining files
internals -- Maintenance commands
obscure -- Obscure features
running -- Running the program
stack -- Examining the stack
status -- Status inquiries
support -- Support facilities
tracepoints -- Tracing of program execution without stopping the program
user-defined -- User-defined commands
Type "help" followed by a class name for a list of commands in that class.
Type "help all" for the list of all commands.
Type "help" followed by command name for full documentation.
Type "apropos word" to search for commands related to "word".
Command name abbreviations are allowed if unambiguous.
3.gdb具有bash类是的命令自动补全功能
4.带参数启动gdb
[mason@cyhongLinuxT510Node download]$ gdb --help
This is the GNU debugger. Usage:
gdb [options] [executable-file [core-file or process-id]]
gdb [options] --args executable-file [inferior-arguments ...]
gdb [options] [--python|-P] script-file [script-arguments ...]
Options:
--args Arguments after executable-file are passed to inferior
-b BAUDRATE Set serial port baud rate used for remote debugging.
--batch Exit after processing options.
--batch-silent As for --batch, but suppress all gdb stdout output.
--return-child-result
GDB exit code will be the child's exit code.
--cd=DIR Change current directory to DIR.
--command=FILE, -x Execute GDB commands from FILE.
--eval-command=COMMAND, -ex
Execute a single GDB command.
May be used multiple times and in conjunction
with --command.
--core=COREFILE Analyze the core dump COREFILE.
--pid=PID Attach to running process PID.
--dbx DBX compatibility mode.
--directory=DIR Search for source files in DIR.
--epoch Output information used by epoch emacs-GDB interface.
--exec=EXECFILE Use EXECFILE as the executable.
--fullname Output information used by emacs-GDB interface.
--help Print this message.
--interpreter=INTERP
Select a specific interpreter / user interface
-l TIMEOUT Set timeout in seconds for remote debugging.
--nw Do not use a window interface.
--nx Do not read .gdbinit file.
--python, -P Following argument is Python script file; remaining
arguments are passed to script.
--quiet Do not print version number on startup.
--readnow Fully read symbol files on first access.
--readnever Do not read symbol files.
--se=FILE Use FILE as symbol file and executable file.
--symbols=SYMFILE Read symbols from SYMFILE.
--tty=TTY Use TTY for input/output by the program being debugged.
--tui Use a terminal user interface.
--version Print version information and then exit.
-w Use a window interface.
--write Set writing into executable and core files.
--xdb XDB compatibility mode.
At startup, GDB reads the following init files and executes their commands:
For more information, type "help" from within GDB, or consult the
GDB manual (available as on-line info or a printed manual).
Report bugs to "<http://www.gnu.org/software/gdb/bugs/>".
1)gdb 程序名 core文件名 #指定出错产生的core文件名/或者读入已存在的core文件进行程序执行过程中崩溃的调试
2)gdb 程序名 进程id #指定进程ID
3)让程序输出core dump文件大小没有限制,ulimit -c unlimited
5.传入调试程序参数
[mason@cyhongLinuxT510Node download]$gdb --args vim fun.c
6.不显示gdb启动的各种信息
[mason@cyhongLinuxT510Node download]$ gdb -silent
(gdb)
7.启动gdb后启动调试程序
[mason@cyhongLinuxT510Node download]$ gdb -silent
(gdb) file fun
8.启动gdb后,在gdb中使用shell命令
[mason@cyhongLinuxT510Node download]$ gdb -silent
(gdb) shell ls
gstreamer-ffmpeg-0.10.11-4.el6.x86_64.rpm nvidia.pdf
JD-Firmware Engineer .docx OpendTect_Installer_lux64.sh
KTorrent stardict-3.0.2-1.el6.x86_64.rpm
linuxqq-v1.0.2-beta1.i386.rpm teamviewer_linux(1).rpm
linuxqq_v1.0.2_i386 teamviewer_linux.rpm
(gdb)
9.可直接执行make arg-of-make等价于shell make arg-of-make
10.gdb 的历史命令
(gdb) set history filename gdb.history
(gdb) set history save on
(gdb) set history size 100
(gdb)
10.设置支持的语言(可以让gdb自动选择):为了区别不同的语言具有的不同的语法,而这影响到gdb的输入格式比如指针的不同
(gdb) set language java
(gdb) set language #打印出所有gdb支持的语言
(gdb)
1)根据gdb启动命令行,启动gdb
2)读取用户主目录下的init文件(.gdbinit),并依次执行其中的命令
3)处理命令行选项和选项参数
4)读取当前目录下的init文件,并依次执行其中的命令
5)读取并执行-x选项中指定的文件(-x文件的功能类似与init文件)
6)读取history文件中的命令历史(如果没有设置history文件,则每次调试会话的历史都会丢弃)
比如为了让其保存历史命令长久有效,可以在这些init文件中包含这些命令
如下
set history filename gdb.history
set history save on
set history size 100
- gdb使用(1)
- 使用GDB调试程序(1)
- 程序调试(1)GDB 基本使用
- gdb调试工具使用(1)
- GDB的使用(转载)
- GDB 使用教程(二)
- gdb使用
- GDB使用
- gdb使用
- 使用GDB
- gdb 使用
- gdb使用
- GDB使用
- gdb使用
- GDB使用
- GDB使用
- GDB使用
- gdb 使用
- 编程之美系列之二——寻找出现频率超过一半的数
- eCos组件初始化
- Java对多线程的支持(一) - Thread类、Runnable接口、Daemon线程、线程同步
- C程序设计语言 2013.10.15
- POJ2503——Babelfish
- gdb使用(1)
- addEventListener 绑定元素组
- Android新的menu实现——ActionMode
- C++程序设计课程2013级学生名单
- java 面试题02 之 《输入a、b、c 三个整数,按大到小排列》
- C++中的操作符重载
- Backing Up the Control File
- Linux常用的指令汇总
- 关于读取文本文件