如何在GDB中查看类似于数组的指针? [英] How to view a pointer like an array in GDB?
本文介绍了如何在GDB中查看类似于数组的指针?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设已定义:int a[100]
键入print a
,则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屋!
查看全文