From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9898 invoked by alias); 10 May 2002 17:04:48 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 9891 invoked from network); 10 May 2002 17:04:47 -0000 Received: from unknown (HELO dr-evil.shagadelic.org) (208.176.2.162) by sources.redhat.com with SMTP; 10 May 2002 17:04:47 -0000 Received: by dr-evil.shagadelic.org (Postfix, from userid 7518) id 0F5FD9869; Fri, 10 May 2002 10:04:47 -0700 (PDT) Date: Fri, 10 May 2002 10:04:00 -0000 From: Jason R Thorpe To: gdb-patches@sources.redhat.com Cc: obrien@freebsd.org, kettenis@gnu.org Subject: [PATCH] Move Alpha BSD register supply/fill to alphabsd-tdep.c Message-ID: <20020510100446.E3435@dr-evil.shagadelic.org> Reply-To: thorpej@wasabisystems.com Mail-Followup-To: Jason R Thorpe , gdb-patches@sources.redhat.com, obrien@freebsd.org, kettenis@gnu.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="z9sQuz+HmDh2hVO4" Content-Disposition: inline User-Agent: Mutt/1.2.5i Organization: Wasabi Systems, Inc. X-SW-Source: 2002-05/txt/msg00346.txt.bz2 --z9sQuz+HmDh2hVO4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1531 This adds an alphabsd-tdep.c which provides the register supply/fill stuff for all Alpha BSD targets. This will facilitate cross-debugging of core files. David/Mark -- I'd like to get a nod from one of you before I commit it, since it does affect FreeBSD/alpha support. I did build an alpha-freebsd GDB, and it compiles fine. After that, the code path is pretty much the same for alpha-netbsd, which I obviously tested :-) * 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 alpha_bsd_supply_register. (fill_gregset): Use alpha_bsd_fill_register. (supply_fpregset): Use alpha_bsd_supply_fpregister. (fill_fpregset): Use alpha_bsd_fill_fpregister. (fetch_inferior_registers): Use struct reg and struct fpreg rather than gregset_t and fpregset_t. Use alpha_bsd_supply_register and alpha_bsd_supply_fpregister. (store_inferior_registers): Use struct reg and struct fpreg rather than gregset_t and fpregset_t. Use alpha_bsd_fill_register and alpha_bsd_fill_fpregister. * alphabsd-tdep.c: New file. * alphabsd-tdep.h: New file. * alphanbsd-nat.c (fetch_core_registers): Use alpha_bsd_supply_fpregister. (fetch_elfcore_registers): Use alpha_bsd_supply_register and alpha_bsd_supply_fpregister. * config/alpha/fbsd.mt (TDEPFILES): Add alphabsd-tdep.o. * config/alpha/nbsd.mt (TDEPFILES): Likewise. -- -- Jason R. Thorpe --z9sQuz+HmDh2hVO4 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=alphabsd-tdep-patch Content-length: 13764 Index: Makefile.in =================================================================== RCS file: /cvs/src/src/gdb/Makefile.in,v retrieving revision 1.180 diff -u -r1.180 Makefile.in --- Makefile.in 4 May 2002 15:52:37 -0000 1.180 +++ Makefile.in 10 May 2002 16:38:59 -0000 @@ -1179,8 +1179,8 @@ 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 @@ $(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) \ @@ -1258,6 +1258,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 Index: alphabsd-nat.c =================================================================== RCS file: /cvs/src/src/gdb/alphabsd-nat.c,v retrieving revision 1.7 diff -u -r1.7 alphabsd-nat.c --- alphabsd-nat.c 21 Apr 2002 16:52:39 -0000 1.7 +++ alphabsd-nat.c 10 May 2002 16:38:59 -0000 @@ -23,6 +23,7 @@ #include "regcache.h" #include "alpha-tdep.h" +#include "alphabsd-tdep.h" #include #include @@ -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]); + alpha_bsd_supply_register ((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]); + alpha_bsd_fill_register ((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); + alpha_bsd_supply_fpregister ((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); + alpha_bsd_fill_fpregister ((char *) fpregsetp, regno); } - - + /* Determine if PT_GETREGS fetches this register. */ static int @@ -146,26 +90,26 @@ 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); + alpha_bsd_supply_register ((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); + alpha_bsd_supply_fpregister ((char *) &fpregs, regno); } /* Reset virtual frame pointer. */ @@ -181,12 +125,12 @@ 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); + alpha_bsd_fill_register ((char *) &gregs, regno); if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) &gregs, 0) == -1) @@ -198,13 +142,13 @@ 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); + alpha_bsd_fill_fpregister ((char *) &fpregs, regno); if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) &fpregs, 0) == -1) Index: alphabsd-tdep.c =================================================================== RCS file: alphabsd-tdep.c diff -N alphabsd-tdep.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ alphabsd-tdep.c 10 May 2002 16:39:00 -0000 @@ -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 +alpha_bsd_supply_register (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 +alpha_bsd_fill_register (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 +alpha_bsd_supply_fpregister (char *regs, 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, regs + ((i - FP0_REGNUM) * 8)); + } + } + + if (regno == ALPHA_FPCR_REGNUM || regno == -1) + supply_register (ALPHA_FPCR_REGNUM, regs + (32 * 8)); +} + +void +alpha_bsd_fill_fpregister (char *regs, 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, regs + ((i - FP0_REGNUM) * 8)); + + if (regno == ALPHA_FPCR_REGNUM || regno == -1) + regcache_collect (ALPHA_FPCR_REGNUM, regs + (32 * 8)); +} Index: alphabsd-tdep.h =================================================================== RCS file: alphabsd-tdep.h diff -N alphabsd-tdep.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ alphabsd-tdep.h 10 May 2002 16:39:00 -0000 @@ -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 alpha_bsd_supply_register (char *, int); +void alpha_bsd_fill_register (char *, int); + +void alpha_bsd_supply_fpregister (char *, int); +void alpha_bsd_fill_fpregister (char *, int); + +#define SIZEOF_STRUCT_REG (32 * 8) +#define SIZEOF_STRUCT_FPREG (33 * 8) + +#endif /* ALPHABSD_TDEP_H */ Index: alphanbsd-nat.c =================================================================== RCS file: /cvs/src/src/gdb/alphanbsd-nat.c,v retrieving revision 1.1 diff -u -r1.1 alphanbsd-nat.c --- alphanbsd-nat.c 25 Apr 2002 02:44:05 -0000 1.1 +++ alphanbsd-nat.c 10 May 2002 16:39:00 -0000 @@ -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 @@ supply_register (PC_REGNUM, regs + (FRAME_PC * 8)); /* Floating point registers. */ - supply_fpregset (&core_reg->md_fpstate); + alpha_bsd_supply_fpregister ((char *) &core_reg->md_fpstate, -1); } static void @@ -91,17 +82,17 @@ 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); + alpha_bsd_supply_register (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); + alpha_bsd_supply_fpregister (core_reg_sect, -1); break; default: Index: config/alpha/fbsd.mt =================================================================== RCS file: /cvs/src/src/gdb/config/alpha/fbsd.mt,v retrieving revision 1.2 diff -u -r1.2 fbsd.mt --- config/alpha/fbsd.mt 25 Jan 2001 18:41:23 -0000 1.2 +++ config/alpha/fbsd.mt 10 May 2002 16:39:01 -0000 @@ -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 Index: config/alpha/nbsd.mt =================================================================== RCS file: /cvs/src/src/gdb/config/alpha/nbsd.mt,v retrieving revision 1.1 diff -u -r1.1 nbsd.mt --- config/alpha/nbsd.mt 25 Apr 2002 02:44:05 -0000 1.1 +++ config/alpha/nbsd.mt 10 May 2002 16:39:01 -0000 @@ -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 --z9sQuz+HmDh2hVO4--