1 /* Definitions to target GDB to a merlin under utek 2.1
2 Copyright (C) 1986, 1987, 1989 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 /* I don't know if this will work for cross-debugging, even if you do get
23 a copy of the right include file. */
24 #include <machine/reg.h>
26 /* Define this if the C compiler puts an underscore at the front
27 of external names before giving them to the linker. */
29 #define NAMES_HAVE_UNDERSCORE
31 /* Debugger information will be in DBX format. */
33 #define READ_DBX_FORMAT
35 /* Offset from address of function to start of its code.
36 Zero on most machines. */
38 #define FUNCTION_START_OFFSET 0
40 /* Advance PC across any function entry prologue instructions
41 to reach some "real" code. */
43 #define SKIP_PROLOGUE(pc) \
44 { register int op = read_memory_integer (pc, 1); \
46 { op = read_memory_integer (pc+2,1); \
47 if ((op & 0x80) == 0) pc += 3; \
48 else if ((op & 0xc0) == 0x80) pc += 4; \
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
57 #define SAVED_PC_AFTER_CALL(frame) \
58 read_memory_integer (read_register (SP_REGNUM), 4)
60 /* Address of end of stack space. */
62 #define STACK_END_ADDR (0x800000)
64 /* Stack grows downward. */
68 /* Sequence of bytes for breakpoint instruction. */
70 #define BREAKPOINT {0xf2}
72 /* Amount PC must be decremented by after a breakpoint.
73 This is often the number of bytes in BREAKPOINT
76 #define DECR_PC_AFTER_BREAK 0
78 /* Nonzero if instruction at PC is a return instruction. */
80 #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0x12)
82 /* Return 1 if P points to an invalid floating point value. */
84 #define INVALID_FLOAT(p, len) 0
86 /* Define this to say that the "svc" insn is followed by
87 codes in memory saying which kind of system call it is. */
89 #define NS32K_SVC_IMMED_OPERANDS
91 /* Say how long (ordinary) registers are. */
93 #define REGISTER_TYPE long
95 /* Number of machine registers */
99 #define NUM_GENERAL_REGS 8
101 /* Initializer for an array of names of registers.
102 There should be NUM_REGS strings in this initializer. */
104 #define REGISTER_NAMES {"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
105 "pc", "sp", "fp", "ps", \
107 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
108 "l0", "l1", "l2", "l3", "l4", \
111 /* Register numbers of various important registers.
112 Note that some of these values are "real" register numbers,
113 and correspond to the general registers of the machine,
114 and some are "phony" register numbers which are too large
115 to be actual register numbers as far as the user is concerned
116 but do serve to get the desired values when passed to read_register. */
118 #define AP_REGNUM FP_REGNUM
119 #define FP_REGNUM 10 /* Contains address of executing stack frame */
120 #define SP_REGNUM 9 /* Contains address of top of stack */
121 #define PC_REGNUM 8 /* Contains program counter */
122 #define PS_REGNUM 11 /* Contains processor status */
123 #define FPS_REGNUM 12 /* Floating point status register */
124 #define FP0_REGNUM 13 /* Floating point register 0 */
125 #define LP0_REGNUM 21 /* Double register 0 (same as FP0) */
127 /* Total amount of space needed to store our copies of the machine's
128 register state, the array `registers'. */
129 #define REGISTER_BYTES ((NUM_REGS - 4) * sizeof (int) + 4 * sizeof (double))
131 /* Index within `registers' of the first byte of the space for
134 #define REGISTER_BYTE(N) ((N) >= LP0_REGNUM ? \
135 LP0_REGNUM * 4 + ((N) - LP0_REGNUM) * 8 : (N) * 4)
137 /* Number of bytes of storage in the actual machine representation
138 for register N. On the 32000, all regs are 4 bytes
139 except for the doubled floating registers. */
141 #define REGISTER_RAW_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4)
143 /* Number of bytes of storage in the program's representation
144 for register N. On the 32000, all regs are 4 bytes
145 except for the doubled floating registers. */
147 #define REGISTER_VIRTUAL_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4)
149 /* Largest value REGISTER_RAW_SIZE can have. */
151 #define MAX_REGISTER_RAW_SIZE 8
153 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
155 #define MAX_REGISTER_VIRTUAL_SIZE 8
157 /* Nonzero if register N requires conversion
158 from raw format to virtual format. */
160 #define REGISTER_CONVERTIBLE(N) 0
162 /* Convert data from raw format for register REGNUM
163 to virtual format for register REGNUM. */
165 #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
166 bcopy ((FROM), (TO), REGISTER_VIRTUAL_SIZE(REGNUM));
168 /* Convert data from virtual format for register REGNUM
169 to raw format for register REGNUM. */
171 #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
172 bcopy ((FROM), (TO), REGISTER_VIRTUAL_SIZE(REGNUM));
174 /* Return the GDB type object for the "standard" data type
175 of data in register N. */
177 #define REGISTER_VIRTUAL_TYPE(N) \
178 ((N) >= FP0_REGNUM ? \
179 ((N) >= LP0_REGNUM ? \
180 builtin_type_double \
181 : builtin_type_float) \
184 /* Store the address of the place in which to copy the structure the
185 subroutine will return. This is called from call_function.
187 On this machine this is a no-op, as gcc doesn't run on it yet.
188 This calling convention is not used. */
190 #define STORE_STRUCT_RETURN(ADDR, SP)
192 /* Extract from an array REGBUF containing the (raw) register state
193 a function return value of type TYPE, and copy that, in virtual format,
196 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
197 bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE))
199 /* Write into appropriate registers a function return value
200 of type TYPE, given in virtual format. */
202 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
203 write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE))
205 /* Extract from an array REGBUF containing the (raw) register state
206 the address in which a function should return its structure value,
207 as a CORE_ADDR (or an expression that can be used as one). */
209 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
211 /* Describe the pointer in each stack frame to the previous stack frame
214 /* FRAME_CHAIN takes a frame's nominal address
215 and produces the frame's chain-pointer.
217 FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address
218 and produces the nominal address of the caller frame.
220 However, if FRAME_CHAIN_VALID returns zero,
221 it means the given frame is the outermost one and has no caller.
222 In that case, FRAME_CHAIN_COMBINE is not used. */
224 /* In the case of the Merlin, the frame's nominal address is the FP value,
225 and at that address is saved previous FP value as a 4-byte word. */
227 #define FRAME_CHAIN(thisframe) \
228 (outside_startup_file ((thisframe)->pc) ? \
229 read_memory_integer ((thisframe)->frame, 4) :\
232 #define FRAME_CHAIN_VALID(chain, thisframe) \
233 (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe))))
235 #define FRAME_CHAIN_COMBINE(chain, thisframe) (chain)
237 /* Define other aspects of the stack frame. */
239 #define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4))
241 /* compute base of arguments */
242 #define FRAME_ARGS_ADDRESS(fi) ((fi)->frame)
244 #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
246 /* Return number of args passed to a frame.
247 Can return -1, meaning no way to tell. */
249 #define FRAME_NUM_ARGS(numargs, fi) \
255 pc = FRAME_SAVED_PC (fi); \
256 insn = read_memory_integer (pc,2); \
257 addr_mode = (insn >> 11) & 0x1f; \
258 insn = insn & 0x7ff; \
259 if ((insn & 0x7fc) == 0x57c \
260 && addr_mode == 0x14) /* immediate */ \
261 { if (insn == 0x57c) /* adjspb */ \
263 else if (insn == 0x57d) /* adjspw */ \
265 else if (insn == 0x57f) /* adjspd */ \
267 numargs = read_memory_integer (pc+2,width); \
269 flip_bytes (&numargs, width); \
270 numargs = - sign_extend (numargs, width*8) / 4; } \
274 /* Return number of bytes at start of arglist that are not really args. */
276 #define FRAME_ARGS_SKIP 8
278 /* Put here the code to store, into a struct frame_saved_regs,
279 the addresses of the saved registers of frame described by FRAME_INFO.
280 This includes special registers such as pc and fp saved in special
281 ways in the stack frame. sp is even more special:
282 the address we return for it IS the sp for the next frame. */
284 #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
285 { int regmask,regnum; \
287 CORE_ADDR enter_addr; \
288 CORE_ADDR next_addr; \
290 enter_addr = get_pc_function_start ((frame_info)->pc); \
291 regmask = read_memory_integer (enter_addr+1, 1); \
292 localcount = ns32k_localcount (enter_addr); \
293 next_addr = (frame_info)->frame + localcount; \
294 for (regnum = 0; regnum < 8; regnum++, regmask >>= 1) \
295 (frame_saved_regs).regs[regnum] \
296 = (regmask & 1) ? (next_addr -= 4) : 0; \
297 (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 4; \
298 (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4; \
299 (frame_saved_regs).regs[FP_REGNUM] \
300 = read_memory_integer ((frame_info)->frame, 4); }
303 /* Things needed for making the inferior call functions. */
305 /* Push an empty stack frame, to record the current PC, etc. */
307 #define PUSH_DUMMY_FRAME \
308 { register CORE_ADDR sp = read_register (SP_REGNUM); \
309 register int regnum; \
310 sp = push_word (sp, read_register (PC_REGNUM)); \
311 sp = push_word (sp, read_register (FP_REGNUM)); \
312 write_register (FP_REGNUM, sp); \
313 for (regnum = 0; regnum < 8; regnum++) \
314 sp = push_word (sp, read_register (regnum)); \
315 write_register (SP_REGNUM, sp); \
318 /* Discard from the stack the innermost frame, restoring all registers. */
321 { register FRAME frame = get_current_frame (); \
322 register CORE_ADDR fp; \
323 register int regnum; \
324 struct frame_saved_regs fsr; \
325 struct frame_info *fi; \
326 fi = get_frame_info (frame); \
328 get_frame_saved_regs (fi, &fsr); \
329 for (regnum = 0; regnum < 8; regnum++) \
330 if (fsr.regs[regnum]) \
331 write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \
332 write_register (FP_REGNUM, read_memory_integer (fp, 4)); \
333 write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \
334 write_register (SP_REGNUM, fp + 8); \
335 flush_cached_frames (); \
336 set_current_frame (create_new_frame (read_register (FP_REGNUM),\
340 /* This sequence of words is the instructions
341 enter 0xff,0 82 ff 00
342 jsr @0x00010203 7f ae c0 01 02 03
343 adjspd 0x69696969 7f a5 01 02 03 04
345 Note this is 16 bytes. */
347 #define CALL_DUMMY { 0x7f00ff82, 0x0201c0ae, 0x01a57f03, 0xf2040302 }
349 #define CALL_DUMMY_START_OFFSET 3
350 #define CALL_DUMMY_LENGTH 16
351 #define CALL_DUMMY_ADDR 5
352 #define CALL_DUMMY_NARGS 11
354 /* Insert the specified number of args and function address
355 into a call sequence of the above form stored at DUMMYNAME. */
357 #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
358 { int flipped = fun | 0xc0000000; \
359 flip_bytes (&flipped, 4); \
360 *((int *) (((char *) dummyname)+CALL_DUMMY_ADDR)) = flipped; \
361 flipped = - nargs * 4; \
362 flip_bytes (&flipped, 4); \
363 *((int *) (((char *) dummyname)+CALL_DUMMY_NARGS)) = flipped; \
This page took 0.051608 seconds and 4 git commands to generate.