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)

  • 相关阅读:
    OpenCV运动检测跟踪(blob track)框架组成模块详解
    C# 控制台应用程序中输出彩色字体
    C#获取隐藏的文件
    用c#怎么比较两张图片的不同
    清除浏览器缓存
    C#判断系统是否已经连接上网络
    如何删除VS2005中显示的最近项目
    设计模式:模板方法模式(Template Method)
    【SQL】数据库对象中查找某一关键字
    【问答】.NET面试题
  • 原文地址:https://www.cnblogs.com/kwingmei/p/3224444.html
Copyright © 2011-2022 走看看