Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: gdb-patches@sourceware.org, tromey@redhat.com
Cc: brobecker@adacore.com
Subject: [rfa] Fix Python lazy strings on Cell
Date: Thu, 04 Mar 2010 20:02:00 -0000	[thread overview]
Message-ID: <201003042002.o24K2HEC013662@d12av02.megacenter.de.ibm.com> (raw)

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


             reply	other threads:[~2010-03-04 20:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-04 20:02 Ulrich Weigand [this message]
2010-03-05 16:01 ` Tom Tromey
2010-03-05 19:34   ` Ulrich Weigand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201003042002.o24K2HEC013662@d12av02.megacenter.de.ibm.com \
    --to=uweigand@de.ibm.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox