标签:watch locking cut fork cat eve art run 转储
1. GDB概述
GNU发布的调试器,可以查看程序如何运行或崩溃时的状态。
主要功能:
GDB启动程序
//通过GDB启动/attach一个可程序或打开一个core文件
gdb [options] [executable-file [core-file or process-id]]
//为可执行程序指定执行参数
gdb [options] --args executable-file [inferior-arguments ...]
//为GDB启动指定扩展脚本
gdb [options] [--python|-P] script-file [script-arguments ...]
其他启动参数:
-tui Text User Interface
-s file read symbol table from file
--silent do not print version number
GDB命令特点:
命令别名
自动完成(命令/符号名)
帮助强大:
help class
help all
help command
2. 运行控制类命令:
run(r)
step(s) [count]
next(n) [count]
contine(c) [ignore-count]
finish(fin)
until(u) line
skip file|func
stepi(si)
nexti(ni)
多线程控制命令:
info thread
thread thread-id
thread apply ID1 ID2 command
thread apply all command
set scheduler-locking off|on|step
break location thread thread-id
break location thread thread-id if ...
3. 程序停止点
3.1 断点
break(b) [line]|[function][address]
break(b) [line]|[function][address] if …
condition break-num
command break-num
tbreak(tb) [line]|[function][address]
rbreak(rb) regex
info break [break-num]
delete(d) break-num
disable(dis) break-num [count]
enable(ena) break-num
ignore break-num count
3.2 观察点
watch [-l|-location] expr [thread thread-id]
rwatch [-l|-location] expr [thread thread-id]
awatch [-l|-location] expr [thread thread-id]
info watchpoints
delete(d) watch-num
disable(dis) watch-num
enable(ena) watch-num
condition watch-num
command watch-num
3.3 扑捉点
catch event [exception][exec][fork][syscall][signal][throw]
tcatch event
清除停止点 clear / delete
保存停止点 save breakpoints [file]
4. 状态查看类命令:
list(l) /-tui(Ctrl+x+a切换)
search/forward-search(fo)/reverse-search(rev)
print(p) /format expr
print(p) *array@len
x/nfu addr
set print pretty
set print array on
set print elements unlimited
info [locals][variables][float][vtbl][registers]
whatis / ptype
display
4.1 堆栈查看命令
backtrace(bt)
info frame(f)
frame frame-num
up [frame-num]
down [frame-num]
5. 改变程序运行类命令:
set [var] expr
jump location
return [expression]
call expression
6.内存转储
dump [format] memory filename start_addr end_addr 转储内存某地址范围内容到指定文件
dump [format] value filename expr 转储变量值到指定文件
append [binary] memory filename start_addr end_addr
append [binary] value filename expr
restore filename [binary] bias start end
generate-core-file(gcore) [file] 生成core文件
标签:watch locking cut fork cat eve art run 转储
原文地址:http://www.cnblogs.com/bitkevin/p/6665085.html