GDB调试工具

一、GDB简介

        GDB是GNU开源组织发布的一个强大的Linux下的程序调试工具。

        一般来说,GDB主要帮助你完成下面四个方面的功能:

1、启动你的程序,可以按照你的自定义的要求随心所欲的运行程序(按着自己的想法运行)。

2、可让被调试的程序在你所指定的调置的断点处停住。(断点可以是条件表达式)

3、当程序被停住时,可以检查此时你的程序中所发生的事。4、你可以改变你的程序,将一个BUG产生的影响修正从而测试其他BUG。

二、GDB基本命令

Here are some of the most frequently needed GDB commands:

       break [file:]function  设置断点(简写b)

           Set a breakpoint at function (in file).

       run [arglist]程序运行起来

           Start your program (with arglist, if specified).

       bt  Backtrace: display the program stack.查看栈

       print expr 打印输出

           Display the value of an expression.

       c   Continue running your program (after stopping, e.g. at abreakpoint).全部执行完

       next一步一步运行

           Execute next program line (after stopping); step over any function

           calls in the line.

     edit [file:]function查看停止的信息

           look at the program line where it is presently stopped.

       list [file:]function查看代码信息

           type the text of the program in the vicinity of where it is

           presently stopped.

       step如果有函数,进入函数,查看函数里面的信息

           Execute next program line (after stopping); step into any function

           calls in the line.

       help [name]

           Show information about GDB command name, or general information

           about using GDB.

       quit

           Exit from GDB.

 三、GDB调试core文件

You can also start with both an executable program and a core file specified:

               gdb program core

 GDB调试正在运行的进程

You can, instead, specify a process ID as a second argument or use option "-p", if you want to debug a running process:

               gdb program 1234

               gdb -p 1234

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值