如何告诉 gdb 我的零长度数组有多长?
有点矛盾的标题! Xcode 答案的加分,但这是一个 gdb 问题。
如果我有一个标准的、静态大小的数组,gdb 将打印它的所有元素 [并且 Xcode 将让我浏览它],但是如果我有一个 零长度数组,它不会,因为它不知道。显然我可以一一打印数组索引,但我想要整个内容的转储。
我如何告诉 gdb 我为数组分配了多少空间以允许它打印数组(或允许 Xcode 查看数组)。有可能吗?
Slightly oxymoronic title! Bonus points for Xcode answer but it's a gdb question.
If I have a standard, statically sized array gdb will print all its elements [and Xcode will let me browse through it] but if I have a zero length array, it won't, because it doesn't know. Obviously I can print the array indexes one by one, but I'd like a dump of the whole thing.
How do I tell gdb how much space I have allocated for the array to allow it to print the array (or to allow Xcode to view the array). Is it even possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
http://www.chemie.fu-berlin .de/chemnet/use/info/gdb/gdb_9.html#SEC54
讨论“人工阵列”
http://www.chemie.fu-berlin.de/chemnet/use/info/gdb/gdb_9.html#SEC54
Discusses "Artificial arrays"
如果
s->a
的类型为char [0]
(这是一个 gcc 扩展),但你知道它实际上是一个 100 的数组,你可以在gdb
打印它:If
s->a
has typechar [0]
(which is a gcc extension), but you know it is really an array of 100, you can use casts ingdb
to print it:请参阅
10.4 人工数组
:See
10.4 Artificial Arrays
: