1 /* Native support for Motorola 88k running Harris CX/UX.
2 Copyright 1988, 1990, 1991, 1992, 1993, 1994 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. */
24 #include <sys/types.h>
25 #include <sys/param.h>
36 #ifndef USER /* added to support BCS ptrace_user */
37 #define USER ptrace_user
39 #include <sys/ioctl.h>
48 #include <sys/ptrace.h>
50 /* CX/UX provides them already, but as word offsets instead of char offsets */
51 #define SXIP_OFFSET (PT_SXIP * 4)
52 #define SNIP_OFFSET (PT_SNIP * 4)
53 #define SFIP_OFFSET (PT_SFIP * 4)
54 #define PSR_OFFSET (PT_PSR * sizeof(int))
55 #define FPSR_OFFSET (PT_FPSR * sizeof(int))
56 #define FPCR_OFFSET (PT_FPCR * sizeof(int))
58 #define XREGADDR(r) (((char *)&u.pt_x0-(char *)&u) + \
59 ((r)-X0_REGNUM)*sizeof(X_REGISTER_RAW_TYPE))
61 extern int have_symbol_file_p();
63 extern jmp_buf stack_jmp
;
66 extern char registers
[REGISTER_BYTES
];
69 fetch_inferior_registers (regno
)
70 int regno
; /* Original value discarded */
72 register unsigned int regaddr
;
73 char buf
[MAX_REGISTER_RAW_SIZE
];
79 offset
= (char *) &u
.pt_r0
- (char *) &u
;
80 regaddr
= offset
; /* byte offset to r0;*/
82 /* offset = ptrace (3, inferior_pid, (PTRACE_ARG3_TYPE) offset, 0) - KERNEL_U_ADDR; */
83 for (regno
= 0; regno
< PC_REGNUM
; regno
++)
85 /*regaddr = register_addr (regno, offset);*/
88 for (i
= 0; i
< REGISTER_RAW_SIZE (regno
); i
+= sizeof (int))
90 *(int *) &buf
[i
] = ptrace (3, inferior_pid
,
91 (PTRACE_ARG3_TYPE
) regaddr
, 0);
92 regaddr
+= sizeof (int);
94 supply_register (regno
, buf
);
96 /* now load up registers 32-37; special pc registers */
97 *(int *) &buf
[0] = ptrace (3, inferior_pid
,
98 (PTRACE_ARG3_TYPE
) PSR_OFFSET
,0);
99 supply_register (PSR_REGNUM
, buf
);
100 *(int *) &buf
[0] = ptrace (3, inferior_pid
,
101 (PTRACE_ARG3_TYPE
) FPSR_OFFSET
,0);
102 supply_register (FPSR_REGNUM
, buf
);
103 *(int *) &buf
[0] = ptrace (3, inferior_pid
,
104 (PTRACE_ARG3_TYPE
) FPCR_OFFSET
,0);
105 supply_register (FPCR_REGNUM
, buf
);
106 *(int *) &buf
[0] = ptrace (3,inferior_pid
,
107 (PTRACE_ARG3_TYPE
) SXIP_OFFSET
,0);
108 supply_register (SXIP_REGNUM
, buf
);
109 *(int *) &buf
[0] = ptrace (3, inferior_pid
,
110 (PTRACE_ARG3_TYPE
) SNIP_OFFSET
,0);
111 supply_register (SNIP_REGNUM
, buf
);
112 *(int *) &buf
[0] = ptrace (3, inferior_pid
,
113 (PTRACE_ARG3_TYPE
) SFIP_OFFSET
,0);
114 supply_register (SFIP_REGNUM
, buf
);
116 if (target_is_m88110
)
118 for (regaddr
= XREGADDR(X0_REGNUM
), regno
= X0_REGNUM
;
120 regno
++, regaddr
+= 16)
122 X_REGISTER_RAW_TYPE xval
;
124 *(int *) &xval
.w1
= ptrace (3, inferior_pid
,
125 (PTRACE_ARG3_TYPE
) regaddr
, 0);
126 *(int *) &xval
.w2
= ptrace (3, inferior_pid
,
127 (PTRACE_ARG3_TYPE
) (regaddr
+4), 0);
128 *(int *) &xval
.w3
= ptrace (3, inferior_pid
,
129 (PTRACE_ARG3_TYPE
) (regaddr
+8), 0);
130 *(int *) &xval
.w4
= ptrace (3, inferior_pid
,
131 (PTRACE_ARG3_TYPE
) (regaddr
+12), 0);
132 supply_register(regno
, (void *)&xval
);
137 /* Store our register values back into the inferior.
138 If REGNO is -1, do this for all registers.
139 Otherwise, REGNO specifies which register (so we can save time). */
142 store_inferior_registers (regno
)
145 register unsigned int regaddr
;
150 unsigned int offset
= (char *) &u
.pt_r0
- (char *) &u
;
154 /* Don't try to deal with EXIP_REGNUM or ENIP_REGNUM, because I think either
155 svr3 doesn't run on an 88110, or the kernel isolates the different (not
156 completely sure this is true, but seems to be. */
159 /* regaddr = register_addr (regno, offset); */
160 if (regno
< PC_REGNUM
)
162 regaddr
= offset
+ regno
* sizeof (int);
164 ptrace (6, inferior_pid
,
165 (PTRACE_ARG3_TYPE
) regaddr
, read_register (regno
));
168 sprintf (buf
, "writing register number %d", regno
);
169 perror_with_name (buf
);
172 else if (regno
== PSR_REGNUM
)
173 ptrace (6, inferior_pid
,
174 (PTRACE_ARG3_TYPE
) PSR_OFFSET
, read_register(regno
));
175 else if (regno
== FPSR_REGNUM
)
176 ptrace (6, inferior_pid
,
177 (PTRACE_ARG3_TYPE
) FPSR_OFFSET
, read_register(regno
));
178 else if (regno
== FPCR_REGNUM
)
179 ptrace (6, inferior_pid
,
180 (PTRACE_ARG3_TYPE
) FPCR_OFFSET
, read_register(regno
));
181 else if (regno
== SXIP_REGNUM
)
182 ptrace (6, inferior_pid
,
183 (PTRACE_ARG3_TYPE
) SXIP_OFFSET
, read_register(regno
));
184 else if (regno
== SNIP_REGNUM
)
185 ptrace (6, inferior_pid
,
186 (PTRACE_ARG3_TYPE
) SNIP_OFFSET
, read_register(regno
));
187 else if (regno
== SFIP_REGNUM
)
188 ptrace (6, inferior_pid
,
189 (PTRACE_ARG3_TYPE
) SFIP_OFFSET
, read_register(regno
));
190 else if (target_is_m88110
&& regno
< NUM_REGS
)
192 X_REGISTER_RAW_TYPE xval
;
194 read_register_bytes(REGISTER_BYTE(regno
), (char *)&xval
,
195 sizeof(X_REGISTER_RAW_TYPE
));
196 regaddr
= XREGADDR(regno
);
197 ptrace (6, inferior_pid
, (PTRACE_ARG3_TYPE
) regaddr
, xval
.w1
);
198 ptrace (6, inferior_pid
, (PTRACE_ARG3_TYPE
) regaddr
+4, xval
.w2
);
199 ptrace (6, inferior_pid
, (PTRACE_ARG3_TYPE
) regaddr
+8, xval
.w3
);
200 ptrace (6, inferior_pid
, (PTRACE_ARG3_TYPE
) regaddr
+12, xval
.w4
);
203 printf_unfiltered ("Bad register number for store_inferior routine\n");
207 for (regno
= 0; regno
< PC_REGNUM
; regno
++)
209 /* regaddr = register_addr (regno, offset); */
211 regaddr
= offset
+ regno
* sizeof (int);
212 ptrace (6, inferior_pid
,
213 (PTRACE_ARG3_TYPE
) regaddr
, read_register (regno
));
216 sprintf (buf
, "writing register number %d", regno
);
217 perror_with_name (buf
);
220 ptrace (6, inferior_pid
,
221 (PTRACE_ARG3_TYPE
) PSR_OFFSET
, read_register(regno
));
222 ptrace (6, inferior_pid
,
223 (PTRACE_ARG3_TYPE
) FPSR_OFFSET
,read_register(regno
));
224 ptrace (6, inferior_pid
,
225 (PTRACE_ARG3_TYPE
) FPCR_OFFSET
,read_register(regno
));
226 ptrace (6,inferior_pid
,
227 (PTRACE_ARG3_TYPE
) SXIP_OFFSET
,read_register(SXIP_REGNUM
));
228 ptrace (6,inferior_pid
,
229 (PTRACE_ARG3_TYPE
) SNIP_OFFSET
,read_register(SNIP_REGNUM
));
230 ptrace (6,inferior_pid
,
231 (PTRACE_ARG3_TYPE
) SFIP_OFFSET
,read_register(SFIP_REGNUM
));
232 if (target_is_m88110
)
234 for (regno
= X0_REGNUM
; regno
< NUM_REGS
; regno
++)
236 X_REGISTER_RAW_TYPE xval
;
238 read_register_bytes(REGISTER_BYTE(regno
), (char *)&xval
,
239 sizeof(X_REGISTER_RAW_TYPE
));
240 regaddr
= XREGADDR(regno
);
241 ptrace (6, inferior_pid
, (PTRACE_ARG3_TYPE
) regaddr
, xval
.w1
);
242 ptrace (6, inferior_pid
, (PTRACE_ARG3_TYPE
) (regaddr
+4), xval
.w2
);
243 ptrace (6, inferior_pid
, (PTRACE_ARG3_TYPE
) (regaddr
+8), xval
.w3
);
244 ptrace (6, inferior_pid
, (PTRACE_ARG3_TYPE
) (regaddr
+12), xval
.w4
);
250 /* blockend is the address of the end of the user structure */
252 m88k_register_u_addr (blockend
, regnum
)
253 int blockend
, regnum
;
256 int ustart
= blockend
- sizeof (struct USER
);
258 if (regnum
< PSR_REGNUM
)
259 return (ustart
+ ((int) &u
.pt_r0
- (int) &u
) +
260 REGISTER_SIZE
* regnum
);
261 else if (regnum
== PSR_REGNUM
)
262 return (ustart
+ ((int) &u
.pt_psr
) - (int) &u
);
263 else if (regnum
== FPSR_REGNUM
)
264 return (ustart
+ ((int) &u
.pt_fpsr
) - (int) &u
);
265 else if (regnum
== FPCR_REGNUM
)
266 return (ustart
+ ((int) &u
.pt_fpcr
) - (int) &u
);
267 else if (regnum
== SXIP_REGNUM
)
268 return (ustart
+ SXIP_OFFSET
);
269 else if (regnum
== SNIP_REGNUM
)
270 return (ustart
+ SNIP_OFFSET
);
271 else if (regnum
== SFIP_REGNUM
)
272 return (ustart
+ SFIP_OFFSET
);
273 else if (target_is_m88110
)
274 return (ustart
+ ((int) &u
.pt_x0
- (int) &u
) + /* Must be X register */
275 sizeof(u
.pt_x0
) * (regnum
- X0_REGNUM
));
277 return (blockend
+ REGISTER_SIZE
* regnum
);
282 #include <sys/procfs.h>
284 /* Given a pointer to a general register set in /proc format (gregset_t *),
285 unpack the register contents and supply them as gdb's idea of the current
289 supply_gregset (gregsetp
)
293 register greg_t
*regp
= (greg_t
*) gregsetp
;
295 for (regi
=0; regi
<= SP_REGNUM
; regi
++)
296 supply_register (regi
, (char *) (regp
+ regi
));
298 supply_register (SXIP_REGNUM
, (char *) (regp
+ R_XIP
));
299 supply_register (SNIP_REGNUM
, (char *) (regp
+ R_NIP
));
300 supply_register (SFIP_REGNUM
, (char *) (regp
+ R_FIP
));
301 supply_register (PSR_REGNUM
, (char *) (regp
+ R_PSR
));
302 supply_register (FPSR_REGNUM
, (char *) (regp
+ R_FPSR
));
303 supply_register (FPCR_REGNUM
, (char *) (regp
+ R_FPCR
));
307 fill_gregset (gregsetp
, regno
)
312 register greg_t
*regp
= (greg_t
*) gregsetp
;
313 extern char registers
[];
315 for (regi
= 0 ; regi
<= R_R31
; regi
++)
316 if ((regno
== -1) || (regno
== regi
))
317 *(regp
+ regi
) = *(int *) ®isters
[REGISTER_BYTE(regi
)];
319 if ((regno
== -1) || (regno
== SXIP_REGNUM
))
320 *(regp
+ R_XIP
) = *(int *) ®isters
[REGISTER_BYTE(SXIP_REGNUM
)];
321 if ((regno
== -1) || (regno
== SNIP_REGNUM
))
322 *(regp
+ R_NIP
) = *(int *) ®isters
[REGISTER_BYTE(SNIP_REGNUM
)];
323 if ((regno
== -1) || (regno
== SFIP_REGNUM
))
324 *(regp
+ R_FIP
) = *(int *) ®isters
[REGISTER_BYTE(SFIP_REGNUM
)];
325 if ((regno
== -1) || (regno
== PSR_REGNUM
))
326 *(regp
+ R_PSR
) = *(int *) ®isters
[REGISTER_BYTE(PSR_REGNUM
)];
327 if ((regno
== -1) || (regno
== FPSR_REGNUM
))
328 *(regp
+ R_FPSR
) = *(int *) ®isters
[REGISTER_BYTE(FPSR_REGNUM
)];
329 if ((regno
== -1) || (regno
== FPCR_REGNUM
))
330 *(regp
+ R_FPCR
) = *(int *) ®isters
[REGISTER_BYTE(FPCR_REGNUM
)];
333 #endif /* USE_PROC_FS */
335 /* This support adds the equivalent of adb's % command. When
336 the `add-shared-symbol-files' command is given, this routine scans
337 the dynamic linker's link map and reads the minimal symbols
338 from each shared object file listed in the map. */
341 unsigned long l_addr
; /* address at which object is mapped */
342 char *l_name
; /* full name of loaded object */
343 void *l_ld
; /* dynamic structure of object */
344 struct link_map
*l_next
; /* next link object */
345 struct link_map
*l_prev
; /* previous link object */
348 #define LINKS_MAP_POINTER "_ld_tail"
349 #define LIBC_FILE "/usr/lib/libc.so.1"
350 #define SHARED_OFFSET 0xf0001000
353 #define PATH_MAX 1023 /* maximum size of path name on OS */
357 add_shared_symbol_files ()
360 struct link_map
*ld_map
, *lm
, lms
;
361 struct minimal_symbol
*minsym
;
362 struct objfile
*objfile
;
367 warning ("The program has not yet been started.");
371 objfile
= symbol_file_add (LIBC_FILE
, 0, 0, 0, 0, 1);
372 minsym
= lookup_minimal_symbol (LINKS_MAP_POINTER
, objfile
);
374 ld_map
= (struct link_map
*)
375 read_memory_integer (((int)SYMBOL_VALUE_ADDRESS(minsym
) + SHARED_OFFSET
), 4);
381 read_memory ((CORE_ADDR
)lm
, (char*)&lms
, sizeof (struct link_map
));
384 if (target_read_string ((CORE_ADDR
)lms
.l_name
, &path_name
,
385 PATH_MAX
, &local_errno
))
387 symbol_file_add (path_name
, 1, lms
.l_addr
, 0, 0, 0);
391 /* traverse links in reverse order so that we get the
392 the symbols the user actually gets. */
396 /* Getting new symbols may change our opinion about what is
398 reinit_frame_cache ();
403 #include <sys/regset.h>
406 m88k_harris_core_register_addr (regno
, reg_ptr
)
409 unsigned int word_offset
;
414 word_offset
= R_EPSR
;
417 word_offset
= R_FPSR
;
420 word_offset
= R_FPCR
;
423 word_offset
= R_EXIP
;
426 word_offset
= R_ENIP
;
429 word_offset
= R_EFIP
;
432 if (regno
<= FP_REGNUM
)
435 word_offset
= ((regno
- X0_REGNUM
) * 4);
437 return (word_offset
* 4);
443 _initialize_m88k_nat()
446 /* Enable 88110 support, as we don't support the 88100 under ES/MP. */
448 target_is_m88110
= 1;
449 #elif defined(_CX_UX)
450 /* Determine whether we're running on an 88100 or an 88110. */
451 target_is_m88110
= (sinfo(SYSMACHINE
,0) == SYS5800
);
456 /* Given a pointer to a general register set in /proc format (gregset_t *),
457 unpack the register contents and supply them as gdb's idea of the current
461 supply_gregset (gregsetp
)
465 register greg_t
*regp
= (greg_t
*) gregsetp
;
467 for (regi
= 0 ; regi
< R_R31
; regi
++)
469 supply_register (regi
, (char *) (regp
+ regi
));
471 supply_register (PSR_REGNUM
, (char *) (regp
+ R_EPSR
));
472 supply_register (FPSR_REGNUM
, (char *) (regp
+ R_FPSR
));
473 supply_register (FPCR_REGNUM
, (char *) (regp
+ R_FPCR
));
474 supply_register (SXIP_REGNUM
, (char *) (regp
+ R_EXIP
));
475 supply_register (SNIP_REGNUM
, (char *) (regp
+ R_ENIP
));
476 supply_register (SFIP_REGNUM
, (char *) (regp
+ R_EFIP
));
479 /* Given a pointer to a floating point register set in /proc format
480 (fpregset_t *), unpack the register contents and supply them as gdb's
481 idea of the current floating point register values. */
484 supply_fpregset (fpregsetp
)
485 fpregset_t
*fpregsetp
;
490 for (regi
= FP0_REGNUM
; regi
<= FPLAST_REGNUM
; regi
++)
492 from
= (char *) &((*fpregsetp
)[regi
-FP0_REGNUM
]);
493 supply_register (regi
, from
);
501 #include <sys/regset.h>
503 unsigned int m88k_harris_core_register_addr(int regno
, int reg_ptr
)
505 unsigned int word_offset
;
508 case PSR_REGNUM
: word_offset
= R_PSR
; break;
509 case FPSR_REGNUM
: word_offset
= R_FPSR
; break;
510 case FPCR_REGNUM
: word_offset
= R_FPCR
; break;
511 case SXIP_REGNUM
: word_offset
= R_XIP
; break;
512 case SNIP_REGNUM
: word_offset
= R_NIP
; break;
513 case SFIP_REGNUM
: word_offset
= R_FIP
; break;
515 if (regno
<= FP_REGNUM
)
518 word_offset
= ((regno
- X0_REGNUM
) * 4) + R_X0
;
520 return (word_offset
* 4);
This page took 0.039928 seconds and 4 git commands to generate.