diff options
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 23 | ||||
-rw-r--r-- | gdb/Makefile.in | 16 | ||||
-rw-r--r-- | gdb/NEWS | 1 | ||||
-rw-r--r-- | gdb/config/powerpc/nm-obsd.h | 28 | ||||
-rw-r--r-- | gdb/config/powerpc/obsd.mh | 3 | ||||
-rw-r--r-- | gdb/config/powerpc/obsd.mt | 4 | ||||
-rw-r--r-- | gdb/configure.host | 1 | ||||
-rw-r--r-- | gdb/configure.tgt | 1 | ||||
-rw-r--r-- | gdb/ppc-tdep.h | 59 | ||||
-rw-r--r-- | gdb/ppcobsd-nat.c | 97 | ||||
-rw-r--r-- | gdb/ppcobsd-tdep.c | 153 | ||||
-rw-r--r-- | gdb/ppcobsd-tdep.h | 54 | ||||
-rw-r--r-- | gdb/rs6000-tdep.c | 161 |
13 files changed, 595 insertions, 6 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e694be7..1287d52 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,26 @@ +2004-04-22 Mark Kettenis <kettenis@gnu.org> + + Add OpenBSD/powerpc support. + * NEWS (New native configurations): Mention OpenBSD/powerpc. + * ppc-tdep.h (struct ppc_reg_offsets): New structure. + (ppc_supply_gregset, ppc_supply_fpregset, ppc_collect_gregset) + (ppc_collect_fpregset): New prototypes. + * ppcobsd-nat.c: New file. + * ppcobsd-tdep.c: New file. + * ppcobsd-tdep.h: New file. + * rs6000-tdep.c: Include "regset.h". + (ppc_supply_reg, ppc_collect_reg, ppc_supply_gregset) + (ppc_supply_fpregset, ppc_collect_gregset, ppc_collect_fpregset): + New functions. + * Makefile.in (ALLDEPFILES): Add pccobsd-nat.c and ppcobsd-tdep.c. + (ppcobsd-nat.o, ppcobsd-tdep.o): New dependencies. + (rs6000-tdep.o): Update dependencies. + * configure.host: Add powerpc-*-openbsd. + * configure.tgt: Add powerpc-*-openbsd. + * config/powerpc/obsd.mh: New file. + * config/powerpc/nm-obsd.h: New file. + * config/powerpc/obsd.mt: New file. + 2004-04-22 Andrew Cagney <cagney@redhat.com> * frame.h (show_frame_info): Delete declaration. diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 8be42e4..2a8e412 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -1352,6 +1352,7 @@ ALLDEPFILES = \ somread.c somsolib.c $(HPREAD_SOURCE) \ ppc-sysv-tdep.c ppc-linux-nat.c ppc-linux-tdep.c \ ppcnbsd-nat.c ppcnbsd-tdep.c \ + ppcobsd-nat.c ppcobsd-tdep.c \ procfs.c \ remote-e7000.c \ remote-hms.c remote-m32r-sdi.c remote-mips.c \ @@ -2157,6 +2158,11 @@ ppcnbsd-nat.o: ppcnbsd-nat.c $(defs_h) $(inferior_h) $(ppc_tdep_h) \ ppcnbsd-tdep.o: ppcnbsd-tdep.c $(defs_h) $(gdbcore_h) $(regcache_h) \ $(target_h) $(breakpoint_h) $(value_h) $(osabi_h) $(ppc_tdep_h) \ $(ppcnbsd_tdep_h) $(nbsd_tdep_h) $(solib_svr4_h) +ppcobsd-nat.o: ppcobsd-nat.c $(defs_h) $(inferior_h) $(regcache_h) \ + $(ppcobsd_tdep_h) +ppcobsd-tdep.o: ppcobsd-tdep.c $(defs_h) $(arch_utils_h) $(osabi_h) \ + $(regcache_h) $(regset_h) $(gdb_string_h) $(ppc_tdep_h) \ + $(ppcobsd_tdep_h) $(solib_svr4_h) ppc-sysv-tdep.o: ppc-sysv-tdep.c $(defs_h) $(gdbcore_h) $(inferior_h) \ $(regcache_h) $(value_h) $(gdb_string_h) $(gdb_assert_h) \ $(ppc_tdep_h) $(target_h) $(objfiles_h) @@ -2254,11 +2260,11 @@ rs6000-nat.o: rs6000-nat.c $(defs_h) $(inferior_h) $(target_h) $(gdbcore_h) \ $(ppc_tdep_h) $(exec_h) $(gdb_stat_h) rs6000-tdep.o: rs6000-tdep.c $(defs_h) $(frame_h) $(inferior_h) $(symtab_h) \ $(target_h) $(gdbcore_h) $(gdbcmd_h) $(objfiles_h) $(arch_utils_h) \ - $(regcache_h) $(doublest_h) $(value_h) $(parser_defs_h) $(osabi_h) \ - $(libbfd_h) $(coff_internal_h) $(libcoff_h) $(coff_xcoff_h) \ - $(libxcoff_h) $(elf_bfd_h) $(solib_svr4_h) $(ppc_tdep_h) \ - $(gdb_assert_h) $(dis_asm_h) $(trad_frame_h) $(frame_unwind_h) \ - $(frame_base_h) + $(regcache_h) $(regset_g) $(doublest_h) $(value_h) $(parser_defs_h) \ + $(osabi_h) $(libbfd_h) $(coff_internal_h) $(libcoff_h) \ + $(coff_xcoff_h) $(libxcoff_h) $(elf_bfd_h) $(solib_svr4_h) \ + $(ppc_tdep_h) $(gdb_assert_h) $(dis_asm_h) $(trad_frame_h) \ + $(frame_unwind_h) $(frame_base_h) s390-nat.o: s390-nat.c $(defs_h) $(tm_h) $(regcache_h) $(inferior_h) \ $(s390_tdep_h) s390-tdep.o: s390-tdep.c $(defs_h) $(arch_utils_h) $(frame_h) $(inferior_h) \ @@ -5,6 +5,7 @@ * New native configurations +OpenBSD/powerpc powerpc-*-openbsd* NetBSD/vax vax-*-netbsd* OpenBSD/vax vax-*-openbsd* diff --git a/gdb/config/powerpc/nm-obsd.h b/gdb/config/powerpc/nm-obsd.h new file mode 100644 index 0000000..e59834f --- /dev/null +++ b/gdb/config/powerpc/nm-obsd.h @@ -0,0 +1,28 @@ +/* Native-dependent definitions for OpenBSD/powerpc. + + Copyright 2004 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 NM_OBSD_H +#define NM_OBSD_H + +/* Get generic BSD native definitions. */ +#include "config/nm-bsd.h" + +#endif /* nm-obsd.h */ diff --git a/gdb/config/powerpc/obsd.mh b/gdb/config/powerpc/obsd.mh new file mode 100644 index 0000000..a20575a --- /dev/null +++ b/gdb/config/powerpc/obsd.mh @@ -0,0 +1,3 @@ +# Host: OpenBSD/powerpc +NATDEPFILES= ppcobsd-nat.o fork-child.o infptrace.o inftarg.o +NAT_FILE= nm-obsd.h diff --git a/gdb/config/powerpc/obsd.mt b/gdb/config/powerpc/obsd.mt new file mode 100644 index 0000000..4441832 --- /dev/null +++ b/gdb/config/powerpc/obsd.mt @@ -0,0 +1,4 @@ +# Target: OpenBSD/powerpc +TDEPFILES= rs6000-tdep.o ppc-sysv-tdep.o ppcobsd-tdep.o \ + corelow.o solib.o solib-svr4.o +TM_FILE= tm-nbsd.h diff --git a/gdb/configure.host b/gdb/configure.host index f3344ce..64d46bd 100644 --- a/gdb/configure.host +++ b/gdb/configure.host @@ -98,6 +98,7 @@ powerpc-*-aix4.3.[0-1]*) gdb_host=aix ;; powerpc-*-aix*) gdb_host=aix432 ;; powerpc-*-linux*) gdb_host=linux ;; powerpc-*-netbsd*) gdb_host=nbsd ;; +powerpc-*-openbsd*) gdb_host=obsd ;; powerpc64-*-linux*) gdb_host=ppc64-linux ;; diff --git a/gdb/configure.tgt b/gdb/configure.tgt index 7364243..aee9c7d 100644 --- a/gdb/configure.tgt +++ b/gdb/configure.tgt @@ -134,6 +134,7 @@ mn10300-*-*) gdb_target=mn10300 ;; ns32k-*-netbsd*) gdb_target=nbsdaout ;; powerpc-*-netbsd*) gdb_target=nbsd ;; +powerpc-*-openbsd*) gdb_target=obsd ;; powerpc-*-aix*) gdb_target=aix ;; powerpc-*-linux*) gdb_target=linux build_gdbserver=yes diff --git a/gdb/ppc-tdep.h b/gdb/ppc-tdep.h index d570f79..7046553 100644 --- a/gdb/ppc-tdep.h +++ b/gdb/ppc-tdep.h @@ -74,11 +74,68 @@ enum return_value_convention ppc64_sysv_abi_return_value (struct gdbarch *gdbarc /* From rs6000-tdep.c... */ int altivec_register_p (int regno); - /* Return non-zero when the architecture has an FPU (or at least when the ABI is using the FPU). */ int ppc_floating_point_unit_p (struct gdbarch *gdbarch); +/* Register set description. */ + +struct ppc_reg_offsets +{ + /* General-purpose registers. */ + int r0_offset; + int pc_offset; + int ps_offset; + int cr_offset; + int lr_offset; + int ctr_offset; + int xer_offset; + int mq_offset; + + /* Floating-point registers. */ + int f0_offset; + int fpscr_offset; + + /* AltiVec registers. */ + int vr0_offset; + int vscr_offset; + int vrsave_offset; +}; + +/* Supply register REGNUM in the general-purpose register set REGSET + from the buffer specified by GREGS and LEN to register cache + REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */ + +extern void ppc_supply_gregset (const struct regset *regset, + struct regcache *regcache, + int regnum, const void *gregs, size_t len); + +/* Supply register REGNUM in the floating-point register set REGSET + from the buffer specified by FPREGS and LEN to register cache + REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */ + +extern void ppc_supply_fpregset (const struct regset *regset, + struct regcache *regcache, + int regnum, const void *fpregs, size_t len); + +/* Collect register REGNUM in the general-purpose register set + REGSET. from register cache REGCACHE into the buffer specified by + GREGS and LEN. If REGNUM is -1, do this for all registers in + REGSET. */ + +extern void ppc_collect_gregset (const struct regset *regset, + const struct regcache *regcache, + int regnum, void *gregs, size_t len); + +/* Collect register REGNUM in the floating-point register set + REGSET. from register cache REGCACHE into the buffer specified by + FPREGS and LEN. If REGNUM is -1, do this for all registers in + REGSET. */ + +extern void ppc_collect_fpregset (const struct regset *regset, + const struct regcache *regcache, + int regnum, void *fpregs, size_t len); + /* Private data that this module attaches to struct gdbarch. */ struct gdbarch_tdep diff --git a/gdb/ppcobsd-nat.c b/gdb/ppcobsd-nat.c new file mode 100644 index 0000000..5f43484 --- /dev/null +++ b/gdb/ppcobsd-nat.c @@ -0,0 +1,97 @@ +/* Native-dependent code for OpenBSD/powerpc. + + Copyright 2004 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 "inferior.h" +#include "regcache.h" + +#include <stddef.h> +#include <sys/types.h> +#include <sys/ptrace.h> +#include <machine/reg.h> + +#include "ppcobsd-tdep.h" + +/* OpenBSD/powerpc doesn't have PT_GETFPREGS/PT_SETFPREGS like + NetBSD/powerpc and FreeBSD/powerpc. */ + +/* Fetch register REGNUM from the inferior. If REGNUM is -1, do this + for all registers. */ + +void +fetch_inferior_registers (int regnum) +{ + struct reg regs; + + if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) ®s, 0) == -1) + perror_with_name ("Couldn't get registers"); + + ppcobsd_supply_gregset (&ppcobsd_gregset, current_regcache, -1, + ®s, sizeof regs); +} + +/* Store register REGNUM back into the inferior. If REGNUM is -1, do + this for all registers. */ + +void +store_inferior_registers (int regnum) +{ + struct reg regs; + + if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) ®s, 0) == -1) + perror_with_name ("Couldn't get registers"); + + ppcobsd_collect_gregset (&ppcobsd_gregset, current_regcache, + regnum, ®s, sizeof regs); + + if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) ®s, 0) == -1) + perror_with_name ("Couldn't write registers"); +} + + +/* Provide a prototype to silence -Wmissing-prototypes. */ +void _initialize_ppcobsd_nat (void); + +void +_initialize_ppcobsd_nat (void) +{ + /* General-purpose registers. */ + ppcobsd_reg_offsets.r0_offset = offsetof (struct reg, gpr); + ppcobsd_reg_offsets.pc_offset = offsetof (struct reg, pc); + ppcobsd_reg_offsets.ps_offset = offsetof (struct reg, ps); + ppcobsd_reg_offsets.cr_offset = offsetof (struct reg, cnd); + ppcobsd_reg_offsets.lr_offset = offsetof (struct reg, lr); + ppcobsd_reg_offsets.ctr_offset = offsetof (struct reg, cnt); + ppcobsd_reg_offsets.xer_offset = offsetof (struct reg, xer); + ppcobsd_reg_offsets.mq_offset = offsetof (struct reg, mq); + + /* Floating-point registers. */ + ppcobsd_reg_offsets.f0_offset = offsetof (struct reg, fpr); + ppcobsd_reg_offsets.fpscr_offset = -1; + + /* AltiVec registers. */ + ppcobsd_reg_offsets.vr0_offset = offsetof (struct vreg, vreg); + ppcobsd_reg_offsets.vscr_offset = offsetof (struct vreg, vscr); + ppcobsd_reg_offsets.vrsave_offset = offsetof (struct vreg, vrsave); +} diff --git a/gdb/ppcobsd-tdep.c b/gdb/ppcobsd-tdep.c new file mode 100644 index 0000000..90381e4 --- /dev/null +++ b/gdb/ppcobsd-tdep.c @@ -0,0 +1,153 @@ +/* Target-dependent code for OpenBSD/powerpc. + + Copyright 2004 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 "arch-utils.h" +#include "osabi.h" +#include "regcache.h" +#include "regset.h" + +#include "gdb_string.h" + +#include "ppc-tdep.h" +#include "ppcobsd-tdep.h" +#include "solib-svr4.h" + +/* Register offsets from <machine/reg.h>. */ +struct ppc_reg_offsets ppcobsd_reg_offsets; + + +/* Core file support. */ + +/* Supply register REGNUM in the general-purpose register set REGSET + from the buffer specified by GREGS and LEN to register cache + REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */ + +void +ppcobsd_supply_gregset (const struct regset *regset, + struct regcache *regcache, int regnum, + const void *gregs, size_t len) +{ + ppc_supply_gregset (regset, regcache, regnum, gregs, len); + ppc_supply_fpregset (regset, regcache, regnum, gregs, len); +} + +/* Collect register REGNUM in the general-purpose register set + REGSET. from register cache REGCACHE into the buffer specified by + GREGS and LEN. If REGNUM is -1, do this for all registers in + REGSET. */ + +void +ppcobsd_collect_gregset (const struct regset *regset, + const struct regcache *regcache, int regnum, + void *gregs, size_t len) +{ + ppc_collect_gregset (regset, regcache, regnum, gregs, len); + ppc_collect_fpregset (regset, regcache, regnum, gregs, len); +} + +/* OpenBS/powerpc register set. */ + +struct regset ppcobsd_gregset = +{ + &ppcobsd_reg_offsets, + ppcobsd_supply_gregset +}; + +/* Return the appropriate register set for the core section identified + by SECT_NAME and SECT_SIZE. */ + +static const struct regset * +ppcobsd_regset_from_core_section (struct gdbarch *gdbarch, + const char *sect_name, size_t sect_size) +{ + if (strcmp (sect_name, ".reg") == 0 && sect_size >= 412) + return &ppcobsd_gregset; + + return NULL; +} + + +static void +ppcobsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) +{ + /* OpenBSD uses SVR4-style shared libraries. */ + set_gdbarch_in_solib_call_trampoline + (gdbarch, generic_in_solib_call_trampoline); + set_solib_svr4_fetch_link_map_offsets + (gdbarch, svr4_ilp32_fetch_link_map_offsets); + + set_gdbarch_regset_from_core_section + (gdbarch, ppcobsd_regset_from_core_section); +} + + +/* OpenBSD uses uses the traditional NetBSD core file format, even for + ports that use ELF. */ +#define GDB_OSABI_NETBSD_CORE GDB_OSABI_OPENBSD_ELF + +static enum gdb_osabi +ppcobsd_core_osabi_sniffer (bfd *abfd) +{ + if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0) + return GDB_OSABI_NETBSD_CORE; + + return GDB_OSABI_UNKNOWN; +} + + +/* Provide a prototype to silence -Wmissing-prototypes. */ +void _initialize_ppcobsd_tdep (void); + +void +_initialize_ppcobsd_tdep (void) +{ + /* BFD doesn't set a flavour for NetBSD style a.out core files. */ + gdbarch_register_osabi_sniffer (bfd_arch_powerpc, bfd_target_unknown_flavour, + ppcobsd_core_osabi_sniffer); + + gdbarch_register_osabi (bfd_arch_powerpc, 0, GDB_OSABI_OPENBSD_ELF, + ppcobsd_init_abi); + + /* Avoid initializing the register offsets again if they were + already initailized by ppcobsd-nat.c. */ + if (ppcobsd_reg_offsets.pc_offset == 0) + { + /* General-purpose registers. */ + ppcobsd_reg_offsets.r0_offset = 0; + ppcobsd_reg_offsets.pc_offset = 384; + ppcobsd_reg_offsets.ps_offset = 388; + ppcobsd_reg_offsets.cr_offset = 392; + ppcobsd_reg_offsets.lr_offset = 396; + ppcobsd_reg_offsets.ctr_offset = 400; + ppcobsd_reg_offsets.xer_offset = 404; + ppcobsd_reg_offsets.mq_offset = 408; + + /* Floating-point registers. */ + ppcobsd_reg_offsets.f0_offset = 128; + ppcobsd_reg_offsets.fpscr_offset = -1; + + /* AltiVec registers. */ + ppcobsd_reg_offsets.vr0_offset = 0; + ppcobsd_reg_offsets.vscr_offset = 512; + ppcobsd_reg_offsets.vrsave_offset = 520; + } +} diff --git a/gdb/ppcobsd-tdep.h b/gdb/ppcobsd-tdep.h new file mode 100644 index 0000000..8f29aaa --- /dev/null +++ b/gdb/ppcobsd-tdep.h @@ -0,0 +1,54 @@ +/* Target-dependent code for OpenBSD/powerpc. + + Copyright 2004 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 PPCOBSD_TDEP_H +#define PPCOBSD_TDEP_H + +#include <stddef.h> + +struct regset; +struct regcache; + +/* Register offsets for OpenBSD/powerpc. */ +extern struct ppc_reg_offsets ppcobsd_reg_offsets; + +/* Register sets for OpenBSD/powerpc. */ +extern struct regset ppcobsd_gregset; + + +/* Supply register REGNUM in the general-purpose register set REGSET + from the buffer specified by GREGS and LEN to register cache + REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */ + +extern void ppcobsd_supply_gregset (const struct regset *regset, + struct regcache *regcache, int regnum, + const void *gregs, size_t len); + +/* Collect register REGNUM in the general-purpose register set + REGSET. from register cache REGCACHE into the buffer specified by + GREGS and LEN. If REGNUM is -1, do this for all registers in + REGSET. */ + +extern void ppcobsd_collect_gregset (const struct regset *regset, + const struct regcache *regcache, + int regnum, void *gregs, size_t len); + +#endif /* ppcobsd-tdep.h */ diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index 7118581..c9ab3a8 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -31,6 +31,7 @@ #include "objfiles.h" #include "arch-utils.h" #include "regcache.h" +#include "regset.h" #include "doublest.h" #include "value.h" #include "parser-defs.h" @@ -150,6 +151,166 @@ ppc_floating_point_unit_p (struct gdbarch *gdbarch) return 1; return 0; } + + +/* Register set support functions. */ + +static void +ppc_supply_reg (struct regcache *regcache, int regnum, + const char *regs, size_t offset) +{ + if (regnum != -1 && offset != -1) + regcache_raw_supply (regcache, regnum, regs + offset); +} + +static void +ppc_collect_reg (const struct regcache *regcache, int regnum, + char *regs, size_t offset) +{ + if (regnum != -1 && offset != -1) + regcache_raw_collect (regcache, regnum, regs + offset); +} + +/* Supply register REGNUM in the general-purpose register set REGSET + from the buffer specified by GREGS and LEN to register cache + REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */ + +void +ppc_supply_gregset (const struct regset *regset, struct regcache *regcache, + int regnum, const void *gregs, size_t len) +{ + struct gdbarch *gdbarch = get_regcache_arch (regcache); + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + const struct ppc_reg_offsets *offsets = regset->descr; + size_t offset; + int i; + + for (i = 0, offset = offsets->r0_offset; i < 32; i++, offset += 4) + { + if (regnum == -1 || regnum == i) + ppc_supply_reg (regcache, i, gregs, offset); + } + + if (regnum == -1 || regnum == PC_REGNUM) + ppc_supply_reg (regcache, PC_REGNUM, gregs, offsets->pc_offset); + if (regnum == -1 || regnum == tdep->ppc_ps_regnum) + ppc_supply_reg (regcache, tdep->ppc_ps_regnum, + gregs, offsets->ps_offset); + if (regnum == -1 || regnum == tdep->ppc_cr_regnum) + ppc_supply_reg (regcache, tdep->ppc_cr_regnum, + gregs, offsets->cr_offset); + if (regnum == -1 || regnum == tdep->ppc_lr_regnum) + ppc_supply_reg (regcache, tdep->ppc_lr_regnum, + gregs, offsets->lr_offset); + if (regnum == -1 || regnum == tdep->ppc_ctr_regnum) + ppc_supply_reg (regcache, tdep->ppc_ctr_regnum, + gregs, offsets->ctr_offset); + if (regnum == -1 || regnum == tdep->ppc_xer_regnum) + ppc_supply_reg (regcache, tdep->ppc_xer_regnum, + gregs, offsets->cr_offset); + if (regnum == -1 || regnum == tdep->ppc_mq_regnum) + ppc_supply_reg (regcache, tdep->ppc_mq_regnum, gregs, offsets->mq_offset); +} + +/* Supply register REGNUM in the floating-point register set REGSET + from the buffer specified by FPREGS and LEN to register cache + REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */ + +void +ppc_supply_fpregset (const struct regset *regset, struct regcache *regcache, + int regnum, const void *fpregs, size_t len) +{ + struct gdbarch *gdbarch = get_regcache_arch (regcache); + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + const struct ppc_reg_offsets *offsets = regset->descr; + size_t offset; + int i; + + offset = offsets->f0_offset; + for (i = FP0_REGNUM; i < FP0_REGNUM + 32; i++, offset += 4) + { + if (regnum == -1 || regnum == i) + ppc_supply_reg (regcache, i, fpregs, offset); + } + + if (regnum == -1 || regnum == tdep->ppc_fpscr_regnum) + ppc_supply_reg (regcache, tdep->ppc_fpscr_regnum, + fpregs, offsets->fpscr_offset); +} + +/* Collect register REGNUM in the general-purpose register set + REGSET. from register cache REGCACHE into the buffer specified by + GREGS and LEN. If REGNUM is -1, do this for all registers in + REGSET. */ + +void +ppc_collect_gregset (const struct regset *regset, + const struct regcache *regcache, + int regnum, void *gregs, size_t len) +{ + struct gdbarch *gdbarch = get_regcache_arch (regcache); + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + const struct ppc_reg_offsets *offsets = regset->descr; + size_t offset; + int i; + + offset = offsets->r0_offset; + for (i = 0; i <= 32; i++, offset += 4) + { + if (regnum == -1 || regnum == i) + ppc_collect_reg (regcache, regnum, gregs, offset); + } + + if (regnum == -1 || regnum == PC_REGNUM) + ppc_collect_reg (regcache, PC_REGNUM, gregs, offsets->pc_offset); + if (regnum == -1 || regnum == tdep->ppc_ps_regnum) + ppc_collect_reg (regcache, tdep->ppc_ps_regnum, + gregs, offsets->ps_offset); + if (regnum == -1 || regnum == tdep->ppc_cr_regnum) + ppc_collect_reg (regcache, tdep->ppc_cr_regnum, + gregs, offsets->cr_offset); + if (regnum == -1 || regnum == tdep->ppc_lr_regnum) + ppc_collect_reg (regcache, tdep->ppc_lr_regnum, + gregs, offsets->lr_offset); + if (regnum == -1 || regnum == tdep->ppc_ctr_regnum) + ppc_collect_reg (regcache, tdep->ppc_ctr_regnum, + gregs, offsets->ctr_offset); + if (regnum == -1 || regnum == tdep->ppc_xer_regnum) + ppc_collect_reg (regcache, tdep->ppc_xer_regnum, + gregs, offsets->xer_offset); + if (regnum == -1 || regnum == tdep->ppc_mq_regnum) + ppc_collect_reg (regcache, tdep->ppc_mq_regnum, + gregs, offsets->mq_offset); +} + +/* Collect register REGNUM in the floating-point register set + REGSET. from register cache REGCACHE into the buffer specified by + FPREGS and LEN. If REGNUM is -1, do this for all registers in + REGSET. */ + +void +ppc_collect_fpregset (const struct regset *regset, + const struct regcache *regcache, + int regnum, void *fpregs, size_t len) +{ + struct gdbarch *gdbarch = get_regcache_arch (regcache); + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + const struct ppc_reg_offsets *offsets = regset->descr; + size_t offset; + int i; + + offset = offsets->f0_offset; + for (i = FP0_REGNUM; i <= FP0_REGNUM + 32; i++, offset += 4) + { + if (regnum == -1 || regnum == i) + ppc_collect_reg (regcache, regnum, fpregs, offset); + } + + if (regnum == -1 || regnum == tdep->ppc_fpscr_regnum) + ppc_collect_reg (regcache, tdep->ppc_fpscr_regnum, + fpregs, offsets->fpscr_offset); +} + /* Read a LEN-byte address from debugged memory address MEMADDR. */ |