This is the mail archive of the gdb-cvs@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]

[binutils-gdb] Fix gdb.Value->python conversion for large unsigned ints.


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=33fa2c6e1b1e63599156f7d79de8c0a6ea69c8af

commit 33fa2c6e1b1e63599156f7d79de8c0a6ea69c8af
Author: Doug Evans <dje@google.com>
Date:   Thu Oct 6 10:41:27 2016 -0700

    Fix gdb.Value->python conversion for large unsigned ints.
    
    gdb/ChangeLog:
    
    	* python/py-value.c (valpy_long): Handle unsigned values.
    
    gdb/testsuite/ChangeLog:
    
    	* gdb.python/py-value.exp (test_value_creation): Add test for large
    	unsigned 64-bit value.

Diff:
---
 gdb/ChangeLog                         | 4 ++++
 gdb/python/py-value.c                 | 5 ++++-
 gdb/testsuite/ChangeLog               | 5 +++++
 gdb/testsuite/gdb.python/py-value.exp | 5 +++++
 4 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b60b3e6..502d3de 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2016-10-06  Doug Evans  <dje@google.com>
+
+	* python/py-value.c (valpy_long): Handle unsigned values.
+
 2016-10-06  Simon Marchi  <simon.marchi@ericsson.com>
 
 	* frame.h: Forward-declare struct ui_out.
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index b0d3df3..46683b8 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/ChangeLog b/gdb/testsuite/ChangeLog
index 7157544..4722c34 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-10-06  Doug Evans  <dje@google.com>
+
+	* gdb.python/py-value.exp (test_value_creation): Add test for large
+	unsigned 64-bit value.
+
 2016-10-06  Tom Tromey  <tom@tromey.com>
 
 	* gdb.compile/compile.exp: Change java tests to rust.
diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp
index 57a9ba1..662c5b4 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"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]