diff options
author | Andrew Burgess <aburgess@redhat.com> | 2022-01-24 15:19:43 +0000 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2022-01-26 21:58:12 +0000 |
commit | 30a87e90be195dcce555a0904cc5dbd960349271 (patch) | |
tree | 0d2c98c5a8416afabe6a39e141928b1fb15d0a56 /gdb/testsuite | |
parent | 51d185a65f3679f887d456e20d22475ac8586938 (diff) | |
download | fsf-binutils-gdb-30a87e90be195dcce555a0904cc5dbd960349271.zip fsf-binutils-gdb-30a87e90be195dcce555a0904cc5dbd960349271.tar.gz fsf-binutils-gdb-30a87e90be195dcce555a0904cc5dbd960349271.tar.bz2 |
gdb/python: add gdb.history_count function
Add a new function gdb.history_count to the Python api, this function
returns an integer, the number of items in GDB's value history.
This is useful if you want to pull items from the history by their
absolute number, for example, if you wanted to show a complete history
list. Previously we could figure out how many items are in the
history list by trying to fetch the items, and then catching the
exception when the item is not available, but having this function
seems nicer.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/gdb.python/py-value.exp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp index 9ee3c5f..60039c9 100644 --- a/gdb/testsuite/gdb.python/py-value.exp +++ b/gdb/testsuite/gdb.python/py-value.exp @@ -647,6 +647,17 @@ proc test_value_sub_classes {} { "check printing of MyValue when initiaized with a type" } +# Test the history count. This must be the first thing called after +# starting GDB as it depends on there being nothing in the value +# history. +proc test_history_count {} { + for { set i 0 } { $i < 5 } { incr i } { + gdb_test "python print('history count is %d' % gdb.history_count())" \ + "history count is $i" "history count is $i" + gdb_test "print $i" " = $i" + } +} + # Build C version of executable. C++ is built later. if { [build_inferior "${binfile}" "c"] < 0 } { return -1 @@ -658,6 +669,7 @@ clean_restart ${binfile} # Skip all tests if Python scripting is not enabled. if { [skip_python_tests] } { continue } +test_history_count test_value_creation test_value_reinit test_value_numeric_ops |