This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On 20/09/16 14:26 +0100, Jonathan Wakely wrote:
This is my attempt to implement the // operator on gdb.Value objects. There is already BINOP_INTDIV which works fine for integral types, but for floats I use BINOP_DIV and then call floor() on the result. This doesn't support decimal floats though. Is this a reasonable solution? Is the test sufficient? I have a follow-up patch which changes the meaning of the / operator for gdb.Value when built against Python 3, to be consistent with Python (see comment 1 in the Bugzilla PR) but I expect that to be more controversial :-)
Here's the follow-up, which I'm only posting for curiosity value. It's a bit of a hack, possibly buggy, and needs more thought about whether this is even a good idea. From: Jonathan Wakely <jwakely@redhat.com> Date: Tue, 20 Sep 2016 14:32:50 +0100 Subject: [PATCH] gdb: Make gdb.Value division consistent with Python In Python 3.x dividing integers does not perform integer division, so make gdb.Value behave the same way when built with Python 3.x or later. gdb/ChangeLog: 2016-09-20 Jonathan Wakely <jwakely@redhat.com> PR python/20624 * python/py-value.c (valpy_binop_throw) [PY_MAJOR_VERSION >= 3]: Convert integers to double for VALPY_DIV to perform exact division. gdb/testsuite/ChangeLog: 2016-09-20 Jonathan Wakely <jwakely@redhat.com> PR python/20624 * gdb.python/py-value.exp: Adjust expected value for dividing two integers.
Attachment:
truediv.txt
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |