gdb/vaxbsd-nat.c - gdb
Functions defined
Source code
- #include "defs.h"
- #include "inferior.h"
- #include "regcache.h"
- #include "target.h"
- #include <sys/types.h>
- #include <sys/ptrace.h>
- #include <machine/reg.h>
- #include "vax-tdep.h"
- #include "inf-ptrace.h"
- static void
- vaxbsd_supply_gregset (struct regcache *regcache, const void *gregs)
- {
- const gdb_byte *regs = gregs;
- int regnum;
- for (regnum = 0; regnum < VAX_NUM_REGS; regnum++)
- regcache_raw_supply (regcache, regnum, regs + regnum * 4);
- }
- static void
- vaxbsd_collect_gregset (const struct regcache *regcache,
- void *gregs, int regnum)
- {
- gdb_byte *regs = gregs;
- int i;
- for (i = 0; i <= VAX_NUM_REGS; i++)
- {
- if (regnum == -1 || regnum == i)
- regcache_raw_collect (regcache, i, regs + i * 4);
- }
- }
- static void
- vaxbsd_fetch_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
- {
- struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) ®s, 0) == -1)
- perror_with_name (_("Couldn't get registers"));
- vaxbsd_supply_gregset (regcache, ®s);
- }
- static void
- vaxbsd_store_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
- {
- struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) ®s, 0) == -1)
- perror_with_name (_("Couldn't get registers"));
- vaxbsd_collect_gregset (regcache, ®s, regnum);
- if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) ®s, 0) == -1)
- perror_with_name (_("Couldn't write registers"));
- }
- #include <machine/pcb.h>
- #include "bsd-kvm.h"
- static int
- vaxbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
- {
- int regnum;
-
-
- if (pcb->KSP == 0)
- 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);
- return 1;
- }
- void _initialize_vaxbsd_nat (void);
- void
- _initialize_vaxbsd_nat (void)
- {
- 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);
-
- bsd_kvm_add_target (vaxbsd_supply_pcb);
- }