This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Fix "attach" command vs user input race [Re: Regression for attach from stdin [Re: [pushed] Re: [PATCH v6 0/2] enable target-async by default]]
- From: Doug Evans <dje at google dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: Mark Wielaard <mjw at redhat dot com>, Jan Kratochvil <jan dot kratochvil at redhat dot com>, gdb-patches at sourceware dot org
- Date: Wed, 9 Jul 2014 09:37:12 -0700
- Subject: Re: [PATCH] Fix "attach" command vs user input race [Re: Regression for attach from stdin [Re: [pushed] Re: [PATCH v6 0/2] enable target-async by default]]
- Authentication-results: sourceware.org; auth=none
- References: <1400878753-24688-1-git-send-email-palves at redhat dot com> <538739A2 dot 2050105 at redhat dot com> <20140701162830 dot GA25877 at host2 dot jankratochvil dot net> <1404291574 dot 3766 dot 35 dot camel at bordewijk dot wildebeest dot org> <53B3CDCC dot 9050502 at redhat dot com> <53B57911 dot 10304 at redhat dot com> <53B6B0B8 dot 2050702 at redhat dot com> <21434 dot 52532 dot 737427 dot 778289 at ruffy dot mtv dot corp dot google dot com> <53BC0D0B dot 7040001 at redhat dot com>
Pedro Alves writes:
> On 07/07/2014 05:39 PM, Doug Evans wrote:
>
> > Our nomenclature here is problematic. I always do a double take when
> > I see attach and target_terminal_foo mentioned in the same sentence.
> > Bleah.
>
> Why? "run; detach; attach SAME_PID" is a trivial case where we end
> up attached to an inferior that is sharing the same tty as GDB. In
> fact, the test does that.
I know.
But for me it's not the normal case.
I wish the naming/wording could better reflect what's happening.
[but that's not something that has to be addressed here of course]
> @@ -2495,10 +2492,26 @@ attach_command (char *args, int from_tty)
> shouldn't refer to attach_target again. */
> attach_target = NULL;
>
> - /* Set up the "saved terminal modes" of the inferior
> - based on what modes we are starting it with. */
> + /* Set up the "saved terminal modes" of the inferior based on what
> + modes we are starting it with. */
> target_terminal_init ();
spurious change
>
> + /* Install inferior's terminal modes. This may look like a no-op,
> + as we've just saved them above, however, this does more than
> + restore terminal settings:
> +
> + - installs a SIGINT handler that forwards SIGINT to the inferior.
> + Otherwise a Ctrl-C pressed just while waiting for that initial
> + stop would end up as a spurious Quit.
> +
> + - removes stdin from the event loop, which we need if attaching
> + in the foreground, otherwise on targets that report an initial
> + stop on attach (which are most) we'd process input/commands
> + while we're in the event loop waiting for that stop. That is,
> + before the attach continuation runs and the command is really
> + finished. */
> + target_terminal_inferior ();
> +
> /* Set up execution context to know that we should return from
> wait_for_inferior as soon as the target reports a stop. */
> init_wait_for_inferior ();
I like this a lot better. Thanks.
The patch is ok with me, modulo removing the spurious change.