summaryrefslogtreecommitdiff
path: root/gdb/doc
diff options
context:
space:
mode:
authorChristian Biesinger <cbiesinger@google.com>2019-08-01 17:22:28 -0500
committerChristian Biesinger <cbiesinger@google.com>2019-08-05 13:06:18 -0500
commit0b27c27d0d3060171876736f05c39f9c86a65d3e (patch)
treee9ea50193b9ee06ba7468ee9bce4440343286c51 /gdb/doc
parent4ee94178afbe062bc244d28595f86d63633a7af7 (diff)
downloadbinutils-gdb-0b27c27d0d3060171876736f05c39f9c86a65d3e.tar.gz
Add block['var'] accessor
Currently we support iteration on blocks; this patch extends that to make subscript access work as well. gdb/ChangeLog: 2019-08-05 Christian Biesinger <cbiesinger@google.com> * NEWS: Mention dictionary access on blocks. * python/py-block.c (blpy_getitem): New function. (block_object_as_mapping): New struct. (block_object_type): Use new struct for tp_as_mapping field. gdb/doc/ChangeLog: 2019-08-05 Christian Biesinger <cbiesinger@google.com> * python.texi (Blocks In Python): Document dictionary access on blocks. gdb/testsuite/ChangeLog: 2019-08-05 Christian Biesinger <cbiesinger@google.com> * gdb.python/py-block.exp: Test dictionary access on blocks.
Diffstat (limited to 'gdb/doc')
-rw-r--r--gdb/doc/ChangeLog4
-rw-r--r--gdb/doc/python.texi7
2 files changed, 10 insertions, 1 deletions
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index 95fd22cddd0..6faf5f359d6 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,7 @@
+2019-08-05 Christian Biesinger <cbiesinger@google.com>
+
+ * python.texi (Blocks In Python): Document dictionary access on blocks.
+
2019-08-03 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.texinfo (Symbols): Document new args -dirname and -basename
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index 3fdccd5e435..832283dede8 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -4722,7 +4722,12 @@ A @code{gdb.Block} is iterable. The iterator returns the symbols
should not assume that a specific block object will always contain a
given symbol, since changes in @value{GDBN} features and
infrastructure may cause symbols move across blocks in a symbol
-table.
+table. You can also use Python's @dfn{dictionary syntax} to access
+variables in this block, e.g.:
+
+@smallexample
+symbol = some_block['variable'] # symbol is of type gdb.Symbol
+@end smallexample
The following block-related functions are available in the @code{gdb}
module: