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