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/python/py-value.c | |
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/python/py-value.c')
-rw-r--r-- | gdb/python/py-value.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index c1ff8e8..a6afcad 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -617,6 +617,7 @@ valpy_format_string (PyObject *self, PyObject *args, PyObject *kw) "array_indexes", /* See set print array-indexes on|off. */ "symbols", /* See set print symbol on|off. */ "unions", /* See set print union on|off. */ + "address", /* See set print address on|off. */ /* C++ options. */ "deref_refs", /* No corresponding setting. */ "actual_objects", /* See set print object on|off. */ @@ -660,13 +661,14 @@ valpy_format_string (PyObject *self, PyObject *args, PyObject *kw) PyObject *array_indexes_obj = NULL; PyObject *symbols_obj = NULL; PyObject *unions_obj = NULL; + PyObject *address_obj = NULL; PyObject *deref_refs_obj = NULL; PyObject *actual_objects_obj = NULL; PyObject *static_members_obj = NULL; char *format = NULL; if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, - "|O!O!O!O!O!O!O!O!O!IIIs", + "|O!O!O!O!O!O!O!O!O!O!IIIs", keywords, &PyBool_Type, &raw_obj, &PyBool_Type, &pretty_arrays_obj, @@ -674,6 +676,7 @@ valpy_format_string (PyObject *self, PyObject *args, PyObject *kw) &PyBool_Type, &array_indexes_obj, &PyBool_Type, &symbols_obj, &PyBool_Type, &unions_obj, + &PyBool_Type, &address_obj, &PyBool_Type, &deref_refs_obj, &PyBool_Type, &actual_objects_obj, &PyBool_Type, &static_members_obj, @@ -696,6 +699,8 @@ valpy_format_string (PyObject *self, PyObject *args, PyObject *kw) return NULL; if (!copy_py_bool_obj (&opts.unionprint, unions_obj)) return NULL; + if (!copy_py_bool_obj (&opts.addressprint, address_obj)) + return NULL; if (!copy_py_bool_obj (&opts.deref_ref, deref_refs_obj)) return NULL; if (!copy_py_bool_obj (&opts.objectprint, actual_objects_obj)) |