gdb - 如何查看像数组一样的指针? [英] gdb - How to view a pointer like an array?
本文介绍了gdb - 如何查看像数组一样的指针?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设定义: int a [100]
类型打印一个
然后gdb会自动将它显示为一个数组: 1,2,3,4 ...
。但是,如果将 a
作为参数传递给一个函数,那么gdb会将其视为一个普通的int指针,输入 print a
将显示:(int *)0x7fffffffdaa0
。如果我想将 a
作为数组来查看,我应该怎么做?
Suppose defined: int a[100]
Type print a
then gdb will automatically display it as an array:1, 2, 3, 4...
. However, if a
is passed to a function as a parameter, then gdb will treat it as a normal int pointer, type print a
will display:(int *)0x7fffffffdaa0
. What should I do if I want to view a
as an array?
推荐答案
See here. In short you should do:
p *array@len
这篇关于gdb - 如何查看像数组一样的指针?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文