www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/05/23/05:22:57

Date: Sun, 23 May 1999 12:20:27 +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>
cc: djgpp-workers AT delorie DOT com
Subject: Re: gdb 4.18 for DJGPP (alpha)
In-Reply-To: <199905201928.WAA12750@is.elta.co.il>
Message-ID: <Pine.SUN.3.91.990523122009.26578C-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

A few more minor changes for GDB are attached to this message.  Here
is the rationale for them:

 - ROOTED_P referenced X[1] without making sure that X[0] is
   non-null.

 - terminal.h was insulting DJGPP claiming that ``nothing works''.
   I couldn't have that ;-)  Changing this required two missing
   functions to be trivially #define'd on inflow.c.

 - I changed fatal_dump_core to raise SIGABRT, since SIGQUIT is
   disabled by default.  The old, v1.x-vintage of quitting was also
   reworked.

 - handle_command() was printing the header even if no signals were
   changed; I fixed that.

 - Several functions on source.c failed for DOS-style file names with
   drive letters.  Other functions didn't handle CR characters
   correctly; in particular, search commands would fail for regexps
   which end with a $.

 - shell_escape now restores the original directory, in case the
   shelled command changes it.

 - The "cd" command didn't cope with DOS-style directories with drive
   letters.  Also, GDB didn't restore the original directory before it
   exited; now it does.



*** gdb/config/i386/xm-go32.h~0	Wed May  5 23:06:28 1999
--- gdb/config/i386/xm-go32.h	Fri May 21 09:45:34 1999
*************** Foundation, Inc., 59 Temple Place - Suit
*** 25,31 ****
  
  #define SLASH_P(X) ((X)=='\\' || (X) == '/')
  
! #define ROOTED_P(X) ((SLASH_P((X)[0]))|| ((X)[1] ==':'))
  
  #define SLASH_CHAR '/'
  #define SLASH_STRING "/"
--- 25,31 ----
  
  #define SLASH_P(X) ((X)=='\\' || (X) == '/')
  
! #define ROOTED_P(X) ((SLASH_P((X)[0])) || ((X)[0] && (X)[1] ==':'))
  
  #define SLASH_CHAR '/'
  #define SLASH_STRING "/"
*** gdb/terminal.h~1	Wed Sep  4 17:09:50 1996
--- gdb/terminal.h	Fri May 21 22:44:08 1999
*************** Foundation, Inc., 59 Temple Place - Suit
*** 29,36 ****
     nothing has already defined the one of the names, and do the right
     thing. */
  
- /* nothing works with go32, and the headers aren't complete */
- #if !defined (__GO32__)
  #if !defined (HAVE_TERMIOS) && !defined(HAVE_TERMIO) && !defined(HAVE_SGTTY)
  #if defined(HAVE_TERMIOS_H)
  #define HAVE_TERMIOS
--- 29,34 ----
*************** Foundation, Inc., 59 Temple Place - Suit
*** 44,56 ****
  #endif /* ! defined (HAVE_TERMIO_H) */
  #endif /* ! defined (HAVE_TERMIOS_H) */
  #endif /* !defined (HAVE_TERMIOS) && !defined(HAVE_TERMIO) && !defined(HAVE_SGTTY) */
- #endif /* ! defined (__GO32__) */
  
  #if defined(HAVE_TERMIOS)
  #include <termios.h>
  #endif
  
! #if !defined(__GO32__) && !defined(_WIN32) && !defined (HAVE_TERMIOS)
  
  /* Define a common set of macros -- BSD based -- and redefine whatever
     the system offers to make it look like that.  FIXME: serial.h and
--- 42,53 ----
  #endif /* ! defined (HAVE_TERMIO_H) */
  #endif /* ! defined (HAVE_TERMIOS_H) */
  #endif /* !defined (HAVE_TERMIOS) && !defined(HAVE_TERMIO) && !defined(HAVE_SGTTY) */
  
  #if defined(HAVE_TERMIOS)
  #include <termios.h>
  #endif
  
! #if !defined(_WIN32) && !defined (HAVE_TERMIOS)
  
  /* Define a common set of macros -- BSD based -- and redefine whatever
     the system offers to make it look like that.  FIXME: serial.h and
*** gdb/inflow.c~1	Thu Dec 10 21:25:42 1998
--- gdb/inflow.c	Fri May 21 23:32:20 1999
*************** Foundation, Inc., 59 Temple Place - Suit
*** 36,41 ****
--- 36,45 ----
  
  #ifdef HAVE_TERMIOS
  #define PROCESS_GROUP_TYPE pid_t
+ #ifdef __DJGPP__
+ #define tcgetpgrp(x) 42
+ #define tcsetpgrp(f,x) 0
+ #endif
  #endif
  
  #ifdef HAVE_TERMIO
*** gdb/utils.c~0	Thu Feb 11 00:24:40 1999
--- gdb/utils.c	Sat May 22 08:47:34 1999
*************** fatal_dump_core (va_alist)
*** 512,519 ****
--- 512,525 ----
    fprintf_unfiltered (gdb_stderr, "\n");
    va_end (args);
  
+ #ifdef __DJGPP__
+   /* SIGQUIT by default is ignored, so use SIGABRT instead.  */
+   signal (SIGABRT, SIG_DFL);
+   kill (getpid (), SIGABRT);
+ #else
    signal (SIGQUIT, SIG_DFL);
    kill (getpid (), SIGQUIT);
+ #endif
    /* We should never get here, but just in case...  */
    exit (1);
  }
*************** quit ()
*** 637,642 ****
--- 643,653 ----
    if (quit_pre_print)
      fprintf_unfiltered (gdb_stderr, quit_pre_print);
  
+ #ifdef __MSDOS__
+       /* No steenking SIGINT will ever be coming our way when the
+          program is resumed.  Don't lie.  */
+   fprintf_unfiltered (gdb_stderr, "Quit\n");
+ #else
    if (job_control
        /* If there is no terminal switching for this target, then we can't
  	 possibly get screwed by the lack of job control.  */
*************** quit ()
*** 645,680 ****
    else
      fprintf_unfiltered (gdb_stderr,
  	     "Quit (expect signal SIGINT when the program is resumed)\n");
    return_to_top_level (RETURN_QUIT);
  }
  
! 
! #if defined(__GO32__)
! 
! /* In the absence of signals, poll keyboard for a quit.
!    Called from #define QUIT pollquit() in xm-go32.h. */
! 
! void
! notice_quit()
! {
!   if (kbhit ())
!     switch (getkey ())
!       {
!       case 1:
! 	quit_flag = 1;
! 	break;
!       case 2:
! 	immediate_quit = 2;
! 	break;
!       default:
! 	/* We just ignore it */
! 	/* FIXME!! Don't think this actually works! */
! 	fprintf_unfiltered (gdb_stderr, "CTRL-A to quit, CTRL-B to quit harder\n");
! 	break;
!       }
! }
! 
! #elif defined(_MSC_VER) /* should test for wingdb instead? */
  
  /*
   * Windows translates all keyboard and mouse events 
--- 656,666 ----
    else
      fprintf_unfiltered (gdb_stderr,
  	     "Quit (expect signal SIGINT when the program is resumed)\n");
+ #endif
    return_to_top_level (RETURN_QUIT);
  }
  
! #if defined(_MSC_VER) /* should test for wingdb instead? */
  
  /*
   * Windows translates all keyboard and mouse events 
*** gdb/infrun.c~1	Mon Mar  1 04:51:52 1999
--- gdb/infrun.c	Sat May 22 09:06:26 1999
*************** Are you sure you want to change it? ",
*** 3328,3339 ****
  
    if (from_tty)
      {
        /* Show the results.  */
-       sig_print_header ();
        for (signum = 0; signum < nsigs; signum++)
  	{
  	  if (sigs[signum])
  	    {
  	      sig_print_info (signum);
  	    }
  	}
--- 3328,3345 ----
  
    if (from_tty)
      {
+       int header_printed = 0;
+ 
        /* Show the results.  */
        for (signum = 0; signum < nsigs; signum++)
  	{
  	  if (sigs[signum])
  	    {
+ 	      if (!header_printed)
+ 		{
+ 		  sig_print_header ();
+ 		  header_printed = 1;
+ 		}
  	      sig_print_info (signum);
  	    }
  	}
*** gdb/source.c~1	Wed May  5 23:06:38 1999
--- gdb/source.c	Sat May 22 10:15:50 1999
*************** mod_path (dirname, which_path)
*** 338,352 ****
  	  }
        }
  
! #ifndef _WIN32 
!       /* On win32 h:\ is different to h: */
!       if (SLASH_P (p[-1]))
  	/* Sigh. "foo/" => "foo" */
  	--p;
- #endif
        *p = '\0';
  
!       while (p[-1] == '.')
  	{
  	  if (p - name == 1)
  	    {
--- 338,354 ----
  	  }
        }
  
!       if (!(SLASH_P (*name) && p <= name + 1) /* "/" */
! #if defined(_WIN32) || defined(__MSDOS__)
! 	   /* On MS-DOS and MS-Windows, h:\ is different from h: */
! 	   && !(!SLASH_P (*name) && ROOTED_P (name) && p <= name + 3)/* d:/ */
! #endif
! 	  && SLASH_P (p[-1]))
  	/* Sigh. "foo/" => "foo" */
  	--p;
        *p = '\0';
  
!       while (p > name && p[-1] == '.')
  	{
  	  if (p - name == 1)
  	    {
*************** mod_path (dirname, which_path)
*** 354,360 ****
  	      name = current_directory;
  	      goto append;
  	    }
! 	  else if (SLASH_P (p[-2]))
  	    {
  	      if (p - name == 2)
  		{
--- 356,362 ----
  	      name = current_directory;
  	      goto append;
  	    }
! 	  else if (p > name + 1 && SLASH_P (p[-2]))
  	    {
  	      if (p - name == 2)
  		{
*************** mod_path (dirname, which_path)
*** 376,381 ****
--- 378,387 ----
  
        if (name[0] == '~')
  	name = tilde_expand (name);
+ #if defined(_WIN32) || defined(__MSDOS__)
+       else if (ROOTED_P (name) && p == name + 2) /* "d:" => "d:." */
+ 	name = concat (name, ".", NULL);
+ #endif
        else if (!ROOTED_P (name) && name[0] != '$') 
  	  name = concat (current_directory, SLASH_STRING, name, NULL);
        else
*************** mod_path (dirname, which_path)
*** 410,415 ****
--- 416,429 ----
  	p = *which_path;
  	while (1)
  	  {
+ 	    /* FIXME: strncmp loses in interesting ways on MS-DOS and
+ 	       MS-Windows because of case-insensitivity and two different
+ 	       but functionally identical slash characters.  We need a
+ 	       special filesystem-dependent file-name comparison function.
+ 
+ 	       Actually, even on Unix I would use realpath() or its work-
+ 	       alike before comparing.  Then all the code above which
+ 	       removes excess slashes and dots could simply go away.  */
  	    if (!strncmp (p, name, len)
  		&& (p[len] == '\0' || p[len] == DIRNAME_SEPARATOR))
  	      {
*************** openp (path, try_cwd_first, string, mode
*** 598,605 ****
  	  /* Beware the // my son, the Emacs barfs, the botch that catch... */
  	  
  	  *filename_opened = concat (current_directory, 
! 				     SLASH_CHAR
! 				     == current_directory[strlen(current_directory)-1] 
    				     ? "": SLASH_STRING,
  				     filename, NULL);
          }
--- 612,618 ----
  	  /* Beware the // my son, the Emacs barfs, the botch that catch... */
  	  
  	  *filename_opened = concat (current_directory, 
! 				     SLASH_P (current_directory[strlen(current_directory)-1])
    				     ? "": SLASH_STRING,
  				     filename, NULL);
          }
*************** print_source_lines_base (s, line, stopli
*** 1057,1063 ****
  #ifdef CRLF_SOURCE_FILES
  	  else if (c == '\r')
  	    {
! 	      /* Just skip \r characters.  */
  	    }
  #endif
  	  else
--- 1070,1082 ----
  #ifdef CRLF_SOURCE_FILES
  	  else if (c == '\r')
  	    {
! 	      /* Skip a \r character, but only before a \n.  */
! 	      int c1 = fgetc (stream);
! 
! 	      if (c1 != '\n')
! 		printf_filtered ("^%c", c + 0100);
! 	      if (c1 != EOF)
! 		ungetc (c1, stream);
  	    }
  #endif
  	  else
*************** forward_search_command (regex, from_tty)
*** 1493,1498 ****
--- 1512,1527 ----
  	}
      } while (c != '\n' && (c = getc (stream)) >= 0);
  
+ #ifdef CRLF_SOURCE_FILES
+     /* Remove the \r, if any, at the end of the line, otherwise
+        regular expressions that end with $ or \n won't work.  */
+     if (p - buf > 1 && p[-2] == '\r')
+       {
+ 	p--;
+ 	p[-1] = '\n';
+       }
+ #endif
+ 
      /* we now have a source line in buf, null terminate and match */
      *p = 0;
      if (re_exec (buf) > 0)
*************** reverse_search_command (regex, from_tty)
*** 1591,1596 ****
--- 1620,1635 ----
  	*p++ = c;
        } while (c != '\n' && (c = getc (stream)) >= 0);
  
+ #ifdef CRLF_SOURCE_FILES
+       /* Remove the \r, if any, at the end of the line, otherwise
+ 	 regular expressions that end with $ or \n won't work.  */
+       if (p - buf > 1 && p[-2] == '\r')
+ 	{
+ 	  p--;
+ 	  p[-1] = '\n';
+ 	}
+ #endif
+ 
        /* We now have a source line in buf; null terminate and match.  */
        *p = 0;
        if (re_exec (buf) > 0)
*** gdb/symtab.c~1	Thu Feb 11 00:24:38 1999
--- gdb/symtab.c	Sat May 22 11:44:26 1999
*************** file_matches (file, files, nfiles)
*** 3403,3408 ****
--- 3403,3412 ----
      {
        for (i = 0; i < nfiles; i++)
          {
+ 	  /* FIXME: This should use strcasecmp on case-insensitive
+ 	     filesystems (DOS, Windows).  However, right now, nobody
+ 	     calls search_symbols, the sole user of file_matches, with
+ 	     a non-NULL files[] argument.  */
            if (strcmp (files[i], basename (file)) == 0)
              return 1;
          }
*** gdb/command.c~1	Tue May 18 21:22:18 1999
--- gdb/command.c	Sat May 22 12:56:30 1999
*************** shell_escape (arg, from_tty)
*** 1464,1469 ****
--- 1464,1474 ----
        fprintf_unfiltered (gdb_stderr, "%s exited with status %d\n", arg, rc);
        gdb_flush (gdb_stderr);
      }
+ #ifdef __DJGPP__
+   /* Make sure to return to the directory GDB thinks it is, in case the
+      shell command we just ran changed it.  */
+   chdir (current_directory);
+ #endif
  #else /* Can fork.  */
    int rc, status, pid;
    char *p, *user_shell;
*** gdb/top.c~1	Fri Jan 29 09:46:02 1999
--- gdb/top.c	Sat May 22 13:01:52 1999
*************** gdb_init (argv0)
*** 656,661 ****
--- 656,667 ----
    getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
    current_directory = gdb_dirbuf;
  
+ #ifdef __MSDOS__
+   /* Make sure we return to the original directory upon exit, come
+      what may, since the OS doesn't do that for us.  */
+   make_final_cleanup ((make_cleanup_func) chdir, strsave (current_directory));
+ #endif
+ 
    init_cmd_lists ();	/* This needs to be done first */
    initialize_targets (); /* Setup target_terminal macros for utils.c */
    initialize_utils ();	/* Make errors and warnings possible */
*************** cd_command (dir, from_tty)
*** 3051,3063 ****
    if (chdir (dir) < 0)
      perror_with_name (dir);
  
    len = strlen (dir);
!   dir = savestring (dir, len - (len > 1 && SLASH_P(dir[len-1])));
    if (ROOTED_P(dir))
      current_directory = dir;
    else
      {
!       if (SLASH_P (current_directory[0]) && current_directory[1] == '\0')
  	current_directory = concat (current_directory, dir, NULL);
        else
  	current_directory = concat (current_directory, SLASH_STRING, dir, NULL);
--- 3057,3087 ----
    if (chdir (dir) < 0)
      perror_with_name (dir);
  
+ #if defined(_WIN32) || defined(__MSDOS__)
+   /* There's too much mess with DOSish names like "d:", "d:.",
+      "d:./foo" etc.  Instead of having lots of special #ifdef'ed code,
+      simply get the canonicalized name of the current directory.  */
+   dir = getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
+ #endif
    len = strlen (dir);
!   if (SLASH_P (dir[len-1]))
!     {
!       /* Remove the trailing slash unless this is a root directory
! 	 (including a drive letter on non-Unix systems).  */
!       if (!(len == 1) /* "/" */
! #if defined(_WIN32) || defined(__MSDOS__)
! 	  && !(!SLASH_P (*dir) && ROOTED_P (dir) && len <= 3) /* "d:/" */
! #endif
! 	  )
! 	len--;
!     }
! 
!   dir = savestring (dir, len);
    if (ROOTED_P(dir))
      current_directory = dir;
    else
      {
!       if (SLASH_P (current_directory[strlen (current_directory) - 1]))
  	current_directory = concat (current_directory, dir, NULL);
        else
  	current_directory = concat (current_directory, SLASH_STRING, dir, NULL);

- Raw text -


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