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., 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, (PTRACE_ARG3_TYPE) 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
,
90 (PTRACE_ARG3_TYPE
) regaddr
, 0);
91 regaddr
+= sizeof (int);
93 supply_register (regno
, buf
);
95 /* now load up registers 36 - 38; special pc registers */
96 *(int *) &buf
[0] = ptrace (3,inferior_pid
,
97 (PTRACE_ARG3_TYPE
) SXIP_OFFSET
,0);
98 supply_register (SXIP_REGNUM
, buf
);
99 *(int *) &buf
[0] = ptrace (3, inferior_pid
,
100 (PTRACE_ARG3_TYPE
) SNIP_OFFSET
,0);
101 supply_register (SNIP_REGNUM
, buf
);
102 *(int *) &buf
[0] = ptrace (3, inferior_pid
,
103 (PTRACE_ARG3_TYPE
) SFIP_OFFSET
,0);
104 supply_register (SFIP_REGNUM
, buf
);
107 /* Store our register values back into the inferior.
108 If REGNO is -1, do this for all registers.
109 Otherwise, REGNO specifies which register (so we can save time). */
112 store_inferior_registers (regno
)
115 register unsigned int regaddr
;
121 unsigned int offset
= (char *) &u
.pt_r0
- (char *) &u
;
127 /* regaddr = register_addr (regno, offset); */
128 if (regno
< PC_REGNUM
)
130 regaddr
= offset
+ regno
* sizeof (int);
132 ptrace (6, inferior_pid
,
133 (PTRACE_ARG3_TYPE
) regaddr
, read_register (regno
));
136 sprintf (buf
, "writing register number %d", regno
);
137 perror_with_name (buf
);
140 else if (regno
== SXIP_REGNUM
)
141 ptrace (6, inferior_pid
,
142 (PTRACE_ARG3_TYPE
) SXIP_OFFSET
, read_register(regno
));
143 else if (regno
== SNIP_REGNUM
)
144 ptrace (6, inferior_pid
,
145 (PTRACE_ARG3_TYPE
) SNIP_OFFSET
, read_register(regno
));
146 else if (regno
== SFIP_REGNUM
)
147 ptrace (6, inferior_pid
,
148 (PTRACE_ARG3_TYPE
) SFIP_OFFSET
, read_register(regno
));
149 else printf ("Bad register number for store_inferior routine\n");
152 for (regno
= 0; regno
< NUM_REGS
- 3; regno
++)
154 /* regaddr = register_addr (regno, offset); */
156 regaddr
= offset
+ regno
* sizeof (int);
157 ptrace (6, inferior_pid
,
158 (PTRACE_ARG3_TYPE
) regaddr
, read_register (regno
));
161 sprintf (buf
, "writing register number %d", regno
);
162 perror_with_name (buf
);
165 ptrace (6,inferior_pid
,
166 (PTRACE_ARG3_TYPE
) SXIP_OFFSET
,read_register(SXIP_REGNUM
));
167 ptrace (6,inferior_pid
,
168 (PTRACE_ARG3_TYPE
) SNIP_OFFSET
,read_register(SNIP_REGNUM
));
169 ptrace (6,inferior_pid
,
170 (PTRACE_ARG3_TYPE
) SFIP_OFFSET
,read_register(SFIP_REGNUM
));
177 /* blockend is the address of the end of the user structure */
178 m88k_register_u_addr (blockend
, regnum
)
181 int ustart
= blockend
- sizeof (struct USER
);
215 case 31: return (ustart
+ ((int) &u
.pt_r0
- (int) &u
) + sizeof(REGISTER_TYPE
) * 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
);
222 default: return (blockend
+ sizeof (REGISTER_TYPE
) * regnum
);
This page took 0.032712 seconds and 4 git commands to generate.