x/nfu-用gdb查看記憶體

來源:互聯網
上載者:User

標籤:

用gdb查看記憶體

2007-12-08 12:43

用gdb查看記憶體

格式: x /nfu <addr>

說明
x 是 examine 的縮寫

n表示要顯示的記憶體單元的個數

f表示顯示方式, 可取如下值
x 按十六進位格式顯示變數。
d 按十進位格式顯示變數。
u 按十進位格式顯示無符號整型。
o 按八進位格式顯示變數。
t 按二進位格式顯示變數。
a 按十六進位格式顯示變數。
i 指令地址格式
c 按字元格式設定顯示變數。
f 按浮點數格式顯示變數。

u表示一個地址單元的長度
b表示單位元組,
h表示雙位元組,
w表示四位元組,
g表示八位元組


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)

舉例
x/3uh buf
表示從記憶體位址buf讀取內容,
h表示以雙位元組為一個單位,
3表示三個單位,
u表示按十六進位顯示

詳細例子:

(gdb) list
1       #include<stdio.h>
2       int main()
3       {
4
5               //char a[1];
6               //a[0]=‘a‘;
7               unsigned long long md5=14126471717450151013;
8
9               //printf("%d\n",a[0]);
10              return 0;
(gdb) break 10
Breakpoint 1 at 0x8048372: file test.c, line 10.
(gdb) run
Starting program: /data/compiler/g_platform/bradenwu/md5/test.out

Breakpoint 1, main () at test.c:10
10              return 0;
(gdb) x/8xb md5
0x8837f465:     Cannot access memory at address 0x8837f465
(gdb) x/8xb &md5
0xbfffefa0:     0x65    0xf4    0x37    0x88    0x2e    0x4f    0x0b   0xc4

x/nfu-用gdb查看記憶體

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.