b2e61b4eca0d4abcb79fb77b804714308488f974
1 /* Host-dependent code for GDB, for NYU Ultra3 running Sym1 OS.
2 Copyright (C) 1988, 1989, 1991, 1992 Free Software Foundation, Inc.
3 Contributed by David Wood (wood@nyu.edu) at New York University.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
28 #include <sys/types.h>
29 #include <sys/param.h>
31 #include <sys/ioctl.h>
39 /* Get all available registers from the inferior. Registers that are
40 * defined in REGISTER_NAMES, but not available to the user/gdb are
41 * supplied as -1. This may include gr64-gr95 and the protected special
46 fetch_inferior_registers (regno
)
49 register int i
,j
,ret_val
=0;
53 fetch_register (regno
);
57 /* Global Registers */
60 ptrace (PT_READ_STRUCT
, inferior_pid
,
61 (PTRACE_ARG3_TYPE
) register_addr(GR96_REGNUM
,0),
62 (int)&pt_struct
.pt_gr
[0], 32*4);
64 perror_with_name ("reading global registers");
66 } else for (regno
=GR96_REGNUM
, j
=0 ; j
<32 ; regno
++, j
++) {
67 supply_register (regno
, &pt_struct
.pt_gr
[j
]);
70 for (regno
=GR96_REGNUM
; !ret_val
&& regno
< GR96_REGNUM
+32 ; regno
++)
71 fetch_register(regno
);
77 ptrace (PT_READ_STRUCT
, inferior_pid
,
78 (PTRACE_ARG3_TYPE
) register_addr(LR0_REGNUM
,0),
79 (int)&pt_struct
.pt_lr
[0], 128*4);
81 perror_with_name ("reading local registers");
83 } else for (regno
=LR0_REGNUM
, j
=0 ; j
<128 ; regno
++, j
++) {
84 supply_register (regno
, &pt_struct
.pt_lr
[j
]);
87 for (regno
=LR0_REGNUM
; !ret_val
&& regno
< LR0_REGNUM
+128 ; regno
++)
88 fetch_register(regno
);
91 /* Special Registers */
92 fetch_register(GR1_REGNUM
);
93 fetch_register(CPS_REGNUM
);
94 fetch_register(PC_REGNUM
);
95 fetch_register(NPC_REGNUM
);
96 fetch_register(PC2_REGNUM
);
97 fetch_register(IPC_REGNUM
);
98 fetch_register(IPA_REGNUM
);
99 fetch_register(IPB_REGNUM
);
100 fetch_register(Q_REGNUM
);
101 fetch_register(BP_REGNUM
);
102 fetch_register(FC_REGNUM
);
104 /* Fake any registers that are in REGISTER_NAMES, but not available to gdb */
108 /* Store our register values back into the inferior.
109 * If REGNO is -1, do this for all registers.
110 * Otherwise, REGNO specifies which register (so we can save time).
111 * NOTE: Assumes AMD's binary compatibility standard.
115 store_inferior_registers (regno
)
118 register unsigned int regaddr
;
123 if (CANNOT_STORE_REGISTER(regno
))
125 regaddr
= register_addr (regno
, 0);
127 ptrace (PT_WRITE_U
, inferior_pid
,
128 (PTRACE_ARG3_TYPE
) regaddr
, read_register(regno
));
131 sprintf (buf
, "writing register %s (#%d)", reg_names
[regno
],regno
);
132 perror_with_name (buf
);
138 pt_struct
.pt_gr1
= read_register(GR1_REGNUM
);
139 for (regno
= GR96_REGNUM
; regno
< GR96_REGNUM
+32; regno
++)
140 pt_struct
.pt_gr
[regno
] = read_register(regno
);
141 for (regno
= LR0_REGNUM
; regno
< LR0_REGNUM
+128; regno
++)
142 pt_struct
.pt_gr
[regno
] = read_register(regno
);
144 ptrace (PT_WRITE_STRUCT
, inferior_pid
,
145 (PTRACE_ARG3_TYPE
) register_addr(GR1_REGNUM
,0),
146 (int)&pt_struct
.pt_gr1
,(1*32*128)*4);
149 sprintf (buf
, "writing all local/global registers");
150 perror_with_name (buf
);
152 pt_struct
.pt_psr
= read_register(CPS_REGNUM
);
153 pt_struct
.pt_pc0
= read_register(NPC_REGNUM
);
154 pt_struct
.pt_pc1
= read_register(PC_REGNUM
);
155 pt_struct
.pt_pc2
= read_register(PC2_REGNUM
);
156 pt_struct
.pt_ipc
= read_register(IPC_REGNUM
);
157 pt_struct
.pt_ipa
= read_register(IPA_REGNUM
);
158 pt_struct
.pt_ipb
= read_register(IPB_REGNUM
);
159 pt_struct
.pt_q
= read_register(Q_REGNUM
);
160 pt_struct
.pt_bp
= read_register(BP_REGNUM
);
161 pt_struct
.pt_fc
= read_register(FC_REGNUM
);
163 ptrace (PT_WRITE_STRUCT
, inferior_pid
,
164 (PTRACE_ARG3_TYPE
) register_addr(CPS_REGNUM
,0),
165 (int)&pt_struct
.pt_psr
,(10)*4);
168 sprintf (buf
, "writing all special registers");
169 perror_with_name (buf
);
173 store_inferior_registers(GR1_REGNUM
);
174 for (regno
=GR96_REGNUM
; regno
<GR96_REGNUM
+32 ; regno
++)
175 store_inferior_registers(regno
);
176 for (regno
=LR0_REGNUM
; regno
<LR0_REGNUM
+128 ; regno
++)
177 store_inferior_registers(regno
);
178 store_inferior_registers(CPS_REGNUM
);
179 store_inferior_registers(PC_REGNUM
);
180 store_inferior_registers(NPC_REGNUM
);
181 store_inferior_registers(PC2_REGNUM
);
182 store_inferior_registers(IPC_REGNUM
);
183 store_inferior_registers(IPA_REGNUM
);
184 store_inferior_registers(IPB_REGNUM
);
185 store_inferior_registers(Q_REGNUM
);
186 store_inferior_registers(BP_REGNUM
);
187 store_inferior_registers(FC_REGNUM
);
193 * Fetch an individual register (and supply it).
194 * return 0 on success, -1 on failure.
195 * NOTE: Assumes AMD's Binary Compatibility Standard for ptrace().
198 fetch_register (regno
)
204 if (CANNOT_FETCH_REGISTER(regno
)) {
206 supply_register (regno
, &val
);
209 val
= ptrace (PT_READ_U
, inferior_pid
,
210 (PTRACE_ARG3_TYPE
) register_addr(regno
,0), 0);
212 sprintf(buf
,"reading register %s (#%d)",reg_names
[regno
],regno
);
213 perror_with_name (buf
);
215 supply_register (regno
, &val
);
222 * Read AMD's Binary Compatibilty Standard conforming core file.
223 * struct ptrace_user is the first thing in the core file
227 fetch_core_registers ()
233 for (regno
= 0 ; regno
< NUM_REGS
; regno
++) {
234 if (!CANNOT_FETCH_REGISTER(regno
)) {
235 val
= bfd_seek (core_bfd
, register_addr (regno
, 0), 0);
236 if (val
< 0 || (val
= bfd_read (buf
, sizeof buf
, 1, core_bfd
)) < 0) {
237 char * buffer
= (char *) alloca (strlen (reg_names
[regno
]) + 35);
238 strcpy (buffer
, "Reading core register ");
239 strcat (buffer
, reg_names
[regno
]);
240 perror_with_name (buffer
);
242 supply_register (regno
, buf
);
246 /* Fake any registers that are in REGISTER_NAMES, but not available to gdb */
This page took 0.034717 seconds and 4 git commands to generate.