X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fppc-nbsd-nat.c;h=22e8915c8a4a3908ec60512a4bae4fc9f0ddf98a;hb=e5af216040aba59952c99d6479ba5279cee6825d;hp=21d927cc1485d6200061b691adeade5dde89227f;hpb=61baf725eca99af2569262d10aca03dcde2698f6;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/ppc-nbsd-nat.c b/gdb/ppc-nbsd-nat.c index 21d927cc14..22e8915c8a 100644 --- a/gdb/ppc-nbsd-nat.c +++ b/gdb/ppc-nbsd-nat.c @@ -1,6 +1,6 @@ /* Native-dependent code for NetBSD/powerpc. - Copyright (C) 2002-2017 Free Software Foundation, Inc. + Copyright (C) 2002-2019 Free Software Foundation, Inc. Contributed by Wasabi Systems, Inc. @@ -36,6 +36,14 @@ #include "bsd-kvm.h" #include "inf-ptrace.h" +struct ppc_nbsd_nat_target final : public inf_ptrace_target +{ + void fetch_registers (struct regcache *, int) override; + void store_registers (struct regcache *, int) override; +}; + +static ppc_nbsd_nat_target the_ppc_nbsd_nat_target; + /* Returns true if PT_GETREGS fetches this register. */ static int @@ -76,18 +84,17 @@ getfpregs_supplies (struct gdbarch *gdbarch, int regnum) || regnum == tdep->ppc_fpscr_regnum); } -static void -ppcnbsd_fetch_inferior_registers (struct target_ops *ops, - struct regcache *regcache, int regnum) +void +ppc_nbsd_nat_target::fetch_registers (struct regcache *regcache, int regnum) { - struct gdbarch *gdbarch = get_regcache_arch (regcache); + struct gdbarch *gdbarch = regcache->arch (); + pid_t pid = regcache->ptid ().pid (); if (regnum == -1 || getregs_supplies (gdbarch, regnum)) { struct reg regs; - if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid), - (PTRACE_TYPE_ARG3) ®s, 0) == -1) + if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't get registers")); ppc_supply_gregset (&ppcnbsd_gregset, regcache, @@ -98,8 +105,7 @@ ppcnbsd_fetch_inferior_registers (struct target_ops *ops, { struct fpreg fpregs; - if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid), - (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) + if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name (_("Couldn't get FP registers")); ppc_supply_fpregset (&ppcnbsd_fpregset, regcache, @@ -107,25 +113,23 @@ ppcnbsd_fetch_inferior_registers (struct target_ops *ops, } } -static void -ppcnbsd_store_inferior_registers (struct target_ops *ops, - struct regcache *regcache, int regnum) +void +ppc_nbsd_nat_target::store_registers (struct regcache *regcache, int regnum) { - struct gdbarch *gdbarch = get_regcache_arch (regcache); + struct gdbarch *gdbarch = regcache->arch (); + pid_t pid = regcache->ptid ().pid (); if (regnum == -1 || getregs_supplies (gdbarch, regnum)) { struct reg regs; - if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid), - (PTRACE_TYPE_ARG3) ®s, 0) == -1) + if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't get registers")); ppc_collect_gregset (&ppcnbsd_gregset, regcache, regnum, ®s, sizeof regs); - if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid), - (PTRACE_TYPE_ARG3) ®s, 0) == -1) + if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't write registers")); } @@ -133,15 +137,13 @@ ppcnbsd_store_inferior_registers (struct target_ops *ops, { struct fpreg fpregs; - if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid), - (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) + if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name (_("Couldn't get FP registers")); ppc_collect_fpregset (&ppcnbsd_fpregset, regcache, regnum, &fpregs, sizeof fpregs); - if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid), - (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) + if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name (_("Couldn't set FP registers")); } } @@ -151,7 +153,7 @@ ppcnbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb) { struct switchframe sf; struct callframe cf; - struct gdbarch *gdbarch = get_regcache_arch (regcache); + struct gdbarch *gdbarch = regcache->arch (); struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); int i; @@ -160,38 +162,28 @@ ppcnbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb) return 0; read_memory (pcb->pcb_sp, (gdb_byte *)&sf, sizeof sf); - regcache_raw_supply (regcache, tdep->ppc_cr_regnum, &sf.cr); - regcache_raw_supply (regcache, tdep->ppc_gp0_regnum + 2, &sf.fixreg2); + regcache->raw_supply (tdep->ppc_cr_regnum, &sf.cr); + regcache->raw_supply (tdep->ppc_gp0_regnum + 2, &sf.fixreg2); for (i = 0 ; i < 19 ; i++) - regcache_raw_supply (regcache, tdep->ppc_gp0_regnum + 13 + i, - &sf.fixreg[i]); + regcache->raw_supply (tdep->ppc_gp0_regnum + 13 + i, &sf.fixreg[i]); read_memory(sf.sp, (gdb_byte *)&cf, sizeof(cf)); - regcache_raw_supply (regcache, tdep->ppc_gp0_regnum + 30, &cf.r30); - regcache_raw_supply (regcache, tdep->ppc_gp0_regnum + 31, &cf.r31); - regcache_raw_supply (regcache, tdep->ppc_gp0_regnum + 1, &cf.sp); + regcache->raw_supply (tdep->ppc_gp0_regnum + 30, &cf.r30); + regcache->raw_supply (tdep->ppc_gp0_regnum + 31, &cf.r31); + regcache->raw_supply (tdep->ppc_gp0_regnum + 1, &cf.sp); read_memory(cf.sp, (gdb_byte *)&cf, sizeof(cf)); - regcache_raw_supply (regcache, tdep->ppc_lr_regnum, &cf.lr); - regcache_raw_supply (regcache, gdbarch_pc_regnum (gdbarch), &cf.lr); + regcache->raw_supply (tdep->ppc_lr_regnum, &cf.lr); + regcache->raw_supply (gdbarch_pc_regnum (gdbarch), &cf.lr); return 1; } -/* Provide a prototype to silence -Wmissing-prototypes. */ -void _initialize_ppcnbsd_nat (void); - void _initialize_ppcnbsd_nat (void) { - struct target_ops *t; - /* Support debugging kernel virtual memory images. */ bsd_kvm_add_target (ppcnbsd_supply_pcb); - /* Add in local overrides. */ - t = inf_ptrace_target (); - t->to_fetch_registers = ppcnbsd_fetch_inferior_registers; - t->to_store_registers = ppcnbsd_store_inferior_registers; - add_target (t); + add_inf_child_target (&the_ppc_nbsd_nat_target); }