From: maw@netcom.com (Martin Walker)
Subject: SCO 3.2.4 and ODT 2.0.0 patches - core and attach
Keywords: sco gdb core-support process-attach
Organization: Netcom - Online Communication Services  (408 241-9760 guest)
Distribution: gnu
Date: Fri, 20 Nov 1992 12:41:30 GMT

Hello all.

Enclosed in this message is a shar file with a patch and an extra include
file for GDB 4.7 for SCO 3.2.4 or SCO ODT 2.0.0 based machines. This
patch fixes a core file problem, and adds support for attaching to
processes. Please note that some of the files which are created by the
patch are exact duplicates of other GDB original files. I have created
new SCO ones merely to keep the file naming conventions intact.

Save the shar file below, and unshar. This will create two files:
gdb47sco.p and ptrace.h. Install ptrace.h in /usr/include/sys.
Then, change to the GDB top-level directory (cd gdb-4.7). Execute
``patch -p1 < ../gdb47sco.p''. Then, run ``./configure i386-sco''
and run a make. Your gdb will now read SCO core files properly, and
you can now use the attach and detach commands.

I have removed the _POSIX_SOURCE macro from the standard GDB config
files. On 3.2.4 development system, this causes major problems with
readline and some minor problems with gdb itself. When _POSIX_SOURCE
is defined, the SCO header files miss out big chunks of useful things,
like the TCGETA ioctl, and many others too.

These patches are known to work with ODT 2.0.0 witht he ODT 2.0.0
devsys, and on SCO Unix 3.2.4 and the 3.2.4 devsys.

I hope this helps all you SCO users. As far as I know, these patches
should work on 3.2.2 based SCO machines, although I do not know if
they provide the ptrace() system call. If they do, then all is well.
If not, remove the ATTACH_DETACH #define from gdb/xm-i386sco.h.

Regards,
Kean Johnston
Tel: +27-12-342-1145
Fax: +27-12-342-1754
Mail: via maw@netcom.com

----------------------------> cut here <-------------------------------
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then feed it
# into a shell via "sh file" or similar.  To overwrite existing files,
# type "sh file -c".
# The tool that generated this appeared in the comp.sources.unix newsgroup;
# send mail to comp-sources-unix@uunet.uu.net if you want that tool.
# Contents:  gdb47sco.p ptrace.h
# Wrapped by jkj@parst17 on Mon Nov 16 19:39:20 1992
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
echo If this archive is complete, you will see the following message:
echo '          "shar: End of archive."'
if test -f 'gdb47sco.p' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'gdb47sco.p'\"
else
  echo shar: Extracting \"'gdb47sco.p'\" \(9574 characters\)
  sed "s/^X//" >'gdb47sco.p' <<'END_OF_FILE'
Xdiff -r -c -N -C 2 gdb-4.7/bfd/config/i386-sco.mt gdb-4.7.new/bfd/config/i386-sco.mt
X*** gdb-4.7/bfd/config/i386-sco.mt
X--- gdb-4.7.new/bfd/config/i386-sco.mt	Mon Nov 16 18:15:05 1992
X***************
X*** 0 ****
X--- 1,2 ----
X+ # Target:  Intel 386 running SCO Unix 3.2.4.
X+ TDEFAULTS = -DDEFAULT_VECTOR=i386coff_vec
Xdiff -r -c -N -C 2 gdb-4.7/bfd/config/i386sco.mh gdb-4.7.new/bfd/config/i386sco.mh
X*** gdb-4.7/bfd/config/i386sco.mh
X--- gdb-4.7.new/bfd/config/i386sco.mh	Mon Nov 16 18:15:05 1992
X***************
X*** 0 ****
X--- 1,4 ----
X+ RANLIB = /bin/true
X+ ALLOCA = 
X+ HDEFINES=-DUSG -DSCO_CORE=1
X+ HDEPFILES=sco-core.o
Xdiff -r -c -N -C 2 gdb-4.7/bfd/configure.host gdb-4.7.new/bfd/configure.host
X*** gdb-4.7/bfd/configure.host	Fri Oct  9 13:38:25 1992
X--- gdb-4.7.new/bfd/configure.host	Mon Nov 16 18:15:06 1992
X***************
X*** 26,33 ****
X  i[34]86-ncr*-sysv4*)	my_host=ncr3000 ;;
X  i[34]86-*-go32)		my_host=go32 ;;
X  i[34]86-*-sysv4*)	my_host=i386v4 ;;
X  i[34]86-*-sysv*)	my_host=i386v ;;
X  i[34]86-*-solaris*)	my_host=i386v ;;
X- i[34]86-*-sco*)		my_host=i386v ;;
X  i[34]86-*-mach*)	my_host=i386mach ;;
X  i[34]86-*-msdos*)	my_host=dose ;;
X--- 26,33 ----
X  i[34]86-ncr*-sysv4*)	my_host=ncr3000 ;;
X  i[34]86-*-go32)		my_host=go32 ;;
X+ i[34]86-*-sco*)		my_host=i386sco ;;
X  i[34]86-*-sysv4*)	my_host=i386v4 ;;
X  i[34]86-*-sysv*)	my_host=i386v ;;
X  i[34]86-*-solaris*)	my_host=i386v ;;
X  i[34]86-*-mach*)	my_host=i386mach ;;
X  i[34]86-*-msdos*)	my_host=dose ;;
Xdiff -r -c -N -C 2 gdb-4.7/bfd/configure.in gdb-4.7.new/bfd/configure.in
X*** gdb-4.7/bfd/configure.in	Fri Oct 23 10:39:13 1992
X--- gdb-4.7.new/bfd/configure.in	Mon Nov 16 18:15:06 1992
X***************
X*** 48,52 ****
X    i[34]86-*-sysv4*)	bfd_target=i386-elf ;;
X    i[34]86-*-sysv*)	bfd_target=i386-coff ;;
X!   i[34]86-*-sco*)	bfd_target=i386-coff ;;
X    i[34]86-*-bsd*)	bfd_target=i386-bsd ;;
X    i[34]86-none-*)	bfd_target=i386-coff ;;
X--- 48,52 ----
X    i[34]86-*-sysv4*)	bfd_target=i386-elf ;;
X    i[34]86-*-sysv*)	bfd_target=i386-coff ;;
X!   i[34]86-*-sco*)	bfd_target=i386-sco ;;
X    i[34]86-*-bsd*)	bfd_target=i386-bsd ;;
X    i[34]86-none-*)	bfd_target=i386-coff ;;
X***************
X*** 83,87 ****
X    *-*-linux*)		bfd_target=${target_cpu}-linux ;;
X    *-*-sysv*)		bfd_target=${target_cpu}-coff ;;
X!   *-*-scosysv*)		bfd_target=${target_cpu}-coff ;;
X  
X    *-adobe-*)		bfd_target=adobe ;;
X--- 83,87 ----
X    *-*-linux*)		bfd_target=${target_cpu}-linux ;;
X    *-*-sysv*)		bfd_target=${target_cpu}-coff ;;
X!   *-*-sco*)		bfd_target=${target_cpu}-sco ;;
X  
X    *-adobe-*)		bfd_target=adobe ;;
Xdiff -r -c -N -C 2 gdb-4.7/bfd/hosts/i386sco.h gdb-4.7.new/bfd/hosts/i386sco.h
X*** gdb-4.7/bfd/hosts/i386sco.h
X--- gdb-4.7.new/bfd/hosts/i386sco.h	Mon Nov 16 18:15:06 1992
X***************
X*** 0 ****
X--- 1,55 ----
X+ #include <fcntl.h>
X+ #include <errno.h>
X+ #include <stdio.h>
X+ #include <sys/types.h>
X+ #include <sys/stat.h>
X+ #include <utime.h>
X+ #include <ctype.h>
X+ #include <string.h>
X+ #include <unistd.h>
X+ 
X+ #ifndef O_ACCMODE
X+ #define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
X+ #endif
X+ #ifndef SEEK_SET
X+ #define SEEK_SET 0
X+ #define SEEK_CUR 1
X+ #endif
X+ 
X+ #define	POSIX_UTIME
X+ 
X+ /* Some things that need to be defined in order to make code written for
X+    BSD Unix compile under System V Unix.  */
X+ 
X+ /*#include <memory.h>*/
X+ #define bcmp(b1,b2,len)		memcmp(b1,b2,len)
X+ #define bcopy(src,dst,len)	memcpy(dst,src,len)
X+ #define bzero(s,n)		memset(s,0,n)
X+ 
X+ #include <string.h>
X+ #define index(s,c)		strchr(s,c)
X+ #define rindex(s,c)		strrchr(s,c)
X+ 
X+ #ifndef DONTDECLARE_MALLOC
X+ extern PTR  EXFUN(malloc,(unsigned));
X+ extern PTR  EXFUN(realloc, (PTR, unsigned));
X+ extern void EXFUN(free,(PTR));
X+ #endif
X+ 
X+ /* EXACT TYPES */
X+ typedef char int8e_type;
X+ typedef unsigned char uint8e_type;
X+ typedef short int16e_type;
X+ typedef unsigned short uint16e_type;
X+ typedef int int32e_type;
X+ typedef unsigned int uint32e_type;
X+ 
X+ /* CORRECT SIZE OR GREATER */
X+ typedef char int8_type;
X+ typedef unsigned char uint8_type;
X+ typedef short int16_type;
X+ typedef unsigned short uint16_type;
X+ typedef int int32_type;
X+ typedef unsigned int uint32_type;
X+ 
X+ #include "fopen-same.h"
Xdiff -r -c -N -C 2 gdb-4.7/bfd/sco-core.c gdb-4.7.new/bfd/sco-core.c
X*** gdb-4.7/bfd/sco-core.c	Fri Oct 16 21:16:09 1992
X--- gdb-4.7.new/bfd/sco-core.c	Mon Nov 16 18:15:06 1992
X***************
X*** 270,273 ****
X--- 270,274 ----
X  
X    (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
X+     '_',                                                   /* symbol prefix */
X      ' ',						   /* ar_pad_char */
X      16,							   /* ar_max_namelen */
Xdiff -r -c -N -C 2 gdb-4.7/bfd/targets.c gdb-4.7.new/bfd/targets.c
X*** gdb-4.7/bfd/targets.c	Thu Oct  8 22:18:08 1992
X--- gdb-4.7.new/bfd/targets.c	Mon Nov 16 18:15:07 1992
X***************
X*** 375,379 ****
X--- 375,382 ----
X  #define SELECT_VECS &DEFAULT_VECTOR
X  #endif
X+ #ifdef SCO_CORE
X+ #define SELECT_VECS &DEFAULT_VECTOR,&sco_core_vec
X  #endif
X+ #endif
X  
X  /* All known xvecs.  They are listed a second time below, since
X***************
X*** 400,403 ****
X--- 403,409 ----
X  extern bfd_target i386linux_vec;
X  extern bfd_target a29kcoff_big_vec;
X+ #ifdef SCO_CORE
X+ extern bfd_target sco_core_vec;
X+ #endif
X  extern bfd_target trad_core_vec;
X  extern bfd_target rs6000coff_vec;
X***************
X*** 467,470 ****
X--- 473,479 ----
X  #ifdef	TRAD_CORE
X  	&trad_core_vec,
X+ #endif
X+ #ifdef SCO_CORE
X+ 	&sco_core_vec,
X  #endif
X  	NULL, /* end of list marker */
Xdiff -r -c -N -C 2 gdb-4.7/config/mh-sco gdb-4.7.new/config/mh-sco
X*** gdb-4.7/config/mh-sco	Thu Oct 22 09:59:45 1992
X--- gdb-4.7.new/config/mh-sco	Mon Nov 16 18:15:07 1992
X***************
X*** 3,5 ****
X  RANLIB = true
X  BISON = yacc -Sm10400
X! CC = gcc -D_POSIX_SOURCE=1
X--- 3,5 ----
X  RANLIB = true
X  BISON = yacc -Sm10400
X! CC = gcc -O2
Xdiff -r -c -N -C 2 gdb-4.7/gdb/config/i386sco.mh gdb-4.7.new/gdb/config/i386sco.mh
X*** gdb-4.7/gdb/config/i386sco.mh	Thu Oct 22 10:07:12 1992
X--- gdb-4.7.new/gdb/config/i386sco.mh	Mon Nov 16 18:15:07 1992
X***************
X*** 1,13 ****
X! # Host: Intel 386 running SCO Unix (pre-SVR4)
X! XDEPFILES= i387-tdep.o
X  XM_FILE= xm-i386sco.h
X  NAT_FILE= nm-i386sco.h
X  NATDEPFILES= infptrace.o inftarg.o fork-child.o coredep.o corelow.o i386v-nat.o
X! XM_CLIBS= -lPW
X  SYSV_DEFINE=-DSYSV
X  REGEX=regex.o
X  REGEX1=regex.o
X- #msg The SCO C compiler cannot parse symtab.h when value.h has been included.
X- #msg This is a bug in the compiler; the code is valid.
X- #msg Therefore, you must use GCC to compile GDB on SCO machines.
X- CC=gcc -D_POSIX_SOURCE=1
X--- 1,9 ----
X! # Host: Intel 386 running System V release 3.2
X! XDEPFILES= 
X  XM_FILE= xm-i386sco.h
X  NAT_FILE= nm-i386sco.h
X  NATDEPFILES= infptrace.o inftarg.o fork-child.o coredep.o corelow.o i386v-nat.o
X! XM_CLIBS= 
X  SYSV_DEFINE=-DSYSV
X  REGEX=regex.o
X  REGEX1=regex.o
Xdiff -r -c -N -C 2 gdb-4.7/gdb/config/i386sco.mt gdb-4.7.new/gdb/config/i386sco.mt
X*** gdb-4.7/gdb/config/i386sco.mt
X--- gdb-4.7.new/gdb/config/i386sco.mt	Mon Nov 16 18:15:08 1992
X***************
X*** 0 ****
X--- 1,3 ----
X+ # Target: Intel 386 running System V
X+ TDEPFILES= exec.o i386-tdep.o i386-pinsn.o i387-tdep.o
X+ TM_FILE= tm-i386v.h
Xdiff -r -c -N -C 2 gdb-4.7/gdb/configure.in gdb-4.7.new/gdb/configure.in
X*** gdb-4.7/gdb/configure.in	Thu Oct 15 00:50:18 1992
X--- gdb-4.7.new/gdb/configure.in	Mon Nov 16 18:15:08 1992
X***************
X*** 25,29 ****
X  i[34]86-*-linux)	gdb_host=linux ;;
X  i[34]86-*-mach)		gdb_host=i386mach ;;
X! i[34]86-*-scosysv*)	gdb_host=i386sco ;;
X  i[34]86-*-solaris*)	gdb_host=i386sol2 ;;
X  i[34]86-*-sunos*)	gdb_host=sun386 ;;
X--- 25,29 ----
X  i[34]86-*-linux)	gdb_host=linux ;;
X  i[34]86-*-mach)		gdb_host=i386mach ;;
X! i[34]86-*-sco*)		gdb_host=i386sco ;;
X  i[34]86-*-solaris*)	gdb_host=i386sol2 ;;
X  i[34]86-*-sunos*)	gdb_host=sun386 ;;
X***************
X*** 86,90 ****
X  esac
X  
X- 
X  if [ ! -f ${srcdir}/config/${gdb_host}.mh ]; then
X  	echo '***' "Gdb does not support host ${host}" 1>&2
X--- 86,89 ----
X***************
X*** 129,133 ****
X  i[34]86-*-sunos*)	gdb_target=sun386 ;;
X  i[34]86-*-sysv4*)	gdb_target=i386v4 ;;
X! i[34]86-*-scosysv3*)	gdb_target=i386v ;;
X  i[34]86-*-sysv*)	gdb_target=i386v ;;
X  i[34]86-*-linux)	gdb_target=linux ;;
X--- 128,132 ----
X  i[34]86-*-sunos*)	gdb_target=sun386 ;;
X  i[34]86-*-sysv4*)	gdb_target=i386v4 ;;
X! i[34]86-*-sco*)		gdb_target=i386sco ;;
X  i[34]86-*-sysv*)	gdb_target=i386v ;;
X  i[34]86-*-linux)	gdb_target=linux ;;
Xdiff -r -c -N -C 2 gdb-4.7/gdb/nm-i386sco.h gdb-4.7.new/gdb/nm-i386sco.h
X*** gdb-4.7/gdb/nm-i386sco.h	Thu Oct 22 21:32:06 1992
X--- gdb-4.7.new/gdb/nm-i386sco.h	Mon Nov 16 18:52:47 1992
X***************
X*** 40,42 ****
X   * (why, I don't know), and we don't need it.
X   */
X- #define NO_PTRACE_H
X--- 40,41 ----
Xdiff -r -c -N -C 2 gdb-4.7/gdb/xm-i386sco.h gdb-4.7.new/gdb/xm-i386sco.h
X*** gdb-4.7/gdb/xm-i386sco.h	Thu Oct 22 06:47:04 1992
X--- gdb-4.7.new/gdb/xm-i386sco.h	Mon Nov 16 18:51:46 1992
X***************
X*** 41,42 ****
X--- 41,43 ----
X  /* Use setpgid instead of setpgrp on SCO */
X  #define NEED_POSIX_SETPGID
X+ #define ATTACH_DETACH
Xdiff -r -c -N -C 2 gdb-4.7/readline/config/mh-sco gdb-4.7.new/readline/config/mh-sco
X*** gdb-4.7/readline/config/mh-sco	Fri Jun 19 21:54:57 1992
X--- gdb-4.7.new/readline/config/mh-sco	Mon Nov 16 18:15:09 1992
X***************
X*** 1,4 ****
X  # Define USG as -DUSG if you are using a System V operating system.
X! USG = -DUSG -D_POSIX_SOURCE=1
X  RANLIB = true
X  INSTALL_PROG = cp
X--- 1,4 ----
X  # Define USG as -DUSG if you are using a System V operating system.
X! USG = -DUSG
X  RANLIB = true
X  INSTALL_PROG = cp
END_OF_FILE
  if test 9574 -ne `wc -c <'gdb47sco.p'`; then
    echo shar: \"'gdb47sco.p'\" unpacked with wrong size!
  fi
  # end of 'gdb47sco.p'
fi
if test -f 'ptrace.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ptrace.h'\"
else
  echo shar: Extracting \"'ptrace.h'\" \(1632 characters\)
  sed "s/^X//" >'ptrace.h' <<'END_OF_FILE'
X#ifndef _SYS_PTRACE
X#define _SYS_PTRACE
X
X/*
X** This header file defines the ptrace function, and the symbolic names
X** for the different requests which can be made to ptrace. This allows
X** programs like GDB to make use of ptrace for attached to and detaching
X** from a child process. Why SCO, in their wisdom(?) left this out of the
X** development system will remain a mystery for all time.
X**
X** Thanks to the SunOS header file for ptrace. I have made the definition
X** and names as close to that original as possible.
X**
X** The SCO documentation also says that you can use ptrace() to modify the
X** 80[34]86 debug registers. Maybe this can be put to good use by GDB.
X** I will look into this, and keep you posted. If you already know how
X** this can be used, then please leave me mail at maw@netcom.com.
X*/
X
Xenum ptracereq {
X	PTRACE_TRACEME = 0,		/* 0, by tracee to begin tracing */
X	PTRACE_CHILDDONE = 0,	/* 0, tracee is done with his half */
X	PTRACE_PEEKTEXT,		/* 1, read word from text segment */
X	PTRACE_PEEKDATA,		/* 2, read word from data segment */
X	PTRACE_PEEKUSER,		/* 3, read word from user struct */
X	PTRACE_POKETEXT,		/* 4, write word into text segment */
X	PTRACE_POKEDATA,		/* 5, write word into data segment */
X	PTRACE_POKEUSER,		/* 6, write word into user struct */
X	PTRACE_CONT,			/* 7, continue process */
X	PTRACE_KILL,			/* 8, terminate process */
X	PTRACE_SINGLESTEP,		/* 9, single step process */
X	PTRACE_ATTACH,			/* 10, attach to an existing process */
X	PTRACE_DETACH,			/* 11, detach from a process */
X};
X
Xextern int ptrace (enum ptracereq request, int pid, char *addr, int data);
X
X#endif /* _SYS_PTRACE */
END_OF_FILE
  if test 1632 -ne `wc -c <'ptrace.h'`; then
    echo shar: \"'ptrace.h'\" unpacked with wrong size!
  fi
  # end of 'ptrace.h'
fi
echo shar: End of archive.
exit 0
----------------------------> cut here <-------------------------------

-- 
Martin Walker               |  "One way to stop a runaway horse
++27-12-344-3973 (w)        |   is to bet on him"
++27-12-998-7263 (h)        |   maw@netcom.com
Pretoria, South Africa      |   martin@paradigm.CO.ZA

Newsgroups: gnu.gdb.bug