zoukankan      html  css  js  c++  java
  • gdb 使用 基本

    Making gdb do more (debugging) for less (re-typing)

    gdb allows us to debug our code primitively. 调试我们的代码

    Yet, gdb supports a large number of knobs and levers, all of which are quite documented. 也可以说太仔细了, 我们不会去看而已

    are too lazy to read documentation... ...and even more so, for software we've been using for years. 尽管在你我身边多时了

    An executable program needs to have "debug symbols" in order to be properly debugged under gdb. 加 -g 调试选项

    gdb <executable>

    gdb gdb <executable> <PID> (为什么很少使用?)

    run

    run <parameters>

    'next' performs the next instruction (if a function call - performs the full function call). 不进入函数的 下一步

    'step' steps into the next command (for a function call - stops at the first instruction of the function). 进入函数的 下一步

    'nexti' and 'stepi' do the same, at the machine-language level. 汇编语句的 下一步

    'cont' lets the program continue execution (until the next ctrl-C). 继续知道需要 ‘停下点’

    'bt' shows you the execution stack (innermost function first).  ‘backtrace’ 调用栈环境

    'up' and 'down' move between stack frames, to allow examining their contents 移动栈(外/内) 但程序指针不移动

    frame <number>' moves to the given frame ('bt' shows frame numbers'). 移到给定的编号

    'frame' to see the current stack frame. 查看当前的栈

    'print <expression>' evaluates an expression. 查看笔表达式的值  use it to view contents of variables.

    'list' shows a part of the "currently selected source file".查看源代码(当前的运行环境)

    list <line number>

    list <function>

    info break 查看断点

    break <line> 断点

    break <function> 如 break main

    delete <break-point number> 删除断点

    delete 删除所有的断点

    display <variable> 显示变量(variable moves out of scope 变量的范围)

    undisplay <number>

    undisplay

    display <expression>, just like with print.

    set print pretty on  : pretty 输出

    (gdb) set print pretty on 
    (gdb) print v
    $2 = {
      num1 = 4, 
      num2 = 1999759, 
      more = {
        val1 = 99 'c', 
        val2 = 100 'd', 
        arr1 = {0, 573440, 1146880, 1720320, 2293760, 2867200, 3440640, 4014080, 
          4587520, 5160960}
      }
    }
    vs
    (gdb) print v
    $1 = {num1 = 4, num2 = 1999759, more = {val1 = 99 'c', val2 = 100 'd', arr1 = {
          0, 573440, 1146880, 1720320, 2293760, 2867200, 3440640, 4014080, 
          4587520, 5160960}}}
    

    info frame 当前栈信息

    delete

     info local 当前local变量进制输出print/baseprint 10进制print /x 16进制print /o 8进制print /t 2进制

    examne memory area and we want to view its contents. 查看内存

    x /10c addr :10byte

    x /10wd add : 10 4-byte

    x /10xg add : 10 8-byte(in hex)

  • 相关阅读:
    解决: 误将分区的GHO镜像文件恢复到整个硬盘
    腾讯的迷你门户首页新闻用到的Silverlight技术引用
    [转]如何在word文档里面的小方框内打钩
    Microsoft .NET Framework 3.5/4 Client Profile
    Java Web 开发软件下载地址
    tomcat 6.0环境, 网页超链接,文件下载另存为时,不能识别msi文件类型,另存为只能选htm和所有文件。
    英语小记
    去掉WORD文档中向下的小箭头(换行符)
    开个小餐馆要多少成本
    如何租间餐饮店
  • 原文地址:https://www.cnblogs.com/kwingmei/p/3224444.html
Copyright © 2011-2022 走看看