1 /* Host-dependent Motorola 88xxx support for GDB, the GNU Debugger.
2 Copyright 1988, 1990, 1991 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
25 #include <sys/types.h>
28 #include <sys/param.h>
34 #ifndef USER /* added to support BCS ptrace_user */
35 #define USER ptrace_user
37 #include <sys/ioctl.h>
47 #include <sys/ptrace.h>
49 /* define offsets to the pc instruction offsets in ptrace_user struct */
50 #define SXIP_OFFSET (char *)&u.pt_sigframe.sig_sxip - (char *)&u
51 #define SNIP_OFFSET (char *)&u.pt_sigframe.sig_snip - (char *)&u
52 #define SFIP_OFFSET (char *)&u.pt_sigframe.sig_sfip - (char *)&u
54 /* define offsets to the pc instruction offsets in ptrace_user struct */
55 #define SXIP_OFFSET (char *)&u.pt_sigframe.dg_sigframe.sc_sxip - (char *)&u
56 #define SNIP_OFFSET (char *)&u.pt_sigframe.dg_sigframe.sc_snip - (char *)&u
57 #define SFIP_OFFSET (char *)&u.pt_sigframe.dg_sigframe.sc_sfip - (char *)&u
60 extern int have_symbol_file_p();
62 extern jmp_buf stack_jmp
;
65 extern char registers
[REGISTER_BYTES
];
68 fetch_inferior_registers (regno
)
69 int regno
; /* Original value discarded */
71 register unsigned int regaddr
;
72 char buf
[MAX_REGISTER_RAW_SIZE
];
78 offset
= (char *) &u
.pt_r0
- (char *) &u
;
79 regaddr
= offset
; /* byte offset to r0;*/
81 /* offset = ptrace (3, inferior_pid, offset, 0) - KERNEL_U_ADDR; */
82 for (regno
= 0; regno
< NUM_REGS
; regno
++)
84 /*regaddr = register_addr (regno, offset);*/
87 for (i
= 0; i
< REGISTER_RAW_SIZE (regno
); i
+= sizeof (int))
89 *(int *) &buf
[i
] = ptrace (3, inferior_pid
, regaddr
, 0);
90 regaddr
+= sizeof (int);
92 supply_register (regno
, buf
);
94 /* now load up registers 36 - 38; special pc registers */
95 *(int *) &buf
[0] = ptrace (3,inferior_pid
,SXIP_OFFSET
,0);
96 supply_register (SXIP_REGNUM
, buf
);
97 *(int *) &buf
[0] = ptrace (3, inferior_pid
,SNIP_OFFSET
,0);
98 supply_register (SNIP_REGNUM
, buf
);
99 *(int *) &buf
[0] = ptrace (3, inferior_pid
,SFIP_OFFSET
,0);
100 supply_register (SFIP_REGNUM
, buf
);
103 /* Store our register values back into the inferior.
104 If REGNO is -1, do this for all registers.
105 Otherwise, REGNO specifies which register (so we can save time). */
108 store_inferior_registers (regno
)
111 register unsigned int regaddr
;
117 unsigned int offset
= (char *) &u
.pt_r0
- (char *) &u
;
123 /* regaddr = register_addr (regno, offset); */
124 if (regno
< PC_REGNUM
)
126 regaddr
= offset
+ regno
* sizeof (int);
128 ptrace (6, inferior_pid
, regaddr
, read_register (regno
));
131 sprintf (buf
, "writing register number %d", regno
);
132 perror_with_name (buf
);
135 else if (regno
== SXIP_REGNUM
)
136 ptrace (6, inferior_pid
, SXIP_OFFSET
, read_register(regno
));
137 else if (regno
== SNIP_REGNUM
)
138 ptrace (6, inferior_pid
, SNIP_OFFSET
, read_register(regno
));
139 else if (regno
== SFIP_REGNUM
)
140 ptrace (6, inferior_pid
, SFIP_OFFSET
, read_register(regno
));
141 else printf ("Bad register number for store_inferior routine\n");
144 for (regno
= 0; regno
< NUM_REGS
- 3; regno
++)
146 /* regaddr = register_addr (regno, offset); */
148 regaddr
= offset
+ regno
* sizeof (int);
149 ptrace (6, inferior_pid
, regaddr
, read_register (regno
));
152 sprintf (buf
, "writing register number %d", regno
);
153 perror_with_name (buf
);
156 ptrace (6,inferior_pid
,SXIP_OFFSET
,read_register(SXIP_REGNUM
));
157 ptrace (6,inferior_pid
,SNIP_OFFSET
,read_register(SNIP_REGNUM
));
158 ptrace (6,inferior_pid
,SFIP_OFFSET
,read_register(SFIP_REGNUM
));
165 /* Core files are now a function of BFD. */
168 core_file_command (filename
, from_tty
)
173 extern char registers
[];
175 /* Need symbol file and one with tdesc info for corefiles to work */
176 if (!have_symbol_file_p())
177 error ("Requires symbol-file and exec-file");
179 error ("Requires exec-file and symbol-file");
181 /* Discard all vestiges of any previous core file
182 and mark data and stack spaces as empty. */
194 stack_start
= STACK_END_ADDR
;
195 stack_end
= STACK_END_ADDR
;
197 /* Now, if a new core file was specified, open it and digest it. */
201 filename
= tilde_expand (filename
);
202 make_cleanup (free
, filename
);
204 if (have_inferior_p ())
205 error ("To look at a core file, you must kill the inferior with \"kill\".");
206 corechan
= open (filename
, O_RDONLY
, 0);
208 perror_with_name (filename
);
209 /* 4.2-style (and perhaps also sysV-style) core dump file. */
215 val
= myread (corechan
, &u
, sizeof u
);
217 perror_with_name (filename
);
218 data_start
= u
.pt_o_data_start
;
220 data_end
= data_start
+ u
.pt_dsize
;
221 stack_start
= stack_end
- u
.pt_ssize
;
222 data_offset
= u
.pt_dataptr
;
223 stack_offset
= data_offset
+ u
.pt_dsize
;
231 #endif /* defined (DGUX) */
235 reg_offset
= (int) u
.pt_r0
- KERNEL_U_ADDR
;
237 #endif /* defined(BCS) */
239 /* I don't know where to find this info.
240 So, for now, mark it as not available. */
241 /* N_SET_MAGIC (core_aouthdr, 0); */
242 bzero ((char *) &core_aouthdr
, sizeof core_aouthdr
);
244 /* Read the register values out of the core file and store
245 them where `read_register' will find them. */
250 for (regno
= 0; regno
< NUM_REGS
; regno
++)
252 char buf
[MAX_REGISTER_RAW_SIZE
];
254 val
= lseek (corechan
, register_addr (regno
, reg_offset
), 0);
256 perror_with_name (filename
);
258 val
= myread (corechan
, buf
, sizeof buf
);
260 perror_with_name (filename
);
261 supply_register (regno
, buf
);
265 if (filename
[0] == '/')
266 corefile
= savestring (filename
, strlen (filename
));
269 corefile
= concat (current_directory
, "/", filename
, NULL
);
272 current_context
= init_dcontext();
273 set_current_frame ( create_new_frame(get_frame_base (read_pc()),
275 select_frame (get_current_frame (), 0);
279 printf ("No core file now.\n");
283 /* blockend is the address of the end of the user structure */
284 m88k_register_u_addr (blockend
, regnum
)
287 int ustart
= blockend
- sizeof (struct USER
);
321 case 31: return (ustart
+ ((int) &u
.pt_r0
- (int) &u
) + sizeof(REGISTER_TYPE
) * regnum
);
322 case PSR_REGNUM
: return (ustart
+ ((int) &u
.pt_psr
- (int) &u
));
323 case FPSR_REGNUM
: return (ustart
+ ((int) &u
.pt_fpsr
- (int) &u
));
324 case FPCR_REGNUM
: return (ustart
+ ((int) &u
.pt_fpcr
- (int) &u
));
325 case SXIP_REGNUM
: return (ustart
+ SXIP_OFFSET
);
326 case SNIP_REGNUM
: return (ustart
+ SNIP_OFFSET
);
327 case SFIP_REGNUM
: return (ustart
+ SFIP_OFFSET
);
328 default: return (blockend
+ sizeof (REGISTER_TYPE
) * regnum
);
This page took 0.044697 seconds and 4 git commands to generate.