Name change (It's hitacho micro systems, not hitachi data systems)
[deliverable/binutils-gdb.git] / gdb / mips-xdep.c
CommitLineData
dd3b648e
RP
1/* Low level MIPS interface to ptrace, for GDB when running under Unix.
2 Copyright (C) 1988, 1989, 1991 Free Software Foundation, Inc.
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
RP
21
22#include <stdio.h>
625453dc
SG
23#ifdef sgi
24#include <sys/inst.h>
25#else
dd3b648e 26#include <mips/inst.h>
625453dc 27#endif
dd3b648e 28#include "defs.h"
dd3b648e
RP
29#include "frame.h"
30#include "inferior.h"
31#include "symtab.h"
32#include "value.h"
33
34#ifdef USG
35#include <sys/types.h>
36#endif
37
38#include <sys/param.h>
39#include <sys/dir.h>
40#include <signal.h>
41#include <sys/ioctl.h>
42/* #include <fcntl.h> Can we live without this? */
43
44#include "gdbcore.h"
45
46#include <sys/user.h> /* After a.out.h */
47#include <sys/file.h>
48#include <sys/stat.h>
49
625453dc
SG
50/* For now we stub this out; sgi format is super-hairy (and completely
51 different in the new release) */
52
53#ifdef sgi
54void
55fetch_core_registers ()
56{
57 return;
58}
59
60void
61fetch_inferior_registers ()
62{
63 return;
64}
65
66store_inferior_registers (regno)
67 int regno;
68{
69 return;
70}
71
72
73#else
74
abefb1f1
PB
75/* Map gdb internal register number to ptrace address. */
76
77#define REGISTER_PTRACE_ADDR(regno) \
78 (regno < 32 ? regno \
79 : regno == PC_REGNUM ? 96 \
80 : regno == CAUSE_REGNUM ? 97 \
81 : regno == HI_REGNUM ? 98 \
82 : regno == LO_REGNUM ? 99 \
83 : regno == FCRCS_REGNUM ? 100 \
84 : regno == FCRIR_REGNUM ? 101 \
85 : regno >= FP0_REGNUM ? regno - (FP0_REGNUM-32)\
86 : 0)
87
dd3b648e
RP
88/* Get all registers from the inferior */
89
90void
91fetch_inferior_registers ()
92{
93 register int regno;
94 register unsigned int regaddr;
95 char buf[MAX_REGISTER_RAW_SIZE];
96 register int i;
97
98 registers_fetched ();
99
100 for (regno = 1; regno < NUM_REGS; regno++)
101 {
abefb1f1 102 regaddr = REGISTER_PTRACE_ADDR (regno);
dd3b648e
RP
103 for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
104 {
105 *(int *) &buf[i] = ptrace (3, inferior_pid, regaddr, 0);
106 regaddr += sizeof (int);
107 }
108 supply_register (regno, buf);
109 }
110}
111
112/* Store our register values back into the inferior.
113 If REGNO is -1, do this for all registers.
114 Otherwise, REGNO specifies which register (so we can save time). */
115
625453dc 116void
dd3b648e
RP
117store_inferior_registers (regno)
118 int regno;
625453dc 119 {
dd3b648e
RP
120 register unsigned int regaddr;
121 char buf[80];
122
123 if (regno == 0)
124 return;
125
126 if (regno > 0)
127 {
abefb1f1 128 regaddr = REGISTER_PTRACE_ADDR (regno);
dd3b648e
RP
129 errno = 0;
130 ptrace (6, inferior_pid, regaddr, read_register (regno));
131 if (errno != 0)
132 {
133 sprintf (buf, "writing register number %d", regno);
134 perror_with_name (buf);
135 }
136 }
137 else
138 {
abefb1f1 139 for (regno = 0; regno < NUM_REGS; regno++)
dd3b648e 140 {
abefb1f1
PB
141 if (regno == ZERO_REGNUM || regno == PS_REGNUM
142 || regno == BADVADDR_REGNUM || regno == CAUSE_REGNUM
143 || regno == FCRIR_REGNUM || regno == FP_REGNUM)
dd3b648e
RP
144 continue;
145 regaddr = register_addr (regno, 1);
146 errno = 0;
147 ptrace (6, inferior_pid, regaddr, read_register (regno));
148 if (errno != 0)
149 {
150 sprintf (buf, "writing all regs, number %d", regno);
151 perror_with_name (buf);
152 }
153 }
154 }
155}
156
625453dc
SG
157#endif /* sgi */
158
31ef19fc 159#if 0
dd3b648e
RP
160void
161fetch_core_registers ()
162{
163 register int regno;
164 int val;
165
166 for (regno = 1; regno < NUM_REGS; regno++) {
167 char buf[MAX_REGISTER_RAW_SIZE];
168
169 val = bfd_seek (core_bfd, register_addr (regno, 0));
170 if (val < 0 || (val = bfd_read (core_bfd, buf, sizeof buf)) < 0) {
171 char buffer[50];
172 strcpy (buffer, "Reading register ");
173 strcat (buffer, reg_names[regno]);
174
175 perror_with_name (buffer);
176 }
177 supply_register (regno, buf);
178 }
179}
31ef19fc 180#endif /* 0 */
This page took 0.051474 seconds and 4 git commands to generate.