Welcome cvs to the big time.
[deliverable/binutils-gdb.git] / gdb / tm-umax.h
1 /* Definitions to make GDB run on an encore under umax 4.2
2 Copyright (C) 1987, 1989 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
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.
10
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.
15
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20 #define TARGET_BYTE_ORDER LITTLE_ENDIAN
21
22 /* Define this if the C compiler puts an underscore at the front
23 of external names before giving them to the linker. */
24
25 #define NAMES_HAVE_UNDERSCORE
26
27 /* Exec files and symbol tables are in COFF format */
28
29 #define COFF_FORMAT
30
31 /* Need to get function ends by adding this to epilogue address from .bf
32 record, not using x_fsize field. */
33 #define FUNCTION_EPILOGUE_SIZE 4
34
35 /* Offset from address of function to start of its code.
36 Zero on most machines. */
37
38 #define FUNCTION_START_OFFSET 0
39
40 /* Advance PC across any function entry prologue instructions
41 to reach some "real" code. */
42
43 #define SKIP_PROLOGUE(pc) \
44 { register unsigned char op = read_memory_integer (pc, 1); \
45 if (op == 0x82) { op = read_memory_integer (pc+2,1); \
46 if ((op & 0x80) == 0) pc += 3; \
47 else if ((op & 0xc0) == 0x80) pc += 4; \
48 else pc += 6; \
49 } \
50 }
51
52 /* Immediately after a function call, return the saved pc.
53 Can't always go through the frames for this because on some machines
54 the new frame is not set up until the new function executes
55 some instructions. */
56
57 #define SAVED_PC_AFTER_CALL(frame) \
58 read_memory_integer (read_register (SP_REGNUM), 4)
59
60 /* Address of end of stack space. */
61
62 #define STACK_END_ADDR (0xfffff000)
63
64 /* Stack grows downward. */
65
66 #define INNER_THAN <
67
68 /* Sequence of bytes for breakpoint instruction. */
69
70 #define BREAKPOINT {0xf2}
71
72 /* Amount PC must be decremented by after a breakpoint.
73 This is often the number of bytes in BREAKPOINT
74 but not always. */
75
76 #define DECR_PC_AFTER_BREAK 0
77
78 /* Nonzero if instruction at PC is a return instruction. */
79
80 #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0x12)
81
82 #ifndef NaN
83 #include <nan.h>
84 #endif NaN
85
86 /* Return 1 if P points to an invalid floating point value. */
87 /* Surely wrong for cross-debugging. */
88 #define INVALID_FLOAT(p, s) \
89 ((s == sizeof (float))? \
90 NaF (*(float *) p) : \
91 NaD (*(double *) p))
92
93 /* Say how long (ordinary) registers are. */
94
95 #define REGISTER_TYPE long
96
97 /* Number of machine registers */
98
99 #define NUM_REGS 25
100
101 #define NUM_GENERAL_REGS 8
102
103 /* Initializer for an array of names of registers.
104 There should be NUM_REGS strings in this initializer. */
105
106 #define REGISTER_NAMES {"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
107 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
108 "sp", "fp", "pc", "ps", \
109 "fsr", \
110 "l0", "l1", "l2", "l3", "xx", \
111 }
112
113 /* Register numbers of various important registers.
114 Note that some of these values are "real" register numbers,
115 and correspond to the general registers of the machine,
116 and some are "phony" register numbers which are too large
117 to be actual register numbers as far as the user is concerned
118 but do serve to get the desired values when passed to read_register. */
119
120 #define FP0_REGNUM 8 /* Floating point register 0 */
121 #define SP_REGNUM 16 /* Contains address of top of stack */
122 #define AP_REGNUM FP_REGNUM
123 #define FP_REGNUM 17 /* Contains address of executing stack frame */
124 #define PC_REGNUM 18 /* Contains program counter */
125 #define PS_REGNUM 19 /* Contains processor status */
126 #define FPS_REGNUM 20 /* Floating point status register */
127 #define LP0_REGNUM 21 /* Double register 0 (same as FP0) */
128
129 /* Total amount of space needed to store our copies of the machine's
130 register state, the array `registers'. */
131 #define REGISTER_BYTES ((NUM_REGS - 4) * sizeof (int) + 4 * sizeof (double))
132
133 /* Index within `registers' of the first byte of the space for
134 register N. */
135
136 #define REGISTER_BYTE(N) ((N) >= LP0_REGNUM ? \
137 LP0_REGNUM * 4 + ((N) - LP0_REGNUM) * 8 : (N) * 4)
138
139 /* Number of bytes of storage in the actual machine representation
140 for register N. On the 32000, all regs are 4 bytes
141 except for the doubled floating registers. */
142
143 #define REGISTER_RAW_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4)
144
145 /* Number of bytes of storage in the program's representation
146 for register N. On the 32000, all regs are 4 bytes
147 except for the doubled floating registers. */
148
149 #define REGISTER_VIRTUAL_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4)
150
151 /* Largest value REGISTER_RAW_SIZE can have. */
152
153 #define MAX_REGISTER_RAW_SIZE 8
154
155 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
156
157 #define MAX_REGISTER_VIRTUAL_SIZE 8
158
159 /* Nonzero if register N requires conversion
160 from raw format to virtual format. */
161
162 #define REGISTER_CONVERTIBLE(N) 0
163
164 /* Convert data from raw format for register REGNUM
165 to virtual format for register REGNUM. */
166
167 #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
168 bcopy ((FROM), (TO), REGISTER_VIRTUAL_SIZE(REGNUM));
169
170 /* Convert data from virtual format for register REGNUM
171 to raw format for register REGNUM. */
172
173 #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
174 bcopy ((FROM), (TO), REGISTER_VIRTUAL_SIZE(REGNUM));
175
176 /* Return the GDB type object for the "standard" data type
177 of data in register N. */
178
179 #define REGISTER_VIRTUAL_TYPE(N) \
180 (((N) < FP0_REGNUM) ? \
181 builtin_type_int : \
182 ((N) < FP0_REGNUM + 8) ? \
183 builtin_type_float : \
184 ((N) < LP0_REGNUM) ? \
185 builtin_type_int : \
186 builtin_type_double)
187
188 /* Store the address of the place in which to copy the structure the
189 subroutine will return. This is called from call_function.
190
191 On this machine this is a no-op, because gcc isn't used on it
192 yet. So this calling convention is not used. */
193
194 #define STORE_STRUCT_RETURN(ADDR, SP)
195
196 /* Extract from an array REGBUF containing the (raw) register state
197 a function return value of type TYPE, and copy that, in virtual format,
198 into VALBUF. */
199
200 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
201 bcopy (REGBUF+REGISTER_BYTE (TYPE_CODE (TYPE) == TYPE_CODE_FLT ? FP0_REGNUM : 0), VALBUF, TYPE_LENGTH (TYPE))
202
203 /* Write into appropriate registers a function return value
204 of type TYPE, given in virtual format. */
205
206 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
207 write_register_bytes (REGISTER_BYTE (TYPE_CODE (TYPE) == TYPE_CODE_FLT ? FP0_REGNUM : 0), VALBUF, TYPE_LENGTH (TYPE))
208
209 /* Extract from an array REGBUF containing the (raw) register state
210 the address in which a function should return its structure value,
211 as a CORE_ADDR (or an expression that can be used as one). */
212
213 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
214 \f
215 /* Describe the pointer in each stack frame to the previous stack frame
216 (its caller). */
217
218 /* FRAME_CHAIN takes a frame's nominal address
219 and produces the frame's chain-pointer.
220
221 FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address
222 and produces the nominal address of the caller frame.
223
224 However, if FRAME_CHAIN_VALID returns zero,
225 it means the given frame is the outermost one and has no caller.
226 In that case, FRAME_CHAIN_COMBINE is not used. */
227
228 /* In the case of the ns32000 series, the frame's nominal address is the FP
229 value, and at that address is saved previous FP value as a 4-byte word. */
230
231 #define FRAME_CHAIN(thisframe) \
232 (outside_startup_file ((thisframe)->pc) ? \
233 read_memory_integer ((thisframe)->frame, 4) :\
234 0)
235
236 #define FRAME_CHAIN_VALID(chain, thisframe) \
237 (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe))))
238
239 #define FRAME_CHAIN_COMBINE(chain, thisframe) (chain)
240
241 /* Define other aspects of the stack frame. */
242
243 #define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4))
244
245 /* Compute base of arguments. */
246
247 #define FRAME_ARGS_ADDRESS(fi) \
248 ((ns32k_get_enter_addr ((fi)->pc) > 1) ? \
249 ((fi)->frame) : (read_register (SP_REGNUM) - 4))
250
251 #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
252
253 /* Get the address of the enter opcode for this function, if it is active.
254 Returns positive address > 1 if pc is between enter/exit,
255 1 if pc before enter or after exit, 0 otherwise. */
256
257 #ifndef CORE_ADDR
258 #include "defs.h" /* Make sure CORE_ADDR is defined. */
259 #endif
260
261 extern CORE_ADDR ns32k_get_enter_addr ();
262
263 /* Return number of args passed to a frame.
264 Can return -1, meaning no way to tell.
265 Encore's C compiler often reuses same area on stack for args,
266 so this will often not work properly. If the arg names
267 are known, it's likely most of them will be printed. */
268
269 #define FRAME_NUM_ARGS(numargs, fi) \
270 { CORE_ADDR pc; \
271 CORE_ADDR enter_addr; \
272 unsigned int insn; \
273 unsigned int addr_mode; \
274 int width; \
275 \
276 numargs = -1; \
277 enter_addr = ns32k_get_enter_addr ((fi)->pc); \
278 if (enter_addr > 0) \
279 { \
280 pc = (enter_addr == 1) ? \
281 SAVED_PC_AFTER_CALL (fi) : \
282 FRAME_SAVED_PC (fi); \
283 insn = read_memory_integer (pc,2); \
284 addr_mode = (insn >> 11) & 0x1f; \
285 insn = insn & 0x7ff; \
286 if ((insn & 0x7fc) == 0x57c && \
287 addr_mode == 0x14) /* immediate */ \
288 { \
289 if (insn == 0x57c) /* adjspb */ \
290 width = 1; \
291 else if (insn == 0x57d) /* adjspw */ \
292 width = 2; \
293 else if (insn == 0x57f) /* adjspd */ \
294 width = 4; \
295 numargs = read_memory_integer (pc+2,width); \
296 if (width > 1) \
297 flip_bytes (&numargs, width); \
298 numargs = - sign_extend (numargs, width*8) / 4;\
299 } \
300 } \
301 }
302
303 /* Return number of bytes at start of arglist that are not really args. */
304
305 #define FRAME_ARGS_SKIP 8
306
307 /* Put here the code to store, into a struct frame_saved_regs,
308 the addresses of the saved registers of frame described by FRAME_INFO.
309 This includes special registers such as pc and fp saved in special
310 ways in the stack frame. sp is even more special:
311 the address we return for it IS the sp for the next frame. */
312
313 #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
314 { \
315 register int regmask, regnum; \
316 int localcount; \
317 register CORE_ADDR enter_addr; \
318 register CORE_ADDR next_addr; \
319 \
320 bzero (&(frame_saved_regs), sizeof (frame_saved_regs)); \
321 enter_addr = ns32k_get_enter_addr ((frame_info)->pc); \
322 if (enter_addr > 1) \
323 { \
324 regmask = read_memory_integer (enter_addr+1, 1) & 0xff; \
325 localcount = ns32k_localcount (enter_addr); \
326 next_addr = (frame_info)->frame + localcount; \
327 for (regnum = 0; regnum < 8; regnum++, regmask >>= 1) \
328 (frame_saved_regs).regs[regnum] = (regmask & 1) ? \
329 (next_addr -= 4) : 0; \
330 (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 4;\
331 (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4;\
332 (frame_saved_regs).regs[FP_REGNUM] = \
333 (read_memory_integer ((frame_info)->frame, 4));\
334 } \
335 else if (enter_addr == 1) \
336 { \
337 CORE_ADDR sp = read_register (SP_REGNUM); \
338 (frame_saved_regs).regs[PC_REGNUM] = sp; \
339 (frame_saved_regs).regs[SP_REGNUM] = sp + 4; \
340 } \
341 }
342 \f
343 /* Things needed for making the inferior call functions. */
344
345 /* Push an empty stack frame, to record the current PC, etc. */
346
347 #define PUSH_DUMMY_FRAME \
348 { register CORE_ADDR sp = read_register (SP_REGNUM);\
349 register int regnum; \
350 sp = push_word (sp, read_register (PC_REGNUM)); \
351 sp = push_word (sp, read_register (FP_REGNUM)); \
352 write_register (FP_REGNUM, sp); \
353 for (regnum = 0; regnum < 8; regnum++) \
354 sp = push_word (sp, read_register (regnum)); \
355 write_register (SP_REGNUM, sp); \
356 }
357
358 /* Discard from the stack the innermost frame, restoring all registers. */
359
360 #define POP_FRAME \
361 { register FRAME frame = get_current_frame (); \
362 register CORE_ADDR fp; \
363 register int regnum; \
364 struct frame_saved_regs fsr; \
365 struct frame_info *fi; \
366 fi = get_frame_info (frame); \
367 fp = fi->frame; \
368 get_frame_saved_regs (fi, &fsr); \
369 for (regnum = 0; regnum < 8; regnum++) \
370 if (fsr.regs[regnum]) \
371 write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \
372 write_register (FP_REGNUM, read_memory_integer (fp, 4)); \
373 write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \
374 write_register (SP_REGNUM, fp + 8); \
375 flush_cached_frames (); \
376 set_current_frame (create_new_frame (read_register (FP_REGNUM),\
377 read_pc ())); }
378
379 /* This sequence of words is the instructions
380 enter 0xff,0 82 ff 00
381 jsr @0x00010203 7f ae c0 01 02 03
382 adjspd 0x69696969 7f a5 01 02 03 04
383 bpt f2
384 Note this is 16 bytes. */
385
386 #define CALL_DUMMY { 0x7f00ff82, 0x0201c0ae, 0x01a57f03, 0xf2040302 }
387
388 #define CALL_DUMMY_START_OFFSET 3
389 #define CALL_DUMMY_LENGTH 16
390 #define CALL_DUMMY_ADDR 5
391 #define CALL_DUMMY_NARGS 11
392
393 /* Insert the specified number of args and function address
394 into a call sequence of the above form stored at DUMMYNAME. */
395
396 #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
397 { \
398 int flipped; \
399 flipped = fun | 0xc0000000; \
400 flip_bytes (&flipped, 4); \
401 *((int *) (((char *) dummyname)+CALL_DUMMY_ADDR)) = flipped; \
402 flipped = - nargs * 4; \
403 flip_bytes (&flipped, 4); \
404 *((int *) (((char *) dummyname)+CALL_DUMMY_NARGS)) = flipped; \
405 }
This page took 0.11277 seconds and 4 git commands to generate.