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.
This commit is contained in:
Hannes Domani 2020-12-18 17:23:06 +01:00
parent b3f9469bfa
commit 4aea001fd8
6 changed files with 66 additions and 1 deletions

View file

@ -906,6 +906,11 @@ corresponding symbol name (if one exists), @code{False} if it shouldn't
should be expanded, @code{False} if they shouldn't (see @code{set print
union} in @ref{Print Settings}).
@item address
@code{True} if the string representation of a pointer should include the
address, @code{False} if it shouldn't (see @code{set print address} in
@ref{Print Settings}).
@item deref_refs
@code{True} if C@t{++} references should be resolved to the value they
refer to, @code{False} (the default) if they shouldn't. Note that, unlike