public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Aktemur, Tankut Baris" <tankut.baris.aktemur@intel.com>
To: Tom Tromey <tom@tromey.com>,
	"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: Pedro Alves <pedro@palves.net>
Subject: RE: [RFC 2/3] gdb: wait for inferior after attaching instead of adding a continuation
Date: Mon, 22 Apr 2024 06:48:55 +0000	[thread overview]
Message-ID: <DM4PR11MB73033D4F878838BF88FF76A9C4122@DM4PR11MB7303.namprd11.prod.outlook.com> (raw)
In-Reply-To: <874jbxt7nh.fsf@tromey.com>

On Friday, April 19, 2024 10:33 PM, Tom Tromey wrote:
> >>>>> "Tankut" == Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> writes:
> 
> Tankut> In a less harmful case, the current implementation causes an unnatural
> Tankut> positioning of the GDB prompt in a single target setting when
> Tankut> executing the attach command in async mode using the '&' operator.
> 
> I'd prefer Pedro review this, since he's the infrun expert, but I was
> curious about this point -- it seems to me that "attach &" should be
> expected not to wait.
> 
> So maybe the issue is that somehow a continuation is being run for the
> wrong inferior?  Like in this part of the final patch:
> 
> -      /* Do all continuations associated with the whole inferior (not
> -	 a particular thread).  */
> -      if (inferior_ptid != null_ptid)
> -	current_inferior ()->do_all_continuations ();
> 
> ... do inferior_ptid and current_inferior disagree here?
> Or else why does this code get invoked?
> 
> Tom

In the "attach &" example, there is only one inferior, actually.  So, there
is no mismatch between inferior_ptid and current_inferior.  Here is a timeline
of important events:

 - the "attach &" command starts executing.
 - target's "attach" op is invoked.
 - GDB sends a stop request to the target.
 - the inferior is added a continuation.
 - the attach command is done, we'll go back to the event loop.
   -> because we're in async mode (&), the GDB prompt is displayed.
 - the event corresponding to the stop request is received and handled.
 - when the stop event's handling is complete, the continuation is invoked.

I'd think that a reasonable question is "why does GDB send a stop request
to the target in async (&) mode?"  I believe that's the behavior in both
sync and async cases so that GDB can finish setting up the inferior properly
(in attach_post_wait).

-Baris


Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


  reply	other threads:[~2024-04-22  6:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-18  7:36 [RFC 0/3] Wait for inferior after attaching Tankut Baris Aktemur
2024-04-18  7:36 ` [PATCH 1/3] gdb: print target in print_target_wait_results Tankut Baris Aktemur
2024-04-18  7:36 ` [RFC 2/3] gdb: wait for inferior after attaching instead of adding a continuation Tankut Baris Aktemur
2024-04-19 20:33   ` Tom Tromey
2024-04-22  6:48     ` Aktemur, Tankut Baris [this message]
2024-04-18  7:36 ` [RFC 3/3] gdb: remove inferior continuations Tankut Baris Aktemur

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=DM4PR11MB73033D4F878838BF88FF76A9C4122@DM4PR11MB7303.namprd11.prod.outlook.com \
    --to=tankut.baris.aktemur@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@palves.net \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).