From 407a8389b40fa7af08cae8f1eb347c67cc2436ad Mon Sep 17 00:00:00 2001 From: Stu Grossman Date: Thu, 5 Mar 1992 20:20:27 +0000 Subject: [PATCH] * config.sub configure.in config/.Sanitize config/mh-irix4 gdb/.Sanitize gdb/configure.in gdb/mips-tdep.c gdb/mipsread.c gdb/procfs.c gdb/signame.h gdb/tm-irix3.h gdb/tm-mips.h gdb/xm-irix4.h gdb/config/.Sanitize gdb/config/mt-irix3 gdb/config/mh-irix4 texinfo/configure.in: Port to SGI Irix-4.x. --- config/.Sanitize | 1 + config/mh-irix4 | 5 ++ configure.in | 3 +- gdb/.Sanitize | 1 + gdb/config/.Sanitize | 1 + gdb/config/irix3.mt | 2 +- gdb/config/irix4.mh | 7 +++ gdb/configure.in | 7 ++- gdb/mips-tdep.c | 113 +++++++++++++++++++++++++++++++++++++++++++ gdb/mipsread.c | 5 +- gdb/procfs.c | 33 ++++++++++++- gdb/signame.h | 2 + gdb/tm-irix3.h | 14 ++++++ gdb/tm-mips.h | 2 +- gdb/xm-irix4.h | 50 +++++++++++++++++++ 15 files changed, 238 insertions(+), 8 deletions(-) create mode 100644 config/mh-irix4 create mode 100644 gdb/config/irix4.mh create mode 100644 gdb/xm-irix4.h diff --git a/config/.Sanitize b/config/.Sanitize index a9ce3475e12..06719bbb10d 100644 --- a/config/.Sanitize +++ b/config/.Sanitize @@ -25,6 +25,7 @@ mh-apollo68 mh-decstation mh-delta88 mh-dgux +mh-irix4 mh-sco mh-sysv mh-sysv4 diff --git a/config/mh-irix4 b/config/mh-irix4 new file mode 100644 index 00000000000..a11517e4455 --- /dev/null +++ b/config/mh-irix4 @@ -0,0 +1,5 @@ +# Makefile changes for SGI's running IRIX-4.x. +# Tell compiler to use K&R C. We can't compile under the SGI Ansi environment. +CC = cc -cckr +SYSV = -DSYSV +RANLIB = echo >/dev/null diff --git a/configure.in b/configure.in index bc7c0ec55c3..bb98e6edd21 100644 --- a/configure.in +++ b/configure.in @@ -14,7 +14,8 @@ srcname="gnu development package" case "${host_os}" in m88kbcs) host_makefile_frag=config/mh-delta88;; sysv4*) host_makefile_frag=config/mh-sysv4 ;; -sysv* | irix*) host_makefile_frag=config/mh-sysv ;; +sysv* | irix3) host_makefile_frag=config/mh-sysv ;; +irix4) host_makefile_frag=config/mh-irix4 ;; ultrix*) case "${host_cpu}" in mips) host_makefile_frag=config/mh-decstation ;; diff --git a/gdb/.Sanitize b/gdb/.Sanitize index 5cefd71556f..4c709226324 100644 --- a/gdb/.Sanitize +++ b/gdb/.Sanitize @@ -266,6 +266,7 @@ xm-i386v.h xm-i386v4.h xm-i386v32.h xm-irix3.h +xm-irix4.h xm-isi.h xm-m68k.h xm-merlin.h diff --git a/gdb/config/.Sanitize b/gdb/config/.Sanitize index f66f767d3f9..cb48765d707 100644 --- a/gdb/config/.Sanitize +++ b/gdb/config/.Sanitize @@ -41,6 +41,7 @@ mh-i386v-g mh-i386v32 mh-i386v32-g mh-irix3 +mh-irix4 mh-isi mh-littlemips mh-m88k diff --git a/gdb/config/irix3.mt b/gdb/config/irix3.mt index 3cd05bb1e9d..18948d9a1a6 100644 --- a/gdb/config/irix3.mt +++ b/gdb/config/irix3.mt @@ -1,3 +1,3 @@ -# Target: Big-endian MIPS machine such as Sony News +# Target: SGI mips TDEPFILES= mips-pinsn.o mips-tdep.o mipsread.o exec.o TM_FILE= tm-irix3.h diff --git a/gdb/config/irix4.mh b/gdb/config/irix4.mh new file mode 100644 index 00000000000..d6276ccd7ab --- /dev/null +++ b/gdb/config/irix4.mh @@ -0,0 +1,7 @@ +# Host: SGI Iris running irix 4.x +XDEPFILES= procfs.o coredep.o +XM_FILE= xm-irix4.h +ALLOCA=alloca.o +ALLOCA1=alloca.o +MUNCH_DEFINE=-B +XM_CLIBS=-lbsd diff --git a/gdb/configure.in b/gdb/configure.in index f4d90257cdd..a5b1cd6249e 100644 --- a/gdb/configure.in +++ b/gdb/configure.in @@ -80,7 +80,12 @@ mips) sony) gdb_host=bigmips ;; dec) gdb_host=decstation ;; little) gdb_host=littlemips ;; - sgi) gdb_host=irix3 ;; + sgi) + case "${host_os}" in + sysv) gdb_host=irix3 ;; + irix4) gdb_host=irix4 ;; + esac + ;; esac ;; diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 8a9d93c70b6..98520d43d09 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -36,6 +36,12 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include +#ifdef sgi +/* Must do it this way only for SGIs, as other mips platforms get their + JB_ symbols from machine/pcb.h (included via sys/user.h). */ +#include +#endif + #include "gdbcore.h" #ifndef MIPSMAGIC @@ -641,7 +647,114 @@ isa_NAN(p, len) } else return 1; } + +/* + * Implemented for Irix 4.x by Garrett A. Wollman + */ +#ifdef USE_PROC_FS /* Target-dependent /proc support */ + +#include +#include + +typedef unsigned int greg_t; /* why isn't this defined? */ + +/* + * See the comment in m68k-tdep.c regarding the utility of these functions. + */ + +void +supply_gregset (gregsetp) + gregset_t *gregsetp; +{ + register int regno; + register greg_t *regp = (greg_t *)(gregsetp->gp_regs); + + /* FIXME: somewhere, there should be a #define for the meaning + of this magic number 32; we should use that. */ + for(regno = 0; regno < 32; regno++) + supply_register (regno, (char *)(regp + regno)); + + supply_register (PC_REGNUM, (char *)&(gregsetp->gp_pc)); + supply_register (HI_REGNUM, (char *)&(gregsetp->gp_mdhi)); + supply_register (LO_REGNUM, (char *)&(gregsetp->gp_mdlo)); + supply_register (PS_REGNUM, (char *)&(gregsetp->gp_cause)); +} + +void +fill_gregset (gregsetp, regno) + gregset_t *gregsetp; + int regno; +{ + int regi; + register greg_t *regp = (greg_t *)(gregsetp->gp_regs); + extern char registers[]; + + /* same FIXME as above wrt 32*/ + for (regi = 0; regi < 32; regi++) + if ((regno == -1) || (regno == regi)) + *(regp + regno) = *(greg_t *) ®isters[REGISTER_BYTE (regi)]; + + if ((regno == -1) || (regno == PC_REGNUM)) + gregsetp->gp_pc = *(greg_t *) ®isters[REGISTER_BYTE (PC_REGNUM)]; + + if ((regno == -1) || (regno == PS_REGNUM)) + gregsetp->gp_cause = *(greg_t *) ®isters[REGISTER_BYTE (PS_REGNUM)]; + + if ((regno == -1) || (regno == HI_REGNUM)) + gregsetp->gp_mdhi = *(greg_t *) ®isters[REGISTER_BYTE (HI_REGNUM)]; + + if ((regno == -1) || (regno == LO_REGNUM)) + gregsetp->gp_mdlo = *(greg_t *) ®isters[REGISTER_BYTE (LO_REGNUM)]; +} + +/* + * Now we do the same thing for floating-point registers. + * We don't bother to condition on FP0_REGNUM since any + * reasonable MIPS configuration has an R3010 in it. + * + * Again, see the comments in m68k-tdep.c. + */ +void +supply_fpregset (fpregsetp) + fpregset_t *fpregsetp; +{ + register int regno; + + for (regno = 0; regno < 32; regno++) + supply_register (FP0_REGNUM + regno, + (char *)&fpregsetp->fp_r.fp_regs[regno]); + + supply_register (FCRCS_REGNUM, (char *)&fpregsetp->fp_csr); + + /* FIXME: how can we supply FCRIR_REGNUM? SGI doesn't tell us. */ +} + +void +fill_fpregset (fpregsetp, regno) + fpregset_t *fpregsetp; + int regno; +{ + int regi; + char *from, *to; + extern char registers[]; + + for (regi = FP0_REGNUM; regi < FP0_REGNUM + 32; regi++) + { + if ((regno == -1) || (regno == regi)) + { + from = (char *) ®isters[REGISTER_BYTE (regi)]; + to = (char *) &(fpregsetp->fp_r.fp_regs[regi]); + bcopy(from, to, REGISTER_RAW_SIZE (regno)); + } + } + + if ((regno == -1) || (regno == FCRCS_REGNUM)) + fpregsetp->fp_csr = *(unsigned *) ®isters[REGISTER_BYTE(FCRCS_REGNUM)]; +} + +#endif /* USE_PROC_FS */ + /* To skip prologues, I use this predicate. Returns either PC itself if the code at PC does not look like a function prologue, PC+4 if it does (our caller does not need anything more fancy). */ diff --git a/gdb/mipsread.c b/gdb/mipsread.c index 3f2fcd0ec05..61c3d3a84c6 100644 --- a/gdb/mipsread.c +++ b/gdb/mipsread.c @@ -2347,10 +2347,11 @@ psymtab_to_symtab_1(pst, filename) /* Procedures next, note we need to look-ahead to find out where the procedure's code ends */ - for (i = 0; i < fh->cpd-1; i++) { + if (fh->cpd > 0) + for (i = 0; i < fh->cpd-1; i++) { pr = (PDR *) (IPDFIRST(cur_hdr, fh)) + i; parse_procedure(pr, pr[1].adr); /* next proc up */ - } + } if (fh->cpd) { pr = (PDR *) (IPDFIRST(cur_hdr, fh)) + i; parse_procedure(pr, bound); /* next file up */ diff --git a/gdb/procfs.c b/gdb/procfs.c index c10ba0a6544..58e8878633e 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -36,6 +36,7 @@ regardless of whether or not the actual target has floating point hardware. #ifdef USE_PROC_FS /* Entire file goes away if not using /proc */ +#include #include #include #include @@ -466,8 +467,23 @@ proc_set_exec_trap () _exit (127); } premptyset (&exitset); + +/* + * GW: Rationale... + * Not all systems with /proc have all the exec* syscalls with the same + * names. On the SGI, for example, there is no SYS_exec, but there + * *is* a SYS_execv. So, we try to account for that. + */ +#ifdef SYS_exec praddset (&exitset, SYS_exec); +#endif +#ifdef SYS_execve praddset (&exitset, SYS_execve); +#endif +#ifdef SYS_execv + praddset(&exitset, SYS_execv); +#endif + if (ioctl (fd, PIOCSEXIT, &exitset) < 0) { perror (procname); @@ -886,8 +902,21 @@ proc_wait (statloc) { statval = (what << 8) | 0177; } - else if ((why == PR_SYSEXIT) && - (what == SYS_exec || what == SYS_execve)) + else if ((why == PR_SYSEXIT) + && + ( +#ifdef SYS_exec + what == SYS_exec +#else + 0 == 0 +#endif +#ifdef SYS_execve + || what == SYS_execve +#endif +#ifdef SYS_execv + || what == SYS_execv +#endif + )) { statval = (SIGTRAP << 8) | 0177; } diff --git a/gdb/signame.h b/gdb/signame.h index caa1bba35b3..0010796e8f5 100755 --- a/gdb/signame.h +++ b/gdb/signame.h @@ -34,10 +34,12 @@ sig_abbrev PARAMS ((int)); extern int sig_number PARAMS ((const char *)); +#ifndef PSIGNAL_IN_SIGNAL_H /* Print to standard error the name of SIGNAL, preceded by MESSAGE and a colon, and followed by a newline. */ extern void psignal PARAMS ((unsigned, const char *)); +#endif #endif /* !defined (SIGNAME_H) */ diff --git a/gdb/tm-irix3.h b/gdb/tm-irix3.h index f62a39e4419..f5f34696e19 100644 --- a/gdb/tm-irix3.h +++ b/gdb/tm-irix3.h @@ -102,6 +102,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ to be actual register numbers as far as the user is concerned but do serve to get the desired values when passed to read_register. */ +#define A0_REGNUM 4 /* Loc of first arg during a subr call */ #define SP_REGNUM 29 /* Contains address of top of stack */ #define FP_REGNUM 30 /* Pseudo register that contains true address of executing stack frame */ #define RA_REGNUM 31 /* Contains return address value */ @@ -323,3 +324,16 @@ typedef struct mips_extra_func_info { struct frame_saved_regs *saved_regs; #define INIT_EXTRA_FRAME_INFO(fromleaf, fci) init_extra_frame_info(fci) + +/* Size of elements in jmpbuf */ + +#define JB_ELEMENT_SIZE 4 + +/* Figure out where the longjmp will land. We expect that we have just entered + longjmp and haven't yet setup the stack frame, so the args are still in the + argument regs. a0 (CALL_ARG0) points at the jmp_buf structure from which we + extract the pc (JB_PC) that we will land at. The pc is copied into ADDR. + This routine returns true on success */ + +/* Note that caller must #include in order to get def of JB_* */ +#define GET_LONGJMP_TARGET(ADDR) get_longjmp_target(ADDR) diff --git a/gdb/tm-mips.h b/gdb/tm-mips.h index 44390eff235..bf726d21f60 100644 --- a/gdb/tm-mips.h +++ b/gdb/tm-mips.h @@ -122,7 +122,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ but do serve to get the desired values when passed to read_register. */ #define ZERO_REGNUM 0 /* read-only register, always 0 */ -#define A0_REGNUM 4 /* Lo of first arg during a subr call */ +#define A0_REGNUM 4 /* Loc of first arg during a subr call */ #define SP_REGNUM 29 /* Contains address of top of stack */ #define RA_REGNUM 31 /* Contains return address value */ #define PS_REGNUM 32 /* Contains processor status */ diff --git a/gdb/xm-irix4.h b/gdb/xm-irix4.h new file mode 100644 index 00000000000..e25a144a79f --- /dev/null +++ b/gdb/xm-irix4.h @@ -0,0 +1,50 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. + +This file is part of GDB. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* This is for the iris. */ + +#define HAVE_TERMIO + +#define U_REGS_OFFSET 0 + +#include "xm-bigmips.h" + +/* Override register locations in upage for SGI machines */ +#undef REGISTER_U_ADDR +#define REGISTER_U_ADDR(addr, blockend, regno) \ + if (regno < PC_REGNUM) \ + addr = regno; \ + else \ + addr = regno + NSIG_HNDLRS; /* Skip over signal handlers */ + +/* Don't need special routines for the SGI -- we can use infptrace.c */ +#undef FETCH_INFERIOR_REGISTERS + +/* BEGIN GW MODS */ +/* + * Let's use /debug instead of all this dangerous mucking about + * with ptrace(), which seems *extremely* fragile, anyway. + */ +#define USE_PROC_FS +#define PROC_NAME_FMT "/debug/%d" +#define CREATE_INFERIOR_HOOK(pid) inferior_proc_init(pid) + +/* Irix defines psignal() in signal.h, which gets gcc rather angry at us + * because their definition is markedly different. + */ +#define PSIGNAL_IN_SIGNAL_H -- 2.30.2