From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29779 invoked by alias); 21 May 2013 07:58:12 -0000 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 Received: (qmail 29650 invoked by uid 89); 21 May 2013 07:58:10 -0000 X-Spam-SWARE-Status: No, score=-6.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 21 May 2013 07:58:10 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r4L7w8FK029083 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 21 May 2013 03:58:09 -0400 Received: from host2.jankratochvil.net (ovpn-116-16.ams2.redhat.com [10.36.116.16]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r4L7w47q005726 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Tue, 21 May 2013 03:58:07 -0400 Date: Tue, 21 May 2013 07:58:00 -0000 From: Jan Kratochvil To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: [patch] Compilation regression with python-2.6 [Re: [PATCH 24/28] introduce gdb_pymodule_addobject] Message-ID: <20130521075803.GA404@host2.jankratochvil.net> References: <87ehe638ww.fsf@fleche.redhat.com> <8761ziy43f.fsf@fleche.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-2022-jp Content-Disposition: inline In-Reply-To: <8761ziy43f.fsf@fleche.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes X-SW-Source: 2013-05/txt/msg00759.txt.bz2 On Fri, 19 Apr 2013 16:42:12 +0200, Tom Tromey wrote: > --- a/gdb/python/py-utils.c > +++ b/gdb/python/py-utils.c [...] > +int > +gdb_pymodule_addobject (PyObject *module, const char *name, PyObject *object) > +{ > + int result; > + > + Py_INCREF (object); > + result = PyModule_AddObject (module, name, object); > + if (result < 0) > + Py_DECREF (object); > + return result; > +} commit 62234c99e3a311c07838ebaea38198d7f4239d0c Author: Tom Tromey Date: Mon May 20 20:36:18 2013 +0000 CentOS-6.4 x86_64 ./python/py-utils.c: In function ‘gdb_pymodule_addobject’: ./python/py-utils.c:445: error: suggest explicit braces to avoid ambiguous ‘else’ python-devel-2.7.3-13.fc18.x86_64 /usr/include/python2.7/object.h #define Py_DECREF(op) \ do { \ if (_Py_DEC_REFTOTAL _Py_REF_DEBUG_COMMA \ --((PyObject*)(op))->ob_refcnt != 0) \ _Py_CHECK_REFCNT(op) \ else \ _Py_Dealloc((PyObject *)(op)); \ } while (0) python-devel-2.6.6-36.el6.x86_64 /usr/include/python2.6/object.h #define Py_DECREF(op) \ if (_Py_DEC_REFTOTAL _Py_REF_DEBUG_COMMA \ --((PyObject*)(op))->ob_refcnt != 0) \ _Py_CHECK_REFCNT(op) \ else \ _Py_Dealloc((PyObject *)(op)) I will check it in today. Regards, Jan gdb/ 2013-05-21 Jan Kratochvil Workaround Python 2.6. * python/py-utils.c (gdb_pymodule_addobject): Wrap Py_DECREF into a block. diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c index d87eb8c..23fcf3f 100644 --- a/gdb/python/py-utils.c +++ b/gdb/python/py-utils.c @@ -443,6 +443,9 @@ gdb_pymodule_addobject (PyObject *module, const char *name, PyObject *object) Py_INCREF (object); result = PyModule_AddObject (module, name, object); if (result < 0) - Py_DECREF (object); + { + /* Python 2.6 did not wrap Py_DECREF in do { } while (0);. */ + Py_DECREF (object); + } return result; }