gdb使用记录

gdb使用记录

用于记录日常调试用到的方法,而不是简单的命令说明

首先还是先将用过的命令列出
命令:缩写:说明
run:r:执行程序
break:b:设置断点
print:p:打印变量内容
next:n:执行到下一条语句
step:s:进入函数执行(gdb官方说法是Step program until it reaches a different source line.)
continue:c:继续执行
backtrace:bt:打印调用堆栈
frame::显示当前堆栈信息
finish::完成当前函数的执行(gdb手册的官方说法是Execute until selected stack frame returns.此处的函数为通俗说法)
examine:x:打印内存内容
until:u:完成当前循环的(不过在很多情况下并非如此,gdb手册的官方说法是Execute until the program reaches a source line greater than the current or a specified location (same args as break command) within the current frame.)
jump:j:跳到指定的位置执行
handle::选择gdb对信号的处理方式
thread::进行线程之间的切换
info::提供相应的信息
display::每次完成执行显示变量内容
watch::观察变量的变化,在变量发生变化时程序中断
delete:d:删除断点(break)/观察点(watch)/显示点(display)

常用的手段
1、重定向。run 0<input.file 1>output.file或者set args 0<input.file 1>output.file
2、重复执行代码(在同一函数内)。b line_number \n j line_number\n
3、打印内存。x/8xb address,以16进制方式打印8个字节

配置.gdbinit
set print pretty on
set print object on
handle SIGUSR1 nostop noprint

转载于:https://www.cnblogs.com/northhurricane/p/3995168.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值