]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix stdin ending up not registered after a Quit
authorPedro Alves <palves@redhat.com>
Thu, 16 Nov 2017 18:44:43 +0000 (18:44 +0000)
committerPedro Alves <palves@redhat.com>
Thu, 16 Nov 2017 18:44:43 +0000 (18:44 +0000)
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.

gdb/ChangeLog
gdb/inf-loop.c

index 23403b6cfef7996410a83e32ff1f2c9f7ed08491..766d1531de51909c700b1bcf335fad84f19bd4f3 100644 (file)
@@ -1,3 +1,8 @@
+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
index bb9fa011ee29ad2a40fb808f487522a2928c3990..1d573b947d4180eea304e2faf25276d13e4f9d47 100644 (file)
@@ -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
        }