* configure.in: removed target_dependent line.
[deliverable/binutils-gdb.git] / gdb / mips-xdep.c
CommitLineData
dd3b648e 1/* Low level MIPS interface to ptrace, for GDB when running under Unix.
b543979c 2 Copyright 1988, 1989, 1991, 1992 Free Software Foundation, Inc.
dd3b648e
RP
3 Contributed by Alessandro Forin(af@cs.cmu.edu) at CMU
4 and by Per Bothner(bothner@cs.wisc.edu) at U.Wisconsin.
5
6This file is part of GDB.
7
99a7de40 8This program is free software; you can redistribute it and/or modify
dd3b648e 9it under the terms of the GNU General Public License as published by
99a7de40
JG
10the Free Software Foundation; either version 2 of the License, or
11(at your option) any later version.
dd3b648e 12
99a7de40 13This program is distributed in the hope that it will be useful,
dd3b648e
RP
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
99a7de40
JG
19along with this program; if not, write to the Free Software
20Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
dd3b648e 21
d747e0af 22#include "defs.h"
dd3b648e 23#include "inferior.h"
dd3b648e
RP
24#include "gdbcore.h"
25
6872cfda
JG
26/* For now we stub this out; sgi core format is super-hairy (and completely
27 different in the new release).
28 For most mips systems, this function is defined in coredep.c. */
625453dc 29
6872cfda 30#if defined(sgi)
625453dc 31void
43a16f26
JG
32fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr)
33 char *core_reg_sect;
34 unsigned core_reg_size;
35 int which;
36 unsigned int reg_addr;
625453dc
SG
37{
38 return;
39}
6872cfda
JG
40#endif
41
42/* Access to the inferior is only good for native systems, not cross.
43 I am not sure why this is stubbed out on SGI... --gnu@cygnus.com */
44
45#if defined(sgi) || !defined(GDB_TARGET_IS_MIPS)
625453dc 46
1ab3bf1b 47/* ARGSUSED */
625453dc 48void
1ab3bf1b
JG
49fetch_inferior_registers (regno)
50 int regno;
625453dc
SG
51{
52 return;
53}
54
1ab3bf1b
JG
55/* ARGSUSED */
56void
625453dc
SG
57store_inferior_registers (regno)
58 int regno;
59{
60 return;
61}
62
63
64#else
65
eb54a95a
JG
66/* DECstation native... */
67
68#include <sys/ptrace.h>
69
70/* Map gdb internal register number to ptrace ``address''.
71 These ``addresses'' are defined in DECstation <sys/ptrace.h> */
abefb1f1
PB
72
73#define REGISTER_PTRACE_ADDR(regno) \
eb54a95a
JG
74 (regno < 32 ? GPR_BASE + regno \
75 : regno == PC_REGNUM ? PC \
76 : regno == CAUSE_REGNUM ? CAUSE \
77 : regno == HI_REGNUM ? MMHI \
78 : regno == LO_REGNUM ? MMLO \
79 : regno == FCRCS_REGNUM ? FPC_CSR \
80 : regno == FCRIR_REGNUM ? FPC_EIR \
81 : regno >= FP0_REGNUM ? FPR_BASE + (regno - FP0_REGNUM) \
abefb1f1
PB
82 : 0)
83
2886f8b2
JG
84static const char zerobuf[MAX_REGISTER_RAW_SIZE];
85
dd3b648e
RP
86/* Get all registers from the inferior */
87
88void
1ab3bf1b
JG
89fetch_inferior_registers (regno)
90 int regno;
dd3b648e 91{
dd3b648e
RP
92 register unsigned int regaddr;
93 char buf[MAX_REGISTER_RAW_SIZE];
94 register int i;
95
96 registers_fetched ();
97
98 for (regno = 1; regno < NUM_REGS; regno++)
99 {
abefb1f1 100 regaddr = REGISTER_PTRACE_ADDR (regno);
dd3b648e
RP
101 for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
102 {
eb54a95a 103 *(int *) &buf[i] = ptrace (PT_READ_U, inferior_pid,
e676a15f 104 (PTRACE_ARG3_TYPE) regaddr, 0);
dd3b648e
RP
105 regaddr += sizeof (int);
106 }
107 supply_register (regno, buf);
108 }
2886f8b2
JG
109
110 supply_register (ZERO_REGNUM, zerobuf);
111 /* Frame ptr reg must appear to be 0; it is faked by stack handling code. */
112 supply_register (FP_REGNUM, zerobuf);
dd3b648e
RP
113}
114
115/* Store our register values back into the inferior.
116 If REGNO is -1, do this for all registers.
117 Otherwise, REGNO specifies which register (so we can save time). */
118
625453dc 119void
dd3b648e
RP
120store_inferior_registers (regno)
121 int regno;
625453dc 122 {
dd3b648e
RP
123 register unsigned int regaddr;
124 char buf[80];
125
126 if (regno == 0)
127 return;
128
129 if (regno > 0)
130 {
abefb1f1 131 regaddr = REGISTER_PTRACE_ADDR (regno);
dd3b648e 132 errno = 0;
eb54a95a 133 ptrace (PT_WRITE_U, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
e676a15f 134 read_register (regno));
dd3b648e
RP
135 if (errno != 0)
136 {
137 sprintf (buf, "writing register number %d", regno);
138 perror_with_name (buf);
139 }
140 }
141 else
142 {
abefb1f1 143 for (regno = 0; regno < NUM_REGS; regno++)
dd3b648e 144 {
abefb1f1
PB
145 if (regno == ZERO_REGNUM || regno == PS_REGNUM
146 || regno == BADVADDR_REGNUM || regno == CAUSE_REGNUM
b543979c
JG
147 || regno == FCRIR_REGNUM || regno == FP_REGNUM
148 || (regno >= FIRST_EMBED_REGNUM && regno <= LAST_EMBED_REGNUM))
dd3b648e
RP
149 continue;
150 regaddr = register_addr (regno, 1);
151 errno = 0;
e676a15f
FF
152 ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
153 read_register (regno));
dd3b648e
RP
154 if (errno != 0)
155 {
156 sprintf (buf, "writing all regs, number %d", regno);
157 perror_with_name (buf);
158 }
159 }
160 }
161}
162
625453dc 163#endif /* sgi */
This page took 0.074643 seconds and 4 git commands to generate.