delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1996/11/19/09:17:40

Date: Tue, 19 Nov 1996 16:06:36 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: djgpp-workers AT delorie DOT com
Subject: GDB hangs when you quit before program exits
Message-Id: <Pine.SUN.3.91.961119160355.18292E-100000@is>
Mime-Version: 1.0

GDB 4.16 will hang after asking whether you want to kill the debuggee, if
the debuggee has switched stdin to binary mode (like e.g. Emacs and Less
do).  Patches below; I've submitted them to FSF as well.

*** gdb/top.c~0	Sat Apr 13 11:51:42 1996
--- gdb/top.c	Tue Nov 19 14:22:06 1996
***************
*** 1322,1327 ****
--- 1322,1335 ----
    int input_index = 0;
    int result_size = 80;
  
+ #ifdef __DJGPP__
+   /* On MSDOS, the debugger and the debuggee share file handles.
+      If the debuggee switches its stdin to binary mode, the same
+      happens to the debugger's stdin, and fgetc below loses.  We
+      need therefore to switch stdin to TEXT mode.  */
+   int saved_mode = setmode (fileno (stdin), O_TEXT);
+ #endif
+ 
    if (prrompt)
      {
        /* Don't use a _filtered function here.  It causes the assumed
***************
*** 1352,1357 ****
--- 1360,1369 ----
  	       we'll return NULL then.  */
  	    break;
  	  free (result);
+ #ifdef __DJGPP__
+ 	  /* Restore the handle mode.  */
+ 	  setmode (fileno (stdin), saved_mode);
+ #endif
  	  return NULL;
  	}
  
***************
*** 1367,1372 ****
--- 1379,1388 ----
      }
  
    result[input_index++] = '\0';
+ #ifdef __DJGPP__
+   /* Restore the handle mode.  */
+   setmode (fileno (stdin), saved_mode);
+ #endif
    return result;
  }
  
*** gdb/utils.c~0	Tue Apr 23 11:35:12 1996
--- gdb/utils.c	Tue Nov 19 14:35:30 1996
***************
*** 23,28 ****
--- 23,31 ----
  #include <sys/param.h>
  #include <pwd.h>
  #endif
+ #ifdef __DJGPP__
+ #include <fcntl.h>
+ #endif
  #ifdef ANSI_PROTOTYPES
  #include <stdarg.h>
  #else
***************
*** 901,906 ****
--- 904,913 ----
    register int ans2;
    int retval;
  
+ #ifdef __DJGPP__
+   int saved_mode;
+ #endif
+ 
  #ifdef ANSI_PROTOTYPES
    va_start (args, ctlstr);
  #else
***************
*** 923,928 ****
--- 930,943 ----
      return 1;
  #endif /* MPW */
  
+ #ifdef __DJGPP__
+   /* On MSDOS, the debugger and the debuggee share file handles.
+      If the debuggee switches its stdin to binary mode, the same
+      happens to the debugger's stdin, and fgetc below loses.  We
+      need therefore to make sure stdin is in TEXT mode.  */
+   saved_mode = setmode (fileno (stdin), O_TEXT);
+ #endif
+ 
    while (1)
      {
        wrap_here ("");		/* Flush any buffered output */
***************
*** 976,981 ****
--- 991,1000 ----
  
    if (annotation_level > 1)
      printf_filtered ("\n\032\032post-query\n");
+ #ifdef __DJGPP__
+   /* Restore the handle mode.  */
+   setmode (fileno (stdin), saved_mode);
+ #endif
    return retval;
  }
  

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019