admin管理员组文章数量:1026989
gdb中三种输出 print, x, display 的区别
最常用的输出格式是 print (简写为p)。print 会根据表达式在程序中的类型输出值。
但是也可以指定输出类型。
print/f expression
f 可以有以下格式:
format | 释义 |
---|---|
x | hexadecimal |
d | signed decimal |
u | unsigned decimal |
o | octal |
t | binary ( t stands for two) |
a | address |
c | character |
f | floating number |
s | string |
x (examine)
x 用来以指定格式查看内存,和在程序中的数值类型没有关系。
x/nfu addr
x addr
x
- n 重复的次数
- f 输出格式
- 除了 print 的格式外,还有格式 ‘i’ (maching instructions)。
- 初始化默认是 ‘x’
- 每次 print 或 x 会修改默认的格式
- u unit size
- b Bytes
- h Halfwords (two bytes)
- w words (four bytes). 初始化的默认值
- g giant words (eight bytes)
注意:如果省略 f 或 u 的话,会使用默认值。如果不清楚,最好全部指定。
display
display 相当于自动输出的 x 或 print。display 会在每次暂停的时候输出表达式的值。display 会根据指定的模式自动选择使用 x 或是 print:
如果使用 ‘i’ 或 ‘s’ 格式, 或者指定了 unit size,会使用 x 输出值,其他情况下使用 print。
display expr
display/f expr
display/t addr
gdb中三种输出 print, x, display 的区别
最常用的输出格式是 print (简写为p)。print 会根据表达式在程序中的类型输出值。
但是也可以指定输出类型。
print/f expression
f 可以有以下格式:
format | 释义 |
---|---|
x | hexadecimal |
d | signed decimal |
u | unsigned decimal |
o | octal |
t | binary ( t stands for two) |
a | address |
c | character |
f | floating number |
s | string |
x (examine)
x 用来以指定格式查看内存,和在程序中的数值类型没有关系。
x/nfu addr
x addr
x
- n 重复的次数
- f 输出格式
- 除了 print 的格式外,还有格式 ‘i’ (maching instructions)。
- 初始化默认是 ‘x’
- 每次 print 或 x 会修改默认的格式
- u unit size
- b Bytes
- h Halfwords (two bytes)
- w words (four bytes). 初始化的默认值
- g giant words (eight bytes)
注意:如果省略 f 或 u 的话,会使用默认值。如果不清楚,最好全部指定。
display
display 相当于自动输出的 x 或 print。display 会在每次暂停的时候输出表达式的值。display 会根据指定的模式自动选择使用 x 或是 print:
如果使用 ‘i’ 或 ‘s’ 格式, 或者指定了 unit size,会使用 x 输出值,其他情况下使用 print。
display expr
display/f expr
display/t addr
本文标签: gdb中三种输出 printxdisplay 的区别
版权声明:本文标题:gdb中三种输出 print, x, display 的区别 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/jiaocheng/1700050076a331095.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论