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