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, Boston, MA 02111-1307, USA. */
24 #include <sys/types.h>
25 #include <sys/param.h>
31 #ifndef USER /* added to support BCS ptrace_user */
32 #define USER ptrace_user
34 #include <sys/ioctl.h>
44 #include <sys/ptrace.h>
46 /* define offsets to the pc instruction offsets in ptrace_user struct */
47 #define SXIP_OFFSET ((char *)&u.pt_sigframe.sig_sxip - (char *)&u)
48 #define SNIP_OFFSET ((char *)&u.pt_sigframe.sig_snip - (char *)&u)
49 #define SFIP_OFFSET ((char *)&u.pt_sigframe.sig_sfip - (char *)&u)
51 /* define offsets to the pc instruction offsets in ptrace_user struct */
52 #define SXIP_OFFSET ((char *)&u.pt_sigframe.dg_sigframe.sc_sxip - (char *)&u)
53 #define SNIP_OFFSET ((char *)&u.pt_sigframe.dg_sigframe.sc_snip - (char *)&u)
54 #define SFIP_OFFSET ((char *)&u.pt_sigframe.dg_sigframe.sc_sfip - (char *)&u)
57 extern int have_symbol_file_p();
59 extern jmp_buf stack_jmp
;
62 extern char registers
[REGISTER_BYTES
];
65 fetch_inferior_registers (regno
)
66 int regno
; /* Original value discarded */
68 register unsigned int regaddr
;
69 char buf
[MAX_REGISTER_RAW_SIZE
];
75 offset
= (char *) &u
.pt_r0
- (char *) &u
;
76 regaddr
= offset
; /* byte offset to r0;*/
78 /* offset = ptrace (3, inferior_pid, (PTRACE_ARG3_TYPE) offset, 0) - KERNEL_U_ADDR; */
79 for (regno
= 0; regno
< NUM_REGS
; regno
++)
81 /*regaddr = register_addr (regno, offset);*/
84 for (i
= 0; i
< REGISTER_RAW_SIZE (regno
); i
+= sizeof (int))
86 *(int *) &buf
[i
] = ptrace (3, inferior_pid
,
87 (PTRACE_ARG3_TYPE
) regaddr
, 0);
88 regaddr
+= sizeof (int);
90 supply_register (regno
, buf
);
92 /* now load up registers 36 - 38; special pc registers */
93 *(int *) &buf
[0] = ptrace (3,inferior_pid
,
94 (PTRACE_ARG3_TYPE
) SXIP_OFFSET
,0);
95 supply_register (SXIP_REGNUM
, buf
);
96 *(int *) &buf
[0] = ptrace (3, inferior_pid
,
97 (PTRACE_ARG3_TYPE
) SNIP_OFFSET
,0);
98 supply_register (SNIP_REGNUM
, buf
);
99 *(int *) &buf
[0] = ptrace (3, inferior_pid
,
100 (PTRACE_ARG3_TYPE
) SFIP_OFFSET
,0);
101 supply_register (SFIP_REGNUM
, buf
);
104 /* Store our register values back into the inferior.
105 If REGNO is -1, do this for all registers.
106 Otherwise, REGNO specifies which register (so we can save time). */
109 store_inferior_registers (regno
)
112 register unsigned int regaddr
;
117 unsigned int offset
= (char *) &u
.pt_r0
- (char *) &u
;
121 /* Don't try to deal with EXIP_REGNUM or ENIP_REGNUM, because I think either
122 svr3 doesn't run on an 88110, or the kernel isolates the different (not
123 completely sure this is true, but seems to be. */
126 /* regaddr = register_addr (regno, offset); */
127 if (regno
< PC_REGNUM
)
129 regaddr
= offset
+ regno
* sizeof (int);
131 ptrace (6, inferior_pid
,
132 (PTRACE_ARG3_TYPE
) regaddr
, read_register (regno
));
135 sprintf (buf
, "writing register number %d", regno
);
136 perror_with_name (buf
);
139 else if (regno
== SXIP_REGNUM
)
140 ptrace (6, inferior_pid
,
141 (PTRACE_ARG3_TYPE
) SXIP_OFFSET
, read_register(regno
));
142 else if (regno
== SNIP_REGNUM
)
143 ptrace (6, inferior_pid
,
144 (PTRACE_ARG3_TYPE
) SNIP_OFFSET
, read_register(regno
));
145 else if (regno
== SFIP_REGNUM
)
146 ptrace (6, inferior_pid
,
147 (PTRACE_ARG3_TYPE
) SFIP_OFFSET
, read_register(regno
));
149 printf_unfiltered ("Bad register number for store_inferior routine\n");
153 for (regno
= 0; regno
< PC_REGNUM
; regno
++)
155 /* regaddr = register_addr (regno, offset); */
157 regaddr
= offset
+ regno
* sizeof (int);
158 ptrace (6, inferior_pid
,
159 (PTRACE_ARG3_TYPE
) regaddr
, read_register (regno
));
162 sprintf (buf
, "writing register number %d", regno
);
163 perror_with_name (buf
);
166 ptrace (6,inferior_pid
,
167 (PTRACE_ARG3_TYPE
) SXIP_OFFSET
,read_register(SXIP_REGNUM
));
168 ptrace (6,inferior_pid
,
169 (PTRACE_ARG3_TYPE
) SNIP_OFFSET
,read_register(SNIP_REGNUM
));
170 ptrace (6,inferior_pid
,
171 (PTRACE_ARG3_TYPE
) SFIP_OFFSET
,read_register(SFIP_REGNUM
));
176 /* blockend is the address of the end of the user structure */
177 m88k_register_u_addr (blockend
, regnum
)
180 int ustart
= blockend
- sizeof (struct USER
);
215 return (ustart
+ ((int) &u
.pt_r0
- (int) &u
) + REGISTER_SIZE
* regnum
);
216 case PSR_REGNUM
: return (ustart
+ ((int) &u
.pt_psr
- (int) &u
));
217 case FPSR_REGNUM
: return (ustart
+ ((int) &u
.pt_fpsr
- (int) &u
));
218 case FPCR_REGNUM
: return (ustart
+ ((int) &u
.pt_fpcr
- (int) &u
));
219 case SXIP_REGNUM
: return (ustart
+ SXIP_OFFSET
);
220 case SNIP_REGNUM
: return (ustart
+ SNIP_OFFSET
);
221 case SFIP_REGNUM
: return (ustart
+ SFIP_OFFSET
);
223 if (regnum
< NUM_REGS
)
224 /* The register is one of those which is not defined...
226 return (ustart
+ ((int) &u
.pt_r0
- (int) &u
));
228 return (blockend
+ REGISTER_SIZE
* regnum
);
234 #include <sys/procfs.h>
236 /* Given a pointer to a general register set in /proc format (gregset_t *),
237 unpack the register contents and supply them as gdb's idea of the current
241 supply_gregset (gregsetp
)
245 register greg_t
*regp
= (greg_t
*) gregsetp
;
247 for (regi
=0; regi
<= SP_REGNUM
; regi
++)
248 supply_register (regi
, (char *) (regp
+ regi
));
250 supply_register (SXIP_REGNUM
, (char *) (regp
+ R_XIP
));
251 supply_register (SNIP_REGNUM
, (char *) (regp
+ R_NIP
));
252 supply_register (SFIP_REGNUM
, (char *) (regp
+ R_FIP
));
253 supply_register (PSR_REGNUM
, (char *) (regp
+ R_PSR
));
254 supply_register (FPSR_REGNUM
, (char *) (regp
+ R_FPSR
));
255 supply_register (FPCR_REGNUM
, (char *) (regp
+ R_FPCR
));
259 fill_gregset (gregsetp
, regno
)
264 register greg_t
*regp
= (greg_t
*) gregsetp
;
265 extern char registers
[];
267 for (regi
= 0 ; regi
<= R_R31
; regi
++)
268 if ((regno
== -1) || (regno
== regi
))
269 *(regp
+ regi
) = *(int *) ®isters
[REGISTER_BYTE(regi
)];
271 if ((regno
== -1) || (regno
== SXIP_REGNUM
))
272 *(regp
+ R_XIP
) = *(int *) ®isters
[REGISTER_BYTE(SXIP_REGNUM
)];
273 if ((regno
== -1) || (regno
== SNIP_REGNUM
))
274 *(regp
+ R_NIP
) = *(int *) ®isters
[REGISTER_BYTE(SNIP_REGNUM
)];
275 if ((regno
== -1) || (regno
== SFIP_REGNUM
))
276 *(regp
+ R_FIP
) = *(int *) ®isters
[REGISTER_BYTE(SFIP_REGNUM
)];
277 if ((regno
== -1) || (regno
== PSR_REGNUM
))
278 *(regp
+ R_PSR
) = *(int *) ®isters
[REGISTER_BYTE(PSR_REGNUM
)];
279 if ((regno
== -1) || (regno
== FPSR_REGNUM
))
280 *(regp
+ R_FPSR
) = *(int *) ®isters
[REGISTER_BYTE(FPSR_REGNUM
)];
281 if ((regno
== -1) || (regno
== FPCR_REGNUM
))
282 *(regp
+ R_FPCR
) = *(int *) ®isters
[REGISTER_BYTE(FPCR_REGNUM
)];
285 #endif /* USE_PROC_FS */
This page took 0.035491 seconds and 4 git commands to generate.