public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix gdb.Value->python conversion for large unsigned ints
@ 2016-03-30  6:57 Doug Evans
  2016-10-04 14:40 ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Doug Evans @ 2016-03-30  6:57 UTC (permalink / raw)
  To: gdb-patches

Hi.

I was seeing this in gdb:

(gdb) py print long(gdb.Value(18446744071563607160))
-2145944456

whereas with plain python:

(gdb) py print long(18446744071563607160)
18446744071563607160

2016-03-29  Doug Evans  <dje@google.com>

	* python/py-value.c (valpy_long): Handle unsigned values.

	testsuite/
	* gdb.python/py-value.exp (test_value_creation): Add test for large
	unsigned 64-bit value.

diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index 7dba0ad..09e8055 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -1518,7 +1518,10 @@ valpy_long (PyObject *self)
      }
    END_CATCH

-  return gdb_py_long_from_longest (l);
+  if (TYPE_UNSIGNED (type))
+    return gdb_py_long_from_ulongest (l);
+  else
+    return gdb_py_long_from_longest (l);
  }

  /* Implements conversion to float.  */
diff --git a/gdb/testsuite/gdb.python/py-value.exp  
b/gdb/testsuite/gdb.python/py-value.exp
index a9dbe97..ca2dc08 100644
--- a/gdb/testsuite/gdb.python/py-value.exp
+++ b/gdb/testsuite/gdb.python/py-value.exp
@@ -54,10 +54,15 @@ proc test_value_creation {} {
    if { $gdb_py_is_py3k == 0 } {
      gdb_py_test_silent_cmd "python i = gdb.Value (5L)" "create long value"  
1
    }
+
+  gdb_py_test_silent_cmd "python l =  
gdb.Value(0xffffffff12345678)" "create large unsigned 64-bit value" 1
+  gdb_test "python print long(l)" "18446744069720004216" "large unsigned  
64-bit int conversion to python"
+
    gdb_py_test_silent_cmd "python f = gdb.Value (1.25)" "create double  
value" 1
    gdb_py_test_silent_cmd "python a = gdb.Value ('string test')" "create  
8-bit string value" 1
    gdb_test "python print (a)" "\"string test\"" "print 8-bit string"
    gdb_test "python print (a.__class__)" "<(type| 
class) 'gdb.Value'>" "verify type of 8-bit string"
+
    if { $gdb_py_is_py3k == 0 } {
      gdb_py_test_silent_cmd "python a = gdb.Value (u'unicode  
test')" "create unicode value" 1
      gdb_test "python print (a)" "\"unicode test\"" "print Unicode string"

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix gdb.Value->python conversion for large unsigned ints
  2016-03-30  6:57 [PATCH] Fix gdb.Value->python conversion for large unsigned ints Doug Evans
@ 2016-10-04 14:40 ` Pedro Alves
  2016-10-06 17:51   ` Doug Evans
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2016-10-04 14:40 UTC (permalink / raw)
  To: Doug Evans, gdb-patches

Hi Doug,

On 03/30/2016 07:57 AM, Doug Evans wrote:
> Hi.
> 
> I was seeing this in gdb:
> 
> (gdb) py print long(gdb.Value(18446744071563607160))
> -2145944456
> 
> whereas with plain python:
> 
> (gdb) py print long(18446744071563607160)
> 18446744071563607160
> 

Looks like this fell through the cracks?

LGTM.

> 2016-03-29  Doug Evans  <dje@google.com>
> 
>     * python/py-value.c (valpy_long): Handle unsigned values.
> 
>     testsuite/
>     * gdb.python/py-value.exp (test_value_creation): Add test for large
>     unsigned 64-bit value.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix gdb.Value->python conversion for large unsigned ints
  2016-10-04 14:40 ` Pedro Alves
@ 2016-10-06 17:51   ` Doug Evans
  0 siblings, 0 replies; 3+ messages in thread
From: Doug Evans @ 2016-10-06 17:51 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

[sorry for the resend ...
We've got gdb to use c++ now. Yay.
Can we maybe someday get the list to not bounce text/html?]

On Tue, Oct 4, 2016 at 7:40 AM, Pedro Alves <palves@redhat.com> wrote:
> Hi Doug,
>
> On 03/30/2016 07:57 AM, Doug Evans wrote:
>> Hi.
>>
>> I was seeing this in gdb:
>>
>> (gdb) py print long(gdb.Value(18446744071563607160))
>> -2145944456
>>
>> whereas with plain python:
>>
>> (gdb) py print long(18446744071563607160)
>> 18446744071563607160
>>
>
> Looks like this fell through the cracks?
>
> LGTM.
>
>> 2016-03-29  Doug Evans  <dje@google.com>
>>
>>     * python/py-value.c (valpy_long): Handle unsigned values.
>>
>>     testsuite/
>>     * gdb.python/py-value.exp (test_value_creation): Add test for large
>>     unsigned 64-bit value.
>
> Thanks,
> Pedro Alves
>

Thanks!
I usually do an audit of email sent to gdb-patches every few months.
Totally missed this one (and potentially others - a distracting year
for many reasons -
I'll go through and try to find if there's any more).

Committed.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-10-06 17:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-30  6:57 [PATCH] Fix gdb.Value->python conversion for large unsigned ints Doug Evans
2016-10-04 14:40 ` Pedro Alves
2016-10-06 17:51   ` Doug Evans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).