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/] [alphabsd-nat.c] - Blame information for rev 285

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 jeremybenn
/* Native-dependent code for Alpha BSD's.
2
 
3
   Copyright (C) 2000, 2001, 2002, 2004, 2005, 2006, 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
 
25
#include "alpha-tdep.h"
26
#include "alphabsd-tdep.h"
27
#include "inf-ptrace.h"
28
 
29
#include <sys/types.h>
30
#include <sys/ptrace.h>
31
#include <machine/reg.h>
32
 
33
#ifdef HAVE_SYS_PROCFS_H
34
#include <sys/procfs.h>
35
#endif
36
 
37
#ifndef HAVE_GREGSET_T
38
typedef struct reg gregset_t;
39
#endif
40
 
41
#ifndef HAVE_FPREGSET_T 
42
typedef struct fpreg fpregset_t;
43
#endif 
44
 
45
#include "gregset.h"
46
 
47
/* Provide *regset() wrappers around the generic Alpha BSD register
48
   supply/fill routines.  */
49
 
50
void
51
supply_gregset (struct regcache *regcache, const gregset_t *gregsetp)
52
{
53
  alphabsd_supply_reg (regcache, (const char *) gregsetp, -1);
54
}
55
 
56
void
57
fill_gregset (const struct regcache *regcache, gregset_t *gregsetp, int regno)
58
{
59
  alphabsd_fill_reg (regcache, (char *) gregsetp, regno);
60
}
61
 
62
void
63
supply_fpregset (struct regcache *regcache, const fpregset_t *fpregsetp)
64
{
65
  alphabsd_supply_fpreg (regcache, (const char *) fpregsetp, -1);
66
}
67
 
68
void
69
fill_fpregset (const struct regcache *regcache, fpregset_t *fpregsetp, int regno)
70
{
71
  alphabsd_fill_fpreg (regcache, (char *) fpregsetp, regno);
72
}
73
 
74
/* Determine if PT_GETREGS fetches this register.  */
75
 
76
static int
77
getregs_supplies (int regno)
78
{
79
  return ((regno >= ALPHA_V0_REGNUM && regno <= ALPHA_ZERO_REGNUM)
80
          || regno >= ALPHA_PC_REGNUM);
81
}
82
 
83
/* Fetch register REGNO from the inferior.  If REGNO is -1, do this
84
   for all registers (including the floating point registers).  */
85
 
86
static void
87
alphabsd_fetch_inferior_registers (struct target_ops *ops,
88
                                   struct regcache *regcache, int regno)
89
{
90
  if (regno == -1 || getregs_supplies (regno))
91
    {
92
      struct reg gregs;
93
 
94
      if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
95
                  (PTRACE_TYPE_ARG3) &gregs, 0) == -1)
96
        perror_with_name (_("Couldn't get registers"));
97
 
98
      alphabsd_supply_reg (regcache, (char *) &gregs, regno);
99
      if (regno != -1)
100
        return;
101
    }
102
 
103
  if (regno == -1 || regno >= gdbarch_fp0_regnum (get_regcache_arch (regcache)))
104
    {
105
      struct fpreg fpregs;
106
 
107
      if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
108
                  (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
109
        perror_with_name (_("Couldn't get floating point status"));
110
 
111
      alphabsd_supply_fpreg (regcache, (char *) &fpregs, regno);
112
    }
113
}
114
 
115
/* Store register REGNO back into the inferior.  If REGNO is -1, do
116
   this for all registers (including the floating point registers).  */
117
 
118
static void
119
alphabsd_store_inferior_registers (struct target_ops *ops,
120
                                   struct regcache *regcache, int regno)
121
{
122
  if (regno == -1 || getregs_supplies (regno))
123
    {
124
      struct reg gregs;
125
      if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
126
                  (PTRACE_TYPE_ARG3) &gregs, 0) == -1)
127
        perror_with_name (_("Couldn't get registers"));
128
 
129
      alphabsd_fill_reg (regcache, (char *) &gregs, regno);
130
 
131
      if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
132
                  (PTRACE_TYPE_ARG3) &gregs, 0) == -1)
133
        perror_with_name (_("Couldn't write registers"));
134
 
135
      if (regno != -1)
136
        return;
137
    }
138
 
139
  if (regno == -1 || regno >= gdbarch_fp0_regnum (get_regcache_arch (regcache)))
140
    {
141
      struct fpreg fpregs;
142
 
143
      if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
144
                  (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
145
        perror_with_name (_("Couldn't get floating point status"));
146
 
147
      alphabsd_fill_fpreg (regcache, (char *) &fpregs, regno);
148
 
149
      if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid),
150
                  (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
151
        perror_with_name (_("Couldn't write floating point status"));
152
    }
153
}
154
 
155
 
156
/* Support for debugging kernel virtual memory images.  */
157
 
158
#include <sys/types.h>
159
#include <sys/signal.h>
160
#include <machine/pcb.h>
161
 
162
#include "bsd-kvm.h"
163
 
164
static int
165
alphabsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
166
{
167
  int regnum;
168
 
169
  /* The following is true for OpenBSD 3.9:
170
 
171
     The pcb contains the register state at the context switch inside
172
     cpu_switch().  */
173
 
174
  /* The stack pointer shouldn't be zero.  */
175
  if (pcb->pcb_hw.apcb_ksp == 0)
176
    return 0;
177
 
178
  regcache_raw_supply (regcache, ALPHA_SP_REGNUM, &pcb->pcb_hw.apcb_ksp);
179
 
180
  for (regnum = ALPHA_S0_REGNUM; regnum < ALPHA_A0_REGNUM; regnum++)
181
    regcache_raw_supply (regcache, regnum,
182
                         &pcb->pcb_context[regnum - ALPHA_S0_REGNUM]);
183
  regcache_raw_supply (regcache, ALPHA_RA_REGNUM, &pcb->pcb_context[7]);
184
 
185
  return 1;
186
}
187
 
188
 
189
/* Provide a prototype to silence -Wmissing-prototypes.  */
190
void _initialize_alphabsd_nat (void);
191
 
192
void
193
_initialize_alphabsd_nat (void)
194
{
195
  struct target_ops *t;
196
 
197
  t = inf_ptrace_target ();
198
  t->to_fetch_registers = alphabsd_fetch_inferior_registers;
199
  t->to_store_registers = alphabsd_store_inferior_registers;
200
  add_target (t);
201
 
202
  /* Support debugging kernel virtual memory images.  */
203
  bsd_kvm_add_target (alphabsd_supply_pcb);
204
}

powered by: WebSVN 2.1.0

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