diff options
author | Jason Thorpe <thorpej@netbsd.org> | 2002-05-11 16:21:16 +0000 |
---|---|---|
committer | Jason Thorpe <thorpej@netbsd.org> | 2002-05-11 16:21:16 +0000 |
commit | 12bcb0fe6dec61c540012f469c4cb0a56d6b6ea4 (patch) | |
tree | 95a605240f8bdc2bafce763190e2b8f07ce1051d | |
parent | 361d1df04393ac0e921d52e9bd158fbceffb0c0f (diff) | |
download | gdb-12bcb0fe6dec61c540012f469c4cb0a56d6b6ea4.zip gdb-12bcb0fe6dec61c540012f469c4cb0a56d6b6ea4.tar.gz gdb-12bcb0fe6dec61c540012f469c4cb0a56d6b6ea4.tar.bz2 |
* Makefile.in (ALLDEPFILES): Add alphabsd-tdep.c.
(alphabsd-nat.o): Depend on alphabsd-tdep.h.
(alphanbsd-nat.o): Likewise.
(alphabsd-tdep.o): New dependency list.
* alphabsd-nat.c (supply_gregset): Use alphabsd_supply_reg.
(fill_gregset): Use alphabsd_fill_reg.
(supply_fpregset): Use alphabsd_supply_fpreg.
(fill_fpregset): Use alphabsd_fill_fpreg.
(fetch_inferior_registers): Use struct reg and struct fpreg
rather than gregset_t and fpregset_t. Use alphabsd_supply_reg
and alphabsd_supply_fpreg.
(store_inferior_registers): Use struct reg and struct fpreg
rather than gregset_t and fpregset_t. Use alphabsd_fill_reg
and alphabsd_fill_fpreg.
* alphabsd-tdep.c: New file.
* alphabsd-tdep.h: New file.
* alphanbsd-nat.c (fetch_core_registers): Use alphabsd_supply_fpreg.
(fetch_elfcore_registers): Use alphabsd_supply_reg and
alphabsd_supply_fpreg.
* config/alpha/fbsd.mt (TDEPFILES): Add alphabsd-tdep.o.
* config/alpha/nbsd.mt (TDEPFILES): Likewise.
-rw-r--r-- | gdb/ChangeLog | 24 | ||||
-rw-r--r-- | gdb/Makefile.in | 10 | ||||
-rw-r--r-- | gdb/alphabsd-nat.c | 94 | ||||
-rw-r--r-- | gdb/alphabsd-tdep.c | 102 | ||||
-rw-r--r-- | gdb/alphabsd-tdep.h | 33 | ||||
-rw-r--r-- | gdb/alphanbsd-nat.c | 21 | ||||
-rw-r--r-- | gdb/config/alpha/fbsd.mt | 2 | ||||
-rw-r--r-- | gdb/config/alpha/nbsd.mt | 2 |
8 files changed, 192 insertions, 96 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 55ff0a9..be0d4d9 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,27 @@ +2002-05-11 Jason Thorpe <thorpej@wasabisystems.com> + + * Makefile.in (ALLDEPFILES): Add alphabsd-tdep.c. + (alphabsd-nat.o): Depend on alphabsd-tdep.h. + (alphanbsd-nat.o): Likewise. + (alphabsd-tdep.o): New dependency list. + * alphabsd-nat.c (supply_gregset): Use alphabsd_supply_reg. + (fill_gregset): Use alphabsd_fill_reg. + (supply_fpregset): Use alphabsd_supply_fpreg. + (fill_fpregset): Use alphabsd_fill_fpreg. + (fetch_inferior_registers): Use struct reg and struct fpreg + rather than gregset_t and fpregset_t. Use alphabsd_supply_reg + and alphabsd_supply_fpreg. + (store_inferior_registers): Use struct reg and struct fpreg + rather than gregset_t and fpregset_t. Use alphabsd_fill_reg + and alphabsd_fill_fpreg. + * alphabsd-tdep.c: New file. + * alphabsd-tdep.h: New file. + * alphanbsd-nat.c (fetch_core_registers): Use alphabsd_supply_fpreg. + (fetch_elfcore_registers): Use alphabsd_supply_reg and + alphabsd_supply_fpreg. + * config/alpha/fbsd.mt (TDEPFILES): Add alphabsd-tdep.o. + * config/alpha/nbsd.mt (TDEPFILES): Likewise. + 2002-05-11 Eric Christopher <echristo@redhat.com> * mips-tdep.c (mips_double_register_type): Fix thinko. diff --git a/gdb/Makefile.in b/gdb/Makefile.in index de30f43..6af6fe9 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -1179,8 +1179,8 @@ ALLDEPFILES = 29k-share/udi/udip2soc.c 29k-share/udi/udr.c \ 29k-share/udi/udi2go32.c \ a29k-tdep.c a68v-nat.c \ alpha-nat.c alphabsd-nat.c alphanbsd-nat.c \ - alpha-tdep.c alpha-linux-tdep.c alphanbsd-tdep.c alpha-osf1-tdep.c \ - alphafbsd-tdep.c \ + alpha-tdep.c alpha-linux-tdep.c alphabsd-tdep.c alphanbsd-tdep.c \ + alpha-osf1-tdep.c alphafbsd-tdep.c \ arm-linux-nat.c arm-linux-tdep.c arm-tdep.c \ armnbsd-nat.c armnbsd-tdep.c \ avr-tdep.c \ @@ -1246,10 +1246,10 @@ alpha-nat.o: alpha-nat.c $(defs_h) $(gdbcore_h) $(inferior_h) $(target_h) \ $(regcache_h) alpha-tdep.h alphabsd-nat.o: alphabsd-nat.c $(defs_h) $(inferior_h) $(regcache_h) \ - alpha-tdep.h + alpha-tdep.h alphabsd-tdep.h alphanbsd-nat.o: alphanbsd-nat.c $(defs_h) $(inferior_h) $(regcache_h) \ - $(gdbcore_h) alpha-tdep.h + $(gdbcore_h) alpha-tdep.h alphabsd-tdep.h alpha-tdep.o: alpha-tdep.c $(defs_h) $(gdbcmd_h) $(gdbcore_h) \ $(inferior_h) $(symtab_h) $(dis_asm_h) $(gdb_string_h) $(linespec_h) \ @@ -1259,6 +1259,8 @@ alpha-linux-tdep.o: alpha-linux-tdep.c $(defs_h) $(value_h) alpha-tdep.h alpha-osf1-tdep.o: alpha-osf1-tdep.c $(defs_h) $(value_h) alpha-tdep.h +alphabsd-tdep.o: alphabsd-tdep.c $(defs_h) $(regcache_h) alphabsd-tdep.h + alphafbsd-tdep.o: alphafbsd-tdep.c $(defs_h) $(value_h) alpha-tdep.h alphanbsd-tdep.o: alphanbsd-tdep.c $(defs_h) $(gdbcore_h) $(value_h) \ diff --git a/gdb/alphabsd-nat.c b/gdb/alphabsd-nat.c index 92b0fc2..b26d3ea 100644 --- a/gdb/alphabsd-nat.c +++ b/gdb/alphabsd-nat.c @@ -23,6 +23,7 @@ #include "regcache.h" #include "alpha-tdep.h" +#include "alphabsd-tdep.h" #include <sys/types.h> #include <sys/ptrace.h> @@ -36,96 +37,39 @@ typedef struct reg gregset_t; #endif -#ifndef HAVE_FPREGSET_T -typedef struct fpreg fpregset_t; -#endif +#ifndef HAVE_FPREGSET_T +typedef struct fpreg fpregset_t; +#endif #include "gregset.h" -/* Number of general-purpose registers. */ -#define NUM_GREGS 32 - -/* Number of floating point registers. */ -#define NUM_FPREGS 31 - - -/* Transfering the registers between GDB, inferiors and core files. */ - -/* Fill GDB's register array with the general-purpose register values - in *GREGSETP. */ +/* Provide *regset() wrappers around the generic Alpha BSD register + supply/fill routines. */ void supply_gregset (gregset_t *gregsetp) { - int i; - - for (i = 0; i < NUM_GREGS; i++) - { - if (CANNOT_FETCH_REGISTER (i)) - supply_register (i, NULL); - else - supply_register (i, (char *) &gregsetp->r_regs[i]); - } - - /* The PC travels in the R_ZERO slot. */ - supply_register (PC_REGNUM, (char *) &gregsetp->r_regs[R_ZERO]); + alphabsd_supply_reg ((char *) gregsetp, -1); } -/* Fill register REGNO (if it is a general-purpose register) in - *GREGSETPS with the value in GDB's register array. If REGNO is -1, - do this for all registers. */ - void fill_gregset (gregset_t *gregsetp, int regno) { - int i; - - for (i = 0; i < NUM_GREGS; i++) - if ((regno == -1 || regno == i) && ! CANNOT_STORE_REGISTER (i)) - regcache_collect (i, (char *) &gregsetp->r_regs[i]); - - /* The PC travels in the R_ZERO slot. */ - if (regno == -1 || regno == PC_REGNUM) - regcache_collect (PC_REGNUM, (char *) &gregsetp->r_regs[R_ZERO]); + alphabsd_fill_reg ((char *) gregsetp, regno); } -/* Fill GDB's register array with the floating-point register values - in *FPREGSETP. */ - void supply_fpregset (fpregset_t *fpregsetp) { - int i; - - for (i = FP0_REGNUM; i < FP0_REGNUM + NUM_FPREGS; i++) - { - if (CANNOT_FETCH_REGISTER (i)) - supply_register (i, NULL); - else - supply_register (i, (char *) &fpregsetp->fpr_regs[i - FP0_REGNUM]); - } - - supply_register (ALPHA_FPCR_REGNUM, (char *) &fpregsetp->fpr_cr); + alphabsd_supply_fpreg ((char *) fpregsetp, -1); } -/* Fill register REGNO (if it is a floating-point register) in - *FPREGSETP with the value in GDB's register array. If REGNO is -1, - do this for all registers. */ - void fill_fpregset (fpregset_t *fpregsetp, int regno) { - int i; - - for (i = FP0_REGNUM; i < FP0_REGNUM + NUM_FPREGS; i++) - if ((regno == -1 || regno == i) && ! CANNOT_STORE_REGISTER (i)) - regcache_collect (i, (char *) &fpregsetp->fpr_regs[i - FP0_REGNUM]); - - if (regno == -1 || regno == ALPHA_FPCR_REGNUM) - regcache_collect (ALPHA_FPCR_REGNUM, (char *) &fpregsetp->fpr_cr); + alphabsd_fill_fpreg ((char *) fpregsetp, regno); } - - + /* Determine if PT_GETREGS fetches this register. */ static int @@ -146,26 +90,26 @@ fetch_inferior_registers (int regno) if (regno == -1 || getregs_supplies (regno)) { - gregset_t gregs; + struct reg gregs; if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) &gregs, 0) == -1) perror_with_name ("Couldn't get registers"); - supply_gregset (&gregs); + alphabsd_supply_reg ((char *) &gregs, regno); if (regno != -1) return; } if (regno == -1 || regno >= FP0_REGNUM) { - fpregset_t fpregs; + struct fpreg fpregs; if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) &fpregs, 0) == -1) perror_with_name ("Couldn't get floating point status"); - supply_fpregset (&fpregs); + alphabsd_supply_fpreg ((char *) &fpregs, regno); } /* Reset virtual frame pointer. */ @@ -181,12 +125,12 @@ store_inferior_registers (int regno) if (regno == -1 || getregs_supplies (regno)) { - gregset_t gregs; + struct reg gregs; if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) &gregs, 0) == -1) perror_with_name ("Couldn't get registers"); - fill_gregset (&gregs, regno); + alphabsd_fill_reg ((char *) &gregs, regno); if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) &gregs, 0) == -1) @@ -198,13 +142,13 @@ store_inferior_registers (int regno) if (regno == -1 || regno >= FP0_REGNUM) { - fpregset_t fpregs; + struct fpreg fpregs; if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) &fpregs, 0) == -1) perror_with_name ("Couldn't get floating point status"); - fill_fpregset (&fpregs, regno); + alphabsd_fill_fpreg ((char *) &fpregs, regno); if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) &fpregs, 0) == -1) diff --git a/gdb/alphabsd-tdep.c b/gdb/alphabsd-tdep.c new file mode 100644 index 0000000..39a9b1a --- /dev/null +++ b/gdb/alphabsd-tdep.c @@ -0,0 +1,102 @@ +/* Common target dependent code for GDB on Alpha systems running BSD. + Copyright 2000, 2001, 2002 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include "defs.h" +#include "regcache.h" + +#include "alpha-tdep.h" +#include "alphabsd-tdep.h" + +/* Number of general-purpose registers. */ +#define NUM_GREGS 32 + +/* Number of floating-point registers. */ +#define NUM_FPREGS 31 + +/* Conviently, GDB uses the same register numbering as the + ptrace register structure used by BSD on Alpha. */ + +void +alphabsd_supply_reg (char *regs, int regno) +{ + int i; + + for (i = 0; i < NUM_GREGS; i++) + { + if (i == regno || regno == -1) + { + if (CANNOT_FETCH_REGISTER (i)) + supply_register (i, NULL); + else + supply_register (i, regs + (i * 8)); + } + } + + /* The PC travels in the ZERO slot. */ + if (regno == PC_REGNUM || regno == -1) + supply_register (PC_REGNUM, regs + (31 * 8)); +} + +void +alphabsd_fill_reg (char *regs, int regno) +{ + int i; + + for (i = 0; i < NUM_GREGS; i++) + if ((regno == i || regno == -1) && ! CANNOT_STORE_REGISTER (i)) + regcache_collect (i, regs + (i * 8)); + + /* The PC travels in the ZERO slot. */ + if (regno == PC_REGNUM || regno == -1) + regcache_collect (PC_REGNUM, regs + (31 * 8)); +} + +void +alphabsd_supply_fpreg (char *fpregs, int regno) +{ + int i; + + for (i = FP0_REGNUM; i < FP0_REGNUM + NUM_FPREGS; i++) + { + if (i == regno || regno == -1) + { + if (CANNOT_FETCH_REGISTER (i)) + supply_register (i, NULL); + else + supply_register (i, fpregs + ((i - FP0_REGNUM) * 8)); + } + } + + if (regno == ALPHA_FPCR_REGNUM || regno == -1) + supply_register (ALPHA_FPCR_REGNUM, fpregs + (32 * 8)); +} + +void +alphabsd_fill_fpreg (char *fpregs, int regno) +{ + int i; + + for (i = FP0_REGNUM; i < FP0_REGNUM + NUM_FPREGS; i++) + if ((regno == i || regno == -1) && ! CANNOT_STORE_REGISTER (i)) + regcache_collect (i, fpregs + ((i - FP0_REGNUM) * 8)); + + if (regno == ALPHA_FPCR_REGNUM || regno == -1) + regcache_collect (ALPHA_FPCR_REGNUM, fpregs + (32 * 8)); +} diff --git a/gdb/alphabsd-tdep.h b/gdb/alphabsd-tdep.h new file mode 100644 index 0000000..48d8798 --- /dev/null +++ b/gdb/alphabsd-tdep.h @@ -0,0 +1,33 @@ +/* Common target dependent code for GDB on Alpha systems running BSD. + Copyright 2002 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef ALPHABSD_TDEP_H +#define ALPHABSD_TDEP_H + +void alphabsd_supply_reg (char *, int); +void alphabsd_fill_reg (char *, int); + +void alphabsd_supply_fpreg (char *, int); +void alphabsd_fill_fpreg (char *, int); + +#define SIZEOF_STRUCT_REG (32 * 8) +#define SIZEOF_STRUCT_FPREG (33 * 8) + +#endif /* ALPHABSD_TDEP_H */ diff --git a/gdb/alphanbsd-nat.c b/gdb/alphanbsd-nat.c index ed90de3..61e24fd 100644 --- a/gdb/alphanbsd-nat.c +++ b/gdb/alphanbsd-nat.c @@ -28,16 +28,7 @@ #include "regcache.h" #include "alpha-tdep.h" - -#ifndef HAVE_GREGSET_T -typedef struct reg gregset_t; -#endif - -#ifndef HAVE_FPREGSET_T -typedef struct fpreg fpregset_t; -#endif - -#include "gregset.h" +#include "alphabsd-tdep.h" static void fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which, @@ -81,7 +72,7 @@ fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which, supply_register (PC_REGNUM, regs + (FRAME_PC * 8)); /* Floating point registers. */ - supply_fpregset (&core_reg->md_fpstate); + alphabsd_supply_fpreg ((char *) &core_reg->md_fpstate, -1); } static void @@ -91,17 +82,17 @@ fetch_elfcore_registers (char *core_reg_sect, unsigned core_reg_size, int which, switch (which) { case 0: /* Integer registers. */ - if (core_reg_size != sizeof (struct reg)) + if (core_reg_size != SIZEOF_STRUCT_REG) warning ("Wrong size register set in core file."); else - supply_gregset ((gregset_t *) core_reg_sect); + alphabsd_supply_reg (core_reg_sect, -1); break; case 2: /* Floating point registers. */ - if (core_reg_size != sizeof (struct fpreg)) + if (core_reg_size != SIZEOF_STRUCT_FPREG) warning ("Wrong size FP register set in core file."); else - supply_fpregset ((fpregset_t *) core_reg_sect); + alphabsd_supply_fpreg (core_reg_sect, -1); break; default: diff --git a/gdb/config/alpha/fbsd.mt b/gdb/config/alpha/fbsd.mt index 48e54fa..4b4ecbf 100644 --- a/gdb/config/alpha/fbsd.mt +++ b/gdb/config/alpha/fbsd.mt @@ -1,3 +1,3 @@ # Target: FreeBSD/Alpha -TDEPFILES= alpha-tdep.o alphafbsd-tdep.o +TDEPFILES= alpha-tdep.o alphabsd-tdep.o alphafbsd-tdep.o TM_FILE= tm-fbsd.h diff --git a/gdb/config/alpha/nbsd.mt b/gdb/config/alpha/nbsd.mt index f3a2ff1..dff8c68 100644 --- a/gdb/config/alpha/nbsd.mt +++ b/gdb/config/alpha/nbsd.mt @@ -1,3 +1,3 @@ # Target: Alpha running NetBSD -TDEPFILES= alpha-tdep.o alphanbsd-tdep.o solib.o solib-svr4.o +TDEPFILES= alpha-tdep.o alphabsd-tdep.o alphanbsd-tdep.o solib.o solib-svr4.o TM_FILE= tm-nbsd.h |