From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32731 invoked by alias); 4 Mar 2010 20:02:26 -0000 Received: (qmail 32619 invoked by uid 22791); 4 Mar 2010 20:02:25 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,MSGID_FROM_MTA_HEADER X-Spam-Check-By: sourceware.org Received: from mtagate2.de.ibm.com (HELO mtagate2.de.ibm.com) (195.212.17.162) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 04 Mar 2010 20:02:21 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate2.de.ibm.com (8.13.1/8.13.1) with ESMTP id o24K2JFu003007 for ; Thu, 4 Mar 2010 20:02:19 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o24K2Jgl1335336 for ; Thu, 4 Mar 2010 21:02:19 +0100 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id o24K2IF8013976 for ; Thu, 4 Mar 2010 21:02:19 +0100 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with SMTP id o24K2HEC013662; Thu, 4 Mar 2010 21:02:17 +0100 Message-Id: <201003042002.o24K2HEC013662@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Thu, 04 Mar 2010 21:02:17 +0100 Subject: [rfa] Fix Python lazy strings on Cell To: gdb-patches@sourceware.org, tromey@redhat.com Date: Thu, 04 Mar 2010 20:02:00 -0000 From: "Ulrich Weigand" Cc: brobecker@adacore.com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-03/txt/msg00211.txt.bz2 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