Gdb学习笔记1

  其实,从很早就开始接触gdb程序,gdb调试程序伴我成长,现在对其用法记录以下:

  当程序的运行结果和预期结果不一致,或者程序出现运行错误时,gdb就可以派上大用处了。调试的基本过程是: 
 -> 根据情况,分析现象 -> 根据直觉,假设原因 -> 根据经验,修改验证 ->

 |                                 |

 <-   根据经验,修改验证 <-  根据直觉,假设原因 <- 根据情况,分析现象 <-

  直到程序的结果和预期完全一致为止,就可以结束苦逼的程序调试了。调试器(如GDB)的目的是允许你在程序运行时进入到某个程序内部去看看该程序在做什么,或者在该程序崩溃时它在做什么。GDB主要可以做4大类事(加上一些其他的辅助工作),以帮助用户在程序运行过程中发现bug。 
  1、 启动您的程序,并列出可能会影响它运行的一些信息 
  2、 使您的程序在特定条件下停止下来 
  3、 当程序停下来的时候,检查发生了什么 
  4、 对程序做出相应的调整,这样您就能尝试纠正一个错误并继续发现其它错误

  在使用gdb过程中,随时可以使用帮助,主要有以下几种:

  1、

  2、

  3、

  4

Type "help" followed by a class name for a list of commands in that class.
Type "help all" for the list of all commands.
Type "help" followed by command name for full documentation.
Type "apropos word" to search for commands related to "word".
Command name abbreviations are allowed if unambiguous.
参看文章:http://blog.csdn.net/xiang90721/article/details/53115778

http://blog.csdn.net/gatieme/article/details/51671430

原文地址:https://www.cnblogs.com/guochaoxxl/p/7083184.html