1 // OBSOLETE /* Intel 386 native support.
2 // OBSOLETE Copyright 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999,
3 // OBSOLETE 2000, 2001 Free Software Foundation, Inc.
5 // OBSOLETE This file is part of GDB.
7 // OBSOLETE This program is free software; you can redistribute it and/or modify
8 // OBSOLETE it under the terms of the GNU General Public License as published by
9 // OBSOLETE the Free Software Foundation; either version 2 of the License, or
10 // OBSOLETE (at your option) any later version.
12 // OBSOLETE This program is distributed in the hope that it will be useful,
13 // OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // OBSOLETE GNU General Public License for more details.
17 // OBSOLETE You should have received a copy of the GNU General Public License
18 // OBSOLETE along with this program; if not, write to the Free Software
19 // OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330,
20 // OBSOLETE Boston, MA 02111-1307, USA. */
22 // OBSOLETE #include "defs.h"
23 // OBSOLETE #include "frame.h"
24 // OBSOLETE #include "inferior.h"
25 // OBSOLETE #include "language.h"
26 // OBSOLETE #include "gdbcore.h"
27 // OBSOLETE #include "regcache.h"
29 // OBSOLETE #ifdef USG
30 // OBSOLETE #include <sys/types.h>
33 // OBSOLETE #include <sys/param.h>
34 // OBSOLETE #include <sys/dir.h>
35 // OBSOLETE #include <signal.h>
36 // OBSOLETE #include <sys/user.h>
37 // OBSOLETE #include <sys/ioctl.h>
38 // OBSOLETE #include <fcntl.h>
40 // OBSOLETE #include <sys/file.h>
41 // OBSOLETE #include "gdb_stat.h"
43 // OBSOLETE #include <stddef.h>
44 // OBSOLETE #include <sys/ptrace.h>
46 // OBSOLETE /* Does AIX define this in <errno.h>? */
47 // OBSOLETE extern int errno;
49 // OBSOLETE #ifdef HAVE_SYS_REG_H
50 // OBSOLETE #include <sys/reg.h>
53 // OBSOLETE #include "floatformat.h"
55 // OBSOLETE #include "target.h"
57 // OBSOLETE static void fetch_core_registers (char *, unsigned, int, CORE_ADDR);
60 // OBSOLETE /* this table must line up with REGISTER_NAMES in tm-i386v.h */
61 // OBSOLETE /* symbols like 'EAX' come from <sys/reg.h> */
62 // OBSOLETE static int regmap[] =
64 // OBSOLETE EAX, ECX, EDX, EBX,
65 // OBSOLETE USP, EBP, ESI, EDI,
66 // OBSOLETE EIP, EFL, CS, SS,
67 // OBSOLETE DS, ES, FS, GS,
70 // OBSOLETE /* blockend is the value of u.u_ar0, and points to the
71 // OBSOLETE * place where GS is stored
75 // OBSOLETE i386_register_u_addr (int blockend, int regnum)
78 // OBSOLETE /* this will be needed if fp registers are reinstated */
79 // OBSOLETE /* for now, you can look at them with 'info float'
80 // OBSOLETE * sys5 wont let you change them with ptrace anyway
82 // OBSOLETE if (regnum >= FP0_REGNUM && regnum <= FP7_REGNUM)
84 // OBSOLETE int ubase, fpstate;
85 // OBSOLETE struct user u;
86 // OBSOLETE ubase = blockend + 4 * (SS + 1) - KSTKSZ;
87 // OBSOLETE fpstate = ubase + ((char *) &u.u_fpstate - (char *) &u);
88 // OBSOLETE return (fpstate + 0x1c + 10 * (regnum - FP0_REGNUM));
92 // OBSOLETE return (blockend + 4 * regmap[regnum]);
96 // OBSOLETE /* The code below only work on the aix ps/2 (i386-ibm-aix) -
97 // OBSOLETE * mtranle@paris - Sat Apr 11 10:34:12 1992
100 // OBSOLETE struct env387
102 // OBSOLETE unsigned short control;
103 // OBSOLETE unsigned short r0;
104 // OBSOLETE unsigned short status;
105 // OBSOLETE unsigned short r1;
106 // OBSOLETE unsigned short tag;
107 // OBSOLETE unsigned short r2;
108 // OBSOLETE unsigned long eip;
109 // OBSOLETE unsigned short code_seg;
110 // OBSOLETE unsigned short opcode;
111 // OBSOLETE unsigned long operand;
112 // OBSOLETE unsigned short operand_seg;
113 // OBSOLETE unsigned short r3;
114 // OBSOLETE unsigned char regs[8][10];
118 // OBSOLETE print_387_status (unsigned short status, struct env387 *ep)
121 // OBSOLETE int bothstatus;
123 // OBSOLETE int fpreg;
124 // OBSOLETE unsigned char *p;
126 // OBSOLETE bothstatus = ((status != 0) && (ep->status != 0));
127 // OBSOLETE if (status != 0)
129 // OBSOLETE if (bothstatus)
130 // OBSOLETE printf_unfiltered ("u: ");
131 // OBSOLETE print_387_status_word (status);
134 // OBSOLETE if (ep->status != 0)
136 // OBSOLETE if (bothstatus)
137 // OBSOLETE printf_unfiltered ("e: ");
138 // OBSOLETE print_387_status_word (ep->status);
141 // OBSOLETE print_387_control_word (ep->control);
142 // OBSOLETE printf_unfiltered ("last exception: ");
143 // OBSOLETE printf_unfiltered ("opcode %s; ", local_hex_string (ep->opcode));
144 // OBSOLETE printf_unfiltered ("pc %s:", local_hex_string (ep->code_seg));
145 // OBSOLETE printf_unfiltered ("%s; ", local_hex_string (ep->eip));
146 // OBSOLETE printf_unfiltered ("operand %s", local_hex_string (ep->operand_seg));
147 // OBSOLETE printf_unfiltered (":%s\n", local_hex_string (ep->operand));
149 // OBSOLETE top = ((ep->status >> 11) & 7);
151 // OBSOLETE printf_unfiltered ("regno tag msb lsb value\n");
152 // OBSOLETE for (fpreg = 7; fpreg >= 0; fpreg--)
154 // OBSOLETE double val;
156 // OBSOLETE printf_unfiltered ("%s %d: ", fpreg == top ? "=>" : " ", fpreg);
158 // OBSOLETE switch ((ep->tag >> ((7 - fpreg) * 2)) & 3)
161 // OBSOLETE printf_unfiltered ("valid ");
164 // OBSOLETE printf_unfiltered ("zero ");
167 // OBSOLETE printf_unfiltered ("trap ");
170 // OBSOLETE printf_unfiltered ("empty ");
173 // OBSOLETE for (i = 9; i >= 0; i--)
174 // OBSOLETE printf_unfiltered ("%02x", ep->regs[fpreg][i]);
176 // OBSOLETE i387_to_double ((char *) ep->regs[fpreg], (char *) &val);
177 // OBSOLETE printf_unfiltered (" %#g\n", val);
181 // OBSOLETE static struct env387 core_env387;
184 // OBSOLETE i386_float_info (void)
186 // OBSOLETE struct env387 fps;
187 // OBSOLETE int fpsaved = 0;
188 // OBSOLETE /* We need to reverse the order of the registers. Apparently AIX stores
189 // OBSOLETE the highest-numbered ones first. */
190 // OBSOLETE struct env387 fps_fixed;
193 // OBSOLETE if (! ptid_equal (inferior_ptid, null_ptid))
195 // OBSOLETE char buf[10];
196 // OBSOLETE unsigned short status;
198 // OBSOLETE ptrace (PT_READ_FPR, PIDGET (inferior_ptid), buf,
199 // OBSOLETE offsetof (struct env387, status));
200 // OBSOLETE memcpy (&status, buf, sizeof (status));
201 // OBSOLETE fpsaved = status;
205 // OBSOLETE if ((fpsaved = core_env387.status) != 0)
206 // OBSOLETE memcpy (&fps, &core_env387, sizeof (fps));
209 // OBSOLETE if (fpsaved == 0)
211 // OBSOLETE printf_unfiltered ("no floating point status saved\n");
215 // OBSOLETE if (! ptid_equal (inferior_ptid, null_ptid))
217 // OBSOLETE int offset;
218 // OBSOLETE for (offset = 0; offset < sizeof (fps); offset += 10)
220 // OBSOLETE char buf[10];
221 // OBSOLETE ptrace (PT_READ_FPR, PIDGET (inferior_ptid), buf, offset);
222 // OBSOLETE memcpy ((char *) &fps.control + offset, buf,
223 // OBSOLETE MIN (10, sizeof (fps) - offset));
226 // OBSOLETE fps_fixed = fps;
227 // OBSOLETE for (i = 0; i < 8; ++i)
228 // OBSOLETE memcpy (fps_fixed.regs[i], fps.regs[7 - i], 10);
229 // OBSOLETE print_387_status (0, &fps_fixed);
232 // OBSOLETE /* Fetch one register. */
233 // OBSOLETE static void
234 // OBSOLETE fetch_register (int regno)
236 // OBSOLETE char buf[MAX_REGISTER_RAW_SIZE];
237 // OBSOLETE if (regno < FP0_REGNUM)
238 // OBSOLETE *(int *) buf = ptrace (PT_READ_GPR, PIDGET (inferior_ptid),
239 // OBSOLETE PT_REG (regmap[regno]), 0, 0);
241 // OBSOLETE ptrace (PT_READ_FPR, PIDGET (inferior_ptid), buf,
242 // OBSOLETE (regno - FP0_REGNUM) * 10 + offsetof (struct env387, regs));
243 // OBSOLETE supply_register (regno, buf);
247 // OBSOLETE fetch_inferior_registers (int regno)
249 // OBSOLETE if (regno < 0)
250 // OBSOLETE for (regno = 0; regno < NUM_REGS; regno++)
251 // OBSOLETE fetch_register (regno);
253 // OBSOLETE fetch_register (regno);
256 // OBSOLETE /* store one register */
257 // OBSOLETE static void
258 // OBSOLETE store_register (int regno)
260 // OBSOLETE char buf[80];
261 // OBSOLETE errno = 0;
262 // OBSOLETE if (regno < FP0_REGNUM)
263 // OBSOLETE ptrace (PT_WRITE_GPR, PIDGET (inferior_ptid), PT_REG (regmap[regno]),
264 // OBSOLETE *(int *) ®isters[REGISTER_BYTE (regno)], 0);
266 // OBSOLETE ptrace (PT_WRITE_FPR, PIDGET (inferior_ptid),
267 // OBSOLETE ®isters[REGISTER_BYTE (regno)],
268 // OBSOLETE (regno - FP0_REGNUM) * 10 + offsetof (struct env387, regs));
270 // OBSOLETE if (errno != 0)
272 // OBSOLETE sprintf (buf, "writing register number %d", regno);
273 // OBSOLETE perror_with_name (buf);
277 // OBSOLETE /* Store our register values back into the inferior.
278 // OBSOLETE If REGNO is -1, do this for all registers.
279 // OBSOLETE Otherwise, REGNO specifies which register (so we can save time). */
281 // OBSOLETE store_inferior_registers (int regno)
283 // OBSOLETE if (regno < 0)
284 // OBSOLETE for (regno = 0; regno < NUM_REGS; regno++)
285 // OBSOLETE store_register (regno);
287 // OBSOLETE store_register (regno);
290 // OBSOLETE #ifndef CD_AX /* defined in sys/i386/coredump.h */
291 // OBSOLETE #define CD_AX 0
292 // OBSOLETE #define CD_BX 1
293 // OBSOLETE #define CD_CX 2
294 // OBSOLETE #define CD_DX 3
295 // OBSOLETE #define CD_SI 4
296 // OBSOLETE #define CD_DI 5
297 // OBSOLETE #define CD_BP 6
298 // OBSOLETE #define CD_SP 7
299 // OBSOLETE #define CD_FL 8
300 // OBSOLETE #define CD_IP 9
301 // OBSOLETE #define CD_CS 10
302 // OBSOLETE #define CD_DS 11
303 // OBSOLETE #define CD_ES 12
304 // OBSOLETE #define CD_FS 13
305 // OBSOLETE #define CD_GS 14
306 // OBSOLETE #define CD_SS 15
310 // OBSOLETE * The order here in core_regmap[] has to be the same as in
311 // OBSOLETE * regmap[] above.
313 // OBSOLETE static int core_regmap[] =
315 // OBSOLETE CD_AX, CD_CX, CD_DX, CD_BX,
316 // OBSOLETE CD_SP, CD_BP, CD_SI, CD_DI,
317 // OBSOLETE CD_IP, CD_FL, CD_CS, CD_SS,
318 // OBSOLETE CD_DS, CD_ES, CD_FS, CD_GS,
321 // OBSOLETE /* Provide registers to GDB from a core file.
323 // OBSOLETE CORE_REG_SECT points to an array of bytes, which were obtained from
324 // OBSOLETE a core file which BFD thinks might contain register contents.
325 // OBSOLETE CORE_REG_SIZE is its size.
327 // OBSOLETE WHICH says which register set corelow suspects this is:
328 // OBSOLETE 0 --- the general-purpose register set
329 // OBSOLETE 2 --- the floating-point register set
331 // OBSOLETE REG_ADDR isn't used. */
333 // OBSOLETE static void
334 // OBSOLETE fetch_core_registers (char *core_reg_sect, unsigned core_reg_size,
335 // OBSOLETE int which, CORE_ADDR reg_addr)
338 // OBSOLETE if (which == 0)
340 // OBSOLETE /* Integer registers */
342 // OBSOLETE #define cd_regs(n) ((int *)core_reg_sect)[n]
343 // OBSOLETE #define regs(n) *((int *) ®isters[REGISTER_BYTE (n)])
346 // OBSOLETE for (i = 0; i < FP0_REGNUM; i++)
347 // OBSOLETE regs (i) = cd_regs (core_regmap[i]);
349 // OBSOLETE else if (which == 2)
351 // OBSOLETE /* Floating point registers */
353 // OBSOLETE if (core_reg_size >= sizeof (core_env387))
354 // OBSOLETE memcpy (&core_env387, core_reg_sect, core_reg_size);
356 // OBSOLETE fprintf_unfiltered (gdb_stderr, "Couldn't read float regs from core file\n");
361 // OBSOLETE /* Register that we are able to handle i386aix core file formats.
362 // OBSOLETE FIXME: is this really bfd_target_unknown_flavour? */
364 // OBSOLETE static struct core_fns i386aix_core_fns =
366 // OBSOLETE bfd_target_unknown_flavour, /* core_flavour */
367 // OBSOLETE default_check_format, /* check_format */
368 // OBSOLETE default_core_sniffer, /* core_sniffer */
369 // OBSOLETE fetch_core_registers, /* core_read_registers */
370 // OBSOLETE NULL /* next */
374 // OBSOLETE _initialize_core_i386aix (void)
376 // OBSOLETE add_core_fns (&i386aix_core_fns);
This page took 0.036952 seconds and 4 git commands to generate.