]>
Commit | Line | Data |
---|---|---|
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([email protected]) at CMU |
4 | and by Per Bothner([email protected]) at U.Wisconsin. | |
5 | ||
6 | This file is part of GDB. | |
7 | ||
99a7de40 | 8 | This program is free software; you can redistribute it and/or modify |
dd3b648e | 9 | it under the terms of the GNU General Public License as published by |
99a7de40 JG |
10 | the Free Software Foundation; either version 2 of the License, or |
11 | (at your option) any later version. | |
dd3b648e | 12 | |
99a7de40 | 13 | This program is distributed in the hope that it will be useful, |
dd3b648e RP |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
99a7de40 JG |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, 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 | ||
625453dc SG |
26 | /* For now we stub this out; sgi format is super-hairy (and completely |
27 | different in the new release) */ | |
28 | ||
43a16f26 | 29 | #if defined(sgi) || !defined(GDB_TARGET_IS_MIPS) |
625453dc | 30 | void |
43a16f26 JG |
31 | fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr) |
32 | char *core_reg_sect; | |
33 | unsigned core_reg_size; | |
34 | int which; | |
35 | unsigned int reg_addr; | |
625453dc SG |
36 | { |
37 | return; | |
38 | } | |
39 | ||
1ab3bf1b | 40 | /* ARGSUSED */ |
625453dc | 41 | void |
1ab3bf1b JG |
42 | fetch_inferior_registers (regno) |
43 | int regno; | |
625453dc SG |
44 | { |
45 | return; | |
46 | } | |
47 | ||
1ab3bf1b JG |
48 | /* ARGSUSED */ |
49 | void | |
625453dc SG |
50 | store_inferior_registers (regno) |
51 | int regno; | |
52 | { | |
53 | return; | |
54 | } | |
55 | ||
56 | ||
57 | #else | |
58 | ||
abefb1f1 PB |
59 | /* Map gdb internal register number to ptrace address. */ |
60 | ||
61 | #define REGISTER_PTRACE_ADDR(regno) \ | |
62 | (regno < 32 ? regno \ | |
63 | : regno == PC_REGNUM ? 96 \ | |
64 | : regno == CAUSE_REGNUM ? 97 \ | |
65 | : regno == HI_REGNUM ? 98 \ | |
66 | : regno == LO_REGNUM ? 99 \ | |
67 | : regno == FCRCS_REGNUM ? 100 \ | |
68 | : regno == FCRIR_REGNUM ? 101 \ | |
69 | : regno >= FP0_REGNUM ? regno - (FP0_REGNUM-32)\ | |
70 | : 0) | |
71 | ||
dd3b648e RP |
72 | /* Get all registers from the inferior */ |
73 | ||
74 | void | |
1ab3bf1b JG |
75 | fetch_inferior_registers (regno) |
76 | int regno; | |
dd3b648e | 77 | { |
dd3b648e RP |
78 | register unsigned int regaddr; |
79 | char buf[MAX_REGISTER_RAW_SIZE]; | |
80 | register int i; | |
81 | ||
82 | registers_fetched (); | |
83 | ||
84 | for (regno = 1; regno < NUM_REGS; regno++) | |
85 | { | |
abefb1f1 | 86 | regaddr = REGISTER_PTRACE_ADDR (regno); |
dd3b648e RP |
87 | for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int)) |
88 | { | |
e676a15f FF |
89 | *(int *) &buf[i] = ptrace (3, inferior_pid, |
90 | (PTRACE_ARG3_TYPE) regaddr, 0); | |
dd3b648e RP |
91 | regaddr += sizeof (int); |
92 | } | |
93 | supply_register (regno, buf); | |
94 | } | |
95 | } | |
96 | ||
97 | /* Store our register values back into the inferior. | |
98 | If REGNO is -1, do this for all registers. | |
99 | Otherwise, REGNO specifies which register (so we can save time). */ | |
100 | ||
625453dc | 101 | void |
dd3b648e RP |
102 | store_inferior_registers (regno) |
103 | int regno; | |
625453dc | 104 | { |
dd3b648e RP |
105 | register unsigned int regaddr; |
106 | char buf[80]; | |
107 | ||
108 | if (regno == 0) | |
109 | return; | |
110 | ||
111 | if (regno > 0) | |
112 | { | |
abefb1f1 | 113 | regaddr = REGISTER_PTRACE_ADDR (regno); |
dd3b648e | 114 | errno = 0; |
e676a15f FF |
115 | ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, |
116 | read_register (regno)); | |
dd3b648e RP |
117 | if (errno != 0) |
118 | { | |
119 | sprintf (buf, "writing register number %d", regno); | |
120 | perror_with_name (buf); | |
121 | } | |
122 | } | |
123 | else | |
124 | { | |
abefb1f1 | 125 | for (regno = 0; regno < NUM_REGS; regno++) |
dd3b648e | 126 | { |
abefb1f1 PB |
127 | if (regno == ZERO_REGNUM || regno == PS_REGNUM |
128 | || regno == BADVADDR_REGNUM || regno == CAUSE_REGNUM | |
b543979c JG |
129 | || regno == FCRIR_REGNUM || regno == FP_REGNUM |
130 | || (regno >= FIRST_EMBED_REGNUM && regno <= LAST_EMBED_REGNUM)) | |
dd3b648e RP |
131 | continue; |
132 | regaddr = register_addr (regno, 1); | |
133 | errno = 0; | |
e676a15f FF |
134 | ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, |
135 | read_register (regno)); | |
dd3b648e RP |
136 | if (errno != 0) |
137 | { | |
138 | sprintf (buf, "writing all regs, number %d", regno); | |
139 | perror_with_name (buf); | |
140 | } | |
141 | } | |
142 | } | |
143 | } | |
144 | ||
625453dc SG |
145 | #endif /* sgi */ |
146 | ||
31ef19fc | 147 | #if 0 |
dd3b648e RP |
148 | void |
149 | fetch_core_registers () | |
150 | { | |
151 | register int regno; | |
152 | int val; | |
153 | ||
154 | for (regno = 1; regno < NUM_REGS; regno++) { | |
155 | char buf[MAX_REGISTER_RAW_SIZE]; | |
156 | ||
157 | val = bfd_seek (core_bfd, register_addr (regno, 0)); | |
158 | if (val < 0 || (val = bfd_read (core_bfd, buf, sizeof buf)) < 0) { | |
159 | char buffer[50]; | |
160 | strcpy (buffer, "Reading register "); | |
161 | strcat (buffer, reg_names[regno]); | |
162 | ||
163 | perror_with_name (buffer); | |
164 | } | |
165 | supply_register (regno, buf); | |
166 | } | |
167 | } | |
31ef19fc | 168 | #endif /* 0 */ |