This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 2/5] Fix stdin ending up not registered after a Quit
- From: Pedro Alves <palves at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 6 Nov 2017 23:27:13 +0000
- Subject: [PATCH 2/5] Fix stdin ending up not registered after a Quit
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=palves at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B420BB5BB
- References: <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