1 /* Native-dependent Motorola 88xxx support for GDB, the GNU Debugger.
2 Copyright 1988, 1990, 1991, 1992 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., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
25 #include <sys/types.h>
26 #include <sys/param.h>
32 #ifndef USER /* added to support BCS ptrace_user */
33 #define USER ptrace_user
35 #include <sys/ioctl.h>
45 #include <sys/ptrace.h>
47 /* define offsets to the pc instruction offsets in ptrace_user struct */
48 #define SXIP_OFFSET ((char *)&u.pt_sigframe.sig_sxip - (char *)&u)
49 #define SNIP_OFFSET ((char *)&u.pt_sigframe.sig_snip - (char *)&u)
50 #define SFIP_OFFSET ((char *)&u.pt_sigframe.sig_sfip - (char *)&u)
52 /* define offsets to the pc instruction offsets in ptrace_user struct */
53 #define SXIP_OFFSET ((char *)&u.pt_sigframe.dg_sigframe.sc_sxip - (char *)&u)
54 #define SNIP_OFFSET ((char *)&u.pt_sigframe.dg_sigframe.sc_snip - (char *)&u)
55 #define SFIP_OFFSET ((char *)&u.pt_sigframe.dg_sigframe.sc_sfip - (char *)&u)
58 extern int have_symbol_file_p ();
60 extern jmp_buf stack_jmp
;
65 fetch_inferior_registers (int regno
)
67 register unsigned int regaddr
;
68 char buf
[MAX_REGISTER_RAW_SIZE
];
74 offset
= (char *) &u
.pt_r0
- (char *) &u
;
75 regaddr
= offset
; /* byte offset to r0; */
77 /* offset = ptrace (3, inferior_pid, (PTRACE_ARG3_TYPE) offset, 0) - KERNEL_U_ADDR; */
78 for (regno
= 0; regno
< NUM_REGS
; regno
++)
80 /*regaddr = register_addr (regno, offset); */
83 for (i
= 0; i
< REGISTER_RAW_SIZE (regno
); i
+= sizeof (int))
85 *(int *) &buf
[i
] = ptrace (3, inferior_pid
,
86 (PTRACE_ARG3_TYPE
) regaddr
, 0);
87 regaddr
+= sizeof (int);
89 supply_register (regno
, buf
);
91 /* now load up registers 36 - 38; special pc registers */
92 *(int *) &buf
[0] = ptrace (3, inferior_pid
,
93 (PTRACE_ARG3_TYPE
) SXIP_OFFSET
, 0);
94 supply_register (SXIP_REGNUM
, buf
);
95 *(int *) &buf
[0] = ptrace (3, inferior_pid
,
96 (PTRACE_ARG3_TYPE
) SNIP_OFFSET
, 0);
97 supply_register (SNIP_REGNUM
, buf
);
98 *(int *) &buf
[0] = ptrace (3, inferior_pid
,
99 (PTRACE_ARG3_TYPE
) 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 (int regno
)
110 register unsigned int regaddr
;
115 unsigned int offset
= (char *) &u
.pt_r0
- (char *) &u
;
119 /* Don't try to deal with EXIP_REGNUM or ENIP_REGNUM, because I think either
120 svr3 doesn't run on an 88110, or the kernel isolates the different (not
121 completely sure this is true, but seems to be. */
124 /* regaddr = register_addr (regno, offset); */
125 if (regno
< PC_REGNUM
)
127 regaddr
= offset
+ regno
* sizeof (int);
129 ptrace (6, inferior_pid
,
130 (PTRACE_ARG3_TYPE
) regaddr
, read_register (regno
));
133 sprintf (buf
, "writing register number %d", regno
);
134 perror_with_name (buf
);
137 else if (regno
== SXIP_REGNUM
)
138 ptrace (6, inferior_pid
,
139 (PTRACE_ARG3_TYPE
) SXIP_OFFSET
, read_register (regno
));
140 else if (regno
== SNIP_REGNUM
)
141 ptrace (6, inferior_pid
,
142 (PTRACE_ARG3_TYPE
) SNIP_OFFSET
, read_register (regno
));
143 else if (regno
== SFIP_REGNUM
)
144 ptrace (6, inferior_pid
,
145 (PTRACE_ARG3_TYPE
) SFIP_OFFSET
, read_register (regno
));
147 printf_unfiltered ("Bad register number for store_inferior routine\n");
151 for (regno
= 0; regno
< PC_REGNUM
; regno
++)
153 /* regaddr = register_addr (regno, offset); */
155 regaddr
= offset
+ regno
* sizeof (int);
156 ptrace (6, inferior_pid
,
157 (PTRACE_ARG3_TYPE
) regaddr
, read_register (regno
));
160 sprintf (buf
, "writing register number %d", regno
);
161 perror_with_name (buf
);
164 ptrace (6, inferior_pid
,
165 (PTRACE_ARG3_TYPE
) SXIP_OFFSET
, read_register (SXIP_REGNUM
));
166 ptrace (6, inferior_pid
,
167 (PTRACE_ARG3_TYPE
) SNIP_OFFSET
, read_register (SNIP_REGNUM
));
168 ptrace (6, inferior_pid
,
169 (PTRACE_ARG3_TYPE
) SFIP_OFFSET
, read_register (SFIP_REGNUM
));
174 /* blockend is the address of the end of the user structure */
175 m88k_register_u_addr (int blockend
, int regnum
)
178 int ustart
= blockend
- sizeof (struct USER
);
213 return (ustart
+ ((int) &u
.pt_r0
- (int) &u
) + REGISTER_SIZE
* regnum
);
215 return (ustart
+ ((int) &u
.pt_psr
- (int) &u
));
217 return (ustart
+ ((int) &u
.pt_fpsr
- (int) &u
));
219 return (ustart
+ ((int) &u
.pt_fpcr
- (int) &u
));
221 return (ustart
+ SXIP_OFFSET
);
223 return (ustart
+ SNIP_OFFSET
);
225 return (ustart
+ SFIP_OFFSET
);
227 if (regnum
< NUM_REGS
)
228 /* The register is one of those which is not defined...
230 return (ustart
+ ((int) &u
.pt_r0
- (int) &u
));
232 return (blockend
+ REGISTER_SIZE
* regnum
);
238 #include <sys/procfs.h>
240 /* Prototypes for supply_gregset etc. */
243 /* Given a pointer to a general register set in /proc format (gregset_t *),
244 unpack the register contents and supply them as gdb's idea of the current
248 supply_gregset (gregset_t
*gregsetp
)
251 register greg_t
*regp
= (greg_t
*) gregsetp
;
253 for (regi
= 0; regi
<= SP_REGNUM
; regi
++)
254 supply_register (regi
, (char *) (regp
+ regi
));
256 supply_register (SXIP_REGNUM
, (char *) (regp
+ R_XIP
));
257 supply_register (SNIP_REGNUM
, (char *) (regp
+ R_NIP
));
258 supply_register (SFIP_REGNUM
, (char *) (regp
+ R_FIP
));
259 supply_register (PSR_REGNUM
, (char *) (regp
+ R_PSR
));
260 supply_register (FPSR_REGNUM
, (char *) (regp
+ R_FPSR
));
261 supply_register (FPCR_REGNUM
, (char *) (regp
+ R_FPCR
));
265 fill_gregset (gregset_t
*gregsetp
, int regno
)
268 register greg_t
*regp
= (greg_t
*) gregsetp
;
270 for (regi
= 0; regi
<= R_R31
; regi
++)
271 if ((regno
== -1) || (regno
== regi
))
272 *(regp
+ regi
) = *(int *) ®isters
[REGISTER_BYTE (regi
)];
274 if ((regno
== -1) || (regno
== SXIP_REGNUM
))
275 *(regp
+ R_XIP
) = *(int *) ®isters
[REGISTER_BYTE (SXIP_REGNUM
)];
276 if ((regno
== -1) || (regno
== SNIP_REGNUM
))
277 *(regp
+ R_NIP
) = *(int *) ®isters
[REGISTER_BYTE (SNIP_REGNUM
)];
278 if ((regno
== -1) || (regno
== SFIP_REGNUM
))
279 *(regp
+ R_FIP
) = *(int *) ®isters
[REGISTER_BYTE (SFIP_REGNUM
)];
280 if ((regno
== -1) || (regno
== PSR_REGNUM
))
281 *(regp
+ R_PSR
) = *(int *) ®isters
[REGISTER_BYTE (PSR_REGNUM
)];
282 if ((regno
== -1) || (regno
== FPSR_REGNUM
))
283 *(regp
+ R_FPSR
) = *(int *) ®isters
[REGISTER_BYTE (FPSR_REGNUM
)];
284 if ((regno
== -1) || (regno
== FPCR_REGNUM
))
285 *(regp
+ R_FPCR
) = *(int *) ®isters
[REGISTER_BYTE (FPCR_REGNUM
)];
288 #endif /* USE_PROC_FS */
This page took 0.045642 seconds and 4 git commands to generate.