linux使用--13.ubuntu14.04下安装cgdb及程序调试

本文介绍如何在Ubuntu 14.04系统中安装并使用CGDB,包括基本命令操作、设置断点及变量显示等技巧。还介绍了如何解决.gdbinit脚本加载问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.ubuntun14.04下安装cgdb
cong@msi:~$ sudo apt-get install cgdb
2. 使用: cgdb ./hello就可以了
a. cgdb分为上面的vi窗口与下面的gdb窗口
  1. ESC-->切到vi窗口
  2. -->切到gdb窗口
  3. - -->减小vi窗口
  4. = -->增大vi窗口
  5.  shift - -->减小很多vi窗口
  6.  shift = -->增大很多vi窗口
b.断点
空格添加/删除断点
3. gdb
a. 在指定文件中指定函数处设断点
b : 
b
  1. <filename>: <func_name>
  2. <filename>: <line_num>


<filename
c. .gdbinit脚本不能用
  1. warning: File "/work/ffmpeg/jpeg/jpegc/.gdbinit" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-loa
  2. d".
  3. To enable execution of this file add
  4.         add-auto-load-safe-path /work/ffmpeg/jpeg/jpegc/.gdbinit
  5. line to your configuration file "/home/cong/.gdbinit".
  6. To completely disable this security protection add
  7.         set auto-load safe-path /
  8. line to your configuration file "/home/cong/.gdbinit".
  9. For more information about this security protection see the
  10. "Auto-loading safe path" section in the GDB manual. E.g., run from the shell:
  11.         info "(gdb)Auto-loading safe path"
在gdb的命令行里面  source .gdbinit
暂时先这么用着吧
d. 打印多个变量
{i,j,k,l}
display {i,j,k,l}   --> 每执行一次都打印这几个变量
undisplay           --> 去掉display
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值