From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 86161 invoked by alias); 28 Oct 2017 18:21:38 -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 86151 invoked by uid 89); 28 Oct 2017 18:21:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2138 X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 28 Oct 2017 18:21:37 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id v9SILUqk006472 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 28 Oct 2017 14:21:35 -0400 Received: by simark.ca (Postfix, from userid 112) id 5F59D1E533; Sat, 28 Oct 2017 14:21:30 -0400 (EDT) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id 505491E51C; Sat, 28 Oct 2017 14:21:19 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Sat, 28 Oct 2017 18:21:00 -0000 From: Simon Marchi To: Maksim Dzabraev Cc: gdb-patches@sourceware.org, tom@tromey.com Subject: Re: [PATCH] Make gdb.selected_thread().inferior return a new reference In-Reply-To: <20171028181434.3825-1-dzabraew@gmail.com> References: <20171028181434.3825-1-dzabraew@gmail.com> Message-ID: <3d0e1bee1c94daba14d57dc6bbb682dd@polymtl.ca> X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.0 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Sat, 28 Oct 2017 18:21:30 +0000 X-IsSubscribed: yes X-SW-Source: 2017-10/txt/msg00869.txt.bz2 Thanks! I pushed the patch with the following changes: On 2017-10-28 14:14, Maksim Dzabraev wrote: > thpy_get_inferior function should return a new reference to the > existing inferior object, and therefore should increment its refcount. > > Fixed bug lokks like this. lokks -> looks > If multiple time call gdb.selected_thread ().inferior, gdb throws > exception: > (gdb) pi gdb.selected_thread().inferior > > (gdb) pi gdb.selected_thread().inferior > Python Exception 'NoneType' object > has no attribute 'inferior': > Error while executing Python code. > (gdb) info threads > Id Target Id Frame > * 1 Thread 0x7f54f0474740 (LWP 584) "mc" 0x00007f54ef055c33 in > --- > gdb/ChangeLog | 6 ++++++ > gdb/python/py-infthread.c | 1 + > gdb/testsuite/ChangeLog | 6 ++++++ > gdb/testsuite/gdb.python/py-infthread.exp | 9 +++++++++ > 4 files changed, 22 insertions(+) > > diff --git a/gdb/ChangeLog b/gdb/ChangeLog > index 9fe632985e..4583a78fe5 100644 > --- a/gdb/ChangeLog > +++ b/gdb/ChangeLog > @@ -1,3 +1,9 @@ > +2017-10-28 Maksim Dzabraev > + > + PR python/21213 > + * python/py-infthread.c (thpy_get_inferior): Increment reference > + of inferior before returning it. > + > 2017-10-27 Simon Marchi > > * unittests/common-utils-selftests.c (format): Add > diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c > index 626c15cedb..31d576f7c7 100644 > --- a/gdb/python/py-infthread.c > +++ b/gdb/python/py-infthread.c > @@ -162,6 +162,7 @@ thpy_get_inferior (PyObject *self, void *ignore) > thread_object *thread_obj = (thread_object *) self; > > THPY_REQUIRE_VALID (thread_obj); > + Py_INCREF (thread_obj->inf_obj); > > return thread_obj->inf_obj; > } > diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog > index 0254a28550..72334fd3e2 100644 > --- a/gdb/testsuite/ChangeLog > +++ b/gdb/testsuite/ChangeLog > @@ -1,3 +1,9 @@ > +2017-10-28 Maksim Dzabraev Used two spaces between fields. Simon