[comp.unix.i386] Patches for GDB 3.5 on SCO Unix 3.2

chip@tct.uucp (Chip Salzenberg) (08/07/90)

This article consists of a patch and a sharchive of new files for GDB
3.5 under SCO Unix/386.  I would like to ask the maintainers of GDB to
consider incorporating the enclosed patches and files into the
standard GDB distribution.

I use G++ with NO_DOLLARS_IN_LABEL defined, so the labels created by
G++ have dots instead of dollars.  For example, "$this" is actually
".this".  This patch includes a macro CPLUS_MARKER which is normally
'$' but which can be redefined to '.' in configuration headers.  Of
course, there's a lot more to do before GDB works with G++ and SDB
debugging information, but this first step is necessary.

SCO Unix has POSIX job control.  Unfortunately, neither the standard
shells nor Bash 1.05 support POSIX job control (Bash supports BSD job
control, which isn't quite the same).  Therefore, this patch includes
<singnal.h> from "signals.h" and <termio.h> or <sgtty.h> from
"terminal.h".  This change provides the ability to undefine macros
related to job control.  I hope someday to make GDB support POSIX job
control; until then, this works.

On SCO Unix systems, the Bourne shell /bin/sh is not readable to mere
peon users.  Therefore, trying to execute it after calling ptrace(0)
fails with "No permissions".  This patch prefers to use the user's
$SHELL, which is more likely to be something readable like /bin/bash.

Finally, let me say that GDB is the best debugger I have EVER used,
bar none.  Excellent work, people.  Just fabulous.

Index: defs.h
***************
*** 23,26 ****
--- 23,28 ----
  #define max(a, b) ((a) > (b) ? (a) : (b))
  
+ #define CPLUS_MARKER '$'	/* May be overridden to '.' for SysV */
+ 
  extern char *savestring ();
  extern char *concat ();

Index: expread.y
***************
*** 1383,1390 ****
        if (!strncmp (tokstart, "long", 4))
  	return LONG;
!       if (!strncmp (tokstart, "this", 4)
! 	  && lookup_symbol ("$this", expression_context_block,
! 			    VAR_NAMESPACE, 0))
! 	return THIS;
        break;
      case 3:
--- 1383,1394 ----
        if (!strncmp (tokstart, "long", 4))
  	return LONG;
!       if (!strncmp (tokstart, "this", 4))
! 	{
! 	  static char this_name[] = { CPLUS_MARKER, 't', 'h', 'i', 's', '\0' };
! 
! 	  if (lookup_symbol (this_name, expression_context_block,
! 			     VAR_NAMESPACE, 0))
! 	    return THIS;
! 	}
        break;
      case 3:

Index: expread.tab.c
***************
*** 2128,2135 ****
        if (!strncmp (tokstart, "long", 4))
  	return LONG;
!       if (!strncmp (tokstart, "this", 4)
! 	  && lookup_symbol ("$this", expression_context_block,
! 			    VAR_NAMESPACE, 0))
! 	return THIS;
        break;
      case 3:
--- 2128,2139 ----
        if (!strncmp (tokstart, "long", 4))
  	return LONG;
!       if (!strncmp (tokstart, "this", 4))
! 	{
! 	  static char this_name[] = { CPLUS_MARKER, 't', 'h', 'i', 's', '\0' };
! 
! 	  if (lookup_symbol (this_name, expression_context_block,
! 			     VAR_NAMESPACE, 0))
! 	    return THIS;
! 	}
        break;
      case 3:

Index: inflow.c
***************
*** 23,26 ****
--- 23,28 ----
  #include "frame.h"
  #include "inferior.h"
+ #include "signals.h"
+ #include "terminal.h"
  
  #ifdef USG
***************
*** 34,55 ****
  #include <sys/param.h>
  #include <sys/dir.h>
- #include <signal.h>
  
- #ifdef HAVE_TERMIO
- #include <termio.h>
- #undef TIOCGETP
- #define TIOCGETP TCGETA
- #undef TIOCSETN
- #define TIOCSETN TCSETA
- #undef TIOCSETP
- #define TIOCSETP TCSETAF
- #define TERMINAL struct termio
- #else
- #include <sys/ioctl.h>
- #include <fcntl.h>
- #include <sgtty.h>
- #define TERMINAL struct sgttyb
- #endif
- 
  #ifdef SET_STACK_LIMIT_HUGE
  #include <sys/time.h>
--- 36,40 ----
***************
*** 371,378 ****
  {
    int pid;
!   char *shell_command;
    extern int sys_nerr;
    extern char *sys_errlist[];
    extern int errno;
  
    /* If desired, concat something onto the front of ALLARGS.
--- 356,373 ----
  {
    int pid;
!   char *shell, *shell_base, *shell_command;
    extern int sys_nerr;
    extern char *sys_errlist[];
    extern int errno;
+   extern char *getenv();
+   extern char *rindex();
+ 
+   /* What is our shell? */
+   if ((shell = getenv ("SHELL")) == NULL)
+     shell = SHELL_FILE;
+   if ((shell_base = rindex (shell, '/')) != NULL)
+     ++shell_base;
+   else
+     shell_base = shell;
  
    /* If desired, concat something onto the front of ALLARGS.
***************
*** 431,435 ****
  
        call_ptrace (0);
!       execle (SHELL_FILE, "sh", "-c", shell_command, 0, env);
  
        fprintf (stderr, "Cannot exec %s: %s.\n", SHELL_FILE,
--- 426,430 ----
  
        call_ptrace (0);
!       execle (shell, shell_base, "-c", shell_command, (void *)0, env);
  
        fprintf (stderr, "Cannot exec %s: %s.\n", SHELL_FILE,

Index: main.c
***************
*** 22,25 ****
--- 22,26 ----
  #include "command.h"
  #include "param.h"
+ #include "signals.h"
  
  #ifdef USG
***************
*** 30,34 ****
  #include <sys/file.h>
  #include <setjmp.h>
- #include <signal.h>
  #include <sys/param.h>
  #include <sys/stat.h>
--- 31,34 ----

Index: standalone.c
***************
*** 20,24 ****
  #include <stdio.h>
  #include <sys/ioctl.h>
- #include <signal.h>
  #include <errno.h>
  #include <sys/types.h>
--- 20,23 ----
***************
*** 32,35 ****
--- 31,35 ----
  #include "defs.h"
  #include "param.h"
+ #include "signals.h"
  #include "symtab.h"
  #include "frame.h"

Index: utils.c
***************
*** 19,23 ****
  
  #include <stdio.h>
- #include <signal.h>
  #include <sys/ioctl.h>
  #include <sys/param.h>
--- 19,22 ----
***************
*** 25,31 ****
  #include "defs.h"
  #include "param.h"
! #ifdef HAVE_TERMIO
! #include <termio.h>
! #endif
  
  /* If this definition isn't overridden by the header files, assume
--- 24,29 ----
  #include "defs.h"
  #include "param.h"
! #include "signals.h"
! #include "terminal.h"
  
  /* If this definition isn't overridden by the header files, assume

Index: valprint.c
***************
*** 409,413 ****
  	      fprintf (stream, kind);
  	      if (TYPE_FN_FIELD_PHYSNAME (f, j)[0] == '_'
! 		  && TYPE_FN_FIELD_PHYSNAME (f, j)[1] == '$')
  		type_print_method_args
  		  (TYPE_FN_FIELD_ARGS (f, j) + 1, "~",
--- 409,413 ----
  	      fprintf (stream, kind);
  	      if (TYPE_FN_FIELD_PHYSNAME (f, j)[0] == '_'
! 		  && TYPE_FN_FIELD_PHYSNAME (f, j)[1] == CPLUS_MARKER)
  		type_print_method_args
  		  (TYPE_FN_FIELD_ARGS (f, j) + 1, "~",
***************
*** 1169,1174 ****
  	      QUIT;
  	      /* Don't print out virtual function table.  */
! 	      if (! strncmp (TYPE_FIELD_NAME (type, i),
! 			   "_vptr$", 6))
  		continue;
  
--- 1169,1174 ----
  	      QUIT;
  	      /* Don't print out virtual function table.  */
! 	      if (! strncmp (TYPE_FIELD_NAME (type, i), "_vptr", 5)
! 		  && *(TYPE_FIELD_NAME (type, i) + 5) == CPLUS_MARKER)
  		continue;
  
***************
*** 1213,1217 ****
  		  type_print (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)), "", stream, 0);
  		  if (TYPE_FN_FIELD_PHYSNAME (f, j)[0] == '_'
! 		      && TYPE_FN_FIELD_PHYSNAME (f, j)[1] == '$')
  		    type_print_method_args
  		      (TYPE_FN_FIELD_ARGS (f, j) + 1, "~",
--- 1213,1217 ----
  		  type_print (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)), "", stream, 0);
  		  if (TYPE_FN_FIELD_PHYSNAME (f, j)[0] == '_'
! 		      && TYPE_FN_FIELD_PHYSNAME (f, j)[1] == CPLUS_MARKER)
  		    type_print_method_args
  		      (TYPE_FN_FIELD_ARGS (f, j) + 1, "~",
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  m-i386-sco.h signals.h terminal.h
# Wrapped by chip@tct on Mon Aug  6 11:55:27 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'm-i386-sco.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'m-i386-sco.h'\"
else
echo shar: Extracting \"'m-i386-sco.h'\" \(1430 characters\)
sed "s/^X//" >'m-i386-sco.h' <<'END_OF_FILE'
X/* Macro defintions for i386, running SCO Unix System V/386 3.2.
X   Copyright (C) 1989 Free Software Foundation, Inc.
X
XThis file is part of GDB.
X
XGDB is free software; you can redistribute it and/or modify
Xit under the terms of the GNU General Public License as published by
Xthe Free Software Foundation; either version 1, or (at your option)
Xany later version.
X
XGDB is distributed in the hope that it will be useful,
Xbut WITHOUT ANY WARRANTY; without even the implied warranty of
XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
XGNU General Public License for more details.
X
XYou should have received a copy of the GNU General Public License
Xalong with GDB; see the file COPYING.  If not, write to
Xthe Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
X
X#include "m-i386.h"
X
X/* Apparently there is inconsistency among various System V's about what
X   the name of this field is.  */
X#define U_FPSTATE(u) u.u_fps.u_fpstate
X
X/* TIOCGETC is defined in System V 3.2 termio.h, but struct tchars
X   is not.  This makes problems for inflow.c.  */
X#define TIOCGETC_BROKEN
X
X/* All the job control definitions exist in SCO Unix, but the standard
X   shells don't use them.  So we must disable job control. */
X#define NO_JOB_CONTROL
X
X/* SCO's assembler doesn't grok dollar signs in identifiers.
X   So we use dots instead.  This item must be coordinated with G++. */
X#undef CPLUS_MARKER
X#define CPLUS_MARKER '.'
END_OF_FILE
if test 1430 -ne `wc -c <'m-i386-sco.h'`; then
    echo shar: \"'m-i386-sco.h'\" unpacked with wrong size!
fi
# end of 'm-i386-sco.h'
fi
if test -f 'signals.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'signals.h'\"
else
echo shar: Extracting \"'signals.h'\" \(130 characters\)
sed "s/^X//" >'signals.h' <<'END_OF_FILE'
X#include <signal.h>
X
X#ifdef NO_JOB_CONTROL
X# undef SIGTSTP
X# undef SIGSTOP
X# undef SIGCONT
X# undef SIGTTIN
X# undef SIGTTOU
X#endif
END_OF_FILE
if test 130 -ne `wc -c <'signals.h'`; then
    echo shar: \"'signals.h'\" unpacked with wrong size!
fi
# end of 'signals.h'
fi
if test -f 'terminal.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'terminal.h'\"
else
echo shar: Extracting \"'terminal.h'\" \(399 characters\)
sed "s/^X//" >'terminal.h' <<'END_OF_FILE'
X#ifdef HAVE_TERMIO
X
X#include <termio.h>
X
X#undef TIOCGETP
X#define TIOCGETP TCGETA
X#undef TIOCSETN
X#define TIOCSETN TCSETA
X#undef TIOCSETP
X#define TIOCSETP TCSETAF
X#define TERMINAL struct termio
X
X#ifdef NO_JOB_CONTROL
X# undef TIOCGPGRP
X# undef TIOCGPGRP
X#endif
X
X#else /* no termio */
X
X#include <sys/ioctl.h>
X#include <fcntl.h>
X#include <sgtty.h>
X#define TERMINAL struct sgttyb
X
X#endif /* no termio */
END_OF_FILE
if test 399 -ne `wc -c <'terminal.h'`; then
    echo shar: \"'terminal.h'\" unpacked with wrong size!
fi
# end of 'terminal.h'
fi
echo shar: End of shell archive.
exit 0
-- 
Chip Salzenberg at ComDev/TCT     <chip@tct.uucp>, <uunet!ateng!tct!chip>