2002-12-06 Andrew Cagney <ac131313@redhat.com>
[deliverable/binutils-gdb.git] / gdb / i386aix-nat.c
CommitLineData
1c7cc583
MK
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.
4// OBSOLETE
5// OBSOLETE This file is part of GDB.
6// OBSOLETE
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.
11// OBSOLETE
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.
16// OBSOLETE
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. */
21// OBSOLETE
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"
28// OBSOLETE
29// OBSOLETE #ifdef USG
30// OBSOLETE #include <sys/types.h>
31// OBSOLETE #endif
32// OBSOLETE
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>
39// OBSOLETE
40// OBSOLETE #include <sys/file.h>
41// OBSOLETE #include "gdb_stat.h"
42// OBSOLETE
43// OBSOLETE #include <stddef.h>
44// OBSOLETE #include <sys/ptrace.h>
45// OBSOLETE
46// OBSOLETE /* Does AIX define this in <errno.h>? */
47// OBSOLETE extern int errno;
48// OBSOLETE
49// OBSOLETE #ifdef HAVE_SYS_REG_H
50// OBSOLETE #include <sys/reg.h>
51// OBSOLETE #endif
52// OBSOLETE
53// OBSOLETE #include "floatformat.h"
54// OBSOLETE
55// OBSOLETE #include "target.h"
56// OBSOLETE
57// OBSOLETE static void fetch_core_registers (char *, unsigned, int, CORE_ADDR);
58// OBSOLETE \f
59// OBSOLETE
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[] =
63// OBSOLETE {
64// OBSOLETE EAX, ECX, EDX, EBX,
65// OBSOLETE USP, EBP, ESI, EDI,
66// OBSOLETE EIP, EFL, CS, SS,
67// OBSOLETE DS, ES, FS, GS,
68// OBSOLETE };
69// OBSOLETE
70// OBSOLETE /* blockend is the value of u.u_ar0, and points to the
71// OBSOLETE * place where GS is stored
72// OBSOLETE */
73// OBSOLETE
74// OBSOLETE int
75// OBSOLETE i386_register_u_addr (int blockend, int regnum)
76// OBSOLETE {
77// OBSOLETE #if 0
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
81// OBSOLETE */
82// OBSOLETE if (regnum >= FP0_REGNUM && regnum <= FP7_REGNUM)
83// OBSOLETE {
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));
89// OBSOLETE }
90// OBSOLETE else
91// OBSOLETE #endif
92// OBSOLETE return (blockend + 4 * regmap[regnum]);
93// OBSOLETE
94// OBSOLETE }
95// OBSOLETE
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
98// OBSOLETE */
99// OBSOLETE
100// OBSOLETE struct env387
101// OBSOLETE {
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];
115// OBSOLETE };
116// OBSOLETE
117// OBSOLETE static
118// OBSOLETE print_387_status (unsigned short status, struct env387 *ep)
119// OBSOLETE {
120// OBSOLETE int i;
121// OBSOLETE int bothstatus;
122// OBSOLETE int top;
123// OBSOLETE int fpreg;
124// OBSOLETE unsigned char *p;
125// OBSOLETE
126// OBSOLETE bothstatus = ((status != 0) && (ep->status != 0));
127// OBSOLETE if (status != 0)
128// OBSOLETE {
129// OBSOLETE if (bothstatus)
130// OBSOLETE printf_unfiltered ("u: ");
131// OBSOLETE print_387_status_word (status);
132// OBSOLETE }
133// OBSOLETE
134// OBSOLETE if (ep->status != 0)
135// OBSOLETE {
136// OBSOLETE if (bothstatus)
137// OBSOLETE printf_unfiltered ("e: ");
138// OBSOLETE print_387_status_word (ep->status);
139// OBSOLETE }
140// OBSOLETE
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));
148// OBSOLETE
149// OBSOLETE top = ((ep->status >> 11) & 7);
150// OBSOLETE
151// OBSOLETE printf_unfiltered ("regno tag msb lsb value\n");
152// OBSOLETE for (fpreg = 7; fpreg >= 0; fpreg--)
153// OBSOLETE {
154// OBSOLETE double val;
155// OBSOLETE
156// OBSOLETE printf_unfiltered ("%s %d: ", fpreg == top ? "=>" : " ", fpreg);
157// OBSOLETE
158// OBSOLETE switch ((ep->tag >> ((7 - fpreg) * 2)) & 3)
159// OBSOLETE {
160// OBSOLETE case 0:
161// OBSOLETE printf_unfiltered ("valid ");
162// OBSOLETE break;
163// OBSOLETE case 1:
164// OBSOLETE printf_unfiltered ("zero ");
165// OBSOLETE break;
166// OBSOLETE case 2:
167// OBSOLETE printf_unfiltered ("trap ");
168// OBSOLETE break;
169// OBSOLETE case 3:
170// OBSOLETE printf_unfiltered ("empty ");
171// OBSOLETE break;
172// OBSOLETE }
173// OBSOLETE for (i = 9; i >= 0; i--)
174// OBSOLETE printf_unfiltered ("%02x", ep->regs[fpreg][i]);
175// OBSOLETE
176// OBSOLETE i387_to_double ((char *) ep->regs[fpreg], (char *) &val);
177// OBSOLETE printf_unfiltered (" %#g\n", val);
178// OBSOLETE }
179// OBSOLETE }
180// OBSOLETE
181// OBSOLETE static struct env387 core_env387;
182// OBSOLETE
183// OBSOLETE void
184// OBSOLETE i386_float_info (void)
185// OBSOLETE {
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;
191// OBSOLETE int i;
192// OBSOLETE
193// OBSOLETE if (! ptid_equal (inferior_ptid, null_ptid))
194// OBSOLETE {
195// OBSOLETE char buf[10];
196// OBSOLETE unsigned short status;
197// OBSOLETE
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;
202// OBSOLETE }
203// OBSOLETE else
204// OBSOLETE {
205// OBSOLETE if ((fpsaved = core_env387.status) != 0)
206// OBSOLETE memcpy (&fps, &core_env387, sizeof (fps));
207// OBSOLETE }
208// OBSOLETE
209// OBSOLETE if (fpsaved == 0)
210// OBSOLETE {
211// OBSOLETE printf_unfiltered ("no floating point status saved\n");
212// OBSOLETE return;
213// OBSOLETE }
214// OBSOLETE
215// OBSOLETE if (! ptid_equal (inferior_ptid, null_ptid))
216// OBSOLETE {
217// OBSOLETE int offset;
218// OBSOLETE for (offset = 0; offset < sizeof (fps); offset += 10)
219// OBSOLETE {
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));
224// OBSOLETE }
225// OBSOLETE }
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);
230// OBSOLETE }
231// OBSOLETE
232// OBSOLETE /* Fetch one register. */
233// OBSOLETE static void
234// OBSOLETE fetch_register (int regno)
235// OBSOLETE {
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);
240// OBSOLETE else
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);
244// OBSOLETE }
245// OBSOLETE
246// OBSOLETE void
247// OBSOLETE fetch_inferior_registers (int regno)
248// OBSOLETE {
249// OBSOLETE if (regno < 0)
250// OBSOLETE for (regno = 0; regno < NUM_REGS; regno++)
251// OBSOLETE fetch_register (regno);
252// OBSOLETE else
253// OBSOLETE fetch_register (regno);
254// OBSOLETE }
255// OBSOLETE
256// OBSOLETE /* store one register */
257// OBSOLETE static void
258// OBSOLETE store_register (int regno)
259// OBSOLETE {
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 *) &registers[REGISTER_BYTE (regno)], 0);
265// OBSOLETE else
266// OBSOLETE ptrace (PT_WRITE_FPR, PIDGET (inferior_ptid),
267// OBSOLETE &registers[REGISTER_BYTE (regno)],
268// OBSOLETE (regno - FP0_REGNUM) * 10 + offsetof (struct env387, regs));
269// OBSOLETE
270// OBSOLETE if (errno != 0)
271// OBSOLETE {
272// OBSOLETE sprintf (buf, "writing register number %d", regno);
273// OBSOLETE perror_with_name (buf);
274// OBSOLETE }
275// OBSOLETE }
276// OBSOLETE
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). */
280// OBSOLETE void
281// OBSOLETE store_inferior_registers (int regno)
282// OBSOLETE {
283// OBSOLETE if (regno < 0)
284// OBSOLETE for (regno = 0; regno < NUM_REGS; regno++)
285// OBSOLETE store_register (regno);
286// OBSOLETE else
287// OBSOLETE store_register (regno);
288// OBSOLETE }
289// OBSOLETE
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
307// OBSOLETE #endif
308// OBSOLETE
309// OBSOLETE /*
310// OBSOLETE * The order here in core_regmap[] has to be the same as in
311// OBSOLETE * regmap[] above.
312// OBSOLETE */
313// OBSOLETE static int core_regmap[] =
314// OBSOLETE {
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,
319// OBSOLETE };
320// OBSOLETE
321// OBSOLETE /* Provide registers to GDB from a core file.
322// OBSOLETE
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.
326// OBSOLETE
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
330// OBSOLETE
331// OBSOLETE REG_ADDR isn't used. */
332// OBSOLETE
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)
336// OBSOLETE {
337// OBSOLETE
338// OBSOLETE if (which == 0)
339// OBSOLETE {
340// OBSOLETE /* Integer registers */
341// OBSOLETE
342// OBSOLETE #define cd_regs(n) ((int *)core_reg_sect)[n]
343// OBSOLETE #define regs(n) *((int *) &registers[REGISTER_BYTE (n)])
344// OBSOLETE
345// OBSOLETE int i;
346// OBSOLETE for (i = 0; i < FP0_REGNUM; i++)
347// OBSOLETE regs (i) = cd_regs (core_regmap[i]);
348// OBSOLETE }
349// OBSOLETE else if (which == 2)
350// OBSOLETE {
351// OBSOLETE /* Floating point registers */
352// OBSOLETE
353// OBSOLETE if (core_reg_size >= sizeof (core_env387))
354// OBSOLETE memcpy (&core_env387, core_reg_sect, core_reg_size);
355// OBSOLETE else
356// OBSOLETE fprintf_unfiltered (gdb_stderr, "Couldn't read float regs from core file\n");
357// OBSOLETE }
358// OBSOLETE }
359// OBSOLETE \f
360// OBSOLETE
361// OBSOLETE /* Register that we are able to handle i386aix core file formats.
362// OBSOLETE FIXME: is this really bfd_target_unknown_flavour? */
363// OBSOLETE
364// OBSOLETE static struct core_fns i386aix_core_fns =
365// OBSOLETE {
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 */
371// OBSOLETE };
372// OBSOLETE
373// OBSOLETE void
374// OBSOLETE _initialize_core_i386aix (void)
375// OBSOLETE {
376// OBSOLETE add_core_fns (&i386aix_core_fns);
377// OBSOLETE }
This page took 0.111605 seconds and 4 git commands to generate.