在LLDB中查看数组:相当于Xcode 4.1中GDB的“@”运算符 [英] View array in LLDB: equivalent of GDB's '@' operator in Xcode 4.1
问题描述
我想查看指针指向的元素数组。在GDB中,可以使用运算符@作为一个给定长度的人造数组来处理指针记忆,作为
*指针@长度
其中长度
是要查看的元素数量。
上述语法在Xcode 4.1附带的LLDB中不起作用。
有没有办法如何在LLDB中完成上述?
实际上有一个简单的方式来做,通过投射指针指向数组。
例如,如果你有一个 int * ptr
,你想把它看成是一个十个整数的数组,你可以做
p *(int(*)[10]) ptr
由于它仅依赖于标准C功能,因此该方法无需任何插件或特殊设置,与其他调试器(如GDB或CDB)配合使用,尽管后两者具有此类功能的专用语法>
I would like to view an array of elements pointed to by a pointer. In GDB this can be done by treating the pointed memory as an artificial array of a given length using the operator '@' as
*pointer @ length
where length
is the number of elements I want to view.
The above syntax does not work in LLDB supplied with Xcode 4.1.
Is there any way how to accomplish the above in LLDB?
Actually there is a simple way to do it, by casting the pointer to a pointer-to-array.
For example, if you have a int* ptr
, and you want to view it as an array of ten integers, you can do
p *(int(*)[10])ptr
Because it relies only on standard C features, this method works without any plugins or special settings, and works with other debuggers like GDB or CDB, even though the latter two has specialized syntax for such thing.
这篇关于在LLDB中查看数组:相当于Xcode 4.1中GDB的“@”运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!