Bug 20126

Summary: valpy_int needs to respect unsignedness
Product: gdb Reporter: dje
Component: pythonAssignee: Tom Tromey <tromey>
Severity: normal CC: markflorisson88, tromey
Priority: P2    
Version: unknown   
Target Milestone: 8.3   
Host: Target:
Build: Last reconfirmed:

Description dje 2016-05-20 16:27:05 UTC
I was trying to figure out why

(gdb) py print "%x" % (gdb.parse_and_eval("0xffffffff12345678"))

was coming out negative


and traced it to valpy_int not respecting unsignedness.

I see valpy_long DTRT. I guess valpy_int didn't get similarly updated.
Comment 1 Tom Tromey 2018-09-15 05:23:12 UTC
*** Bug 12267 has been marked as a duplicate of this bug. ***
Comment 2 Sourceware Commits 2018-09-24 05:16:55 UTC
The master branch has been updated by Tom Tromey <tromey@sourceware.org>:


commit 1c1e54f6b4b6de83aa3f31e6584f5bb4d6242930
Author: Tom Tromey <tom@tromey.com>
Date:   Fri Sep 14 22:44:10 2018 -0600

    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.
    2018-09-23  Tom Tromey  <tom@tromey.com>
    	PR python/20126:
    	* python/py-value.c (valpy_int): Respect type sign.
    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.
Comment 3 Tom Tromey 2018-09-24 05:17:44 UTC