From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 130651 invoked by alias); 28 Oct 2017 17:46:49 -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 130627 invoked by uid 89); 28 Oct 2017 17:46:46 -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= 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 17:46:44 +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 v9SHkbvL022529 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 28 Oct 2017 13:46:42 -0400 Received: by simark.ca (Postfix, from userid 112) id 9E89E1E533; Sat, 28 Oct 2017 13:46:37 -0400 (EDT) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id 563B51E4F2; Sat, 28 Oct 2017 13:46:26 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Sat, 28 Oct 2017 17:46:00 -0000 From: Simon Marchi To: Maksim Dzabraev Cc: gdb-patches@sourceware.org, tom@tromney.com Subject: Re: [PATCH] fix bug PR 21213 and add test case In-Reply-To: <20171028171856.3540-1-dzabraew@gmail.com> References: <20171028171856.3540-1-dzabraew@gmail.com> Message-ID: <3eb05df3adcb9b7657411e29c9ecbc3e@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 17:46:37 +0000 X-IsSubscribed: yes X-SW-Source: 2017-10/txt/msg00867.txt.bz2 Hi Maksim, Thanks for the update. Your patch would need a more descriptive name than just the PR number. I suggest "Make gdb.selected_thread().inferior return a new reference". It would also need a summary in the commit log. What you had in your original email was good, and you can also mention that the thpy_get_inferior function should return a new reference to the existing inferior object, and therefore should increment its refcount. On 2017-10-28 13:18, Maksim Dzabraev wrote: > --- > gdb/ChangeLog | 7 +++++++ > gdb/python/py-infthread.c | 1 + > gdb/testsuite/ChangeLog | 6 ++++++ > gdb/testsuite/gdb.python/py-infthread.exp | 9 +++++++++ > 4 files changed, 23 insertions(+) > > diff --git a/gdb/ChangeLog b/gdb/ChangeLog > index 9fe632985e..160c521c96 100644 > --- a/gdb/ChangeLog > +++ b/gdb/ChangeLog > @@ -1,3 +1,10 @@ > +2017-10-28 Maksim Dzabraev Please use two spaces between each field (between date and name, and between name and email). > + > + 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 Same here. > + > + PR python/21213 > + * gdb.python/py-infthread.exp: Test calling > + InferiorThread.inferior () multiple times in a row. > + > 2017-10-27 Keith Seitz > > * gdb.opt/inline-break.exp (break_info_1): New procedure. > diff --git a/gdb/testsuite/gdb.python/py-infthread.exp > b/gdb/testsuite/gdb.python/py-infthread.exp > index 0711d6994e..69fc9709b2 100644 > --- a/gdb/testsuite/gdb.python/py-infthread.exp > +++ b/gdb/testsuite/gdb.python/py-infthread.exp > @@ -51,6 +51,15 @@ gdb_test "python print(seen_a_thread)" "True" > > # Test basic gdb.Inferior attributes and methods. > > +# Make sure that InferiorThread.inferior returns a new reference (see > PR 21213). > + > +gdb_py_test_silent_cmd "python gdb.selected_thread ().inferior" "test > InferiorThread.inferior 1" 1 > +gdb_py_test_silent_cmd "python gdb.selected_thread ().inferior" "test > InferiorThread.inferior 2" 1 > +gdb_test_no_output "python import gc; gc.collect()" "call Python > garbage collection" > +gdb_py_test_silent_cmd "python gdb.selected_thread ().inferior" "test > InferiorThread.inferior 3" 1 > +gdb_py_test_silent_cmd "python gdb.selected_thread ().inferior" "test > InferiorThread.inferior 4" 1 > + > + > gdb_py_test_silent_cmd "python t0 = gdb.selected_thread ()" "test > gdb.selected_thread" 1 > gdb_test "python print (t0)" "\\ 0x\[\[:xdigit:\]\]+>" "verify InferiorThread object" > gdb_test "python print ('result = %s' % t0.num)" " = 1" "test > InferiorThread.num" Thanks, Simon