www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/05/31/02:40:17

Date: Mon, 31 May 1999 09:36:37 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Robert Hoehne <robert DOT hoehne AT gmx DOT net>, djgpp-workers AT delorie DOT com
Subject: Re: gdb 4.18 for DJGPP (alpha)
In-Reply-To: <Pine.SUN.3.91.990530135851.20904C-100000@is>
Message-ID: <Pine.SUN.3.91.990531093300.10861N-100000@is>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Sun, 30 May 1999, Eli Zaretskii wrote:

> Although this version already works for me in many cases, including
> while stepping through `redir's code, I'm still testing dbgredir.c
> under different situations, so some changes are possible in the next
> few days.  Stay tuned.

The following additional changes to go32-nat.c make it work better
with programs that redirect their standard handles, in particular if
some of the standard handles are closed.  (The version I sent
yesterday would treat such cases as fatal errors.)

The diffs below should be applied on top of those I sent yesterday.
If they don't apply, ask me for the full go32-nat.c.

Note that I also checked in a change for dbgredir.c that copes with
closed handles gracefully.

I'm sending in a separate message a short test program that can be
used to test all these new features.

*** gdb/go32-nat.c~3	Sat May 29 19:02:42 1999
--- gdb/go32-nat.c	Mon May 31 00:01:02 1999
*************** go32_terminal_info (char *args, int from
*** 950,955 ****
--- 950,958 ----
  	  if (child_cmd.redirection[i]->file_name)
  	    printf_unfiltered ("\tFile handle %d is redirected to `%s'.\n",
  			       i, child_cmd.redirection[i]->file_name);
+ 	  else if (_get_dev_info(child_cmd.redirection[i]->inf_handle) == -1)
+ 	    printf_unfiltered
+ 	      ("\tFile handle %d appears to be closed by inferior.\n", i);
  	  /* Mask off the raw/cooked bit when comparing device info words.  */
  	  else if ((_get_dev_info(child_cmd.redirection[i]->inf_handle) & 0xdf)
  		   != (_get_dev_info(i) & 0xdf))
*************** go32_terminal_inferior (void)
*** 973,981 ****
      }
    /* set the console device of the inferior to whatever mode
       (raw or cooked) we found it last time */
!   if (inf_mode_valid)
!     device_mode (0, inf_terminal_mode);
!   terminal_is_ours = 0;
  }
  
  static void
--- 976,987 ----
      }
    /* set the console device of the inferior to whatever mode
       (raw or cooked) we found it last time */
!   if (terminal_is_ours)
!     {
!       if (inf_mode_valid)
! 	device_mode (0, inf_terminal_mode);
!       terminal_is_ours = 0;
!     }
  }
  
  static void
*************** go32_terminal_ours (void)
*** 988,1000 ****
        inf_terminal_mode = device_mode (0, 0);
        if (inf_terminal_mode != -1)
  	inf_mode_valid = 1;
        terminal_is_ours = 1;
  
        /* Restore debugger's standard handles.  */
        errno = 0;
        if (redir_to_debugger (&child_cmd) == -1)
! 	error ("Cannot redirect standard handles for debugger: %s.",
! 	       strerror (errno));
      }
  }
  
--- 994,1013 ----
        inf_terminal_mode = device_mode (0, 0);
        if (inf_terminal_mode != -1)
  	inf_mode_valid = 1;
+       else
+ 	/* If device_mode returned -1, we don't know what happens with
+ 	   handle 0 anymore, so make the info invalid.  */
+ 	inf_mode_valid = 0;
        terminal_is_ours = 1;
  
        /* Restore debugger's standard handles.  */
        errno = 0;
        if (redir_to_debugger (&child_cmd) == -1)
! 	{
! 	  redir_to_child (&child_cmd);
! 	  error ("Cannot redirect standard handles for debugger: %s.",
! 		 strerror (errno));
! 	}
      }
  }
  

- Raw text -


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