代码之家  ›  专栏  ›  技术社区  ›  oz10

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

  •  2
  • oz10  · 技术社区  · 16 年前

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

    1 回复  |  直到 16 年前
        1
  •  9
  •   Marat Mkhitaryan    5 年前

    对:

    (gdb)p

    一些属性可以识别,而其他属性则无法识别。(在下面列出的内容中,find是一个布尔变量。)

    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
    

    这是我们网站上的列表 Ada section

    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,尽管第一个项目符号说它对类型无效。)