1 /* Definitions to make GDB run on an encore under umax 4.2
2 Copyright 1987, 1989, 1991, 1993 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20 /* This is also included by tm-ns32km3.h, as well as being used by umax. */
22 #define TARGET_BYTE_ORDER LITTLE_ENDIAN
24 /* Need to get function ends by adding this to epilogue address from .bf
25 record, not using x_fsize field. */
26 #define FUNCTION_EPILOGUE_SIZE 4
28 /* Offset from address of function to start of its code.
29 Zero on most machines. */
31 #define FUNCTION_START_OFFSET 0
33 /* Advance PC across any function entry prologue instructions
34 to reach some "real" code. */
36 extern CORE_ADDR umax_skip_prologue
PARAMS ((CORE_ADDR
));
37 #define SKIP_PROLOGUE(pc) (umax_skip_prologue (pc))
39 /* Immediately after a function call, return the saved pc.
40 Can't always go through the frames for this because on some machines
41 the new frame is not set up until the new function executes
44 #define SAVED_PC_AFTER_CALL(frame) \
45 read_memory_integer (read_register (SP_REGNUM), 4)
47 /* Address of end of stack space. */
49 #ifndef STACK_END_ADDR
50 #define STACK_END_ADDR (0xfffff000)
53 /* Stack grows downward. */
55 #define INNER_THAN(lhs,rhs) ((lhs) < (rhs))
57 /* Sequence of bytes for breakpoint instruction. */
59 #define BREAKPOINT {0xf2}
61 /* Amount PC must be decremented by after a breakpoint.
62 This is often the number of bytes in BREAKPOINT
65 #define DECR_PC_AFTER_BREAK 0
67 #if 0 /* Disable until fixed *correctly*. */
73 /* Return 1 if P points to an invalid floating point value. */
74 /* Surely wrong for cross-debugging. */
75 #define INVALID_FLOAT(p, s) \
76 ((s == sizeof (float))? \
77 NaF (*(float *) p) : \
79 #endif /* INVALID_FLOAT */
82 /* Say how long (ordinary) registers are. This is a piece of bogosity
83 used in push_word and a few other places; REGISTER_RAW_SIZE is the
84 real way to know how big a register is. */
86 #define REGISTER_SIZE 4
88 /* Number of machine registers */
92 #define NUM_GENERAL_REGS 8
94 /* Initializer for an array of names of registers.
95 There should be NUM_REGS strings in this initializer. */
97 #define REGISTER_NAMES {"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
98 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
99 "sp", "fp", "pc", "ps", \
101 "l0", "l1", "l2", "l3", "xx", \
104 /* Register numbers of various important registers.
105 Note that some of these values are "real" register numbers,
106 and correspond to the general registers of the machine,
107 and some are "phony" register numbers which are too large
108 to be actual register numbers as far as the user is concerned
109 but do serve to get the desired values when passed to read_register. */
111 #define R0_REGNUM 0 /* General register 0 */
112 #define FP0_REGNUM 8 /* Floating point register 0 */
113 #define SP_REGNUM 16 /* Contains address of top of stack */
114 #define AP_REGNUM FP_REGNUM
115 #define FP_REGNUM 17 /* Contains address of executing stack frame */
116 #define PC_REGNUM 18 /* Contains program counter */
117 #define PS_REGNUM 19 /* Contains processor status */
118 #define FPS_REGNUM 20 /* Floating point status register */
119 #define LP0_REGNUM 21 /* Double register 0 (same as FP0) */
121 /* Total amount of space needed to store our copies of the machine's
122 register state, the array `registers'. */
123 #define REGISTER_BYTES \
124 ((NUM_REGS - 4) * REGISTER_RAW_SIZE(R0_REGNUM) \
125 + 4 * REGISTER_RAW_SIZE(LP0_REGNUM))
127 /* Index within `registers' of the first byte of the space for
130 #define REGISTER_BYTE(N) ((N) >= LP0_REGNUM ? \
131 LP0_REGNUM * 4 + ((N) - LP0_REGNUM) * 8 : (N) * 4)
133 /* Number of bytes of storage in the actual machine representation
134 for register N. On the 32000, all regs are 4 bytes
135 except for the doubled floating registers. */
137 #define REGISTER_RAW_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4)
139 /* Number of bytes of storage in the program's representation
140 for register N. On the 32000, all regs are 4 bytes
141 except for the doubled floating registers. */
143 #define REGISTER_VIRTUAL_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4)
145 /* Largest value REGISTER_RAW_SIZE can have. */
147 #define MAX_REGISTER_RAW_SIZE 8
149 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
151 #define MAX_REGISTER_VIRTUAL_SIZE 8
153 /* Return the GDB type object for the "standard" data type
154 of data in register N. */
156 #define REGISTER_VIRTUAL_TYPE(N) \
157 (((N) < FP0_REGNUM) ? \
159 ((N) < FP0_REGNUM + 8) ? \
160 builtin_type_float : \
161 ((N) < LP0_REGNUM) ? \
165 /* Store the address of the place in which to copy the structure the
166 subroutine will return. This is called from call_function.
168 On this machine this is a no-op, because gcc isn't used on it
169 yet. So this calling convention is not used. */
171 #define STORE_STRUCT_RETURN(ADDR, SP)
173 /* Extract from an array REGBUF containing the (raw) register state
174 a function return value of type TYPE, and copy that, in virtual format,
177 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
178 memcpy (VALBUF, REGBUF+REGISTER_BYTE (TYPE_CODE (TYPE) == TYPE_CODE_FLT ? FP0_REGNUM : 0), TYPE_LENGTH (TYPE))
180 /* Write into appropriate registers a function return value
181 of type TYPE, given in virtual format. */
183 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
184 write_register_bytes (REGISTER_BYTE (TYPE_CODE (TYPE) == TYPE_CODE_FLT ? FP0_REGNUM : 0), VALBUF, TYPE_LENGTH (TYPE))
186 /* Extract from an array REGBUF containing the (raw) register state
187 the address in which a function should return its structure value,
188 as a CORE_ADDR (or an expression that can be used as one). */
190 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
192 /* Describe the pointer in each stack frame to the previous stack frame
195 /* FRAME_CHAIN takes a frame's nominal address
196 and produces the frame's chain-pointer. */
198 /* In the case of the ns32000 series, the frame's nominal address is the FP
199 value, and at that address is saved previous FP value as a 4-byte word. */
201 #define FRAME_CHAIN(thisframe) \
202 (!inside_entry_file ((thisframe)->pc) ? \
203 read_memory_integer ((thisframe)->frame, 4) :\
206 /* Define other aspects of the stack frame. */
208 #define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4))
210 /* Compute base of arguments. */
212 #define FRAME_ARGS_ADDRESS(fi) \
213 ((ns32k_get_enter_addr ((fi)->pc) > 1) ? \
214 ((fi)->frame) : (read_register (SP_REGNUM) - 4))
216 #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
218 /* Get the address of the enter opcode for this function, if it is active.
219 Returns positive address > 1 if pc is between enter/exit,
220 1 if pc before enter or after exit, 0 otherwise. */
222 extern CORE_ADDR
ns32k_get_enter_addr ();
224 /* Return number of args passed to a frame.
225 Can return -1, meaning no way to tell.
226 Encore's C compiler often reuses same area on stack for args,
227 so this will often not work properly. If the arg names
228 are known, it's likely most of them will be printed. */
230 #define FRAME_NUM_ARGS(numargs, fi) \
232 CORE_ADDR enter_addr; \
234 unsigned int addr_mode; \
238 enter_addr = ns32k_get_enter_addr ((fi)->pc); \
239 if (enter_addr > 0) \
241 pc = (enter_addr == 1) ? \
242 SAVED_PC_AFTER_CALL (fi) : \
243 FRAME_SAVED_PC (fi); \
244 insn = read_memory_integer (pc,2); \
245 addr_mode = (insn >> 11) & 0x1f; \
246 insn = insn & 0x7ff; \
247 if ((insn & 0x7fc) == 0x57c && \
248 addr_mode == 0x14) /* immediate */ \
250 if (insn == 0x57c) /* adjspb */ \
252 else if (insn == 0x57d) /* adjspw */ \
254 else if (insn == 0x57f) /* adjspd */ \
256 numargs = read_memory_integer (pc+2,width); \
258 flip_bytes (&numargs, width); \
259 numargs = - sign_extend (numargs, width*8) / 4;\
264 /* Return number of bytes at start of arglist that are not really args. */
266 #define FRAME_ARGS_SKIP 8
268 /* Put here the code to store, into a struct frame_saved_regs,
269 the addresses of the saved registers of frame described by FRAME_INFO.
270 This includes special registers such as pc and fp saved in special
271 ways in the stack frame. sp is even more special:
272 the address we return for it IS the sp for the next frame. */
274 extern int umax_frame_num_args
PARAMS ((struct frame_info
*fi
));
275 #define FRAME_NUM_ARGS (umax_frame_num_args ((fi)))
277 /* Things needed for making the inferior call functions. */
279 /* Push an empty stack frame, to record the current PC, etc. */
281 #define PUSH_DUMMY_FRAME \
282 { register CORE_ADDR sp = read_register (SP_REGNUM);\
283 register int regnum; \
284 sp = push_word (sp, read_register (PC_REGNUM)); \
285 sp = push_word (sp, read_register (FP_REGNUM)); \
286 write_register (FP_REGNUM, sp); \
287 for (regnum = 0; regnum < 8; regnum++) \
288 sp = push_word (sp, read_register (regnum)); \
289 write_register (SP_REGNUM, sp); \
292 /* Discard from the stack the innermost frame, restoring all registers. */
295 { register struct frame_info *frame = get_current_frame (); \
296 register CORE_ADDR fp; \
297 register int regnum; \
298 struct frame_saved_regs fsr; \
299 struct frame_info *fi; \
301 get_frame_saved_regs (frame, &fsr); \
302 for (regnum = 0; regnum < 8; regnum++) \
303 if (fsr.regs[regnum]) \
304 write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \
305 write_register (FP_REGNUM, read_memory_integer (fp, 4)); \
306 write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \
307 write_register (SP_REGNUM, fp + 8); \
308 flush_cached_frames (); \
311 /* This sequence of words is the instructions
312 enter 0xff,0 82 ff 00
313 jsr @0x00010203 7f ae c0 01 02 03
314 adjspd 0x69696969 7f a5 01 02 03 04
316 Note this is 16 bytes. */
318 #define CALL_DUMMY { 0x7f00ff82, 0x0201c0ae, 0x01a57f03, 0xf2040302 }
320 #define CALL_DUMMY_START_OFFSET 3
321 #define CALL_DUMMY_LENGTH 16
322 #define CALL_DUMMY_ADDR 5
323 #define CALL_DUMMY_NARGS 11
325 /* Insert the specified number of args and function address
326 into a call sequence of the above form stored at DUMMYNAME. */
328 #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
331 flipped = fun | 0xc0000000; \
332 flip_bytes (&flipped, 4); \
333 *((int *) (((char *) dummyname)+CALL_DUMMY_ADDR)) = flipped; \
334 flipped = - nargs * 4; \
335 flip_bytes (&flipped, 4); \
336 *((int *) (((char *) dummyname)+CALL_DUMMY_NARGS)) = flipped; \