From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31209 invoked by alias); 19 Apr 2013 14:28:18 -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 31200 invoked by uid 89); 19 Apr 2013 14:28:17 -0000 X-Spam-SWARE-Status: No, score=-6.8 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_BJ 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; Fri, 19 Apr 2013 14:28:17 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3JESGWH030226 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 19 Apr 2013 10:28:16 -0400 Received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r3JESDjT024173 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Fri, 19 Apr 2013 10:28:14 -0400 To: gdb-patches@sourceware.org Subject: Re: [0/27] RFC: fix reports from the CPython checker References: <87ehe638ww.fsf@fleche.redhat.com> From: Tom Tromey Date: Fri, 19 Apr 2013 14:36:00 -0000 In-Reply-To: <87ehe638ww.fsf@fleche.redhat.com> (Tom Tromey's message of "Fri, 19 Apr 2013 08:13:51 -0600") Message-ID: <87vc7i1toi.fsf@fleche.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2013-04/txt/msg00585.txt.bz2 This adds the borrowed-ref attribute from the CPython checker, and then updates the code to use it in various places. This attribute tells the checker that a function returns a borrowed reference. * python/py-threadevent.c (get_event_thread): Use CPYCHECKER_RETURNS_BORROWED_REF. * python/python-internal.h (CPYCHECKER_RETURNS_BORROWED_REF): New define. (pspace_to_pspace_object, objfile_to_objfile_object) (find_thread_object): Use it. --- gdb/python/py-threadevent.c | 3 +++ gdb/python/python-internal.h | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/gdb/python/py-threadevent.c b/gdb/python/py-threadevent.c index 7e13f14..ea9de89 100644 --- a/gdb/python/py-threadevent.c +++ b/gdb/python/py-threadevent.c @@ -24,6 +24,9 @@ This function returns the currently stopped thread in non-stop mode and Py_None otherwise. In each case it returns a borrowed reference. */ +static PyObject *get_event_thread (void) + CPYCHECKER_RETURNS_BORROWED_REF; + static PyObject * get_event_thread (void) { diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index 802dd33..394a148 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -20,6 +20,13 @@ #ifndef GDB_PYTHON_INTERNAL_H #define GDB_PYTHON_INTERNAL_H +#ifdef WITH_CPYCHECKER_RETURNS_BORROWED_REF_ATTRIBUTE +#define CPYCHECKER_RETURNS_BORROWED_REF \ + __attribute__ ((cpychecker_returns_borrowed_ref)) +#else +#define CPYCHECKER_RETURNS_BORROWED_REF +#endif + #ifdef WITH_CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF_ATTRIBUTE #define CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF(ARG) \ __attribute__ ((cpychecker_type_object_for_typedef (ARG))) @@ -263,16 +270,19 @@ PyObject *value_to_value_object (struct value *v); PyObject *type_to_type_object (struct type *); PyObject *frame_info_to_frame_object (struct frame_info *frame); -PyObject *pspace_to_pspace_object (struct program_space *); +PyObject *pspace_to_pspace_object (struct program_space *) + CPYCHECKER_RETURNS_BORROWED_REF; PyObject *pspy_get_printers (PyObject *, void *); -PyObject *objfile_to_objfile_object (struct objfile *); +PyObject *objfile_to_objfile_object (struct objfile *) + CPYCHECKER_RETURNS_BORROWED_REF; PyObject *objfpy_get_printers (PyObject *, void *); PyObject *gdbarch_to_arch_object (struct gdbarch *gdbarch); thread_object *create_thread_object (struct thread_info *tp); -thread_object *find_thread_object (ptid_t ptid); +thread_object *find_thread_object (ptid_t ptid) + CPYCHECKER_RETURNS_BORROWED_REF; PyObject *find_inferior_object (int pid); PyObject *inferior_to_inferior_object (struct inferior *inferior); -- 1.8.1.4