This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Fix stdin ending up not registered after a Quit


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=38dc2859c464733314c591d30a5359db20167f7f

commit 38dc2859c464733314c591d30a5359db20167f7f
Author: Pedro Alves <palves@redhat.com>
Date:   Thu Nov 16 18:44:43 2017 +0000

    Fix stdin ending up not registered after a Quit
    
    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-16  Pedro Alves  <palves@redhat.com>
    
    	* inf-loop.c (inferior_event_handler): Don't swallow the exception
    	if the prompt is blocked.

Diff:
---
 gdb/ChangeLog  |  5 +++++
 gdb/inf-loop.c | 10 +++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 23403b6..766d153 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 2017-11-16  Pedro Alves  <palves@redhat.com>
 
+	* inf-loop.c (inferior_event_handler): Don't swallow the exception
+	if the prompt is blocked.
+
+2017-11-16  Pedro Alves  <palves@redhat.com>
+
 	* breakpoint.c (insert_bp_location): Replace bp_err and
 	bp_err_message locals by a gdb_exception local.
 
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
 	}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]