diff options
author | Tom Tromey <tromey@adacore.com> | 2020-04-24 13:40:31 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2020-04-24 13:40:33 -0600 |
commit | 1acda8039ba681e88416a7da6a6e3abdcae6b86b (patch) | |
tree | 4ca5562817e90e1a657fc47eced4369a0c75b342 /gdb/doc | |
parent | adfb981595c1ea12736b6d3c4686973040f171ff (diff) | |
download | gdb-1acda8039ba681e88416a7da6a6e3abdcae6b86b.zip gdb-1acda8039ba681e88416a7da6a6e3abdcae6b86b.tar.gz gdb-1acda8039ba681e88416a7da6a6e3abdcae6b86b.tar.bz2 |
Add Python support for dynamic types
This changes the gdb Python API to add support for dynamic types. In
particular, this adds an attribute to gdb.Type, and updates some
attributes to reflect dynamic sizes and field offsets.
There's still no way to get the dynamic type from one of its concrete
instances. This could perhaps be added if needed.
gdb/ChangeLog
2020-04-24 Tom Tromey <tromey@adacore.com>
PR python/23662:
* python/py-type.c (convert_field): Handle
FIELD_LOC_KIND_DWARF_BLOCK.
(typy_get_sizeof): Handle TYPE_HAS_DYNAMIC_LENGTH.
(typy_get_dynamic): Nw function.
(type_object_getset): Add "dynamic".
* NEWS: Add entry.
gdb/doc/ChangeLog
2020-04-24 Tom Tromey <tromey@adacore.com>
PR python/23662:
* python.texi (Types In Python): Document new features.
gdb/testsuite/ChangeLog
2020-04-24 Tom Tromey <tromey@adacore.com>
PR python/23662:
* gdb.ada/variant.exp: Add Python checks.
* gdb.rust/simple.exp: Add dynamic type checks.
Diffstat (limited to 'gdb/doc')
-rw-r--r-- | gdb/doc/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/doc/python.texi | 14 |
2 files changed, 17 insertions, 2 deletions
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 0dc6476..7073c17 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,8 @@ +2020-04-24 Tom Tromey <tromey@adacore.com> + + PR python/23662: + * python.texi (Types In Python): Document new features. + 2020-04-15 Artur Shepilko <nomadbyte@gmail.com> * gdb.texinfo: Transform @var{[host]} to [@var{host}]; this diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi index 31e8995..cfa8131 100644 --- a/gdb/doc/python.texi +++ b/gdb/doc/python.texi @@ -1068,6 +1068,12 @@ The type code for this type. The type code will be one of the @code{TYPE_CODE_} constants defined below. @end defvar +@defvar Type.dynamic +A boolean indicating whether this type is dynamic. In some +situations, such as Rust @code{enum} types or Ada variant records, the +concrete type of a value may vary depending on its contents. +@end defvar + @defvar Type.name The name of this type. If this type has no name, then @code{None} is returned. @@ -1076,7 +1082,9 @@ is returned. @defvar Type.sizeof The size of this type, in target @code{char} units. Usually, a target's @code{char} type will be an 8-bit byte. However, on some -unusual platforms, this type may have a different size. +unusual platforms, this type may have a different size. A dynamic +type may not have a fixed size; in this case, this attribute's value +will be @code{None}. @end defvar @defvar Type.tag @@ -1106,7 +1114,9 @@ Each field is a @code{gdb.Field} object, with some pre-defined attributes: @item bitpos This attribute is not available for @code{enum} or @code{static} (as in C@t{++}) fields. The value is the position, counting -in bits, from the start of the containing type. +in bits, from the start of the containing type. Note that, in a +dynamic type, the position of a field may not be constant. In this +case, the value will be @code{None}. @item enumval This attribute is only available for @code{enum} fields, and its value |