X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fvax-bsd-nat.c;h=1ca1f7bb1e827e71750afe6e5aa87604cee2adfc;hb=8df017996f662ce6ab23aea4abeb8f7ac1f62651;hp=38106653f4f1a7e411e8d117dfd61b2371c94b01;hpb=e2882c85786571175a0b0bfc3bcd2f14620b1ea3;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/vax-bsd-nat.c b/gdb/vax-bsd-nat.c index 38106653f4..1ca1f7bb1e 100644 --- a/gdb/vax-bsd-nat.c +++ b/gdb/vax-bsd-nat.c @@ -1,6 +1,6 @@ /* Native-dependent code for modern VAX BSD's. - Copyright (C) 2004-2018 Free Software Foundation, Inc. + Copyright (C) 2004-2020 Free Software Foundation, Inc. This file is part of GDB. @@ -17,6 +17,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +/* We define this to get types like register_t. */ +#define _KERNTYPES #include "defs.h" #include "inferior.h" #include "regcache.h" @@ -28,17 +30,26 @@ #include "vax-tdep.h" #include "inf-ptrace.h" +#include "nbsd-nat.h" + +struct vax_bsd_nat_target final : public nbsd_nat_target +{ + void fetch_registers (struct regcache *, int) override; + void store_registers (struct regcache *, int) override; +}; + +static vax_bsd_nat_target the_vax_bsd_nat_target; /* Supply the general-purpose registers stored in GREGS to REGCACHE. */ static void vaxbsd_supply_gregset (struct regcache *regcache, const void *gregs) { - const gdb_byte *regs = gregs; + const gdb_byte *regs = (const gdb_byte *)gregs; int regnum; for (regnum = 0; regnum < VAX_NUM_REGS; regnum++) - regcache_raw_supply (regcache, regnum, regs + regnum * 4); + regcache->raw_supply (regnum, regs + regnum * 4); } /* Collect the general-purpose registers from REGCACHE and store them @@ -48,13 +59,13 @@ static void vaxbsd_collect_gregset (const struct regcache *regcache, void *gregs, int regnum) { - gdb_byte *regs = gregs; + gdb_byte *regs = (void *)gregs; int i; for (i = 0; i <= VAX_NUM_REGS; i++) { if (regnum == -1 || regnum == i) - regcache_raw_collect (regcache, i, regs + i * 4); + regcache->raw_collect (i, regs + i * 4); } } @@ -62,14 +73,14 @@ vaxbsd_collect_gregset (const struct regcache *regcache, /* Fetch register REGNUM from the inferior. If REGNUM is -1, do this for all registers. */ -static void -vaxbsd_fetch_inferior_registers (struct target_ops *ops, - struct regcache *regcache, int regnum) +void +vax_bsd_nat_target::fetch_registers (struct regcache *regcache, int regnum) { struct reg regs; - pid_t pid = ptid_get_pid (regcache_get_ptid (regcache)); + pid_t pid = regcache->ptid ().pid (); + int lwp = regcache->ptid ().lwp (); - if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1) + if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp) == -1) perror_with_name (_("Couldn't get registers")); vaxbsd_supply_gregset (regcache, ®s); @@ -78,19 +89,19 @@ vaxbsd_fetch_inferior_registers (struct target_ops *ops, /* Store register REGNUM back into the inferior. If REGNUM is -1, do this for all registers. */ -static void -vaxbsd_store_inferior_registers (struct target_ops *ops, - struct regcache *regcache, int regnum) +void +vax_bsd_nat_target::store_registers (struct regcache *regcache, int regnum) { struct reg regs; - pid_t pid = ptid_get_pid (regcache_get_ptid (regcache)); + pid_t pid = regcache->ptid ().pid (); + int lwp = regcache->ptid ().lwp (); - if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1) + if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp) == -1) perror_with_name (_("Couldn't get registers")); vaxbsd_collect_gregset (regcache, ®s, regnum); - if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1) + if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp) == -1) perror_with_name (_("Couldn't write registers")); } @@ -116,25 +127,21 @@ vaxbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb) return 0; for (regnum = VAX_R0_REGNUM; regnum < VAX_AP_REGNUM; regnum++) - regcache_raw_supply (regcache, regnum, &pcb->R[regnum - VAX_R0_REGNUM]); - regcache_raw_supply (regcache, VAX_AP_REGNUM, &pcb->AP); - regcache_raw_supply (regcache, VAX_FP_REGNUM, &pcb->FP); - regcache_raw_supply (regcache, VAX_SP_REGNUM, &pcb->KSP); - regcache_raw_supply (regcache, VAX_PC_REGNUM, &pcb->PC); - regcache_raw_supply (regcache, VAX_PS_REGNUM, &pcb->PSL); + regcache->raw_supply (regnum, &pcb->R[regnum - VAX_R0_REGNUM]); + regcache->raw_supply (VAX_AP_REGNUM, &pcb->AP); + regcache->raw_supply (VAX_FP_REGNUM, &pcb->FP); + regcache->raw_supply (VAX_SP_REGNUM, &pcb->KSP); + regcache->raw_supply (VAX_PC_REGNUM, &pcb->PC); + regcache->raw_supply (VAX_PS_REGNUM, &pcb->PSL); return 1; } +void _initialize_vaxbsd_nat (); void -_initialize_vaxbsd_nat (void) +_initialize_vaxbsd_nat () { - struct target_ops *t; - - t = inf_ptrace_target (); - t->to_fetch_registers = vaxbsd_fetch_inferior_registers; - t->to_store_registers = vaxbsd_store_inferior_registers; - add_target (t); + add_inf_child_target (&the_vax_bsd_nat_target); /* Support debugging kernel virtual memory images. */ bsd_kvm_add_target (vaxbsd_supply_pcb);