如何在 GDB 中打印类型属性?

发布于 2024-07-18 02:19:59 字数 43 浏览 5 评论 0原文

有没有办法从 GDB 内部打印类型属性?
例如整数的大小。

Is there a way to print a type attribute from inside GDB?
E.g. Integer'Size.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

木落 2024-07-25 02:19:59

是:

(gdb) p thing'attribute

某些属性可以被识别,而另一些属性则不能。 (在下面列出的内容中,Found 是一个布尔变量。)

gdb) p integer'size
Attempt to use a type name as an expression
(gdb) p found'size
$2 = 8
(gdb) p integer'first
$3 = -2147483648
(gdb) p integer'last
$4 = 2147483647

以下是 使用 gdb 进行调试的 Ada 部分:(

Only a subset of the attributes are supported:
 
     * 'First, 'Last, and 'Length on array objects (not on types and subtypes).
     * 'Min and 'Max.
     * 'Pos and 'Val.
     * 'Tag.
     * 'Range on array objects (not subtypes), but only as the right operand of the membership (in) operator.
     * 'Access, 'Unchecked_Access, and 'Unrestricted_Access (a GNAT extension).
     * 'Address.

嗯,该列表可能已过时,因为我可以执行 Integer'Last,尽管第一个项目符号表示它对类型无效。 )

Yes:

(gdb) p thing'attribute

Some attributes are recognized, and others aren't. (In what's listed below, Found is a Boolean variable.)

gdb) p integer'size
Attempt to use a type name as an expression
(gdb) p found'size
$2 = 8
(gdb) p integer'first
$3 = -2147483648
(gdb) p integer'last
$4 = 2147483647

Here's the list from the Ada section of Debugging with gdb:

Only a subset of the attributes are supported:
 
     * 'First, 'Last, and 'Length on array objects (not on types and subtypes).
     * 'Min and 'Max.
     * 'Pos and 'Val.
     * 'Tag.
     * 'Range on array objects (not subtypes), but only as the right operand of the membership (in) operator.
     * 'Access, 'Unchecked_Access, and 'Unrestricted_Access (a GNAT extension).
     * 'Address.

(Hmm, that list may be dated, since I could do Integer'Last, despite the first bullet saying that it's not valid on types.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文