如何在 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屋!
查看全文