From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24475 invoked by alias); 7 Aug 2017 20:57:02 -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 24337 invoked by uid 89); 7 Aug 2017 20:57:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: =?ISO-8859-1?Q?No, score=-21.2 required=5.0 tests=AWL,BAYES_00,BODY_8BITS,GARBLED_BODY,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==d0=b0=d0=ba=d1, Hx-languages-length:4154, readers, =d0=b8=d0=bc?= 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; Mon, 07 Aug 2017 20:56:55 +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 v77KumtA015278 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 7 Aug 2017 16:56:53 -0400 Received: by simark.ca (Postfix, from userid 112) id 9E30F1EA1D; Mon, 7 Aug 2017 16:56:48 -0400 (EDT) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id 9C6001E043; Mon, 7 Aug 2017 16:56:37 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Mon, 07 Aug 2017 20:57:00 -0000 From: Simon Marchi To: =?UTF-8?Q?=D0=9C=D0=B0=D0=BA=D1=81=D0=B8=D0=BC_=D0=94=D0=B7=D0=B0?= =?UTF-8?Q?=D0=B1=D1=80=D0=B0=D0=B5=D0=B2?= Cc: gdb-patches@sourceware.org, Tom Tromey Subject: Re: Garbarge collector eats gdb.selected_thread().inferior In-Reply-To: References: Message-ID: X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.0 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Mon, 7 Aug 2017 20:56:48 +0000 X-IsSubscribed: yes X-SW-Source: 2017-08/txt/msg00135.txt.bz2 Hi Maksim, The fix looks right, and Tom also said so in Bugzilla. However, I'm unable to apply your patch to look at the test case. The long lines have been wrapped, presumably by your email client. Can you send it again using the "git send-email" command? I'll still make the comments I can about the current version. On 2017-08-05 07:57, Максим Дзабраев wrote: > If multiple time call gdb.selected_thread ().inferior, gdb throw > exception: > > (gdb) pi gdb.selected_thread().inferior > > (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 > select () from /lib/x86_64-linux-gnu/libc.so.6 > > I report about this bug here: > https://sourceware.org/bugzilla/show_bug.cgi?id=21213 > > Following patch fixes this bug and add test of this bug. In attachment > I add gdb.log and gdb.sum before and after apply patch to > thpy_get_inferior. > > > ChangeLog > 2017.08.05 Maksim Dzabraev > > * gdb/python/py-infthread.c (hpy_get_inferior) > * gdb/testsuite/gdb.python/py-infthread.exp: Fix bug 21213 and > add test Please consult this page for details about the ChangeLog entries. https://sourceware.org/gdb/wiki/ContributionChecklist In short, each change should be documented in the ChangeLog closest to it (then for each file you write the relative path to it), and should describe what changed a bit more precisely. For example: gdb/ChangeLog: * python/py-infthread.c (thpy_get_inferior): Increment reference of inferior before returning it. gdb/testsuite/ChangeLog: * gdb.python/py-infthread.exp: Test calling InferiorThread.inferior () multiple times in a row. > --- > > diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c > index 626c15c..31d576f 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/gdb.python/py-infthread.exp > b/gdb/testsuite/gdb.python/py-infthread.exp > index a5fed8d..dcb7e26 100644 > --- a/gdb/testsuite/gdb.python/py-infthread.exp > +++ b/gdb/testsuite/gdb.python/py-infthread.exp > @@ -39,6 +39,14 @@ if ![runto_main] then { > > # Test basic gdb.Inferior attributes and methods. > > +#testing https://sourceware.org/bugzilla/show_bug.cgi?id=21213 It's nice to give a bit of context so that readers don't have to visit the PR to have an idea of what it's about. I suggest: # Make sure that InferiorThread.inferior returns a new reference (see PR 21213). > +gdb_py_test_silent_cmd "python gdb.selected_thread ().inferior" "test > gdb.selected_thread" 1 > +gdb_py_test_silent_cmd "python gdb.selected_thread ().inferior" "test > gdb.selected_thread" 1 > +gdb_test_no_output "python import gc; gc.collect()" "test > InferiorThread.inferior" "test InferiorThread.inferior" You have one too many parameter to gdb_test_no_output. Also, the test name should probably be something like "call Python garbage collection". > +gdb_py_test_silent_cmd "python gdb.selected_thread ().inferior" "test > gdb.selected_thread" 1 > +gdb_py_test_silent_cmd "python gdb.selected_thread ().inferior" "test > gdb.selected_thread" 1 All tests (here one line == one test) should have a unique name, so you could name them "test InferiorThread.inferior #" where # is 1, 2, 3, 4. > + > + > 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 Thanks! Simon