From patchwork Tue Aug 8 19:55:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?0JzQsNC60YHQuNC8INCU0LfQsNCx0YDQsNC10LI=?= X-Patchwork-Id: 22000 Received: (qmail 20980 invoked by alias); 8 Aug 2017 19:56:03 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 20971 invoked by uid 89); 8 Aug 2017 19:56:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2607, H*m:gmail X-HELO: mail-lf0-f68.google.com Received: from mail-lf0-f68.google.com (HELO mail-lf0-f68.google.com) (209.85.215.68) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 08 Aug 2017 19:56:01 +0000 Received: by mail-lf0-f68.google.com with SMTP id y15so3157810lfd.5 for ; Tue, 08 Aug 2017 12:56:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=HgaIREfhp4UbtbwBZdR1ZMx3s5RC9UfvlFBolojfCzo=; b=LSk3ehr2bGZrcYqniRDGGZO3RQSCM7Cb77qOVuudlTDm5yM6K0by7/Tr0YcaoJ5FgT EwsHo88RQt0aECFpJlGhKBbpi4bsu6UAAO0YCHzWaDMbTmhz5M0TxVS9Y1YNEPPY4Xon W5q5JrBIfjz7H1oVpoLkvB2eJusEiDWiyZXEEhXmwa5r2db8rFhVUeYwGjYNbjsZt2Jp 4waIljus9NhS5oD+hSrmgoGYE80Ru+VqDQ0myyFzBNxyM0CXB/Wq74rGpzgKvWbjyTgw XW0Dv61l5tOeAL/ca4SCkAPk4TV5g+4+tLo0jbHBhZ0bXx3NRsDgNOVdEmWYuTWByY2n DvMA== X-Gm-Message-State: AHYfb5jeSUlBmzB4v48gJmtFDqTZ4DQJedSfco6+FdI6NUyN1TQxNV3Q KUuWyQg3nQQa9Ja7kOQ= X-Received: by 10.25.22.91 with SMTP id m88mr1996390lfi.19.1502222158313; Tue, 08 Aug 2017 12:55:58 -0700 (PDT) Received: from dza-svk.tomtelnet.ru (nightik.qwertynet.ru. [79.136.160.17]) by smtp.googlemail.com with ESMTPSA id u128sm334964lja.68.2017.08.08.12.55.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 Aug 2017 12:55:57 -0700 (PDT) From: Maksim Dzabraev To: gdb-patches@sourceware.org Cc: tom@tromey.com, Maksim Dzabraev Subject: [PATCH] fix bug PR 21213 and add test case Date: Wed, 9 Aug 2017 02:55:54 +0700 Message-Id: <20170808195554.15778-1-dzabraew@gmail.com> --- gdb/ChangeLog | 5 +++++ gdb/python/py-infthread.c | 1 + gdb/testsuite/ChangeLog | 5 +++++ gdb/testsuite/gdb.python/py-infthread.exp | 9 +++++++++ 4 files changed, 20 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c4ad2bf1eb..7c04d4a50e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2017-08-09 Maksim Dzabraev + + * python/py-infthread.c (thpy_get_inferior): Increment reference + of inferior before returning it. + 2017-08-07 Maciej W. Rozycki PR breakpoints/21886 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 31f419faf5..e8107c39cf 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-08-09 Maksim Dzabraev + + * gdb.python/py-infthread.exp: Test calling + InferiorThread.inferior () multiple times in a row. + 2017-08-05 Tom Tromey * gdb.rust/simple.exp: Allow String to appear in a different diff --git a/gdb/testsuite/gdb.python/py-infthread.exp b/gdb/testsuite/gdb.python/py-infthread.exp index a5fed8d893..4120ff1ce8 100644 --- a/gdb/testsuite/gdb.python/py-infthread.exp +++ b/gdb/testsuite/gdb.python/py-infthread.exp @@ -39,6 +39,15 @@ if ![runto_main] then { # 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)" "\\" "verify InferiorThread object" gdb_test "python print ('result = %s' % t0.num)" " = 1" "test InferiorThread.num"