diff options
author | Christian Biesinger <cbiesinger@google.com> | 2019-08-01 17:22:28 -0500 |
---|---|---|
committer | Christian Biesinger <cbiesinger@google.com> | 2019-08-05 13:06:18 -0500 |
commit | 0b27c27d0d3060171876736f05c39f9c86a65d3e (patch) | |
tree | e9ea50193b9ee06ba7468ee9bce4440343286c51 /gdb/testsuite | |
parent | 4ee94178afbe062bc244d28595f86d63633a7af7 (diff) | |
download | binutils-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/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-block.exp | 5 |
2 files changed, 9 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 236c0e2442e..1a2cb0be18e 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-08-05 Christian Biesinger <cbiesinger@google.com> + + * gdb.python/py-block.exp: Test dictionary access on blocks. + 2019-08-05 Simon Marchi <simon.marchi@efficios.com> PR gdb/24863 diff --git a/gdb/testsuite/gdb.python/py-block.exp b/gdb/testsuite/gdb.python/py-block.exp index 20d3968c046..6be1abe7ae0 100644 --- a/gdb/testsuite/gdb.python/py-block.exp +++ b/gdb/testsuite/gdb.python/py-block.exp @@ -43,6 +43,11 @@ gdb_test "python print (block)" "<gdb.Block object at $hex>" "check block not No gdb_test "python print (block.function)" "None" "first anonymous block" gdb_test "python print (block.start)" "${decimal}" "check start not None" gdb_test "python print (block.end)" "${decimal}" "check end not None" +gdb_test "python print (block\['f'\].name == 'f')" "True" "check variable access" +gdb_test "python print (block\['nonexistent'\])" ".*KeyError: 'nonexistent'.*" \ + "check nonexistent variable" +gdb_test "python print (block\[42\])" ".*TypeError: Expected a string.*" \ + "check non-string key" # Test global/static blocks gdb_py_test_silent_cmd "python frame = gdb.selected_frame()" "Get Frame" 0 |