Merge in irix support.
[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>
23#include <mips/inst.h>
24#include "defs.h"
25#include "param.h"
26#include "frame.h"
27#include "inferior.h"
28#include "symtab.h"
29#include "value.h"
30
31#ifdef USG
32#include <sys/types.h>
33#endif
34
35#include <sys/param.h>
36#include <sys/dir.h>
37#include <signal.h>
38#include <sys/ioctl.h>
39/* #include <fcntl.h> Can we live without this? */
40
41#include "gdbcore.h"
42
43#include <sys/user.h> /* After a.out.h */
44#include <sys/file.h>
45#include <sys/stat.h>
46
47/* Get all registers from the inferior */
48
49void
50fetch_inferior_registers ()
51{
52 register int regno;
53 register unsigned int regaddr;
54 char buf[MAX_REGISTER_RAW_SIZE];
55 register int i;
56
57 registers_fetched ();
58
59 for (regno = 1; regno < NUM_REGS; regno++)
60 {
61 regaddr = register_addr (regno, 1);
62 for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
63 {
64 *(int *) &buf[i] = ptrace (3, inferior_pid, regaddr, 0);
65 regaddr += sizeof (int);
66 }
67 supply_register (regno, buf);
68 }
69}
70
71/* Store our register values back into the inferior.
72 If REGNO is -1, do this for all registers.
73 Otherwise, REGNO specifies which register (so we can save time). */
74
75store_inferior_registers (regno)
76 int regno;
77{
78 register unsigned int regaddr;
79 char buf[80];
80
81 if (regno == 0)
82 return;
83
84 if (regno > 0)
85 {
86 regaddr = register_addr (regno, 1);
87 errno = 0;
88 ptrace (6, inferior_pid, regaddr, read_register (regno));
89 if (errno != 0)
90 {
91 sprintf (buf, "writing register number %d", regno);
92 perror_with_name (buf);
93 }
94 }
95 else
96 {
97 for (regno = 1; regno < NUM_REGS; regno++)
98 {
99 if (regno == 32 || regno == 35 || regno == 36 || regno == 71)
100 continue;
101 regaddr = register_addr (regno, 1);
102 errno = 0;
103 ptrace (6, inferior_pid, regaddr, read_register (regno));
104 if (errno != 0)
105 {
106 sprintf (buf, "writing all regs, number %d", regno);
107 perror_with_name (buf);
108 }
109 }
110 }
111}
112
31ef19fc 113#if 0
dd3b648e
RP
114void
115fetch_core_registers ()
116{
117 register int regno;
118 int val;
119
120 for (regno = 1; regno < NUM_REGS; regno++) {
121 char buf[MAX_REGISTER_RAW_SIZE];
122
123 val = bfd_seek (core_bfd, register_addr (regno, 0));
124 if (val < 0 || (val = bfd_read (core_bfd, buf, sizeof buf)) < 0) {
125 char buffer[50];
126 strcpy (buffer, "Reading register ");
127 strcat (buffer, reg_names[regno]);
128
129 perror_with_name (buffer);
130 }
131 supply_register (regno, buf);
132 }
133}
31ef19fc 134#endif /* 0 */
This page took 0.042437 seconds and 4 git commands to generate.