Vax Ultrix changes from David Taylor <taylor@think.com>.
[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
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
dd3b648e
RP
76/* Get all registers from the inferior */
77
78void
79fetch_inferior_registers ()
80{
81 register int regno;
82 register unsigned int regaddr;
83 char buf[MAX_REGISTER_RAW_SIZE];
84 register int i;
85
86 registers_fetched ();
87
88 for (regno = 1; regno < NUM_REGS; regno++)
89 {
90 regaddr = register_addr (regno, 1);
91 for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
92 {
93 *(int *) &buf[i] = ptrace (3, inferior_pid, regaddr, 0);
94 regaddr += sizeof (int);
95 }
96 supply_register (regno, buf);
97 }
98}
99
100/* Store our register values back into the inferior.
101 If REGNO is -1, do this for all registers.
102 Otherwise, REGNO specifies which register (so we can save time). */
103
625453dc 104void
dd3b648e
RP
105store_inferior_registers (regno)
106 int regno;
625453dc 107 {
dd3b648e
RP
108 register unsigned int regaddr;
109 char buf[80];
110
111 if (regno == 0)
112 return;
113
114 if (regno > 0)
115 {
116 regaddr = register_addr (regno, 1);
117 errno = 0;
118 ptrace (6, inferior_pid, regaddr, read_register (regno));
119 if (errno != 0)
120 {
121 sprintf (buf, "writing register number %d", regno);
122 perror_with_name (buf);
123 }
124 }
125 else
126 {
127 for (regno = 1; regno < NUM_REGS; regno++)
128 {
129 if (regno == 32 || regno == 35 || regno == 36 || regno == 71)
130 continue;
131 regaddr = register_addr (regno, 1);
132 errno = 0;
133 ptrace (6, inferior_pid, regaddr, read_register (regno));
134 if (errno != 0)
135 {
136 sprintf (buf, "writing all regs, number %d", regno);
137 perror_with_name (buf);
138 }
139 }
140 }
141}
142
625453dc
SG
143#endif /* sgi */
144
31ef19fc 145#if 0
dd3b648e
RP
146void
147fetch_core_registers ()
148{
149 register int regno;
150 int val;
151
152 for (regno = 1; regno < NUM_REGS; regno++) {
153 char buf[MAX_REGISTER_RAW_SIZE];
154
155 val = bfd_seek (core_bfd, register_addr (regno, 0));
156 if (val < 0 || (val = bfd_read (core_bfd, buf, sizeof buf)) < 0) {
157 char buffer[50];
158 strcpy (buffer, "Reading register ");
159 strcat (buffer, reg_names[regno]);
160
161 perror_with_name (buffer);
162 }
163 supply_register (regno, buf);
164 }
165}
31ef19fc 166#endif /* 0 */
This page took 0.040499 seconds and 4 git commands to generate.