aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2020-04-27 08:23:53 -0600
committerTom Tromey <tromey@adacore.com>2020-04-27 08:28:16 -0600
commit45fc7c9968485f5ee0532a14fad211372e12f837 (patch)
tree05eba1d5fb4e78ab7d945dc6d8cd1413f6d8c46e
parentff8885c3be6f42ed90a7b0ec0028fad26861cd94 (diff)
downloadgdb-45fc7c9968485f5ee0532a14fad211372e12f837.zip
gdb-45fc7c9968485f5ee0532a14fad211372e12f837.tar.gz
gdb-45fc7c9968485f5ee0532a14fad211372e12f837.tar.bz2
Expand dynamic type documentation
This expands the Python dynamic type documentation, as suggested by Christian. gdb/doc/ChangeLog 2020-04-27 Tom Tromey <tromey@adacore.com> * python.texi (Types In Python): Mention missing fields. Add dynamic type example.
-rw-r--r--gdb/doc/ChangeLog5
-rw-r--r--gdb/doc/python.texi22
2 files changed, 25 insertions, 2 deletions
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index 7073c17..305f2d5 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,8 @@
+2020-04-27 Tom Tromey <tromey@adacore.com>
+
+ * python.texi (Types In Python): Mention missing fields. Add
+ dynamic type example.
+
2020-04-24 Tom Tromey <tromey@adacore.com>
PR python/23662:
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index cfa8131..3b1ccb4 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -1071,7 +1071,24 @@ The type code for this type. The type code will be one of the
@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.
+concrete type of a value may vary depending on its contents. That is,
+the declared type of a variable, or the type returned by
+@code{gdb.lookup_type} may be dynamic; while the type of the
+variable's value will be a concrete instance of that dynamic type.
+
+For example, consider this code:
+@smallexample
+int n;
+int array[n];
+@end smallexample
+
+Here, at least conceptually (whether your compiler actually does this
+is a separate issue), examining @w{@code{gdb.lookup_symbol("array", ...).type}}
+could yield a @code{gdb.Type} which reports a size of @code{None}.
+This is the dynamic type.
+
+However, examining @code{gdb.parse_and_eval("array").type} would yield
+a concrete type, whose length would be known.
@end defvar
@defvar Type.name
@@ -1116,7 +1133,8 @@ 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. Note that, in a
dynamic type, the position of a field may not be constant. In this
-case, the value will be @code{None}.
+case, the value will be @code{None}. Also, a dynamic type may have
+fields that do not appear in a corresponding concrete type.
@item enumval
This attribute is only available for @code{enum} fields, and its value