diff options
author | Tom Tromey <tom@tromey.com> | 2018-09-14 22:44:10 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2018-09-23 23:13:00 -0600 |
commit | 1c1e54f6b4b6de83aa3f31e6584f5bb4d6242930 (patch) | |
tree | cde34c7cdebc1d3920ed01609362978d43c47b11 /gdb/python | |
parent | fb4fa9469c5f5d87a956d45ed3b36fecc1fc31b9 (diff) | |
download | binutils-gdb-1c1e54f6b4b6de83aa3f31e6584f5bb4d6242930.tar.gz |
Preserve sign when converting gdb.Value to Python int
PR python/20126 points out that sometimes the conversion of a
gdb.Value can result in a negative Python integer. This happens
because valpy_int does not examine the signedness of the value's type.
gdb/ChangeLog
2018-09-23 Tom Tromey <tom@tromey.com>
PR python/20126:
* python/py-value.c (valpy_int): Respect type sign.
gdb/testsuite/ChangeLog
2018-09-23 Tom Tromey <tom@tromey.com>
PR python/20126:
* gdb.python/py-value.exp (test_value_numeric_ops): Add
signed-ness conversion tests.
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/py-value.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index 9abcf9212e6..5c6792f85fc 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -1514,7 +1514,10 @@ valpy_int (PyObject *self) } END_CATCH - return gdb_py_object_from_longest (l); + if (TYPE_UNSIGNED (type)) + return gdb_py_object_from_ulongest (l); + else + return gdb_py_object_from_longest (l); } #endif |