GDB使用记录

  1. 帮助信息使用:
    (gdb) help x
    Examine memory: x/FMT ADDRESS.
    ADDRESS is an expression for the memory address to examine.
    FMT is a repeat count followed by a format letter and a size letter.
    Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal),
      t(binary), f(float), a(address), i(instruction), c(char) and s(string).
    Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).
    The specified number of objects of the specified size are printed
    according to the format.
    
    Defaults for format and size letters are those previously used.
    Default count is 1.  Default address is following last thing printed
    with this command or "print".
    (gdb) x/10xb $input1
  2. 条件断点
    break fun1 if loop==1

  3. 构造输入
    (gdb) set $win1 = (winInfo *)malloc(sizeof(winInfo))
    (gdb) set $win1->cnt = 1
    (gdb) set $win1->sum = 2
    (gdb) set $win1->sub = 3
    (gdb) c fun3(win1)
    
    (gdb) p fun1($win1)
    $10 = 3
    (gdb) set $win1->cnt = 100
    (gdb) p fun1($win1)       
    $11 = 99

  4. 查看指针,查看结构体
    (gdb) p win
    $2 = (winInfo *) 0x8592008
    (gdb) p *win
    $3 = {cnt = 13, sum = 12, sub = 11}

  5. 打印内存
    (gdb) x/10xb $input1
    0x8e0c018:      0x00    0x01    0x02    0x03    0x04    0x05    0x06    0x07
    0x8e0c020:      0x08    0x09
    (gdb) x/10xh $input1
    0x8e0c018:      0x0100  0x0302  0x0504  0x0706  0x0908  0x0b0a  0x0d0c  0x0f0e
    0x8e0c028:      0x1110  0x1312
    (gdb) x/10xw $input1
    0x8e0c018:      0x03020100      0x07060504      0x0b0a0908      0x0f0e0d0c
    0x8e0c028:      0x13121110      0x17161514      0x1b1a1918      0x1f1e1d1c
    0x8e0c038:      0x23222120      0x27262524
    (gdb) x/10xg $input1
    0x8e0c018:      0x0706050403020100      0x0f0e0d0c0b0a0908
    0x8e0c028:      0x1716151413121110      0x1f1e1d1c1b1a1918
    0x8e0c038:      0x2726252423222120      0x2f2e2d2c2b2a2928
    0x8e0c048:      0x3736353433323130      0x3f3e3d3c3b3a3938
    0x8e0c058:      0x4746454443424140      0x4f4e4d4c4b4a4948
    (gdb) 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值