public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Simon Marchi <simon.marchi@ericsson.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH v2] Restore terminal state in mi_thread_exit (PR gdb/17627)
Date: Thu, 04 Dec 2014 15:35:00 -0000	[thread overview]
Message-ID: <54807F25.9040506@redhat.com> (raw)
In-Reply-To: <1417558223-27328-1-git-send-email-simon.marchi@ericsson.com>

On 12/02/2014 10:10 PM, Simon Marchi wrote:
> When a thread exits, the terminal is left in mode "terminal_is_ours"
> while the target executes. This patch fixes that.

Right.  The reason we can then type stuff is that the input fd is left
registered in the event loop.  target_terminal_inferior is what
removes it.

> 
> From my understanding, a function calling target_terminal_ours expects
> that the terminal could be in any state at the moment it is called.

Right.  The target_terminal_* functions are idempotent.

> Therefore, it should be its reponsibility to put back the terminal in
> whatever state it was before being called.

That doesn't follow though.  We have a ton of places that call
target_terminal_our that don't need to put back the terminal in
whatever state is was before.  The reason is that usually we'll
be printing after the inferior stopped for some event.  If we end
up re-resuming it, we'll call target_terminal_inferior then.

But in the thread exit case, there's nothing to be re-resumed,
so we need to care about it "manually".  If you take a backtrace
at the point the thread exit event is printed, we should be
still deep within the target backend code.

Please update the commit log to clarify this.

>  extern int target_supports_terminal_ours (void);
>  
> +/* Make a cleanup that restores the state of the terminal to the current
> +   value.  */

Should be "to the current state", I think.

Otherwise OK.

Thanks,
Pedro Alves

  parent reply	other threads:[~2014-12-04 15:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-02 22:10 Simon Marchi
2014-12-03  0:09 ` Patrick Palka
2014-12-03 14:29   ` Simon Marchi
2014-12-04 15:40     ` Pedro Alves
2014-12-04 15:35 ` Pedro Alves [this message]
2014-12-05 16:12   ` Simon Marchi
2014-12-10 17:20     ` Pedro Alves
2014-12-10 18:06       ` 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=54807F25.9040506@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@ericsson.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).