Obsolete sun386i.
[deliverable/binutils-gdb.git] / gdb / sun386-nat.c
CommitLineData
24f89b68
AC
1/* OBSOLETE /* Native support for Sun 386i's for GDB, the GNU debugger. */
2/* OBSOLETE Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1995, 1999, 2000, 2001 */
3/* OBSOLETE Free Software Foundation, Inc. */
4/* OBSOLETE Changes for sun386i by Jean Daniel Fekete (jdf@litp.univ-p6-7.fr), */
5/* OBSOLETE C2V Paris, April 89. */
6/* OBSOLETE */
7/* OBSOLETE This file is part of GDB. */
8/* OBSOLETE */
9/* OBSOLETE This program is free software; you can redistribute it and/or modify */
10/* OBSOLETE it under the terms of the GNU General Public License as published by */
11/* OBSOLETE the Free Software Foundation; either version 2 of the License, or */
12/* OBSOLETE (at your option) any later version. */
13/* OBSOLETE */
14/* OBSOLETE This program is distributed in the hope that it will be useful, */
15/* OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of */
16/* OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
17/* OBSOLETE GNU General Public License for more details. */
18/* OBSOLETE */
19/* OBSOLETE You should have received a copy of the GNU General Public License */
20/* OBSOLETE along with this program; if not, write to the Free Software */
21/* OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330, */
22/* OBSOLETE Boston, MA 02111-1307, USA. */ */
23/* OBSOLETE */
24/* OBSOLETE #include "defs.h" */
25/* OBSOLETE #include "frame.h" */
26/* OBSOLETE #include "inferior.h" */
27/* OBSOLETE #include "gdbcore.h" */
28/* OBSOLETE #include "regcache.h" */
29/* OBSOLETE */
30/* OBSOLETE #include <sys/param.h> */
31/* OBSOLETE #include <sys/dir.h> */
32/* OBSOLETE #include <sys/user.h> */
33/* OBSOLETE #include <signal.h> */
34/* OBSOLETE #include <sys/ioctl.h> */
35/* OBSOLETE #include <fcntl.h> */
36/* OBSOLETE */
37/* OBSOLETE #include <sys/ptrace.h> */
38/* OBSOLETE #include <machine/reg.h> */
39/* OBSOLETE */
40/* OBSOLETE #include <sys/file.h> */
41/* OBSOLETE #include "gdb_stat.h" */
42/* OBSOLETE #include <sys/core.h> */
43/* OBSOLETE \f */
44/* OBSOLETE */
45/* OBSOLETE /* Machine-dependent code which would otherwise be in corefile.c */ */
46/* OBSOLETE /* Work with core files, for GDB. */ */
47/* OBSOLETE \f */
48/* OBSOLETE */
49/* OBSOLETE void */
50/* OBSOLETE core_file_command (char *filename, int from_tty) */
51/* OBSOLETE { */
52/* OBSOLETE int val; */
53/* OBSOLETE */
54/* OBSOLETE /* Discard all vestiges of any previous core file */
55/* OBSOLETE and mark data and stack spaces as empty. */ */
56/* OBSOLETE */
57/* OBSOLETE if (corefile) */
58/* OBSOLETE xfree (corefile); */
59/* OBSOLETE corefile = 0; */
60/* OBSOLETE */
61/* OBSOLETE if (corechan >= 0) */
62/* OBSOLETE close (corechan); */
63/* OBSOLETE corechan = -1; */
64/* OBSOLETE */
65/* OBSOLETE data_start = 0; */
66/* OBSOLETE data_end = 0; */
67/* OBSOLETE stack_start = STACK_END_ADDR; */
68/* OBSOLETE stack_end = STACK_END_ADDR; */
69/* OBSOLETE */
70/* OBSOLETE /* Now, if a new core file was specified, open it and digest it. */ */
71/* OBSOLETE */
72/* OBSOLETE if (filename) */
73/* OBSOLETE { */
74/* OBSOLETE filename = tilde_expand (filename); */
75/* OBSOLETE make_cleanup (xfree, filename); */
76/* OBSOLETE */
77/* OBSOLETE if (have_inferior_p ()) */
78/* OBSOLETE error ("To look at a core file, you must kill the program with \"kill\"."); */
79/* OBSOLETE corechan = open (filename, O_RDONLY, 0); */
80/* OBSOLETE if (corechan < 0) */
81/* OBSOLETE perror_with_name (filename); */
82/* OBSOLETE */
83/* OBSOLETE { */
84/* OBSOLETE struct core corestr; */
85/* OBSOLETE */
86/* OBSOLETE val = myread (corechan, &corestr, sizeof corestr); */
87/* OBSOLETE if (val < 0) */
88/* OBSOLETE perror_with_name (filename); */
89/* OBSOLETE if (corestr.c_magic != CORE_MAGIC) */
90/* OBSOLETE error ("\"%s\" does not appear to be a core dump file (magic 0x%x, expected 0x%x)", */
91/* OBSOLETE filename, corestr.c_magic, (int) CORE_MAGIC); */
92/* OBSOLETE else if (sizeof (struct core) != corestr.c_len) */
93/* OBSOLETE error ("\"%s\" has an invalid struct core length (%d, expected %d)", */
94/* OBSOLETE filename, corestr.c_len, (int) sizeof (struct core)); */
95/* OBSOLETE */
96/* OBSOLETE data_start = exec_data_start; */
97/* OBSOLETE data_end = data_start + corestr.c_dsize; */
98/* OBSOLETE stack_start = stack_end - corestr.c_ssize; */
99/* OBSOLETE data_offset = sizeof corestr; */
100/* OBSOLETE stack_offset = sizeof corestr + corestr.c_dsize; */
101/* OBSOLETE */
102/* OBSOLETE memcpy (registers, &corestr.c_regs, sizeof corestr.c_regs); */
103/* OBSOLETE */
104/* OBSOLETE memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)], */
105/* OBSOLETE corestr.c_fpu.f_fpstatus.f_st, */
106/* OBSOLETE sizeof corestr.c_fpu.f_fpstatus.f_st); */
107/* OBSOLETE memcpy (&registers[REGISTER_BYTE (FPC_REGNUM)], */
108/* OBSOLETE &corestr.c_fpu.f_fpstatus.f_ctrl, */
109/* OBSOLETE sizeof corestr.c_fpu.f_fpstatus - */
110/* OBSOLETE sizeof corestr.c_fpu.f_fpstatus.f_st); */
111/* OBSOLETE */
112/* OBSOLETE /* the struct aouthdr of sun coff is not the struct exec stored */
113/* OBSOLETE in the core file. */ */
114/* OBSOLETE memcpy (&core_aouthdr, &corestr.c_aouthdr, sizeof (struct exec)); */
115/* OBSOLETE #ifndef COFF_ENCAPSULATE */
116/* OBSOLETE core_aouthdr.magic = corestr.c_aouthdr.a_info; */
117/* OBSOLETE core_aouthdr.vstamp = /*SUNVERSION */ 31252; */
118/* OBSOLETE #endif */
119/* OBSOLETE printf_unfiltered ("Core file is from \"%s\".\n", corestr.c_cmdname); */
120/* OBSOLETE if (corestr.c_signo > 0) */
121/* OBSOLETE printf_unfiltered ("Program terminated with signal %d, %s.\n", */
122/* OBSOLETE corestr.c_signo, safe_strsignal (corestr.c_signo)); */
123/* OBSOLETE } */
124/* OBSOLETE if (filename[0] == '/') */
125/* OBSOLETE corefile = savestring (filename, strlen (filename)); */
126/* OBSOLETE else */
127/* OBSOLETE { */
128/* OBSOLETE corefile = concat (current_directory, "/", filename, NULL); */
129/* OBSOLETE } */
130/* OBSOLETE */
131/* OBSOLETE flush_cached_frames (); */
132/* OBSOLETE select_frame (get_current_frame (), 0); */
133/* OBSOLETE */
134/* OBSOLETE validate_files (); */
135/* OBSOLETE } */
136/* OBSOLETE else if (from_tty) */
137/* OBSOLETE printf_unfiltered ("No core file now.\n"); */
138/* OBSOLETE } */
139/* OBSOLETE */
140/* OBSOLETE i387_to_double (char *from, char *to) */
141/* OBSOLETE { */
142/* OBSOLETE long *lp; */
143/* OBSOLETE /* push extended mode on 387 stack, then pop in double mode */
144/* OBSOLETE */
145/* OBSOLETE * first, set exception masks so no error is generated - */
146/* OBSOLETE * number will be rounded to inf or 0, if necessary */
147/* OBSOLETE */ */
148/* OBSOLETE asm ("pushl %eax"); /* grab a stack slot */ */
149/* OBSOLETE asm ("fstcw (%esp)"); /* get 387 control word */ */
150/* OBSOLETE asm ("movl (%esp),%eax"); /* save old value */ */
151/* OBSOLETE asm ("orl $0x3f,%eax"); /* mask all exceptions */ */
152/* OBSOLETE asm ("pushl %eax"); */
153/* OBSOLETE asm ("fldcw (%esp)"); /* load new value into 387 */ */
154/* OBSOLETE */
155/* OBSOLETE asm ("movl 8(%ebp),%eax"); */
156/* OBSOLETE asm ("fldt (%eax)"); /* push extended number on 387 stack */ */
157/* OBSOLETE asm ("fwait"); */
158/* OBSOLETE asm ("movl 12(%ebp),%eax"); */
159/* OBSOLETE asm ("fstpl (%eax)"); /* pop double */ */
160/* OBSOLETE asm ("fwait"); */
161/* OBSOLETE */
162/* OBSOLETE asm ("popl %eax"); /* flush modified control word */ */
163/* OBSOLETE asm ("fnclex"); /* clear exceptions */ */
164/* OBSOLETE asm ("fldcw (%esp)"); /* restore original control word */ */
165/* OBSOLETE asm ("popl %eax"); /* flush saved copy */ */
166/* OBSOLETE } */
167/* OBSOLETE */
168/* OBSOLETE double_to_i387 (char *from, char *to) */
169/* OBSOLETE { */
170/* OBSOLETE /* push double mode on 387 stack, then pop in extended mode */
171/* OBSOLETE * no errors are possible because every 64-bit pattern */
172/* OBSOLETE * can be converted to an extended */
173/* OBSOLETE */ */
174/* OBSOLETE asm ("movl 8(%ebp),%eax"); */
175/* OBSOLETE asm ("fldl (%eax)"); */
176/* OBSOLETE asm ("fwait"); */
177/* OBSOLETE asm ("movl 12(%ebp),%eax"); */
178/* OBSOLETE asm ("fstpt (%eax)"); */
179/* OBSOLETE asm ("fwait"); */
180/* OBSOLETE } */
181/* OBSOLETE */
182/* OBSOLETE void */
183/* OBSOLETE fetch_inferior_registers (int regno) */
184/* OBSOLETE { */
185/* OBSOLETE struct regs inferior_registers; */
186/* OBSOLETE struct fp_state inferior_fp_registers; */
187/* OBSOLETE */
188/* OBSOLETE registers_fetched (); */
189/* OBSOLETE */
190/* OBSOLETE ptrace (PTRACE_GETREGS, inferior_pid, */
191/* OBSOLETE (PTRACE_ARG3_TYPE) & inferior_registers); */
192/* OBSOLETE ptrace (PTRACE_GETFPREGS, inferior_pid, */
193/* OBSOLETE (PTRACE_ARG3_TYPE) & inferior_fp_registers); */
194/* OBSOLETE */
195/* OBSOLETE memcpy (registers, &inferior_registers, sizeof inferior_registers); */
196/* OBSOLETE */
197/* OBSOLETE memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)], inferior_fp_registers.f_st, */
198/* OBSOLETE sizeof inferior_fp_registers.f_st); */
199/* OBSOLETE memcpy (&registers[REGISTER_BYTE (FPC_REGNUM)], */
200/* OBSOLETE &inferior_fp_registers.f_ctrl, */
201/* OBSOLETE sizeof inferior_fp_registers - sizeof inferior_fp_registers.f_st); */
202/* OBSOLETE } */
203/* OBSOLETE */
204/* OBSOLETE /* Store our register values back into the inferior. */
205/* OBSOLETE If REGNO is -1, do this for all registers. */
206/* OBSOLETE Otherwise, REGNO specifies which register (so we can save time). */ */
207/* OBSOLETE */
208/* OBSOLETE void */
209/* OBSOLETE store_inferior_registers (int regno) */
210/* OBSOLETE { */
211/* OBSOLETE struct regs inferior_registers; */
212/* OBSOLETE struct fp_state inferior_fp_registers; */
213/* OBSOLETE */
214/* OBSOLETE memcpy (&inferior_registers, registers, 20 * 4); */
215/* OBSOLETE */
216/* OBSOLETE memcpy (inferior_fp_registers.f_st, */
217/* OBSOLETE &registers[REGISTER_BYTE (FP0_REGNUM)], */
218/* OBSOLETE sizeof inferior_fp_registers.f_st); */
219/* OBSOLETE memcpy (&inferior_fp_registers.f_ctrl, */
220/* OBSOLETE &registers[REGISTER_BYTE (FPC_REGNUM)], */
221/* OBSOLETE sizeof inferior_fp_registers - sizeof inferior_fp_registers.f_st); */
222/* OBSOLETE */
223/* OBSOLETE #ifdef PTRACE_FP_BUG */
224/* OBSOLETE if (regno == FP_REGNUM || regno == -1) */
225/* OBSOLETE /* Storing the frame pointer requires a gross hack, in which an */
226/* OBSOLETE instruction that moves eax into ebp gets single-stepped. */ */
227/* OBSOLETE { */
228/* OBSOLETE int stack = inferior_registers.r_reg[SP_REGNUM]; */
229/* OBSOLETE int stuff = ptrace (PTRACE_PEEKDATA, inferior_pid, */
230/* OBSOLETE (PTRACE_ARG3_TYPE) stack); */
231/* OBSOLETE int reg = inferior_registers.r_reg[EAX]; */
232/* OBSOLETE inferior_registers.r_reg[EAX] = */
233/* OBSOLETE inferior_registers.r_reg[FP_REGNUM]; */
234/* OBSOLETE ptrace (PTRACE_SETREGS, inferior_pid, */
235/* OBSOLETE (PTRACE_ARG3_TYPE) & inferior_registers); */
236/* OBSOLETE ptrace (PTRACE_POKEDATA, inferior_pid, (PTRACE_ARG3_TYPE) stack, */
237/* OBSOLETE 0xc589); */
238/* OBSOLETE ptrace (PTRACE_SINGLESTEP, inferior_pid, (PTRACE_ARG3_TYPE) stack, */
239/* OBSOLETE 0); */
240/* OBSOLETE wait (0); */
241/* OBSOLETE ptrace (PTRACE_POKEDATA, inferior_pid, (PTRACE_ARG3_TYPE) stack, */
242/* OBSOLETE stuff); */
243/* OBSOLETE inferior_registers.r_reg[EAX] = reg; */
244/* OBSOLETE } */
245/* OBSOLETE #endif */
246/* OBSOLETE ptrace (PTRACE_SETREGS, inferior_pid, */
247/* OBSOLETE (PTRACE_ARG3_TYPE) & inferior_registers); */
248/* OBSOLETE ptrace (PTRACE_SETFPREGS, inferior_pid, */
249/* OBSOLETE (PTRACE_ARG3_TYPE) & inferior_fp_registers); */
250/* OBSOLETE } */
This page took 0.034254 seconds and 4 git commands to generate.