OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [gdb/] [vaxbsd-nat.c] - Blame information for rev 227

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 jeremybenn
/* Native-dependent code for modern VAX BSD's.
2
 
3
   Copyright (C) 2004, 2005, 2007, 2008, 2009, 2010
4
   Free Software Foundation, Inc.
5
 
6
   This file is part of GDB.
7
 
8
   This program is free software; you can redistribute it and/or modify
9
   it under the terms of the GNU General Public License as published by
10
   the Free Software Foundation; either version 3 of the License, or
11
   (at your option) any later version.
12
 
13
   This program is distributed in the hope that it will be useful,
14
   but WITHOUT ANY WARRANTY; without even the implied warranty of
15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
   GNU General Public License for more details.
17
 
18
   You should have received a copy of the GNU General Public License
19
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
20
 
21
#include "defs.h"
22
#include "inferior.h"
23
#include "regcache.h"
24
#include "target.h"
25
 
26
#include <sys/types.h>
27
#include <sys/ptrace.h>
28
#include <machine/reg.h>
29
 
30
#include "vax-tdep.h"
31
#include "inf-ptrace.h"
32
 
33
/* Supply the general-purpose registers stored in GREGS to REGCACHE.  */
34
 
35
static void
36
vaxbsd_supply_gregset (struct regcache *regcache, const void *gregs)
37
{
38
  const gdb_byte *regs = gregs;
39
  int regnum;
40
 
41
  for (regnum = 0; regnum < VAX_NUM_REGS; regnum++)
42
    regcache_raw_supply (regcache, regnum, regs + regnum * 4);
43
}
44
 
45
/* Collect the general-purpose registers from REGCACHE and store them
46
   in GREGS.  */
47
 
48
static void
49
vaxbsd_collect_gregset (const struct regcache *regcache,
50
                        void *gregs, int regnum)
51
{
52
  gdb_byte *regs = gregs;
53
  int i;
54
 
55
  for (i = 0; i <= VAX_NUM_REGS; i++)
56
    {
57
      if (regnum == -1 || regnum == i)
58
        regcache_raw_collect (regcache, i, regs + i * 4);
59
    }
60
}
61
 
62
 
63
/* Fetch register REGNUM from the inferior.  If REGNUM is -1, do this
64
   for all registers.  */
65
 
66
static void
67
vaxbsd_fetch_inferior_registers (struct target_ops *ops,
68
                                 struct regcache *regcache, int regnum)
69
{
70
  struct reg regs;
71
 
72
  if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
73
              (PTRACE_TYPE_ARG3) &regs, 0) == -1)
74
    perror_with_name (_("Couldn't get registers"));
75
 
76
  vaxbsd_supply_gregset (regcache, &regs);
77
}
78
 
79
/* Store register REGNUM back into the inferior.  If REGNUM is -1, do
80
   this for all registers.  */
81
 
82
static void
83
vaxbsd_store_inferior_registers (struct target_ops *ops,
84
                                 struct regcache *regcache, int regnum)
85
{
86
  struct reg regs;
87
 
88
  if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
89
              (PTRACE_TYPE_ARG3) &regs, 0) == -1)
90
    perror_with_name (_("Couldn't get registers"));
91
 
92
  vaxbsd_collect_gregset (regcache, &regs, regnum);
93
 
94
  if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
95
              (PTRACE_TYPE_ARG3) &regs, 0) == -1)
96
    perror_with_name (_("Couldn't write registers"));
97
}
98
 
99
 
100
/* Support for debugging kernel virtual memory images.  */
101
 
102
#include <sys/types.h>
103
#include <machine/pcb.h>
104
 
105
#include "bsd-kvm.h"
106
 
107
static int
108
vaxbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
109
{
110
  int regnum;
111
 
112
  /* The following is true for OpenBSD 3.5:
113
 
114
     The pcb contains the register state at the context switch inside
115
     cpu_switch().  */
116
 
117
  /* The stack pointer shouldn't be zero.  */
118
  if (pcb->KSP == 0)
119
    return 0;
120
 
121
  for (regnum = VAX_R0_REGNUM; regnum < VAX_AP_REGNUM; regnum++)
122
    regcache_raw_supply (regcache, regnum, &pcb->R[regnum - VAX_R0_REGNUM]);
123
  regcache_raw_supply (regcache, VAX_AP_REGNUM, &pcb->AP);
124
  regcache_raw_supply (regcache, VAX_FP_REGNUM, &pcb->FP);
125
  regcache_raw_supply (regcache, VAX_SP_REGNUM, &pcb->KSP);
126
  regcache_raw_supply (regcache, VAX_PC_REGNUM, &pcb->PC);
127
  regcache_raw_supply (regcache, VAX_PS_REGNUM, &pcb->PSL);
128
 
129
  return 1;
130
}
131
 
132
 
133
/* Provide a prototype to silence -Wmissing-prototypes.  */
134
void _initialize_vaxbsd_nat (void);
135
 
136
void
137
_initialize_vaxbsd_nat (void)
138
{
139
  struct target_ops *t;
140
 
141
  t = inf_ptrace_target ();
142
  t->to_fetch_registers = vaxbsd_fetch_inferior_registers;
143
  t->to_store_registers = vaxbsd_store_inferior_registers;
144
  add_target (t);
145
 
146
  /* Support debugging kernel virtual memory images.  */
147
  bsd_kvm_add_target (vaxbsd_supply_pcb);
148
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.