import gdb-1999-06-07 snapshot
[deliverable/binutils-gdb.git] / gdb / config / ns32k / tm-merlin.h
CommitLineData
c906108c
SS
1/* Definitions to target GDB to a merlin under utek 2.1
2 Copyright 1986, 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#define TARGET_BYTE_ORDER LITTLE_ENDIAN
21
22/* Offset from address of function to start of its code.
23 Zero on most machines. */
24
25#define FUNCTION_START_OFFSET 0
26
27/* Advance PC across any function entry prologue instructions
28 to reach some "real" code. */
29
b83266a0
SS
30extern CORE_ADDR merlin_skip_prologue PARAMS ((CORE_ADDR));
31#define SKIP_PROLOGUE(pc) (merlin_skip_prologue (pc))
c906108c
SS
32
33/* Immediately after a function call, return the saved pc.
34 Can't always go through the frames for this because on some machines
35 the new frame is not set up until the new function executes
36 some instructions. */
37
38#define SAVED_PC_AFTER_CALL(frame) \
39 read_memory_integer (read_register (SP_REGNUM), 4)
40
41/* Address of end of stack space. */
42
43#define STACK_END_ADDR (0x800000)
44
45/* Stack grows downward. */
46
47#define INNER_THAN(lhs,rhs) ((lhs) < (rhs))
48
49/* Sequence of bytes for breakpoint instruction. */
50
51#define BREAKPOINT {0xf2}
52
53/* Amount PC must be decremented by after a breakpoint.
54 This is often the number of bytes in BREAKPOINT
55 but not always. */
56
57#define DECR_PC_AFTER_BREAK 0
58
59/* Define this to say that the "svc" insn is followed by
60 codes in memory saying which kind of system call it is. */
61
62#define NS32K_SVC_IMMED_OPERANDS
63
64/* Say how long (ordinary) registers are. This is a piece of bogosity
65 used in push_word and a few other places; REGISTER_RAW_SIZE is the
66 real way to know how big a register is. */
67
68#define REGISTER_SIZE 4
69
70/* Number of machine registers */
71
72#define NUM_REGS 25
73
74#define NUM_GENERAL_REGS 8
75
76/* Initializer for an array of names of registers.
77 There should be NUM_REGS strings in this initializer. */
78
79#define REGISTER_NAMES {"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
80 "pc", "sp", "fp", "ps", \
81 "fsr", \
82 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
83 "l0", "l1", "l2", "l3", "l4", \
84 }
85
86/* Register numbers of various important registers.
87 Note that some of these values are "real" register numbers,
88 and correspond to the general registers of the machine,
89 and some are "phony" register numbers which are too large
90 to be actual register numbers as far as the user is concerned
91 but do serve to get the desired values when passed to read_register. */
92
93#define AP_REGNUM FP_REGNUM
94#define FP_REGNUM 10 /* Contains address of executing stack frame */
95#define SP_REGNUM 9 /* Contains address of top of stack */
96#define PC_REGNUM 8 /* Contains program counter */
97#define PS_REGNUM 11 /* Contains processor status */
98#define FPS_REGNUM 12 /* Floating point status register */
99#define FP0_REGNUM 13 /* Floating point register 0 */
100#define LP0_REGNUM 21 /* Double register 0 (same as FP0) */
101
102/* Total amount of space needed to store our copies of the machine's
103 register state, the array `registers'. */
104#define REGISTER_BYTES ((NUM_REGS - 4) * sizeof (int) + 4 * sizeof (double))
105
106/* Index within `registers' of the first byte of the space for
107 register N. */
108
109#define REGISTER_BYTE(N) ((N) >= LP0_REGNUM ? \
110 LP0_REGNUM * 4 + ((N) - LP0_REGNUM) * 8 : (N) * 4)
111
112/* Number of bytes of storage in the actual machine representation
113 for register N. On the 32000, all regs are 4 bytes
114 except for the doubled floating registers. */
115
116#define REGISTER_RAW_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4)
117
118/* Number of bytes of storage in the program's representation
119 for register N. On the 32000, all regs are 4 bytes
120 except for the doubled floating registers. */
121
122#define REGISTER_VIRTUAL_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4)
123
124/* Largest value REGISTER_RAW_SIZE can have. */
125
126#define MAX_REGISTER_RAW_SIZE 8
127
128/* Largest value REGISTER_VIRTUAL_SIZE can have. */
129
130#define MAX_REGISTER_VIRTUAL_SIZE 8
131
132/* Return the GDB type object for the "standard" data type
133 of data in register N. */
134
135#define REGISTER_VIRTUAL_TYPE(N) \
136 ((N) >= FP0_REGNUM ? \
137 ((N) >= LP0_REGNUM ? \
138 builtin_type_double \
139 : builtin_type_float) \
140 : builtin_type_int)
141
142/* Store the address of the place in which to copy the structure the
143 subroutine will return. This is called from call_function.
144
145 On this machine this is a no-op, as gcc doesn't run on it yet.
146 This calling convention is not used. */
147
148#define STORE_STRUCT_RETURN(ADDR, SP)
149
150/* Extract from an array REGBUF containing the (raw) register state
151 a function return value of type TYPE, and copy that, in virtual format,
152 into VALBUF. */
153
154#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
155 memcpy (VALBUF, REGBUF, TYPE_LENGTH (TYPE))
156
157/* Write into appropriate registers a function return value
158 of type TYPE, given in virtual format. */
159
160#define STORE_RETURN_VALUE(TYPE,VALBUF) \
161 write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE))
162
163/* Extract from an array REGBUF containing the (raw) register state
164 the address in which a function should return its structure value,
165 as a CORE_ADDR (or an expression that can be used as one). */
166
167#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
168\f
169/* Describe the pointer in each stack frame to the previous stack frame
170 (its caller). */
171
172/* FRAME_CHAIN takes a frame's nominal address
173 and produces the frame's chain-pointer. */
174
175/* In the case of the Merlin, the frame's nominal address is the FP value,
176 and at that address is saved previous FP value as a 4-byte word. */
177
178#define FRAME_CHAIN(thisframe) \
179 (!inside_entry_file ((thisframe)->pc) ? \
180 read_memory_integer ((thisframe)->frame, 4) :\
181 0)
182
183/* Define other aspects of the stack frame. */
184
185#define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4))
186
187/* compute base of arguments */
188#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame)
189
190#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
191
192/* Return number of args passed to a frame.
193 Can return -1, meaning no way to tell. */
194
392a587b 195extern int merlin_frame_num_args PARAMS ((struct frame_info *fi));
cce74817 196#define FRAME_NUM_ARGS(fi) (merlin_frame_num_args ((fi)))
c906108c
SS
197
198/* Return number of bytes at start of arglist that are not really args. */
199
200#define FRAME_ARGS_SKIP 8
201
202/* Put here the code to store, into a struct frame_saved_regs,
203 the addresses of the saved registers of frame described by FRAME_INFO.
204 This includes special registers such as pc and fp saved in special
205 ways in the stack frame. sp is even more special:
206 the address we return for it IS the sp for the next frame. */
207
208#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
209{ int regmask,regnum; \
210 int localcount; \
211 CORE_ADDR enter_addr; \
212 CORE_ADDR next_addr; \
213 \
214 enter_addr = get_pc_function_start ((frame_info)->pc); \
215 regmask = read_memory_integer (enter_addr+1, 1); \
216 localcount = ns32k_localcount (enter_addr); \
217 next_addr = (frame_info)->frame + localcount; \
218 for (regnum = 0; regnum < 8; regnum++, regmask >>= 1) \
219 (frame_saved_regs).regs[regnum] \
220 = (regmask & 1) ? (next_addr -= 4) : 0; \
221 (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 4; \
222 (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4; \
223 (frame_saved_regs).regs[FP_REGNUM] \
224 = read_memory_integer ((frame_info)->frame, 4); }
225
226\f
227/* Things needed for making the inferior call functions. */
228
229/* Push an empty stack frame, to record the current PC, etc. */
230
231#define PUSH_DUMMY_FRAME \
232{ register CORE_ADDR sp = read_register (SP_REGNUM); \
233 register int regnum; \
234 sp = push_word (sp, read_register (PC_REGNUM)); \
235 sp = push_word (sp, read_register (FP_REGNUM)); \
236 write_register (FP_REGNUM, sp); \
237 for (regnum = 0; regnum < 8; regnum++) \
238 sp = push_word (sp, read_register (regnum)); \
239 write_register (SP_REGNUM, sp); \
240}
241
242/* Discard from the stack the innermost frame, restoring all registers. */
243
244#define POP_FRAME \
245{ register struct frame_info *frame = get_current_frame (); \
246 register CORE_ADDR fp; \
247 register int regnum; \
248 struct frame_saved_regs fsr; \
249 struct frame_info *fi; \
250 fp = frame->frame; \
251 get_frame_saved_regs (frame, &fsr); \
252 for (regnum = 0; regnum < 8; regnum++) \
253 if (fsr.regs[regnum]) \
254 write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \
255 write_register (FP_REGNUM, read_memory_integer (fp, 4)); \
256 write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \
257 write_register (SP_REGNUM, fp + 8); \
258 flush_cached_frames (); \
259}
260
261/* This sequence of words is the instructions
262 enter 0xff,0 82 ff 00
263 jsr @0x00010203 7f ae c0 01 02 03
264 adjspd 0x69696969 7f a5 01 02 03 04
265 bpt f2
266 Note this is 16 bytes. */
267
268#define CALL_DUMMY { 0x7f00ff82, 0x0201c0ae, 0x01a57f03, 0xf2040302 }
269
270#define CALL_DUMMY_START_OFFSET 3
271#define CALL_DUMMY_LENGTH 16
272#define CALL_DUMMY_ADDR 5
273#define CALL_DUMMY_NARGS 11
274
275/* Insert the specified number of args and function address
276 into a call sequence of the above form stored at DUMMYNAME. */
277
278#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
279{ int flipped = fun | 0xc0000000; \
280 flip_bytes (&flipped, 4); \
281 *((int *) (((char *) dummyname)+CALL_DUMMY_ADDR)) = flipped; \
282 flipped = - nargs * 4; \
283 flip_bytes (&flipped, 4); \
284 *((int *) (((char *) dummyname)+CALL_DUMMY_NARGS)) = flipped; \
285}
This page took 0.038784 seconds and 4 git commands to generate.