* [rfa] Fix Python lazy strings on Cell
@ 2010-03-04 20:02 Ulrich Weigand
2010-03-05 16:01 ` Tom Tromey
0 siblings, 1 reply; 3+ messages in thread
From: Ulrich Weigand @ 2010-03-04 20:02 UTC (permalink / raw)
To: gdb-patches, tromey; +Cc: brobecker
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
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [rfa] Fix Python lazy strings on Cell
2010-03-04 20:02 [rfa] Fix Python lazy strings on Cell Ulrich Weigand
@ 2010-03-05 16:01 ` Tom Tromey
2010-03-05 19:34 ` Ulrich Weigand
0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2010-03-05 16:01 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gdb-patches, brobecker
>>>>> "Ulrich" == Ulrich Weigand <uweigand@de.ibm.com> writes:
Ulrich> It seems to be that gdbpy_extract_lazy_string should likewise extract
Ulrich> address values as unsigned, using PyLong_AsUnsignedLongLong, to make
Ulrich> sure to get the same CORE_ADDR value back.
This looks good to me, thanks.
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [rfa] Fix Python lazy strings on Cell
2010-03-05 16:01 ` Tom Tromey
@ 2010-03-05 19:34 ` Ulrich Weigand
0 siblings, 0 replies; 3+ messages in thread
From: Ulrich Weigand @ 2010-03-05 19:34 UTC (permalink / raw)
To: tromey; +Cc: gdb-patches, brobecker
Tom Tromey wrote:
> >>>>> "Ulrich" == Ulrich Weigand <uweigand@de.ibm.com> writes:
>
> Ulrich> It seems to be that gdbpy_extract_lazy_string should likewise extract
> Ulrich> address values as unsigned, using PyLong_AsUnsignedLongLong, to make
> Ulrich> sure to get the same CORE_ADDR value back.
>
> This looks good to me, thanks.
OK, I've checked this in to head and 7.1 branch.
Thanks,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-03-05 19:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-04 20:02 [rfa] Fix Python lazy strings on Cell Ulrich Weigand
2010-03-05 16:01 ` Tom Tromey
2010-03-05 19:34 ` Ulrich Weigand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox