Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Kevin Buettner <kevinb@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v2] [gdb] Prune inferior after switching inferior
Date: Sun, 18 Aug 2024 21:00:55 +0200	[thread overview]
Message-ID: <611d09da-0a42-4915-8c67-37166aa743d4@suse.de> (raw)
In-Reply-To: <20240818114356.459b48f9@f40-zbm-amd>

On 8/18/24 20:43, Kevin Buettner wrote:
> On Wed, 31 Jul 2024 09:46:05 +0200
> Tom de Vries <tdevries@suse.de> wrote:
> 
>> Usually with test-case gdb.python/py-progspace-events.exp I get:
>> ...
>> (gdb) inferior 1^M
>> [Switching to inferior 1 [process 4116] (py-progspace-events)]^M
>> [Switching to thread 1.1 (Thread 0xf77d0ce0 (LWP 4116))]^M
>> 28      { /* Nothing.  */ }^M
>> (gdb) PASS: gdb.python/py-progspace-events.exp: inferior 1
>> step^M
>> FreeProgspaceEvent: <gdb.Progspace object at 0xabf4f850>^M
>> do_parent_stuff () at py-progspace-events.c:41^M
>> 41        ++global_var;^M
>> (gdb) PASS: gdb.python/py-progspace-events.exp: step
>> ...
>>
>> But occasionally I run into the following FAIL:
>> ...
>> (gdb) inferior 1^M
>> [Switching to inferior 1 [process 5199] (py-progspace-events)]^M
>> [Switching to thread 1.1 (Thread 0xf77d0ce0 (LWP 5199))]^M
>> 28      { /* Nothing.  */ }^M
>> (gdb) FreeProgspaceEvent: <gdb.Progspace object at 0xabaf03a0>^M
>> FAIL: gdb.python/py-progspace-events.exp: inferior 1 (timeout)
>> ...
>>
>> This is caused by a race between the handling of an event, and the
>> "inferior 1" command.
>>
>> In the passing case, the event is handled first.  During which prune_inferiors
>> is called, but it can't remove inferior 2, because it's still the current one.
>>
>> In the failing case, the "inferior 1" command is handled first.  Then during
>> handling of the event, prune_inferiors is called, and it can remove inferior 2
>> because it's no longer the current one.
>>
>> This looks like a test-case issue to me, but ISTM that we can do better: by
>> calling prune_inferiors asap, at the end of the "inferior 1" command, we
>> stabilize the moment when the inferior is removed:
>> ...
>> (gdb) inferior 1^M
>> [Switching to inferior 1 [process 5199] (py-progspace-events)]^M
>> [Switching to thread 1.1 (Thread 0xf77d0ce0 (LWP 5199))]^M
>> 28      { /* Nothing.  */ }^M
>> FreeProgspaceEvent: <gdb.Progspace object at 0xabaf03a0>^M
>> (gdb) PASS: gdb.python/py-progspace-events.exp: inferior 1
>> ...
>>
>> This also allows us to simplify the test-case by removing the step command,
>> which is no longer required to trigger the pruning of the inferior.
>>
>> Tested on x86_64-linux.
>>
>> PR gdb/31440
>> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31440
> 
> Approved-by: Kevin Buettner <kevinb@redhat.com>
> 

Hi Kevin,

thanks for the review, pushed.

- Tom

      reply	other threads:[~2024-08-18 19:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-31  7:46 Tom de Vries
2024-08-13 11:17 ` [PING][PATCH " Tom de Vries
2024-08-18 18:43 ` [PATCH " Kevin Buettner
2024-08-18 19:00   ` Tom de Vries [this message]

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=611d09da-0a42-4915-8c67-37166aa743d4@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=kevinb@redhat.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