[pushed,master+7.12] Fix PR remote/20398: File-IO write always outputs "Quit"

Message ID 1470423424-9326-1-git-send-email-palves@redhat.com
State New, archived
Headers

Commit Message

Pedro Alves Aug. 5, 2016, 6:57 p.m. UTC
  Commit bb7c96deb1a1 ("gdb/remote-fileio.c: Eliminate custom SIGINT
signal handler") regressed the File-IO support.

Failed output:

  (gdb) target remote :8888
  Remote debugging using :8888
  0x00008098 in _start ()
  (gdb) c
  Continuing.
  Quit
  Quit
  Quit
  Quit
  Quit
  Quit
  Quit
  Quit
  Quit
  Quit
  Quit
  [Inferior 1 (Remote target) exited normally]

Expected output:

  (gdb) target remote :8888
  Remote debugging using :8888
  0x00008098 in _start ()
  (gdb) c
  Continuing.
  i: 0
  i: 1
  i: 2
  i: 3
  i: 4
  i: 5
  i: 6
  i: 7
  i: 8
  i: 9
  [Inferior 1 (Remote target) exited normally]

The problem that the new File-IO quit handler forgets to check the
quit flag before calling throwing a quit.

gdb/ChangeLog:
2016-08-05  Pedro Alves  <palves@redhat.com>

	PR remote/20398
	* remote-fileio.c (remote_fileio_quit_handler): Check the quit
	flag before calling quit.
---
 gdb/ChangeLog       | 6 ++++++
 gdb/remote-fileio.c | 3 ++-
 2 files changed, 8 insertions(+), 1 deletion(-)
  

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 92f2cec..621235b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@ 
 2016-08-05  Pedro Alves  <palves@redhat.com>
 
+	PR remote/20398
+	* remote-fileio.c (remote_fileio_quit_handler): Check the quit
+	flag before calling quit.
+
+2016-08-05  Pedro Alves  <palves@redhat.com>
+
 	* NEWS: Mention that GDB and GDBserver build with a C++ compiler
 	by default.
 
diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c
index 93121aa..e35bd5b 100644
--- a/gdb/remote-fileio.c
+++ b/gdb/remote-fileio.c
@@ -308,7 +308,8 @@  static quit_handler_ftype *remote_fileio_o_quit_handler;
 static void
 remote_fileio_quit_handler (void)
 {
-  quit ();
+  if (check_quit_flag ())
+    quit ();
 }
 
 static void