Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: Maksim Dzabraev <dzabraew@gmail.com>
Cc: gdb-patches@sourceware.org, tom@tromney.com
Subject: Re: [PATCH] fix bug PR 21213 and add test case
Date: Sat, 28 Oct 2017 17:46:00 -0000	[thread overview]
Message-ID: <3eb05df3adcb9b7657411e29c9ecbc3e@polymtl.ca> (raw)
In-Reply-To: <20171028171856.3540-1-dzabraew@gmail.com>

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 <dzabraew@gmail.com>

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  <simon.marchi@ericsson.com>
> 
>  	* 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 <dzabraew@gmail.com>

Same here.

> +
> +	PR python/21213
> +	* gdb.python/py-infthread.exp: Test calling
> +	InferiorThread.inferior () multiple times in a row.
> +
>  2017-10-27  Keith Seitz  <keiths@redhat.com>
> 
>  	* 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)" "\\<gdb.InferiorThread object at
> 0x\[\[:xdigit:\]\]+>" "verify InferiorThread object"
>  gdb_test "python print ('result = %s' % t0.num)" " = 1" "test
> InferiorThread.num"


Thanks,

Simon


  reply	other threads:[~2017-10-28 17:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-05  5:58 Garbarge collector eats gdb.selected_thread().inferior Максим Дзабраев
2017-08-07 20:57 ` Simon Marchi
2017-10-28 17:19   ` [PATCH] fix bug PR 21213 and add test case Maksim Dzabraev
2017-10-28 17:46     ` Simon Marchi [this message]
2017-10-28 18:14   ` [PATCH] Make gdb.selected_thread().inferior return a new reference Maksim Dzabraev
2017-10-28 18:21     ` Simon Marchi
2017-08-08 19:56 [PATCH] fix bug PR 21213 and add test case Maksim Dzabraev
2017-08-09 18:33 ` Tom Tromey
2017-08-10 18:22 Maksim Dzabraev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3eb05df3adcb9b7657411e29c9ecbc3e@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=dzabraew@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromney.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox