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] Don't set immediate_quit in prompt_for_continue


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

commit d2acc30bb60357815c3965c058965d0f5313f814
Author: Pedro Alves <palves@redhat.com>
Date:   Tue Apr 12 16:49:30 2016 +0100

    Don't set immediate_quit in prompt_for_continue
    
    immediate_quit used to be necessary back when prompt_for_continue used
    blocking fread, but nowadays it uses gdb_readline_wrapper, which is
    implemented in terms of a nested event loop, which already knows how
    to react to SIGINT:
    
     #0  throw_it (reason=RETURN_QUIT, error=GDB_NO_ERROR, fmt=0x9d6d7e "Quit", ap=0x7fffffffcb88)
         at .../src/gdb/common/common-exceptions.c:324
     #1  0x00000000007bab5d in throw_vquit (fmt=0x9d6d7e "Quit", ap=0x7fffffffcb88) at .../src/gdb/common/common-exceptions.c:366
     #2  0x00000000007bac9f in throw_quit (fmt=0x9d6d7e "Quit") at .../src/gdb/common/common-exceptions.c:385
     #3  0x0000000000773a2d in quit () at .../src/gdb/utils.c:1039
     #4  0x000000000065d81b in async_request_quit (arg=0x0) at .../src/gdb/event-top.c:893
     #5  0x000000000065c27b in invoke_async_signal_handlers () at .../src/gdb/event-loop.c:949
     #6  0x000000000065aeef in gdb_do_one_event () at .../src/gdb/event-loop.c:280
     #7  0x0000000000770838 in gdb_readline_wrapper (prompt=0x7fffffffcd40 "---Type <return> to continue, or q <return> to quit---")
         at .../src/gdb/top.c:873
    
    The need for the QUIT in stdin_event_handler is then exposed by the
    gdb.base/double-prompt-target-event-error.exp test, which has:
    
    	# We're now stopped in a pagination query while handling a
    	# target event (printing where the program stopped).  Quitting
    	# the pagination should result in only one prompt being
    	# output.
    	send_gdb "\003p 1\n"
    
    Without that change we'd get:
    
     Continuing.
     ---Type <return> to continue, or q <return> to quit---PASS: gdb.base/double-prompt-target-event-error.exp: ctrlc target event: continue: continue to pagination
     ^CpQuit
     (gdb)  1
     Undefined command: "1".  Try "help".
     (gdb) PASS: gdb.base/double-prompt-target-event-error.exp: ctrlc target event: continue: first prompt
     ERROR: Undefined command "".
     UNRESOLVED: gdb.base/double-prompt-target-event-error.exp: ctrlc target event: continue: no double prompt
    
    Vs:
    
     Continuing.
     ---Type <return> to continue, or q <return> to quit---PASS: gdb.base/double-prompt-target-event-error.exp: ctrlc target event: continue: continue to pagination
     ^CQuit
     (gdb) p 1
     $1 = 1
     (gdb) PASS: gdb.base/double-prompt-target-event-error.exp: ctrlc target event: continue: first prompt
     PASS: gdb.base/double-prompt-target-event-error.exp: ctrlc target event: continue: no double prompt
    
    gdb/ChangeLog:
    2016-04-12  Pedro Alves  <palves@redhat.com>
    
    	* event-top.c (stdin_event_handler): Call QUIT;
    	(prompt_for_continue): Don't run with immediate_quit set.

Diff:
---
 gdb/ChangeLog   | 5 +++++
 gdb/event-top.c | 9 +++++++++
 gdb/utils.c     | 4 ----
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index aa23a65..9d3ff4a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 2016-04-12  Pedro Alves  <palves@redhat.com>
 
+	* event-top.c (stdin_event_handler): Call QUIT;
+	(prompt_for_continue): Don't run with immediate_quit set.
+
+2016-04-12  Pedro Alves  <palves@redhat.com>
+
 	* tui/tui-io.c (tui_redisplay_readline): Check
 	gdb_in_secondary_prompt_p instead of immediate_quit.
 	* tui/tui.c: Include top.h.
diff --git a/gdb/event-top.c b/gdb/event-top.c
index eb4f0b9..a119fe9 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -403,6 +403,15 @@ stdin_event_handler (int error, gdb_client_data client_data)
     }
   else
     {
+    /* This makes sure a ^C immediately followed by further input is
+       always processed in that order.  E.g,. with input like
+       "^Cprint 1\n", the SIGINT handler runs, marks the async signal
+       handler, and then select/poll may return with stdin ready,
+       instead of -1/EINTR.  The
+       gdb.base/double-prompt-target-event-error.exp test exercises
+       this.  */
+      QUIT;
+
       do
 	{
 	  call_stdin_event_handler_again_p = 0;
diff --git a/gdb/utils.c b/gdb/utils.c
index 62e169a..3c7a29c 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1865,9 +1865,6 @@ prompt_for_continue (void)
      beyond the end of the screen.  */
   reinitialize_more_filter ();
 
-  immediate_quit++;
-  QUIT;
-
   /* We'll need to handle input.  */
   target_terminal_ours ();
 
@@ -1895,7 +1892,6 @@ prompt_for_continue (void)
 	throw_quit ("Quit");
       xfree (ignore);
     }
-  immediate_quit--;
 
   /* Now we have to do this again, so that GDB will know that it doesn't
      need to save the ---Type <return>--- line at the top of the screen.  */


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