diff options
author | Hannes Domani <ssbssa@yahoo.de> | 2020-12-18 17:23:06 +0100 |
---|---|---|
committer | Hannes Domani <ssbssa@yahoo.de> | 2020-12-18 22:04:16 +0100 |
commit | 4aea001fd84a05f1e552c5dea1025e3f62dd2d7e (patch) | |
tree | 27ae942e59baf13662d1cf7217f511d407f297d3 /gdb/testsuite/gdb.python/py-format-string.exp | |
parent | b3f9469bfa42ef352e1d96f8733817242dd41a2e (diff) | |
download | binutils-4aea001fd84a05f1e552c5dea1025e3f62dd2d7e.zip binutils-4aea001fd84a05f1e552c5dea1025e3f62dd2d7e.tar.gz binutils-4aea001fd84a05f1e552c5dea1025e3f62dd2d7e.tar.bz2 |
Add address keyword to Value.format_string
This makes it possible to disable the address in the result string:
const char *str = "alpha";
(gdb) py print(gdb.parse_and_eval("str").format_string())
0x404000 "alpha"
(gdb) py print(gdb.parse_and_eval("str").format_string(address=False))
"alpha"
gdb/ChangeLog:
2020-12-18 Hannes Domani <ssbssa@yahoo.de>
* python/py-value.c (valpy_format_string): Implement address keyword.
gdb/doc/ChangeLog:
2020-12-18 Hannes Domani <ssbssa@yahoo.de>
* python.texi (Values From Inferior): Document the address keyword.
gdb/testsuite/ChangeLog:
2020-12-18 Hannes Domani <ssbssa@yahoo.de>
* gdb.python/py-format-string.exp: Add tests for address keyword.
Diffstat (limited to 'gdb/testsuite/gdb.python/py-format-string.exp')
-rw-r--r-- | gdb/testsuite/gdb.python/py-format-string.exp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.python/py-format-string.exp b/gdb/testsuite/gdb.python/py-format-string.exp index b7acc24..f4eaad0 100644 --- a/gdb/testsuite/gdb.python/py-format-string.exp +++ b/gdb/testsuite/gdb.python/py-format-string.exp @@ -487,6 +487,48 @@ proc test_unions {} { } } +# Test the address option for gdb.Value.format_string. +proc test_address {} { + global undefined + global current_lang + + check_var_with_bool_opt "address" "a_point_t" + check_var_with_bool_opt "address" "a_point_t_pointer" \ + $undefined \ + "" + check_var_with_bool_opt "address" "another_point" + check_var_with_bool_opt "symbols" "a_struct_with_union" + check_var_with_bool_opt "address" "an_enum" + check_var_with_bool_opt "address" "a_string" \ + $undefined \ + "\"hello world\"" + check_var_with_bool_opt "address" "a_binary_string" \ + $undefined \ + "\"hello\"" + check_var_with_bool_opt "address" "a_binary_string_array" + check_var_with_bool_opt "address" "a_big_string" + check_var_with_bool_opt "address" "an_array" + check_var_with_bool_opt "address" "an_array_with_repetition" + check_var_with_bool_opt "address" "a_symbol_pointer" \ + $undefined \ + "<global_symbol>" + + if { $current_lang == "c++" } { + check_var_with_bool_opt "address" "a_point_t_ref" + check_var_with_bool_opt "address" "a_base_ref" \ + $undefined \ + "" + } + + with_temp_option "set print address off" "set print address on" { + check_var_with_no_opts "a_string" \ + "\"hello world\"" + check_var_with_bool_opt "address" "a_string" \ + $undefined \ + "\"hello world\"" + } +} + # Test the deref_refs option for gdb.Value.format_string. proc test_deref_refs {} { global current_lang @@ -943,6 +985,7 @@ proc test_all_common {} { test_array_indexes test_symbols test_unions + test_address test_deref_refs test_actual_objects test_static_members |