3bf57d21 |
1 | /* Definitions to make GDB run on an encore under umax 4.2 |
4187119d |
2 | Copyright (C) 1987, 1989 Free Software Foundation, Inc. |
3bf57d21 |
3 | |
4187119d |
4 | This file is part of GDB. |
3bf57d21 |
5 | |
4187119d |
6 | GDB 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 1, or (at your option) |
9 | any later version. |
3bf57d21 |
10 | |
4187119d |
11 | GDB 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. |
15 | |
16 | You should have received a copy of the GNU General Public License |
17 | along with GDB; see the file COPYING. If not, write to |
18 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ |
3bf57d21 |
19 | |
20 | #ifndef ns16000 |
21 | #define ns16000 |
22 | #endif |
23 | |
24 | #define HAVE_WAIT_STRUCT |
25 | |
4187119d |
26 | /* Define the bit, byte, and word ordering of the machine. */ |
27 | /* #define BITS_BIG_ENDIAN */ |
28 | /* #define BYTES_BIG_ENDIAN */ |
29 | /* #define WORDS_BIG_ENDIAN */ |
30 | |
3bf57d21 |
31 | /* Encore's modifications to ptrace format */ |
32 | |
33 | #define UMAX_PTRACE |
34 | |
35 | /* Encore's modifications to core-file format */ |
36 | |
37 | #define UMAX_CORE |
38 | |
39 | /* Do implement the attach and detach commands. */ |
40 | |
41 | #define ATTACH_DETACH |
42 | |
43 | /* Define this if the C compiler puts an underscore at the front |
44 | of external names before giving them to the linker. */ |
45 | |
46 | #define NAMES_HAVE_UNDERSCORE |
47 | |
48 | /* Exec files and symbol tables are in COFF format */ |
49 | |
50 | #define COFF_FORMAT |
51 | |
4187119d |
52 | /* Doesn't have siginterupt. */ |
53 | #define NO_SIGINTERRUPT |
54 | |
3bf57d21 |
55 | /* Offset from address of function to start of its code. |
56 | Zero on most machines. */ |
57 | |
58 | #define FUNCTION_START_OFFSET 0 |
59 | |
60 | /* Advance PC across any function entry prologue instructions |
61 | to reach some "real" code. */ |
62 | |
63 | #define SKIP_PROLOGUE(pc) \ |
64 | { register unsigned char op = read_memory_integer (pc, 1); \ |
65 | if (op == 0x82) { op = read_memory_integer (pc+2,1); \ |
66 | if ((op & 0x80) == 0) pc += 3; \ |
67 | else if ((op & 0xc0) == 0x80) pc += 4; \ |
68 | else pc += 6; \ |
69 | } \ |
70 | } |
71 | |
72 | /* Immediately after a function call, return the saved pc. |
73 | Can't always go through the frames for this because on some machines |
74 | the new frame is not set up until the new function executes |
75 | some instructions. */ |
76 | |
77 | #define SAVED_PC_AFTER_CALL(frame) \ |
78 | read_memory_integer (read_register (SP_REGNUM), 4) |
79 | |
80 | /* Address of end of stack space. */ |
81 | |
82 | #define STACK_END_ADDR (0xfffff000) |
83 | |
84 | /* Stack grows downward. */ |
85 | |
86 | #define INNER_THAN < |
87 | |
88 | /* Sequence of bytes for breakpoint instruction. */ |
89 | |
90 | #define BREAKPOINT {0xf2} |
91 | |
92 | /* Amount PC must be decremented by after a breakpoint. |
93 | This is often the number of bytes in BREAKPOINT |
94 | but not always. */ |
95 | |
96 | #define DECR_PC_AFTER_BREAK 0 |
97 | |
98 | /* Nonzero if instruction at PC is a return instruction. */ |
99 | |
100 | #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0x12) |
101 | |
102 | #ifndef NaN |
103 | #include <nan.h> |
104 | #endif NaN |
105 | |
106 | /* Return 1 if P points to an invalid floating point value. */ |
107 | |
108 | #define INVALID_FLOAT(p, s) \ |
109 | ((s == sizeof (float))? \ |
110 | NaF (*(float *) p) : \ |
111 | NaD (*(double *) p)) |
112 | |
e91b87a3 |
113 | /* Largest integer type */ |
114 | #define LONGEST long |
115 | |
116 | /* Name of the builtin type for the LONGEST type above. */ |
117 | #define BUILTIN_TYPE_LONGEST builtin_type_long |
118 | |
3bf57d21 |
119 | /* Say how long (ordinary) registers are. */ |
120 | |
121 | #define REGISTER_TYPE long |
122 | |
123 | /* Number of machine registers */ |
124 | |
125 | #define NUM_REGS 25 |
126 | |
127 | #define NUM_GENERAL_REGS 8 |
128 | |
129 | /* Initializer for an array of names of registers. |
130 | There should be NUM_REGS strings in this initializer. */ |
131 | |
132 | #define REGISTER_NAMES {"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \ |
133 | "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \ |
134 | "sp", "fp", "pc", "ps", \ |
135 | "fsr", \ |
136 | "l0", "l1", "l2", "l3", "xx", \ |
137 | } |
138 | |
139 | /* Register numbers of various important registers. |
140 | Note that some of these values are "real" register numbers, |
141 | and correspond to the general registers of the machine, |
142 | and some are "phony" register numbers which are too large |
143 | to be actual register numbers as far as the user is concerned |
144 | but do serve to get the desired values when passed to read_register. */ |
145 | |
146 | #define FP0_REGNUM 8 /* Floating point register 0 */ |
147 | #define SP_REGNUM 16 /* Contains address of top of stack */ |
148 | #define AP_REGNUM FP_REGNUM |
149 | #define FP_REGNUM 17 /* Contains address of executing stack frame */ |
150 | #define PC_REGNUM 18 /* Contains program counter */ |
151 | #define PS_REGNUM 19 /* Contains processor status */ |
152 | #define FPS_REGNUM 20 /* Floating point status register */ |
153 | #define LP0_REGNUM 21 /* Double register 0 (same as FP0) */ |
154 | |
155 | /* called from register_addr() -- blockend not used for now */ |
156 | #define REGISTER_U_ADDR(addr, blockend, regno) \ |
157 | { \ |
158 | switch (regno) { \ |
159 | case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: \ |
160 | addr = PU_R0 - (regno * sizeof (int)); break; \ |
161 | case SP_REGNUM: \ |
162 | addr = PU_SP; break; \ |
163 | case PC_REGNUM: \ |
164 | addr = PU_PC; break; \ |
165 | case FP_REGNUM: \ |
166 | addr = PU_FP; break; \ |
167 | case PS_REGNUM: \ |
168 | addr = PU_PSL; break; \ |
169 | case FPS_REGNUM: \ |
170 | addr = PU_FSR; break; \ |
171 | case FP0_REGNUM + 0: case FP0_REGNUM + 1: \ |
172 | case FP0_REGNUM + 2: case FP0_REGNUM + 3: \ |
173 | case FP0_REGNUM + 4: case FP0_REGNUM + 5: \ |
174 | case FP0_REGNUM + 6: case FP0_REGNUM + 7: \ |
175 | addr = PU_F0 + (regno - FP0_REGNUM) * sizeof (float); break; \ |
176 | case LP0_REGNUM + 0: case LP0_REGNUM + 1: \ |
177 | case LP0_REGNUM + 2: case LP0_REGNUM + 3: \ |
178 | addr = PU_F0 + (regno - LP0_REGNUM) * sizeof (double); break; \ |
179 | default: \ |
180 | printf ("bad argument to REGISTER_U_ADDR %d\n", regno); \ |
181 | abort (); \ |
182 | } \ |
183 | } |
184 | |
185 | /* Total amount of space needed to store our copies of the machine's |
186 | register state, the array `registers'. */ |
187 | #define REGISTER_BYTES ((NUM_REGS - 4) * sizeof (int) + 4 * sizeof (double)) |
188 | |
189 | /* Index within `registers' of the first byte of the space for |
190 | register N. */ |
191 | |
192 | #define REGISTER_BYTE(N) ((N) >= LP0_REGNUM ? \ |
193 | LP0_REGNUM * 4 + ((N) - LP0_REGNUM) * 8 : (N) * 4) |
194 | |
195 | /* Number of bytes of storage in the actual machine representation |
196 | for register N. On the 32000, all regs are 4 bytes |
197 | except for the doubled floating registers. */ |
198 | |
199 | #define REGISTER_RAW_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4) |
200 | |
201 | /* Number of bytes of storage in the program's representation |
202 | for register N. On the 32000, all regs are 4 bytes |
203 | except for the doubled floating registers. */ |
204 | |
205 | #define REGISTER_VIRTUAL_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4) |
206 | |
207 | /* Largest value REGISTER_RAW_SIZE can have. */ |
208 | |
209 | #define MAX_REGISTER_RAW_SIZE 8 |
210 | |
211 | /* Largest value REGISTER_VIRTUAL_SIZE can have. */ |
212 | |
213 | #define MAX_REGISTER_VIRTUAL_SIZE 8 |
214 | |
215 | /* Nonzero if register N requires conversion |
216 | from raw format to virtual format. */ |
217 | |
218 | #define REGISTER_CONVERTIBLE(N) 0 |
219 | |
220 | /* Convert data from raw format for register REGNUM |
221 | to virtual format for register REGNUM. */ |
222 | |
223 | #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ |
224 | bcopy ((FROM), (TO), REGISTER_VIRTUAL_SIZE(REGNUM)); |
225 | |
226 | /* Convert data from virtual format for register REGNUM |
227 | to raw format for register REGNUM. */ |
228 | |
229 | #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ |
230 | bcopy ((FROM), (TO), REGISTER_VIRTUAL_SIZE(REGNUM)); |
231 | |
232 | /* Return the GDB type object for the "standard" data type |
233 | of data in register N. */ |
234 | |
235 | #define REGISTER_VIRTUAL_TYPE(N) \ |
236 | (((N) < FP0_REGNUM) ? \ |
237 | builtin_type_int : \ |
238 | ((N) < FP0_REGNUM + 8) ? \ |
239 | builtin_type_float : \ |
240 | ((N) < LP0_REGNUM) ? \ |
241 | builtin_type_int : \ |
242 | builtin_type_double) |
243 | |
e91b87a3 |
244 | /* Store the address of the place in which to copy the structure the |
245 | subroutine will return. This is called from call_function. |
246 | |
247 | On this machine this is a no-op, because gcc isn't used on it |
248 | yet. So this calling convention is not used. */ |
249 | |
250 | #define STORE_STRUCT_RETURN(ADDR, SP) |
251 | |
3bf57d21 |
252 | /* Extract from an array REGBUF containing the (raw) register state |
253 | a function return value of type TYPE, and copy that, in virtual format, |
254 | into VALBUF. */ |
255 | |
256 | #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ |
257 | bcopy (REGBUF+REGISTER_BYTE (TYPE_CODE (TYPE) == TYPE_CODE_FLT ? FP0_REGNUM : 0), VALBUF, TYPE_LENGTH (TYPE)) |
258 | |
259 | /* Write into appropriate registers a function return value |
260 | of type TYPE, given in virtual format. */ |
261 | |
262 | #define STORE_RETURN_VALUE(TYPE,VALBUF) \ |
263 | write_register_bytes (REGISTER_BYTE (TYPE_CODE (TYPE) == TYPE_CODE_FLT ? FP0_REGNUM : 0), VALBUF, TYPE_LENGTH (TYPE)) |
264 | |
265 | /* Extract from an array REGBUF containing the (raw) register state |
266 | the address in which a function should return its structure value, |
267 | as a CORE_ADDR (or an expression that can be used as one). */ |
268 | |
269 | #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF)) |
270 | \f |
271 | /* Describe the pointer in each stack frame to the previous stack frame |
272 | (its caller). */ |
273 | |
274 | /* FRAME_CHAIN takes a frame's nominal address |
275 | and produces the frame's chain-pointer. |
276 | |
277 | FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address |
278 | and produces the nominal address of the caller frame. |
279 | |
280 | However, if FRAME_CHAIN_VALID returns zero, |
281 | it means the given frame is the outermost one and has no caller. |
282 | In that case, FRAME_CHAIN_COMBINE is not used. */ |
283 | |
284 | /* In the case of the ns32000 series, the frame's nominal address is the FP |
285 | value, and at that address is saved previous FP value as a 4-byte word. */ |
286 | |
4187119d |
287 | #define FRAME_CHAIN(thisframe) \ |
288 | (outside_startup_file ((thisframe)->pc) ? \ |
289 | read_memory_integer ((thisframe)->frame, 4) :\ |
290 | 0) |
3bf57d21 |
291 | |
292 | #define FRAME_CHAIN_VALID(chain, thisframe) \ |
4187119d |
293 | (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) |
3bf57d21 |
294 | |
295 | #define FRAME_CHAIN_COMBINE(chain, thisframe) (chain) |
296 | |
297 | /* Define other aspects of the stack frame. */ |
298 | |
e91b87a3 |
299 | #define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4)) |
3bf57d21 |
300 | |
301 | /* Compute base of arguments. */ |
302 | |
303 | #define FRAME_ARGS_ADDRESS(fi) \ |
e91b87a3 |
304 | ((ns32k_get_enter_addr ((fi)->pc) > 1) ? \ |
305 | ((fi)->frame) : (read_register (SP_REGNUM) - 4)) |
3bf57d21 |
306 | |
e91b87a3 |
307 | #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) |
3bf57d21 |
308 | |
309 | /* Get the address of the enter opcode for this function, if it is active. |
310 | Returns positive address > 1 if pc is between enter/exit, |
311 | 1 if pc before enter or after exit, 0 otherwise. */ |
312 | |
313 | #ifndef CORE_ADDR |
314 | #include "defs.h" /* Make sure CORE_ADDR is defined. */ |
315 | #endif |
316 | |
317 | extern CORE_ADDR ns32k_get_enter_addr (); |
318 | |
319 | /* Return number of args passed to a frame. |
320 | Can return -1, meaning no way to tell. |
321 | Encore's C compiler often reuses same area on stack for args, |
322 | so this will often not work properly. If the arg names |
323 | are known, it's likely most of them will be printed. */ |
324 | |
325 | #define FRAME_NUM_ARGS(numargs, fi) \ |
326 | { CORE_ADDR pc; \ |
327 | CORE_ADDR enter_addr; \ |
328 | unsigned int insn; \ |
329 | unsigned int addr_mode; \ |
330 | int width; \ |
331 | \ |
332 | numargs = -1; \ |
e91b87a3 |
333 | enter_addr = ns32k_get_enter_addr ((fi)->pc); \ |
3bf57d21 |
334 | if (enter_addr > 0) \ |
335 | { \ |
336 | pc = (enter_addr == 1) ? \ |
e91b87a3 |
337 | SAVED_PC_AFTER_CALL (fi) : \ |
338 | FRAME_SAVED_PC (fi); \ |
3bf57d21 |
339 | insn = read_memory_integer (pc,2); \ |
340 | addr_mode = (insn >> 11) & 0x1f; \ |
341 | insn = insn & 0x7ff; \ |
342 | if ((insn & 0x7fc) == 0x57c && \ |
343 | addr_mode == 0x14) /* immediate */ \ |
344 | { \ |
345 | if (insn == 0x57c) /* adjspb */ \ |
346 | width = 1; \ |
347 | else if (insn == 0x57d) /* adjspw */ \ |
348 | width = 2; \ |
349 | else if (insn == 0x57f) /* adjspd */ \ |
350 | width = 4; \ |
351 | numargs = read_memory_integer (pc+2,width); \ |
352 | if (width > 1) \ |
353 | flip_bytes (&numargs, width); \ |
354 | numargs = - sign_extend (numargs, width*8) / 4;\ |
355 | } \ |
356 | } \ |
357 | } |
358 | |
359 | /* Return number of bytes at start of arglist that are not really args. */ |
360 | |
361 | #define FRAME_ARGS_SKIP 8 |
362 | |
363 | /* Put here the code to store, into a struct frame_saved_regs, |
364 | the addresses of the saved registers of frame described by FRAME_INFO. |
365 | This includes special registers such as pc and fp saved in special |
366 | ways in the stack frame. sp is even more special: |
367 | the address we return for it IS the sp for the next frame. */ |
368 | |
369 | #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ |
370 | { \ |
371 | register int regmask, regnum; \ |
372 | int localcount; \ |
373 | register CORE_ADDR enter_addr; \ |
374 | register CORE_ADDR next_addr; \ |
375 | \ |
376 | bzero (&(frame_saved_regs), sizeof (frame_saved_regs)); \ |
e91b87a3 |
377 | enter_addr = ns32k_get_enter_addr ((frame_info)->pc); \ |
3bf57d21 |
378 | if (enter_addr > 1) \ |
379 | { \ |
380 | regmask = read_memory_integer (enter_addr+1, 1) & 0xff; \ |
381 | localcount = ns32k_localcount (enter_addr); \ |
e91b87a3 |
382 | next_addr = (frame_info)->frame + localcount; \ |
3bf57d21 |
383 | for (regnum = 0; regnum < 8; regnum++, regmask >>= 1) \ |
384 | (frame_saved_regs).regs[regnum] = (regmask & 1) ? \ |
385 | (next_addr -= 4) : 0; \ |
e91b87a3 |
386 | (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 4;\ |
387 | (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4;\ |
3bf57d21 |
388 | (frame_saved_regs).regs[FP_REGNUM] = \ |
e91b87a3 |
389 | (read_memory_integer ((frame_info)->frame, 4));\ |
3bf57d21 |
390 | } \ |
391 | else if (enter_addr == 1) \ |
392 | { \ |
393 | CORE_ADDR sp = read_register (SP_REGNUM); \ |
394 | (frame_saved_regs).regs[PC_REGNUM] = sp; \ |
395 | (frame_saved_regs).regs[SP_REGNUM] = sp + 4; \ |
396 | } \ |
397 | } |
398 | |
4187119d |
399 | /* Compensate for lack of `vprintf' function. */ |
400 | #ifndef HAVE_VPRINTF |
401 | #define vprintf(format, ap) _doprnt (format, ap, stdout) |
402 | #endif /* not HAVE_VPRINTF */ |
3bf57d21 |
403 | \f |
404 | /* Things needed for making the inferior call functions. */ |
405 | |
406 | /* Push an empty stack frame, to record the current PC, etc. */ |
407 | |
408 | #define PUSH_DUMMY_FRAME \ |
409 | { register CORE_ADDR sp = read_register (SP_REGNUM);\ |
410 | register int regnum; \ |
411 | sp = push_word (sp, read_register (PC_REGNUM)); \ |
412 | sp = push_word (sp, read_register (FP_REGNUM)); \ |
413 | write_register (FP_REGNUM, sp); \ |
414 | for (regnum = 0; regnum < 8; regnum++) \ |
415 | sp = push_word (sp, read_register (regnum)); \ |
416 | write_register (SP_REGNUM, sp); \ |
417 | } |
418 | |
419 | /* Discard from the stack the innermost frame, restoring all registers. */ |
420 | |
421 | #define POP_FRAME \ |
e91b87a3 |
422 | { register FRAME frame = get_current_frame (); \ |
423 | register CORE_ADDR fp; \ |
3bf57d21 |
424 | register int regnum; \ |
425 | struct frame_saved_regs fsr; \ |
e91b87a3 |
426 | struct frame_info *fi; \ |
427 | fi = get_frame_info (frame); \ |
428 | fp = fi->frame; \ |
429 | get_frame_saved_regs (fi, &fsr); \ |
3bf57d21 |
430 | for (regnum = 0; regnum < 8; regnum++) \ |
431 | if (fsr.regs[regnum]) \ |
432 | write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \ |
433 | write_register (FP_REGNUM, read_memory_integer (fp, 4)); \ |
434 | write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \ |
435 | write_register (SP_REGNUM, fp + 8); \ |
e91b87a3 |
436 | flush_cached_frames (); \ |
437 | set_current_frame (create_new_frame (read_register (FP_REGNUM),\ |
438 | read_pc ())); } |
3bf57d21 |
439 | |
440 | /* This sequence of words is the instructions |
441 | enter 0xff,0 82 ff 00 |
442 | jsr @0x00010203 7f ae c0 01 02 03 |
443 | adjspd 0x69696969 7f a5 01 02 03 04 |
444 | bpt f2 |
445 | Note this is 16 bytes. */ |
446 | |
447 | #define CALL_DUMMY { 0x7f00ff82, 0x0201c0ae, 0x01a57f03, 0xf2040302 } |
448 | |
449 | #define CALL_DUMMY_START_OFFSET 3 |
450 | #define CALL_DUMMY_LENGTH 16 |
451 | #define CALL_DUMMY_ADDR 5 |
452 | #define CALL_DUMMY_NARGS 11 |
453 | |
454 | /* Insert the specified number of args and function address |
455 | into a call sequence of the above form stored at DUMMYNAME. */ |
456 | |
e91b87a3 |
457 | #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \ |
3bf57d21 |
458 | { \ |
459 | int flipped; \ |
460 | flipped = fun | 0xc0000000; \ |
461 | flip_bytes (&flipped, 4); \ |
462 | *((int *) (((char *) dummyname)+CALL_DUMMY_ADDR)) = flipped; \ |
463 | flipped = - nargs * 4; \ |
464 | flip_bytes (&flipped, 4); \ |
465 | *((int *) (((char *) dummyname)+CALL_DUMMY_NARGS)) = flipped; \ |
466 | } |