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