1 /* Definitions to make GDB run on a Sequent Symmetry under dynix 3.0,
2 with Weitek 1167 and i387 support.
3 Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
21 /* Symmetry version by Jay Vosburgh (uunet!sequent!fubar) */
23 /* I don't know if this will work for cross-debugging, even if you do get
24 a copy of the right include file. */
25 #include <machine/reg.h>
27 #define TARGET_BYTE_ORDER LITTLE_ENDIAN
29 /* Define this if the C compiler puts an underscore at the front
30 of external names before giving them to the linker. */
32 #define NAMES_HAVE_UNDERSCORE
34 /* Debugger information will be in DBX format. */
36 #define READ_DBX_FORMAT
38 /* Offset from address of function to start of its code.
39 Zero on most machines. */
41 #define FUNCTION_START_OFFSET 0
43 /* Advance PC across any function entry prologue instructions
44 to reach some "real" code. From m-i386.h */
46 #define SKIP_PROLOGUE(frompc) {(frompc) = i386_skip_prologue((frompc));}
48 /* Immediately after a function call, return the saved pc.
49 Can't always go through the frames for this because on some machines
50 the new frame is not set up until the new function executes
53 #define SAVED_PC_AFTER_CALL(frame) \
54 read_memory_integer(read_register(SP_REGNUM), 4)
56 /* I don't know the real values for these. */
57 #define TARGET_UPAGES UPAGES
58 #define TARGET_NBPG NBPG
60 /* Address of end of stack space. */
62 #define STACK_END_ADDR (0x40000000 - (TARGET_UPAGES * TARGET_NBPG))
64 /* Stack grows downward. */
68 /* Sequence of bytes for breakpoint instruction. */
70 #define BREAKPOINT {0xcc}
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. */
79 /* For Symmetry, this is really the 'leave' instruction, which */
80 /* is right before the ret */
82 #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0xc9)
84 /* Return 1 if P points to an invalid floating point value.
87 #define INVALID_FLOAT(p, len) (0)
89 /* code for 80387 fpu. Functions are from i386-dep.c, copied into
92 #define FLOAT_INFO { i386_float_info(); }
94 /* Say how long (ordinary) registers are. */
96 #define REGISTER_TYPE long
98 /* Number of machine registers */
101 /* Initializer for an array of names of registers.
102 There should be NUM_REGS strings in this initializer. */
104 /* Symmetry registers are in this weird order to match the register
105 numbers in the symbol table entries. If you change the order,
106 things will probably break mysteriously for no apparent reason.
107 Also note that the st(0)...st(7) 387 registers are represented as
110 #define REGISTER_NAMES { "eax", "edx", "ecx", "st0", "st1", \
111 "ebx", "esi", "edi", "st2", "st3", \
112 "st4", "st5", "st6", "st7", "esp", \
113 "ebp", "eip", "eflags", "fp1", "fp2", \
114 "fp3", "fp4", "fp5", "fp6", "fp7", \
115 "fp8", "fp9", "fp10", "fp11", "fp12", \
116 "fp13", "fp14", "fp15", "fp16", "fp17", \
117 "fp18", "fp19", "fp20", "fp21", "fp22", \
118 "fp23", "fp24", "fp25", "fp26", "fp27", \
119 "fp28", "fp29", "fp30", "fp31" }
121 /* Register numbers of various important registers.
122 Note that some of these values are "real" register numbers,
123 and correspond to the general registers of the machine,
124 and some are "phony" register numbers which are too large
125 to be actual register numbers as far as the user is concerned
126 but do serve to get the desired values when passed to read_register. */
128 #define FP1_REGNUM 18 /* first 1167 register */
129 #define SP_REGNUM 14 /* Contains address of top of stack */
130 #define FP_REGNUM 15 /* Contains address of executing stack frame */
131 #define PC_REGNUM 16 /* Contains program counter */
132 #define PS_REGNUM 17 /* Contains processor status */
134 /* Total amount of space needed to store our copies of the machine's
135 register state, the array `registers'. */
136 /* 10 i386 registers, 8 i387 registers, and 31 Weitek 1167 registers */
137 #define REGISTER_BYTES ((10 * 4) + (8 * 10) + (31 * 4))
139 /* Index within `registers' of the first byte of the space for
142 #define REGISTER_BYTE(N) \
143 ((N < 3) ? (N * 4) : \
144 (N < 5) ? (((N - 2) * 10) + 2) : \
145 (N < 8) ? (((N - 5) * 4) + 32) : \
146 (N < 14) ? (((N - 8) * 10) + 44) : \
147 (((N - 14) * 4) + 104))
149 /* Number of bytes of storage in the actual machine representation
150 * for register N. All registers are 4 bytes, except 387 st(0) - st(7),
151 * which are 80 bits each.
154 #define REGISTER_RAW_SIZE(N) \
161 /* Number of bytes of storage in the program's representation
162 for register N. On the vax, all regs are 4 bytes. */
164 #define REGISTER_VIRTUAL_SIZE(N) 4
166 /* Largest value REGISTER_RAW_SIZE can have. */
168 #define MAX_REGISTER_RAW_SIZE 10
170 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
172 #define MAX_REGISTER_VIRTUAL_SIZE 4
174 /* Nonzero if register N requires conversion
175 from raw format to virtual format. */
177 #define REGISTER_CONVERTIBLE(N) \
184 /* Convert data from raw format for register REGNUM
185 to virtual format for register REGNUM. */
187 #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
188 ((REGNUM < 3) ? bcopy ((FROM), (TO), 4) : \
189 (REGNUM < 5) ? i387_to_double((FROM), (TO)) : \
190 (REGNUM < 8) ? bcopy ((FROM), (TO), 4) : \
191 (REGNUM < 14) ? i387_to_double((FROM), (TO)) : \
192 bcopy ((FROM), (TO), 4))
194 /* Convert data from virtual format for register REGNUM
195 to raw format for register REGNUM. */
197 #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
198 ((REGNUM < 3) ? bcopy ((FROM), (TO), 4) : \
199 (REGNUM < 5) ? double_to_i387((FROM), (TO)) : \
200 (REGNUM < 8) ? bcopy ((FROM), (TO), 4) : \
201 (REGNUM < 14) ? double_to_i387((FROM), (TO)) : \
202 bcopy ((FROM), (TO), 4))
204 /* Return the GDB type object for the "standard" data type
205 of data in register N. */
207 #define REGISTER_VIRTUAL_TYPE(N) \
208 ((N < 3) ? builtin_type_int : \
209 (N < 5) ? builtin_type_double : \
210 (N < 8) ? builtin_type_int : \
211 (N < 14) ? builtin_type_double : \
215 /* Store the address of the place in which to copy the structure the
216 subroutine will return. This is called from call_function. */
218 #define STORE_STRUCT_RETURN(ADDR, SP) \
219 { (SP) -= sizeof (ADDR); \
220 write_memory ((SP), &(ADDR), sizeof (ADDR)); \
221 write_register(0, (ADDR)); }
223 /* Extract from an array REGBUF containing the (raw) register state
224 a function return value of type TYPE, and copy that, in virtual format,
227 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
228 symmetry_extract_return_value(TYPE, REGBUF, VALBUF)
230 /* Write into appropriate registers a function return value
231 of type TYPE, given in virtual format. */
233 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
234 write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE))
236 /* Extract from an array REGBUF containing the (raw) register state
237 the address in which a function should return its structure value,
238 as a CORE_ADDR (or an expression that can be used as one). */
240 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
243 /* Describe the pointer in each stack frame to the previous stack frame
246 /* FRAME_CHAIN takes a frame's nominal address
247 and produces the frame's chain-pointer.
249 FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address
250 and produces the nominal address of the caller frame.
252 However, if FRAME_CHAIN_VALID returns zero,
253 it means the given frame is the outermost one and has no caller.
254 In that case, FRAME_CHAIN_COMBINE is not used. */
256 /* On Symmetry, %ebp points to caller's %ebp, and the return address
257 is right on top of that.
260 #define FRAME_CHAIN(thisframe) \
261 (outside_startup_file ((thisframe)->pc) ? \
262 read_memory_integer((thisframe)->frame, 4) :\
265 #define FRAME_CHAIN_VALID(chain, thisframe) \
268 #define FRAME_CHAIN_COMBINE(chain, thisframe) (chain)
270 /* Define other aspects of the stack frame. */
272 /* A macro that tells us whether the function invocation represented
273 by FI does not have a frame on the stack associated with it. If it
274 does not, FRAMELESS is set to 1, else 0. */
275 #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \
276 (FRAMELESS) = frameless_look_for_prologue(FI)
278 #define FRAME_SAVED_PC(fi) (read_memory_integer((fi)->frame + 4, 4))
280 #define FRAME_ARGS_ADDRESS(fi) ((fi)->frame)
282 #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
284 /* Return number of args passed to a frame.
285 Can return -1, meaning no way to tell.
287 The weirdness in the "addl $imm8" case is due to gcc sometimes
288 issuing "addl $-int" after function call returns; this would
289 produce ridiculously huge arg counts. */
291 #define FRAME_NUM_ARGS(numargs, fi) \
293 int op = read_memory_integer(FRAME_SAVED_PC((fi)), 4); \
295 if ((op & 0xff) == 0x59) /* 0x59 'popl %ecx' */ \
299 else if ((op & 0xffff) == 0xc483) /* 0xc483 'addl $imm8' */ \
301 narg = ((op >> 16) & 0xff); \
302 numargs = (narg >= 128) ? -1 : narg / 4; \
304 else if ((op & 0xffff) == 0xc481) /* 0xc481 'addl $imm32' */ \
306 narg = read_memory_integer(FRAME_SAVED_PC((fi))+2,4); \
307 numargs = (narg < 0) ? -1 : narg / 4; \
315 /* Return number of bytes at start of arglist that are not really args. */
317 #define FRAME_ARGS_SKIP 8
319 /* Put here the code to store, into a struct frame_saved_regs,
320 the addresses of the saved registers of frame described by FRAME_INFO.
321 This includes special registers such as pc and fp saved in special
322 ways in the stack frame. sp is even more special:
323 the address we return for it IS the sp for the next frame. */
325 #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
326 { i386_frame_find_saved_regs ((frame_info), &(frame_saved_regs)); }
329 /* Things needed for making the inferior call functions. */
331 #define PUSH_DUMMY_FRAME \
332 { CORE_ADDR sp = read_register (SP_REGNUM); \
334 sp = push_word (sp, read_register (PC_REGNUM)); \
335 sp = push_word (sp, read_register (FP_REGNUM)); \
336 write_register (FP_REGNUM, sp); \
337 for (regnum = 0; regnum < NUM_REGS; regnum++) \
338 sp = push_word (sp, read_register (regnum)); \
339 write_register (SP_REGNUM, sp); \
344 FRAME frame = get_current_frame (); \
347 struct frame_saved_regs fsr; \
348 struct frame_info *fi; \
349 fi = get_frame_info (frame); \
351 get_frame_saved_regs (fi, &fsr); \
352 for (regnum = 0; regnum < NUM_REGS; regnum++) { \
354 adr = fsr.regs[regnum]; \
356 write_register (regnum, read_memory_integer (adr, 4)); \
358 write_register (FP_REGNUM, read_memory_integer (fp, 4)); \
359 write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \
360 write_register (SP_REGNUM, fp + 8); \
361 flush_cached_frames (); \
362 set_current_frame ( create_new_frame (read_register (FP_REGNUM), \
366 /* from i386-dep.c, worked better than my original... */
367 /* This sequence of words is the instructions
368 * call (32-bit offset)
373 #define CALL_DUMMY { 0x223344e8, 0xcc11 }
375 #define CALL_DUMMY_LENGTH 8
377 #define CALL_DUMMY_START_OFFSET 0 /* Start execution at beginning of dummy */
379 /* Insert the specified number of args and function address
380 into a call sequence of the above form stored at DUMMYNAME. */
382 #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
384 int from, to, delta, loc; \
385 loc = (int)(read_register (SP_REGNUM) - CALL_DUMMY_LENGTH); \
389 *(int *)((char *)(dummyname) + 1) = delta; \
This page took 0.03778 seconds and 4 git commands to generate.