[gnu.gdb.bug] Some diffs needed for GDB 3.2 on USG systems

jkp@SAUNA.HUT.FI (Jyrki Kuoppala) (07/14/89)

There's some problems compiling GDB 3.2 on USG-based systems.  This
diff gets GDB to compile and run on SVR2 systems with an add-on ndir
library.

The problems are:

- some systems need an extra libndir.a library and include ndir.h
- the special case for Altos in a.out.encap.h is actually not needed;
  in the beginning I used it to get over a kernel bug, but it doesn't
  quite do it so it's better removed
- coffread.c doesn't know about m68k magic
- in core.c <sys/page.h> and <sys/net.h> are needed at least for Altos
- I added definition of alloca to use builtin alloca in defs.h, so
  you get along without an alloca in libc.a
- in readline.c, getpwuid() is struct passwd * instead of struct pwd *
- in readline.c, rl_prep_terminal and rl_reprep_terminal are
  erraneously declared static
- in readline.c, MAX is used instead of max; MAX isn't defined on all
  machines (happens to be on most Bsd machines like sun & vax, so this has
  been unnoticed)

That's all folks, keep up the good work !

//Jyrki

Here's the diff:

diff -cr dist-gdb/Makefile dist-gdb.altos/Makefile
*** dist-gdb/Makefile	Tue Jul 11 07:07:03 1989
--- dist-gdb.altos/Makefile	Thu Jul 13 17:11:38 1989
***************
*** 93,101 ****
  #MUNCH_DEFINE =
  MUNCH_DEFINE = ${SYSV_DEFINE}
  
  # Flags that describe where you can find the termcap library.
! # You may need to make other arrangements for USG.
  TERMCAP = -ltermcap
  
  # for BSD
  CLIBS = ${ADD_FILES} ${TERMCAP}
--- 95,107 ----
  #MUNCH_DEFINE =
  MUNCH_DEFINE = ${SYSV_DEFINE}
  
+ #
+ # define this if you use <ndir.h>
+ NDIR_DEFINE = -DNDIR
+ 
  # Flags that describe where you can find the termcap library.
! # You may need to make other arrangements for USG (ie. -ndir for dir library)
  TERMCAP = -ltermcap
  
  # for BSD
  CLIBS = ${ADD_FILES} ${TERMCAP}
***************
*** 245,251 ****
  #	${CC} -c ${CFLAGS} ${SYSV_DEFINE} history.c
  
  readline/libreadline.a : force_update
! 	cd readline ; ${MAKE} "SYSV_DEFINE=${SYSV_DEFINE}" libreadline.a
  
  force_update :
  
--- 251,257 ----
  #	${CC} -c ${CFLAGS} ${SYSV_DEFINE} history.c
  
  readline/libreadline.a : force_update
! 	cd readline ; ${MAKE} "SYSV_DEFINE=${SYSV_DEFINE}" "NDIR_DEFINE=${NDIR_DEFINE}" libreadline.a
  
  force_update :
  
diff -cr dist-gdb/a.out.encap.h dist-gdb.altos/a.out.encap.h
*** dist-gdb/a.out.encap.h	Thu Jun  1 00:55:21 1989
--- dist-gdb.altos/a.out.encap.h	Thu Jul 13 13:39:07 1989
***************
*** 122,144 ****
  #define N_TXTADDR(x) \
  	((N_FLAGS(x) & N_FLAGS_COFF_ENCAPSULATE) ? \
  	 sizeof (struct coffheader) + sizeof (struct exec) : 0)
- 
- #ifdef ALTOS
- #undef SEGMENT_SIZE
- #undef DEFAULT_MAGIC
- #define DEFAULT_MAGIC NMAGIC
- #define SEGMENT_SIZE 0x40000
- #define N_DATADDR(x) \
- 	((N_FLAGS(x) & N_FLAGS_COFF_ENCAPSULATE) ? \
- 	 (((N_TXTADDR(x)+(x).a_text+0x2000) / SEGMENT_SIZE + 1) * SEGMENT_SIZE + \
- 	 (N_TXTADDR(x)+(x).a_text+0x2000) % 0x2000) : \
- 	 (N_TXTADDR(x)+(x).a_text))
- #else /* not ALTOS */
- 
  #define SEGMENT_SIZE 0x400000
  #define N_DATADDR(x) \
  	((N_FLAGS(x) & N_FLAGS_COFF_ENCAPSULATE) ? \
  	 (SEGMENT_SIZE + ((N_TXTADDR(x)+(x).a_text-1) & ~(SEGMENT_SIZE-1))) : \
  	 (N_TXTADDR(x)+(x).a_text))
- 
- #endif /* not ALTOS */
--- 124,132 ----
  #define N_TXTADDR(x) \
  	((N_FLAGS(x) & N_FLAGS_COFF_ENCAPSULATE) ? \
  	 sizeof (struct coffheader) + sizeof (struct exec) : 0)
  #define SEGMENT_SIZE 0x400000
+ 
  #define N_DATADDR(x) \
  	((N_FLAGS(x) & N_FLAGS_COFF_ENCAPSULATE) ? \
  	 (SEGMENT_SIZE + ((N_TXTADDR(x)+(x).a_text-1) & ~(SEGMENT_SIZE-1))) : \
  	 (N_TXTADDR(x)+(x).a_text))
diff -cr dist-gdb/coffread.c dist-gdb.altos/coffread.c
*** dist-gdb/coffread.c	Wed Jul  5 22:45:00 1989
--- dist-gdb.altos/coffread.c	Thu Jul 13 13:40:01 1989
***************
*** 1081,1086 ****
--- 1081,1089 ----
  
    switch (file_hdr->f_magic)
      {
+ #ifdef MC68MAGIC
+       case MC68MAGIC:
+ #endif
  #ifdef NS32GMAGIC
        case NS32GMAGIC:
        case NS32SMAGIC:
diff -cr dist-gdb/core.c dist-gdb.altos/core.c
*** dist-gdb/core.c	Wed Jul  5 22:45:09 1989
--- dist-gdb.altos/core.c	Thu Jul 13 13:41:10 1989
***************
*** 44,49 ****
--- 44,55 ----
  #include <sys/file.h>
  #include <sys/stat.h>
  
+ #ifdef USG
+ #include <sys/page.h>
+ #ifdef ALTOS
+ #include <sys/net.h>
+ #endif
+ #endif
  #ifdef UMAX_CORE
  #include <sys/ptrace.h>
  #else
diff -cr dist-gdb/defs.h dist-gdb.altos/defs.h
*** dist-gdb/defs.h	Mon Jul 10 03:26:33 1989
--- dist-gdb.altos/defs.h	Thu Jul 13 13:41:59 1989
***************
*** 25,31 ****
--- 25,39 ----
  extern char *savestring ();
  extern char *concat ();
  extern char *xmalloc (), *xrealloc ();
+ #ifdef __GNUC__
+ #define alloca __builtin_alloca
+ #else
+ #ifdef sparc
+ #include <alloca.h>
+ #else
  extern char *alloca ();
+ #endif
+ #endif
  extern int parse_escape ();
  extern char *reg_names[];
  
***************
*** 88,95 ****
  /* String containing the current directory (what getwd would return).  */
  
  char *current_directory;
- 
- #ifdef sparc
- #include <alloca.h>
- #endif
- 
--- 96,98 ----
diff -cr dist-gdb/readline/Makefile dist-gdb.altos/readline/Makefile
*** dist-gdb/readline/Makefile	Sun Jul  9 02:03:50 1989
--- dist-gdb.altos/readline/Makefile	Thu Jul 13 16:51:04 1989
***************
*** 20,26 ****
  # GCC_SUNOS4_FLAG = -Bstatic
  DEBUG_FLAGS = -g
  # LDFLAGS = $(DEBUG_FLAGS) 
! CFLAGS = $(DEBUG_FLAGS)
  
  # If you don't have Gcc use cc.
  # CC = cc
--- 20,26 ----
  # GCC_SUNOS4_FLAG = -Bstatic
  DEBUG_FLAGS = -g
  # LDFLAGS = $(DEBUG_FLAGS) 
! CFLAGS = $(DEBUG_FLAGS) $(SYSV_DEFINE) $(NDIR_DEFINE)
  
  # If you don't have Gcc use cc.
  # CC = cc
diff -cr dist-gdb/readline/history.c dist-gdb.altos/readline/history.c
*** dist-gdb/readline/history.c	Sat Jul  8 00:31:15 1989
--- dist-gdb.altos/readline/history.c	Thu Jul 13 13:42:39 1989
***************
*** 35,40 ****
--- 35,42 ----
  #else
  #if defined (sparc) && defined (sun)
  #include <alloca.h>
+ #else
+ extern char *alloca ();
  #endif
  #endif
  
diff -cr dist-gdb/readline/readline.c dist-gdb.altos/readline/readline.c
*** dist-gdb/readline/readline.c	Sat Jul  8 00:45:35 1989
--- dist-gdb.altos/readline/readline.c	Thu Jul 13 16:58:14 1989
***************
*** 42,47 ****
--- 42,49 ----
  #else
  #if defined (sparc) && defined (sun)
  #include <alloca.h>
+ #else
+ extern char *alloca ();
  #endif
  #endif
  
***************
*** 59,65 ****
  
  #include <pwd.h>
  #ifdef SYSV
! struct pwd *getpwuid (), *getpwent ();
  #endif
  
  #define HACK_TERMCAP_MOTION
--- 61,67 ----
  
  #include <pwd.h>
  #ifdef SYSV
! struct passwd *getpwuid (), *getpwent ();
  #endif
  
  #define HACK_TERMCAP_MOTION
***************
*** 67,73 ****
  #ifndef SYSV
  #include <sys/dir.h>
  #else  /* SYSV */
! #ifdef HPUX
  #include <ndir.h>
  #else
  #include <dirent.h>
--- 69,75 ----
  #ifndef SYSV
  #include <sys/dir.h>
  #else  /* SYSV */
! #if defined(HPUX) || defined(NDIR)
  #include <ndir.h>
  #else
  #include <dirent.h>
***************
*** 1450,1456 ****
  #if defined(SYSV) || defined(HPUX)
  static struct termio otio;
  
- static
  rl_prep_terminal ()
  {
    int tty = open ("/dev/tty", O_RDONLY);
--- 1452,1457 ----
***************
*** 1469,1475 ****
    close (tty);
  }
  
- static
  rl_deprep_terminal ()
  {
    int tty = open ("/dev/tty", O_RDONLY);
--- 1470,1475 ----
diff -cr dist-gdb/source.c dist-gdb.altos/source.c
*** dist-gdb/source.c	Tue Jul 11 05:26:11 1989
--- dist-gdb.altos/source.c	Thu Jul 13 16:58:33 1989
***************
*** 87,93 ****
        sal = sals.sals[0];
        free (sals.sals);
        current_source_symtab = sal.symtab;
!       current_source_line = MAX (sal.line - 9, 1);
        return;
      }
    
--- 87,93 ----
        sal = sals.sals[0];
        free (sals.sals);
        current_source_symtab = sal.symtab;
!       current_source_line = max (sal.line - 9, 1);
        return;
      }