This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[rfa] Fix Python lazy strings on Cell
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: gdb-patches at sourceware dot org, tromey at redhat dot com
- Cc: brobecker at adacore dot com
- Date: Thu, 4 Mar 2010 21:02:17 +0100 (CET)
- Subject: [rfa] Fix Python lazy strings on Cell
Hello,
with current GDB the following test cases fail when built as SPU code and
executed via the combined Cell/B.E. debugger:
FAIL: gdb.python/py-prettyprint.exp: print estring
FAIL: gdb.python/py-prettyprint.exp: print estring
The reason is that in the Cell debugger we get internal 64-bit CORE_ADDR
values with the high bit set. When such addresses are used as part of
a Python "lazy string" object, and then accesses via the "address"
attribute, they get converted via PyLong_FromUnsignedLongLong
(in stpy_get_address) to Python values larger than 2^63.
However, the routine gdbpy_extract_lazy_string then extracts a CORE_ADDR
from such Python values using PyLong_AsLongLong, i.e. as signed values.
This causes an OverflowError, as values larger than 2^63 cannot be
represented.
It seems to be that gdbpy_extract_lazy_string should likewise extract
address values as unsigned, using PyLong_AsUnsignedLongLong, to make
sure to get the same CORE_ADDR value back.
The patch below implements this change, fixing the above test cases.
Tested on Cell/B.E. (PPU and SPU).
OK for mainline and branch?
Bye,
Ulrich
ChangeLog:
* python/py-lazy-string.c (gdbpy_extract_lazy_string): Extract
address as UnsignedLongLong, not LongLong.
Index: gdb/python/py-lazy-string.c
===================================================================
RCS file: /cvs/src/src/gdb/python/py-lazy-string.c,v
retrieving revision 1.1
diff -u -p -r1.1 py-lazy-string.c
--- gdb/python/py-lazy-string.c 14 Jan 2010 08:03:37 -0000 1.1
+++ gdb/python/py-lazy-string.c 4 Mar 2010 18:43:14 -0000
@@ -187,7 +187,7 @@ gdbpy_extract_lazy_string (PyObject *str
goto error;
*length = PyLong_AsLong (py_len);
- addr = PyLong_AsLongLong (py_addr);
+ addr = PyLong_AsUnsignedLongLong (py_addr);
/* If the user supplies Py_None an encoding, set encoding to NULL.
This will trigger the resulting LA_PRINT_CALL to automatically
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com