Chinaunix首页 | 论坛 | 博客
  • 博客访问: 714991
  • 博文数量: 130
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 2198
  • 用 户 组: 普通用户
  • 注册时间: 2011-11-29 12:48
个人简介

每一个“丑得人神共愤”的泡妞高 手都有一颗坚忍的心,这证明了人类 在绝境中毫不妥协的求生精神,反正丑都丑了,索性放开手脚大干一场,这就叫“无产阶级失去的是锁链,得到的是全世界”

文章分类

全部博文(130)

文章存档

2013年(130)

我的朋友

分类: LINUX

2013-08-19 10:56:36

不理解的地方可运行gdb,然后help相关命令
参考《gdb 查看堆栈信息》 、《gdb使用手册

list [-] [ARG1[, ARG2]]
列出指定的函数或者行
不指定参数,list显示前一个list后面的10行;"list -"显示前一个list前面的10行
若指定一个参数,list将显示该参数指定行后面的10行
若指定两个使用逗号分割的参数,list将显示参数1到参数2之间的行
可通过下面的方式指定行:
  LINENUM
  FILE:LINENUM
  FUNCTION
  FILE:FUNCTION
  *ADDRESS

break [LOCATION] [thread THREADNUM] [if CONDITION]:
在指定行或者函数设定断点
LOCATION可以是行号、函数名、或者*和地址
THREADNUM是来自"info threads"的线程号
CONDITION是一个布尔表达式
允许在一个地方设定多个断点,这在condition不同时是很有用的

info break
points:
查看所有断点

delete breakpoints [n1 [n2 ]....]
删除断点。n1,n2为断点号;不带参数时删除所有断点
删除所有断点:               delete breakpoints
删除编号为n的断点:    delete n

enable breakpoints [n1 [n2 ]....]

disable breakpoints [n1 [n2 ]....]
启用/禁用指定断点

run [ARGS]:
开始调试程序。你可以指定传递给被调试程序的参数。
参数中可包含"*"或"[...]",它们将被sh解释;也是使用输入输出重定向">", "<", 或 ">>"。
如果没有指定参数,则使用上次指定的参数(使用"run"或"set args")。
取消前面的参数可使用不带参数的run或不带参数的set args

backtrace [[-]COUNT] [full]:
显示所有栈帧的追踪,或者最里面的(innermost)COUNT个栈帧。
使用负参数(negative argument),显示最外面的(outermost)-COUNT个栈帧。
使用full限定符可显示出局部变量的值

print EXP:
打印表达式EXP的值
Variables accessible are those of the lexical environment of the selected
stack frame, plus all those whose scope is global or an entire file.
$NUM gets previous value number NUM.  $ and $$ are the last two values.
$$NUM refers to NUM'th value back from the last one.
Names starting with $ refer to registers (with the values they would have
if the program were to return to the stack frame now selected, restoring
all registers saved by frames farther in) or else to debugger
"convenience" variables (any such name not a known register).
Use assignment expressions to give values to convenience variables.
{TYPE}ADREXP refers to a datum of data type TYPE, located at address ADREXP.
@ is a binary operator for treating consecutive data objects
anywhere in memory as an array.  FOO@NUM gives an array whose first
element is FOO, whose second element is stored in the space following
where FOO is stored, etc.  FOO must be an expression whose value
resides in memory.
EXP前可放置/FMT,FMT是一个没有次数(count)和大小(size)的格式字符(参见"x"命令)


x/FMT ADDRESS:
查看内存
ADDRESS是一个表示要查看的内存地址的表达式
FMT是重复次数counte后接格式字符format和大小字符size(如x/8x 0xbbbbbbbb)
格式字符可以是o(octal), x(hex), d(decimal), u(unsigned decimal), t(binary),
f(float), a(address), i(instruction), c(char) 和s(string)
大小字符是b(byte), h(halfword), w(word), g(giant, 8 bytes)
指定大小的指定个数的目标将根据格式字符被显示
默认的格式和大小将沿用上次使用的,默认的次数为1.

frame [num]:
选择并打印栈帧信息
不带参数则打印选中的栈帧

up [n]:
选择并打印向上的第n个栈帧信息,不指定n时,默认为1个
down [n]:
选择并打印向下的第n个栈帧信息,不指定n时,默认为1个
(这里的down和up是按着函数调用顺序的,down进入到该函数调用的函数中,up进入到调用该函数的函数中)

info threads [[ID ]...]:
显示当前已知线程
可选参数ID用于查看指定线程;不带参数则查看所有线程。

info frame [num]:
类似于frame [num]
不过frame是源码级的,看到的是处理器当前所运行的C代码;
info frame是汇编级的,可看到栈帧寄存器信息

info args:
打印当前栈帧的函数调用参数
info locals:
打印当前栈帧的局部变量
info catch:
打印捕获在当前栈帧中的异常

thread n:
切换到线程号为n的线程
线程号可通过info threads查看,前面带*的表示当前线程

set scheduler-locking off | on | step:
设置堵塞调度器(locking scheduler)的模式
off  == no locking (threads may preempt at any time)
on   == full locking (no thread except the current thread may run)
step == scheduler locked during every single-step operation.
    In this mode, no other thread may run during a step command.
    Other threads may run while stepping over a function call ('next').

info proc all -- List all available /proc info
info proc cmdline -- List command line arguments of the process
info proc cwd -- List current working directory of the process
info proc exe -- List absolute filename for executable of the process
info proc mappings -- List of mapped memory regions
info proc stat -- List process info from /proc/PID/stat
info proc status -- List process info from /proc/PID/status

call func(args...):
在gdb中调用函数func
阅读(1454) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~