GDB查看指定内存地址的内容——指令x

以下是gdb help中的解释

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”.

翻译过来就是:

X/FMT ADDRESS 
  • ADDRESS是需要检测的内存地址的表达式。
  • FMT是一个重复数量,跟着一个格式字母和一个大小字母
    • 重复数量是指需要打印多少个对象
    • 格式字母为, x(hex), d(decimal), u(unsigned decimal), t(binary), f(float), a(address), i(instruction), c(char)and s(string)
    • 大小字母b(byte), h(halfword), w(word), g(giant, 8 bytes)
    • 根据格式打印指定数量指定大小的对象。

格式和大小字母的默认值是以前使用的。
默认计数为 1。
默认地址是在使用此命令或“打印”打印的最后一个内容之后。

例子:

#include <stdio.h>

void main()
{
    char a[20] = {0x10, 0x20, 0x30, 0x40, 0x50, 0x60};

    printf("%c\n", a[0]);
}

打印a地址后的20个对象,每个对象1个字节,用16进制显示

(gdb) x/20xb a
0x7fffffffdda0: 0x10    0x20    0x30    0x40    0x50    0x60    0x00    0x00
0x7fffffffdda8: 0x00    0x00    0x00    0x00    0x00    0x00    0x00    0x00
0x7fffffffddb0: 0x00    0x00    0x00    0x00
  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值