Buffering problems with "gdb < foo"

Eli Zaretskii eliz@delorie.com
Wed Mar 8 01:48:00 GMT 2000


>  > If this is not DJGPP-specific, then I think _initialize_event_loop
>  > should turn editing off if input_fd is not a tty.
> 
> I think so, can you submit a patch to do this? 

Attached.  Even though the particular problem that triggered this was
elsewhere (see my other message in this thread), I still think that
when stdin comes from a file, editing should be disabled by default.

2000-03-08  Eli Zaretskii  <eliz@is.elta.co.il>

	* event-top.c (_initialize_event_loop): If instream is not
	connecetd to a terminal device, turn editing off.

--- gdb/event-top.c~0	Sat Mar  4 18:28:20 2000
+++ gdb/event-top.c	Wed Mar  8 00:56:42 2000
@@ -1133,9 +1133,25 @@ _initialize_event_loop (void)
 {
   if (event_loop_p)
     {
-      /* When a character is detected on instream by select or poll,
-         readline will be invoked via this callback function. */
-      call_readline = rl_callback_read_char_wrapper;
+      /* If the input stream is connected to a terminal, turn on
+         editing.  */
+      if (ISATTY (instream))
+	{
+	  /* Tell gdb that we will be using the readline library. This
+	     could be overwritten by a command in .gdbinit like 'set
+	     editing on' or 'off'. */
+	  async_command_editing_p = 1;
+	  
+	  /* When a character is detected on instream by select or
+	     poll, readline will be invoked via this callback
+	     function. */
+	  call_readline = rl_callback_read_char_wrapper;
+	}
+      else
+	{
+	  async_command_editing_p = 0;
+	  call_readline = gdb_readline2;
+	}
 
       /* When readline has read an end-of-line character, it passes
          the complete line to gdb for processing. command_line_handler
@@ -1160,10 +1176,5 @@ _initialize_event_loop (void)
          only when it actually exists (I.e. after we say 'run' or
          after we connect to a remote target. */
       add_file_handler (input_fd, stdin_event_handler, 0);
-
-      /* Tell gdb that we will be using the readline library. This
-         could be overwritten by a command in .gdbinit like 'set
-         editing on' or 'off'. */
-      async_command_editing_p = 1;
     }
 }


More information about the Gdb mailing list