public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/5] Fix stdin ending up not registered after a Quit
Date: Mon, 06 Nov 2017 23:27:00 -0000	[thread overview]
Message-ID: <1510010836-15287-3-git-send-email-palves@redhat.com> (raw)
In-Reply-To: <1510010836-15287-1-git-send-email-palves@redhat.com>

If you press Ctrl-C while GDB is processing breakpoint commands the
TRY/CATCH in inferior_event_handler catches the Quit exception and
prints it, and then if the interpreter was running a foreground
execution command, nothing re-adds stdin back in the event loop,
meaning the debug session ends up busted, because the user can't type
anything...

This was exposed by the new gdb.base/bp-cmds-continue-ctrl-c.exp
testcase added later in the series.

gdb/ChangeLog:
2017-11-03  Pedro Alves  <palves@redhat.com>

	* inf-loop.c (inferior_event_handler): Don't swallow the exception
	if the prompt is blocked.
---
 gdb/inf-loop.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/gdb/inf-loop.c b/gdb/inf-loop.c
index bb9fa01..1d573b9 100644
--- a/gdb/inf-loop.c
+++ b/gdb/inf-loop.c
@@ -73,7 +73,15 @@ inferior_event_handler (enum inferior_event_type event_type,
 	    }
 	  CATCH (e, RETURN_MASK_ALL)
 	    {
-	      exception_print (gdb_stderr, e);
+	      /* If the user was running a foreground execution
+		 command, then propagate the error so that the prompt
+		 can be reenabled.  Otherwise, the user already has
+		 the prompt and is typing some unrelated command, so
+		 just inform the user and swallow the exception.  */
+	      if (current_ui->prompt_state == PROMPT_BLOCKED)
+		throw_exception (e);
+	      else
+		exception_print (gdb_stderr, e);
 	    }
 	  END_CATCH
 	}
-- 
2.5.5

  parent reply	other threads:[~2017-11-06 23:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-06 23:27 [PATCH 0/5][Resend] Fix multiple Ctrl-C/Quit issues Pedro Alves
2017-11-06 23:27 ` [PATCH 5/5] Test breakpoint commands w/ "continue" + Ctrl-C Pedro Alves
2017-11-06 23:27 ` [PATCH 4/5] Python unwinder sniffer: PyExc_KeyboardInterrupt -> Quit Pedro Alves
2017-11-06 23:27 ` Pedro Alves [this message]
2017-11-06 23:27 ` [PATCH 3/5] Don't ever Quit out of resume Pedro Alves
2017-12-09  1:21   ` Maciej W. Rozycki
2017-12-11 11:20     ` Pedro Alves
2017-11-06 23:27 ` [PATCH 1/5] Fix swallowed "Quit" when inserting breakpoints Pedro Alves
2017-11-16 18:47 ` [PATCH 0/5][Resend] Fix multiple Ctrl-C/Quit issues Pedro Alves

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=1510010836-15287-3-git-send-email-palves@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /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).