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., 675 Mass Ave, Cambridge, MA 02139, USA. */
20 #define TARGET_BYTE_ORDER LITTLE_ENDIAN
22 /* Need to get function ends by adding this to epilogue address from .bf
23 record, not using x_fsize field. */
24 #define FUNCTION_EPILOGUE_SIZE 4
26 /* Offset from address of function to start of its code.
27 Zero on most machines. */
29 #define FUNCTION_START_OFFSET 0
31 /* Advance PC across any function entry prologue instructions
32 to reach some "real" code. */
34 #define SKIP_PROLOGUE(pc) \
35 { register unsigned char op = read_memory_integer (pc, 1); \
36 if (op == 0x82) { op = read_memory_integer (pc+2,1); \
37 if ((op & 0x80) == 0) pc += 3; \
38 else if ((op & 0xc0) == 0x80) pc += 4; \
43 /* Immediately after a function call, return the saved pc.
44 Can't always go through the frames for this because on some machines
45 the new frame is not set up until the new function executes
48 #define SAVED_PC_AFTER_CALL(frame) \
49 read_memory_integer (read_register (SP_REGNUM), 4)
51 /* Address of end of stack space. */
53 #define STACK_END_ADDR (0xfffff000)
55 /* Stack grows downward. */
59 /* Sequence of bytes for breakpoint instruction. */
61 #define BREAKPOINT {0xf2}
63 /* Amount PC must be decremented by after a breakpoint.
64 This is often the number of bytes in BREAKPOINT
67 #define DECR_PC_AFTER_BREAK 0
69 /* Nonzero if instruction at PC is a return instruction. */
71 #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0x12)
77 /* Return 1 if P points to an invalid floating point value. */
78 /* Surely wrong for cross-debugging. */
79 #define INVALID_FLOAT(p, s) \
80 ((s == sizeof (float))? \
81 NaF (*(float *) p) : \
84 /* Say how long (ordinary) registers are. */
86 #define REGISTER_TYPE long
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 /* Nonzero if register N requires conversion
154 from raw format to virtual format. */
156 #define REGISTER_CONVERTIBLE(N) 0
158 /* Convert data from raw format for register REGNUM
159 to virtual format for register REGNUM. */
161 #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
162 memcpy ((TO), (FROM), REGISTER_VIRTUAL_SIZE(REGNUM));
164 /* Convert data from virtual format for register REGNUM
165 to raw format for register REGNUM. */
167 #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
168 memcpy ((TO), (FROM), REGISTER_VIRTUAL_SIZE(REGNUM));
170 /* Return the GDB type object for the "standard" data type
171 of data in register N. */
173 #define REGISTER_VIRTUAL_TYPE(N) \
174 (((N) < FP0_REGNUM) ? \
176 ((N) < FP0_REGNUM + 8) ? \
177 builtin_type_float : \
178 ((N) < LP0_REGNUM) ? \
182 /* Store the address of the place in which to copy the structure the
183 subroutine will return. This is called from call_function.
185 On this machine this is a no-op, because gcc isn't used on it
186 yet. So this calling convention is not used. */
188 #define STORE_STRUCT_RETURN(ADDR, SP)
190 /* Extract from an array REGBUF containing the (raw) register state
191 a function return value of type TYPE, and copy that, in virtual format,
194 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
195 memcpy (VALBUF, REGBUF+REGISTER_BYTE (TYPE_CODE (TYPE) == TYPE_CODE_FLT ? FP0_REGNUM : 0), TYPE_LENGTH (TYPE))
197 /* Write into appropriate registers a function return value
198 of type TYPE, given in virtual format. */
200 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
201 write_register_bytes (REGISTER_BYTE (TYPE_CODE (TYPE) == TYPE_CODE_FLT ? FP0_REGNUM : 0), VALBUF, TYPE_LENGTH (TYPE))
203 /* Extract from an array REGBUF containing the (raw) register state
204 the address in which a function should return its structure value,
205 as a CORE_ADDR (or an expression that can be used as one). */
207 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
209 /* Describe the pointer in each stack frame to the previous stack frame
212 /* FRAME_CHAIN takes a frame's nominal address
213 and produces the frame's chain-pointer. */
215 /* In the case of the ns32000 series, the frame's nominal address is the FP
216 value, and at that address is saved previous FP value as a 4-byte word. */
218 #define FRAME_CHAIN(thisframe) \
219 (!inside_entry_file ((thisframe)->pc) ? \
220 read_memory_integer ((thisframe)->frame, 4) :\
223 /* Define other aspects of the stack frame. */
225 #define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4))
227 /* Compute base of arguments. */
229 #define FRAME_ARGS_ADDRESS(fi) \
230 ((ns32k_get_enter_addr ((fi)->pc) > 1) ? \
231 ((fi)->frame) : (read_register (SP_REGNUM) - 4))
233 #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
235 /* Get the address of the enter opcode for this function, if it is active.
236 Returns positive address > 1 if pc is between enter/exit,
237 1 if pc before enter or after exit, 0 otherwise. */
239 extern CORE_ADDR
ns32k_get_enter_addr ();
241 /* Return number of args passed to a frame.
242 Can return -1, meaning no way to tell.
243 Encore's C compiler often reuses same area on stack for args,
244 so this will often not work properly. If the arg names
245 are known, it's likely most of them will be printed. */
247 #define FRAME_NUM_ARGS(numargs, fi) \
249 CORE_ADDR enter_addr; \
251 unsigned int addr_mode; \
255 enter_addr = ns32k_get_enter_addr ((fi)->pc); \
256 if (enter_addr > 0) \
258 pc = (enter_addr == 1) ? \
259 SAVED_PC_AFTER_CALL (fi) : \
260 FRAME_SAVED_PC (fi); \
261 insn = read_memory_integer (pc,2); \
262 addr_mode = (insn >> 11) & 0x1f; \
263 insn = insn & 0x7ff; \
264 if ((insn & 0x7fc) == 0x57c && \
265 addr_mode == 0x14) /* immediate */ \
267 if (insn == 0x57c) /* adjspb */ \
269 else if (insn == 0x57d) /* adjspw */ \
271 else if (insn == 0x57f) /* adjspd */ \
273 numargs = read_memory_integer (pc+2,width); \
275 flip_bytes (&numargs, width); \
276 numargs = - sign_extend (numargs, width*8) / 4;\
281 /* Return number of bytes at start of arglist that are not really args. */
283 #define FRAME_ARGS_SKIP 8
285 /* Put here the code to store, into a struct frame_saved_regs,
286 the addresses of the saved registers of frame described by FRAME_INFO.
287 This includes special registers such as pc and fp saved in special
288 ways in the stack frame. sp is even more special:
289 the address we return for it IS the sp for the next frame. */
291 #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
293 register int regmask, regnum; \
295 register CORE_ADDR enter_addr; \
296 register CORE_ADDR next_addr; \
298 bzero (&(frame_saved_regs), sizeof (frame_saved_regs)); \
299 enter_addr = ns32k_get_enter_addr ((frame_info)->pc); \
300 if (enter_addr > 1) \
302 regmask = read_memory_integer (enter_addr+1, 1) & 0xff; \
303 localcount = ns32k_localcount (enter_addr); \
304 next_addr = (frame_info)->frame + localcount; \
305 for (regnum = 0; regnum < 8; regnum++, regmask >>= 1) \
306 (frame_saved_regs).regs[regnum] = (regmask & 1) ? \
307 (next_addr -= 4) : 0; \
308 (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 4;\
309 (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4;\
310 (frame_saved_regs).regs[FP_REGNUM] = \
311 (read_memory_integer ((frame_info)->frame, 4));\
313 else if (enter_addr == 1) \
315 CORE_ADDR sp = read_register (SP_REGNUM); \
316 (frame_saved_regs).regs[PC_REGNUM] = sp; \
317 (frame_saved_regs).regs[SP_REGNUM] = sp + 4; \
321 /* Things needed for making the inferior call functions. */
323 /* Push an empty stack frame, to record the current PC, etc. */
325 #define PUSH_DUMMY_FRAME \
326 { register CORE_ADDR sp = read_register (SP_REGNUM);\
327 register int regnum; \
328 sp = push_word (sp, read_register (PC_REGNUM)); \
329 sp = push_word (sp, read_register (FP_REGNUM)); \
330 write_register (FP_REGNUM, sp); \
331 for (regnum = 0; regnum < 8; regnum++) \
332 sp = push_word (sp, read_register (regnum)); \
333 write_register (SP_REGNUM, sp); \
336 /* Discard from the stack the innermost frame, restoring all registers. */
339 { register FRAME frame = get_current_frame (); \
340 register CORE_ADDR fp; \
341 register int regnum; \
342 struct frame_saved_regs fsr; \
343 struct frame_info *fi; \
344 fi = get_frame_info (frame); \
346 get_frame_saved_regs (fi, &fsr); \
347 for (regnum = 0; regnum < 8; regnum++) \
348 if (fsr.regs[regnum]) \
349 write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \
350 write_register (FP_REGNUM, read_memory_integer (fp, 4)); \
351 write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \
352 write_register (SP_REGNUM, fp + 8); \
353 flush_cached_frames (); \
354 set_current_frame (create_new_frame (read_register (FP_REGNUM),\
357 /* This sequence of words is the instructions
358 enter 0xff,0 82 ff 00
359 jsr @0x00010203 7f ae c0 01 02 03
360 adjspd 0x69696969 7f a5 01 02 03 04
362 Note this is 16 bytes. */
364 #define CALL_DUMMY { 0x7f00ff82, 0x0201c0ae, 0x01a57f03, 0xf2040302 }
366 #define CALL_DUMMY_START_OFFSET 3
367 #define CALL_DUMMY_LENGTH 16
368 #define CALL_DUMMY_ADDR 5
369 #define CALL_DUMMY_NARGS 11
371 /* Insert the specified number of args and function address
372 into a call sequence of the above form stored at DUMMYNAME. */
374 #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
377 flipped = fun | 0xc0000000; \
378 flip_bytes (&flipped, 4); \
379 *((int *) (((char *) dummyname)+CALL_DUMMY_ADDR)) = flipped; \
380 flipped = - nargs * 4; \
381 flip_bytes (&flipped, 4); \
382 *((int *) (((char *) dummyname)+CALL_DUMMY_NARGS)) = flipped; \
This page took 0.039678 seconds and 5 git commands to generate.