]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/config/ns32k/tm-umax.h
import gdb-1999-05-25 snapshot
[thirdparty/binutils-gdb.git] / gdb / config / ns32k / tm-umax.h
CommitLineData
c906108c
SS
1/* Definitions to make GDB run on an encore under umax 4.2
2 Copyright 1987, 1989, 1991, 1993 Free Software Foundation, Inc.
3
4This file is part of GDB.
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19
20/* This is also included by tm-ns32km3.h, as well as being used by umax. */
21
22#define TARGET_BYTE_ORDER LITTLE_ENDIAN
23
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
27
28/* Offset from address of function to start of its code.
29 Zero on most machines. */
30
31#define FUNCTION_START_OFFSET 0
32
33/* Advance PC across any function entry prologue instructions
34 to reach some "real" code. */
35
b83266a0
SS
36extern CORE_ADDR umax_skip_prologue PARAMS ((CORE_ADDR));
37#define SKIP_PROLOGUE(pc) (umax_skip_prologue (pc))
c906108c
SS
38
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
42 some instructions. */
43
44#define SAVED_PC_AFTER_CALL(frame) \
45 read_memory_integer (read_register (SP_REGNUM), 4)
46
47/* Address of end of stack space. */
48
49#ifndef STACK_END_ADDR
50#define STACK_END_ADDR (0xfffff000)
51#endif
52
53/* Stack grows downward. */
54
55#define INNER_THAN(lhs,rhs) ((lhs) < (rhs))
56
57/* Sequence of bytes for breakpoint instruction. */
58
59#define BREAKPOINT {0xf2}
60
61/* Amount PC must be decremented by after a breakpoint.
62 This is often the number of bytes in BREAKPOINT
63 but not always. */
64
65#define DECR_PC_AFTER_BREAK 0
66
67#if 0 /* Disable until fixed *correctly*. */
68#ifndef INVALID_FLOAT
69#ifndef NaN
70#include <nan.h>
71#endif NaN
72
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) : \
78 NaD (*(double *) p))
79#endif /* INVALID_FLOAT */
80#endif
81
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. */
85
86#define REGISTER_SIZE 4
87
88/* Number of machine registers */
89
90#define NUM_REGS 25
91
92#define NUM_GENERAL_REGS 8
93
94/* Initializer for an array of names of registers.
95 There should be NUM_REGS strings in this initializer. */
96
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", \
100 "fsr", \
101 "l0", "l1", "l2", "l3", "xx", \
102 }
103
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. */
110
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) */
120
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))
126
127/* Index within `registers' of the first byte of the space for
128 register N. */
129
130#define REGISTER_BYTE(N) ((N) >= LP0_REGNUM ? \
131 LP0_REGNUM * 4 + ((N) - LP0_REGNUM) * 8 : (N) * 4)
132
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. */
136
137#define REGISTER_RAW_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4)
138
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. */
142
143#define REGISTER_VIRTUAL_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4)
144
145/* Largest value REGISTER_RAW_SIZE can have. */
146
147#define MAX_REGISTER_RAW_SIZE 8
148
149/* Largest value REGISTER_VIRTUAL_SIZE can have. */
150
151#define MAX_REGISTER_VIRTUAL_SIZE 8
152
153/* Return the GDB type object for the "standard" data type
154 of data in register N. */
155
156#define REGISTER_VIRTUAL_TYPE(N) \
157 (((N) < FP0_REGNUM) ? \
158 builtin_type_int : \
159 ((N) < FP0_REGNUM + 8) ? \
160 builtin_type_float : \
161 ((N) < LP0_REGNUM) ? \
162 builtin_type_int : \
163 builtin_type_double)
164
165/* Store the address of the place in which to copy the structure the
166 subroutine will return. This is called from call_function.
167
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. */
170
171#define STORE_STRUCT_RETURN(ADDR, SP)
172
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,
175 into VALBUF. */
176
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))
179
180/* Write into appropriate registers a function return value
181 of type TYPE, given in virtual format. */
182
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))
185
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). */
189
190#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
191\f
192/* Describe the pointer in each stack frame to the previous stack frame
193 (its caller). */
194
195/* FRAME_CHAIN takes a frame's nominal address
196 and produces the frame's chain-pointer. */
197
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. */
200
201#define FRAME_CHAIN(thisframe) \
202 (!inside_entry_file ((thisframe)->pc) ? \
203 read_memory_integer ((thisframe)->frame, 4) :\
204 0)
205
206/* Define other aspects of the stack frame. */
207
208#define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4))
209
210/* Compute base of arguments. */
211
212#define FRAME_ARGS_ADDRESS(fi) \
213 ((ns32k_get_enter_addr ((fi)->pc) > 1) ? \
214 ((fi)->frame) : (read_register (SP_REGNUM) - 4))
215
216#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
217
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. */
221
222extern CORE_ADDR ns32k_get_enter_addr ();
223
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. */
229
230#define FRAME_NUM_ARGS(numargs, fi) \
231{ CORE_ADDR pc; \
232 CORE_ADDR enter_addr; \
233 unsigned int insn; \
234 unsigned int addr_mode; \
235 int width; \
236 \
237 numargs = -1; \
238 enter_addr = ns32k_get_enter_addr ((fi)->pc); \
239 if (enter_addr > 0) \
240 { \
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 */ \
249 { \
250 if (insn == 0x57c) /* adjspb */ \
251 width = 1; \
252 else if (insn == 0x57d) /* adjspw */ \
253 width = 2; \
254 else if (insn == 0x57f) /* adjspd */ \
255 width = 4; \
256 numargs = read_memory_integer (pc+2,width); \
257 if (width > 1) \
258 flip_bytes (&numargs, width); \
259 numargs = - sign_extend (numargs, width*8) / 4;\
260 } \
261 } \
262}
263
264/* Return number of bytes at start of arglist that are not really args. */
265
266#define FRAME_ARGS_SKIP 8
267
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. */
273
392a587b
JM
274extern int umax_frame_num_args PARAMS ((struct frame_info *fi));
275#define FRAME_NUM_ARGS (umax_frame_num_args ((fi)))
c906108c
SS
276\f
277/* Things needed for making the inferior call functions. */
278
279/* Push an empty stack frame, to record the current PC, etc. */
280
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); \
290}
291
292/* Discard from the stack the innermost frame, restoring all registers. */
293
294#define POP_FRAME \
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; \
300 fp = frame->frame; \
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 (); \
309}
310
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
315 bpt f2
316 Note this is 16 bytes. */
317
318#define CALL_DUMMY { 0x7f00ff82, 0x0201c0ae, 0x01a57f03, 0xf2040302 }
319
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
324
325/* Insert the specified number of args and function address
326 into a call sequence of the above form stored at DUMMYNAME. */
327
328#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
329{ \
330 int flipped; \
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; \
337}