From: Simon Marchi <simon.marchi@polymtl.ca>
To: "Максим Дзабраев" <dzabraew@gmail.com>
Cc: gdb-patches@sourceware.org, Tom Tromey <tom@tromey.com>
Subject: Re: Garbarge collector eats gdb.selected_thread().inferior
Date: Mon, 07 Aug 2017 20:57:00 -0000 [thread overview]
Message-ID: <e37eb1e38a23eef3c48a74f67f7ff3f5@polymtl.ca> (raw)
In-Reply-To: <CALiEZtGq0tQG_ZtaLWLr_7u7hzdYqRoaPbC6aL0_LpSCyHjeBw@mail.gmail.com>
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.Inferior object at 0x7f1952bea698>
> (gdb) pi gdb.selected_thread().inferior
> <gdb.Inferior object at 0x7f1952bea698>
> (gdb) pi gdb.selected_thread().inferior
> Python Exception <type 'exceptions.AttributeError'> '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 <dzabraew@gmail.com>
>
> * 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)" "\\<gdb.InferiorThread object at
> 0x\[\[:xdigit:\]\]+>" "verify InferiorThread object"
> gdb_test "python print ('result = %s' % t0.num)" " = 1" "test
Thanks!
Simon
next prev parent reply other threads:[~2017-08-07 20:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-05 5:58 Максим Дзабраев
2017-08-07 20:57 ` Simon Marchi [this message]
2017-10-28 17:19 ` [PATCH] fix bug PR 21213 and add test case Maksim Dzabraev
2017-10-28 17:46 ` Simon Marchi
2017-10-28 18:14 ` [PATCH] Make gdb.selected_thread().inferior return a new reference Maksim Dzabraev
2017-10-28 18:21 ` Simon Marchi
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=e37eb1e38a23eef3c48a74f67f7ff3f5@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=dzabraew@gmail.com \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.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