From 84f652b150d70b36b704182702ee8de5950b0a82 Mon Sep 17 00:00:00 2001 From: "J.T. Conklin" Date: Fri, 23 Sep 1994 22:30:31 +0000 Subject: [PATCH] * solib.c: *BSD systems need to be included before . * i386b-nat.c: Add i386_float_info(), etc. * config/i386/nm-nbsd.h: #define FLOAT_INFO. * config/nm-nbsd.h: New file, for generic NetBSD native support. * config/i386/nm-nbsd.h: Use it. * config/sparc/nm-nbsd.h: Use it. * config/ns32k/nm-nbsd.h: Use it. * configure.in (i386-*-netbsd): Use config/i386/nbsd.m[ht]. (ns32k-*-netbsd): Use config/ns32k/nbsd.m[ht]. * config/i386/{nbsd.mh,nbsd.mt,nm-nbsd.h,tm-nbsd.h,xm-nbsd.h}: New files, support for NetBSD/i386. * config/ns32k/{nbsd.mh,nbsd.mh,nm-nbsd.h,tm-nbsd.h,xm-nbsd.h}: New files, support for NetBSD/ns32k. --- gdb/ChangeLog | 22 ++++++ gdb/config/.Sanitize | 1 + gdb/config/i386/.Sanitize | 4 + gdb/config/i386/nbsd.mh | 7 ++ gdb/config/i386/nm-nbsd.h | 34 ++++++++ gdb/config/i386/tm-nbsd.h | 26 +++++++ gdb/config/i386/xm-nbsd.h | 21 +++++ gdb/config/ns32k/.Sanitize | 6 +- gdb/config/ns32k/nbsd.mh | 4 + gdb/config/ns32k/nbsd.mt | 3 + gdb/config/ns32k/nm-nbsd.h | 36 +++++++++ gdb/config/ns32k/tm-nbsd.h | 38 +++++++++ gdb/config/ns32k/xm-nbsd.h | 21 +++++ gdb/config/sparc/nm-nbsd.h | 11 +-- gdb/configure.in | 2 + gdb/i386b-nat.c | 156 ++++++++++++++++++++++++++++++++++++- 16 files changed, 381 insertions(+), 11 deletions(-) create mode 100644 gdb/config/i386/nbsd.mh create mode 100644 gdb/config/i386/nm-nbsd.h create mode 100644 gdb/config/i386/tm-nbsd.h create mode 100644 gdb/config/i386/xm-nbsd.h create mode 100644 gdb/config/ns32k/nbsd.mh create mode 100644 gdb/config/ns32k/nbsd.mt create mode 100644 gdb/config/ns32k/nm-nbsd.h create mode 100644 gdb/config/ns32k/tm-nbsd.h create mode 100644 gdb/config/ns32k/xm-nbsd.h diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0bc137eeb2b..3724eff0092 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,27 @@ +Fri Sep 23 14:58:49 1994 J.T. Conklin (jtc@rtl.cygnus.com) + + * solib.c: *BSD systems need to be included before + . + + * i386b-nat.c: Add i386_float_info(), etc. + * config/i386/nm-nbsd.h: #define FLOAT_INFO. + + * config/nm-nbsd.h: New file, for generic NetBSD native support. + * config/i386/nm-nbsd.h: Use it. + * config/sparc/nm-nbsd.h: Use it. + * config/ns32k/nm-nbsd.h: Use it. + + * configure.in (i386-*-netbsd): Use config/i386/nbsd.m[ht]. + (ns32k-*-netbsd): Use config/ns32k/nbsd.m[ht]. + * config/i386/{nbsd.mh,nbsd.mt,nm-nbsd.h,tm-nbsd.h,xm-nbsd.h}: + New files, support for NetBSD/i386. + * config/ns32k/{nbsd.mh,nbsd.mh,nm-nbsd.h,tm-nbsd.h,xm-nbsd.h}: + New files, support for NetBSD/ns32k. + Tue Sep 20 11:34:27 1994 Jim Kingdon (kingdon@lioth.cygnus.com) + * .gdbinit: Add list-objfiles command. + * TODO: Reword item regarding NO_STD_REGS. * coffread.c (record_minimal_symbol, coff_read_enum_type, diff --git a/gdb/config/.Sanitize b/gdb/config/.Sanitize index c8eb93d0acc..27a7a3c3a1c 100644 --- a/gdb/config/.Sanitize +++ b/gdb/config/.Sanitize @@ -38,6 +38,7 @@ mips nm-empty.h nm-lynx.h nm-m3.h +nm-nbsd.h nm-sysv4.h none ns32k diff --git a/gdb/config/i386/.Sanitize b/gdb/config/i386/.Sanitize index ad0592822da..5c2f3a74eee 100644 --- a/gdb/config/i386/.Sanitize +++ b/gdb/config/i386/.Sanitize @@ -50,6 +50,8 @@ i386v4.mh i386v4.mt linux.mh linux.mt +nbsd.mh +nbsd.mt ncr3000.mh ncr3000.mt nm-i386aix.h @@ -83,6 +85,7 @@ tm-i386os9k.h tm-i386v.h tm-i386v4.h tm-linux.h +tm-nbsd.h tm-ptx.h tm-ptx4.h tm-sun386.h @@ -99,6 +102,7 @@ xm-i386v.h xm-i386v32.h xm-i386v4.h xm-linux.h +xm-nbsd.h xm-ptx.h xm-ptx4.h xm-sun386.h diff --git a/gdb/config/i386/nbsd.mh b/gdb/config/i386/nbsd.mh new file mode 100644 index 00000000000..0a3cfcafd73 --- /dev/null +++ b/gdb/config/i386/nbsd.mh @@ -0,0 +1,7 @@ +# Host: Intel 386 running NetBSD +XDEPFILES= +NATDEPFILES= exec.o fork-child.o infptrace.o inftarg.o corelow.o coredep.o i386b-nat.o +XM_FILE= xm-nbsd.h +NAT_FILE= nm-nbsd.h +REGEX=regex.o +REGEX1=regex.o diff --git a/gdb/config/i386/nm-nbsd.h b/gdb/config/i386/nm-nbsd.h new file mode 100644 index 00000000000..44257d6694e --- /dev/null +++ b/gdb/config/i386/nm-nbsd.h @@ -0,0 +1,34 @@ +/* Native-dependent definitions for Intel 386 running NetBSD, for GDB. + Copyright 1986, 1987, 1989, 1992, 1994 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. */ + +#ifndef NM_NBSD_H +#define NM_NBSD_H + +/* Get generic NetBSD native definitions. */ +#include "nm-nbsd.h" + +#define FLOAT_INFO { i386_float_info(); } + +#define REGISTER_U_ADDR(addr, blockend, regno) \ + (addr) = i386_register_u_addr ((blockend),(regno)); + +extern int +i386_register_u_addr PARAMS ((int, int)); + +#endif /* NM_NBSD_H */ diff --git a/gdb/config/i386/tm-nbsd.h b/gdb/config/i386/tm-nbsd.h new file mode 100644 index 00000000000..7cb2b870f8c --- /dev/null +++ b/gdb/config/i386/tm-nbsd.h @@ -0,0 +1,26 @@ +/* Macro definitions for Sparc running under NetBSD. + Copyright 1994 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. */ + +#ifndef TM_NBSD_H +#define TM_NBSD_H + +#include "i386/tm-i386bsd.h" +#include "tm-nbsd.h" + +#endif /* TM_NBSD_H */ diff --git a/gdb/config/i386/xm-nbsd.h b/gdb/config/i386/xm-nbsd.h new file mode 100644 index 00000000000..5ba67007242 --- /dev/null +++ b/gdb/config/i386/xm-nbsd.h @@ -0,0 +1,21 @@ +/* Parameters for execution on a i386 running NetBSD, for GDB. + Copyright 1994 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. */ + +/* Get generic NetBSD host definitions. */ +#include "xm-nbsd.h" diff --git a/gdb/config/ns32k/.Sanitize b/gdb/config/ns32k/.Sanitize index 69b0407b599..7ae6862c9fa 100644 --- a/gdb/config/ns32k/.Sanitize +++ b/gdb/config/ns32k/.Sanitize @@ -23,21 +23,25 @@ Things-to-keep: merlin.mh merlin.mt +nbsd.mh +nbsd.mt +nm-nbsd.h nm-umax.h ns32km3.mh ns32km3.mt tm-merlin.h +tm-nbsd.h tm-ns32km3.h tm-umax.h umax.mh umax.mt xm-merlin.h +xm-nbsd.h xm-ns32km3.h xm-umax.h Things-to-lose: - Do-last: # End of file. diff --git a/gdb/config/ns32k/nbsd.mh b/gdb/config/ns32k/nbsd.mh new file mode 100644 index 00000000000..f9cc72aa48c --- /dev/null +++ b/gdb/config/ns32k/nbsd.mh @@ -0,0 +1,4 @@ +# Host: PC532 running NetBSD +XM_FILE= xm-nbsd.h +NAT_FILE= nm-nbsd.h +NATDEPFILES= exec.o fork-child.o infptrace.o inftarg.o corelow.o coredep.o ns32k-nat.o diff --git a/gdb/config/ns32k/nbsd.mt b/gdb/config/ns32k/nbsd.mt new file mode 100644 index 00000000000..0a186328ff9 --- /dev/null +++ b/gdb/config/ns32k/nbsd.mt @@ -0,0 +1,3 @@ +# Target: PC532 running NetBSD +TDEPFILES= exec.o ns32k-tdep.o ns32k-pinsn.o solib.o +TM_FILE= tm-nbsd.h diff --git a/gdb/config/ns32k/nm-nbsd.h b/gdb/config/ns32k/nm-nbsd.h new file mode 100644 index 00000000000..d22218cd041 --- /dev/null +++ b/gdb/config/ns32k/nm-nbsd.h @@ -0,0 +1,36 @@ +/* Native-dependent definitions for ns32k running NetBSD, for GDB. + Copyright 1986, 1987, 1989, 1992, 1994 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. */ + +#ifndef NM_NBSD_H +#define NM_NBSD_H + +/* Get generic NetBSD native definitions. */ +#include "nm-nbsd.h" + +#if 0 +#define FLOAT_INFO { extern ns32k_float_info(); ns32k_float_info(); } +#endif + +#define REGISTER_U_ADDR(addr, blockend, regno) \ + (addr) = ns32k_register_u_addr ((blockend),(regno)); + +extern int +ns32k_register_u_addr PARAMS ((int, int)); + +#endif /* NM_NBSD_H */ diff --git a/gdb/config/ns32k/tm-nbsd.h b/gdb/config/ns32k/tm-nbsd.h new file mode 100644 index 00000000000..871a1538a4e --- /dev/null +++ b/gdb/config/ns32k/tm-nbsd.h @@ -0,0 +1,38 @@ +/* Macro definitions for ns32k running under NetBSD. + Copyright 1986, 1987, 1989, 1991, 1992, 1993 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. */ + +/* Override number of expected traps from sysv. */ +#define START_INFERIOR_TRAPS_EXPECTED 2 + +/* Most definitions from umax could be used. */ +#define INVALID_FLOAT(p, s) isa_NAN(p, s) +#include "ns32k/tm-umax.h" +#include "tm-nbsd.h" + +/* Saved Pc. Get it from sigcontext if within sigtramp. */ + +/* Offset to saved PC in sigcontext, from . */ +#define SIGCONTEXT_PC_OFFSET 20 + +#undef FRAME_SAVED_PC(FRAME) +#define FRAME_SAVED_PC(FRAME) \ + (((FRAME)->signal_handler_caller \ + ? sigtramp_saved_pc (FRAME) \ + : read_memory_integer ((FRAME)->frame + 4, 4)) \ + ) diff --git a/gdb/config/ns32k/xm-nbsd.h b/gdb/config/ns32k/xm-nbsd.h new file mode 100644 index 00000000000..b601f0ebb32 --- /dev/null +++ b/gdb/config/ns32k/xm-nbsd.h @@ -0,0 +1,21 @@ +/* Parameters for execution on a ns32k running NetBSD, for GDB. + Copyright 1994 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. */ + +/* Get generic NetBSD host definitions. */ +#include "xm-nbsd.h" diff --git a/gdb/config/sparc/nm-nbsd.h b/gdb/config/sparc/nm-nbsd.h index 83d918e4182..9116d1d7f79 100644 --- a/gdb/config/sparc/nm-nbsd.h +++ b/gdb/config/sparc/nm-nbsd.h @@ -20,15 +20,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef NM_NBSD_H #define NM_NBSD_H -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -#include -#define KERNEL_U_ADDR USRSTACK - -#define PTRACE_ARG3_TYPE char* - -#define ATTACH_DETACH +/* Get generic NetBSD native definitions. */ +#include "nm-nbsd.h" #define FETCH_INFERIOR_REGISTERS diff --git a/gdb/configure.in b/gdb/configure.in index ddb37b8a0b5..a07bf32f429 100644 --- a/gdb/configure.in +++ b/gdb/configure.in @@ -111,6 +111,7 @@ none-*-*) gdb_host=none ;; np1-*-*) gdb_host=np1 ;; ns32k-*-mach3*) gdb_host=mach3 ;; +ns32k-*-netbsd*) gdb_host=nbsd ;; ns32k-umax-*) gdb_host=umax ;; ns32k-utek-sysv*) gdb_host=merlin ;; @@ -299,6 +300,7 @@ none-*-*) gdb_target=none ;; np1-*-*) gdb_target=np1 ;; ns32k-*-mach3*) gdb_target=mach3 ;; +ns32k-*-netbsd*) gdb_target=nbsd ;; ns32k-utek-sysv*) gdb_target=merlin ;; ns32k-utek-*) gdb_target=umax ;; diff --git a/gdb/i386b-nat.c b/gdb/i386b-nat.c index 0bcde9c121e..beff646311d 100644 --- a/gdb/i386b-nat.c +++ b/gdb/i386b-nat.c @@ -1,5 +1,5 @@ /* Native-dependent code for BSD Unix running on i386's, for GDB. - Copyright 1988, 1989, 1991, 1992 Free Software Foundation, Inc. + Copyright 1988, 1989, 1991, 1992, 1994 Free Software Foundation, Inc. This file is part of GDB. @@ -69,3 +69,157 @@ i386_register_u_addr (blockend, regnum) else return (blockend + 4 * sregmap[regnum]); } + + +#ifdef FLOAT_INFO +#include "floatformat.h" + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#define curpcb Xcurpcb /* XXX avoid leaking declaration from pcb.h */ +#include +#undef curpcb +#include +#include +#include + +extern void print_387_control_word (); /* i387-tdep.h */ +extern void print_387_status_word (); + +#define fpstate save87 +#define U_FPSTATE(u) u.u_pcb.pcb_savefpu + +struct env387 +{ + unsigned short control; + unsigned short r0; + unsigned short status; + unsigned short r1; + unsigned short tag; + unsigned short r2; + unsigned long eip; + unsigned short code_seg; + unsigned short opcode; + unsigned long operand; + unsigned short operand_seg; + unsigned short r3; + unsigned char regs[8][10]; +}; + +static +print_387_status (status, ep) + unsigned short status; + struct env387 *ep; +{ + int i; + int bothstatus; + int top; + int fpreg; + unsigned char *p; + + bothstatus = ((status != 0) && (ep->status != 0)); + if (status != 0) + { + if (bothstatus) + printf_unfiltered ("u: "); + print_387_status_word ((unsigned int)status); + } + + if (ep->status != 0) + { + if (bothstatus) + printf_unfiltered ("e: "); + print_387_status_word ((unsigned int)ep->status); + } + + print_387_control_word ((unsigned int)ep->control); + printf_unfiltered ("last exception: "); + printf_unfiltered ("opcode %s; ", local_hex_string(ep->opcode)); + printf_unfiltered ("pc %s:", local_hex_string(ep->code_seg)); + printf_unfiltered ("%s; ", local_hex_string(ep->eip)); + printf_unfiltered ("operand %s", local_hex_string(ep->operand_seg)); + printf_unfiltered (":%s\n", local_hex_string(ep->operand)); + + top = (ep->status >> 11) & 7; + + printf_unfiltered ("regno tag msb lsb value\n"); + for (fpreg = 7; fpreg >= 0; fpreg--) + { + double val; + + printf_unfiltered ("%s %d: ", fpreg == top ? "=>" : " ", fpreg); + + switch ((ep->tag >> (fpreg * 2)) & 3) + { + case 0: printf_unfiltered ("valid "); break; + case 1: printf_unfiltered ("zero "); break; + case 2: printf_unfiltered ("trap "); break; + case 3: printf_unfiltered ("empty "); break; + } + for (i = 9; i >= 0; i--) + printf_unfiltered ("%02x", ep->regs[fpreg][i]); + + floatformat_to_double(&floatformat_i387_ext, (char *) ep->regs[fpreg], + &val); + printf_unfiltered (" %g\n", val); + } +} + +i386_float_info () +{ + struct user u; /* just for address computations */ + int i; + /* fpstate defined in */ + struct fpstate *fpstatep; + char buf[sizeof (struct fpstate) + 2 * sizeof (int)]; + unsigned int uaddr; + char fpvalid; + unsigned int rounded_addr; + unsigned int rounded_size; + /*extern int corechan;*/ + int skip; + extern int inferior_pid; + + uaddr = (char *)&U_FPSTATE(u) - (char *)&u; + if (inferior_pid) + { + int *ip; + + rounded_addr = uaddr & -sizeof (int); + rounded_size = (((uaddr + sizeof (struct fpstate)) - uaddr) + + sizeof (int) - 1) / sizeof (int); + skip = uaddr - rounded_addr; + + ip = (int *)buf; + for (i = 0; i < rounded_size; i++) + { + *ip++ = ptrace (PT_READ_U, inferior_pid, (caddr_t)rounded_addr, 0); + rounded_addr += sizeof (int); + } + } + else + { + printf("float info: can't do a core file (yet)\n"); + return; +#if 0 + if (lseek (corechan, uaddr, 0) < 0) + perror_with_name ("seek on core file"); + if (myread (corechan, buf, sizeof (struct fpstate)) < 0) + perror_with_name ("read from core file"); + skip = 0; +#endif + } + + print_387_status (0, (struct env387 *)buf); +} + +#endif -- 2.30.2