Tue Jan 19 09:06:14 1993 Ian Lance Taylor (ian@cygnus.com)
[deliverable/binutils-gdb.git] / gdb / tm-symmetry.h
1 /* Target machine definitions for GDB on a Sequent Symmetry under dynix 3.0,
2 with Weitek 1167 and i387 support.
3 Copyright 1986, 1987, 1989, 1991, 1992 Free Software Foundation, Inc.
4 Symmetry version by Jay Vosburgh (uunet!sequent!fubar).
5
6 This file is part of GDB.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
21
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>
25
26 #define TARGET_BYTE_ORDER LITTLE_ENDIAN
27
28 /* Define this if the C compiler puts an underscore at the front
29 of external names before giving them to the linker. */
30
31 #define NAMES_HAVE_UNDERSCORE
32
33 /* Offset from address of function to start of its code.
34 Zero on most machines. */
35
36 #define FUNCTION_START_OFFSET 0
37
38 /* Advance PC across any function entry prologue instructions
39 to reach some "real" code. From m-i386.h */
40
41 #define SKIP_PROLOGUE(frompc) {(frompc) = i386_skip_prologue((frompc));}
42
43 extern int
44 i386_skip_prologue PARAMS ((int));
45
46 /* Immediately after a function call, return the saved pc.
47 Can't always go through the frames for this because on some machines
48 the new frame is not set up until the new function executes
49 some instructions. */
50
51 #define SAVED_PC_AFTER_CALL(frame) \
52 read_memory_integer(read_register(SP_REGNUM), 4)
53
54 /* I don't know the real values for these. */
55 #define TARGET_UPAGES UPAGES
56 #define TARGET_NBPG NBPG
57
58 /* Address of end of stack space. */
59
60 #define STACK_END_ADDR (0x40000000 - (TARGET_UPAGES * TARGET_NBPG))
61
62 /* Stack grows downward. */
63
64 #define INNER_THAN <
65
66 /* Sequence of bytes for breakpoint instruction. */
67
68 #define BREAKPOINT {0xcc}
69
70 /* Amount PC must be decremented by after a breakpoint.
71 This is often the number of bytes in BREAKPOINT
72 but not always. */
73
74 #define DECR_PC_AFTER_BREAK 0
75
76 /* Nonzero if instruction at PC is a return instruction. */
77 /* For Symmetry, this is really the 'leave' instruction, which */
78 /* is right before the ret */
79
80 #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0xc9)
81
82 /* Return 1 if P points to an invalid floating point value.
83 */
84
85 #define INVALID_FLOAT(p, len) (0)
86
87 #if 0
88 --- this code can't be used unless we know we are running native,
89 since it uses host specific ptrace calls.
90 /* code for 80387 fpu. Functions are from i386-dep.c, copied into
91 * symm-dep.c.
92 */
93 #define FLOAT_INFO { i386_float_info(); }
94 #endif
95
96 /* Say how long (ordinary) registers are. */
97
98 #define REGISTER_TYPE long
99
100 /* Number of machine registers */
101 #define NUM_REGS 49
102
103 /* Initializer for an array of names of registers.
104 There should be NUM_REGS strings in this initializer. */
105
106 /* Symmetry registers are in this weird order to match the register
107 numbers in the symbol table entries. If you change the order,
108 things will probably break mysteriously for no apparent reason.
109 Also note that the st(0)...st(7) 387 registers are represented as
110 st0...st7. */
111
112 #define REGISTER_NAMES { "eax", "edx", "ecx", "st0", "st1", \
113 "ebx", "esi", "edi", "st2", "st3", \
114 "st4", "st5", "st6", "st7", "esp", \
115 "ebp", "eip", "eflags", "fp1", "fp2", \
116 "fp3", "fp4", "fp5", "fp6", "fp7", \
117 "fp8", "fp9", "fp10", "fp11", "fp12", \
118 "fp13", "fp14", "fp15", "fp16", "fp17", \
119 "fp18", "fp19", "fp20", "fp21", "fp22", \
120 "fp23", "fp24", "fp25", "fp26", "fp27", \
121 "fp28", "fp29", "fp30", "fp31" }
122
123 /* Register numbers of various important registers.
124 Note that some of these values are "real" register numbers,
125 and correspond to the general registers of the machine,
126 and some are "phony" register numbers which are too large
127 to be actual register numbers as far as the user is concerned
128 but do serve to get the desired values when passed to read_register. */
129
130 #define FP1_REGNUM 18 /* first 1167 register */
131 #define SP_REGNUM 14 /* Contains address of top of stack */
132 #define FP_REGNUM 15 /* Contains address of executing stack frame */
133 #define PC_REGNUM 16 /* Contains program counter */
134 #define PS_REGNUM 17 /* Contains processor status */
135
136 /* Total amount of space needed to store our copies of the machine's
137 register state, the array `registers'. */
138 /* 10 i386 registers, 8 i387 registers, and 31 Weitek 1167 registers */
139 #define REGISTER_BYTES ((10 * 4) + (8 * 10) + (31 * 4))
140
141 /* Index within `registers' of the first byte of the space for
142 register N. */
143
144 #define REGISTER_BYTE(N) \
145 ((N < 3) ? (N * 4) : \
146 (N < 5) ? (((N - 2) * 10) + 2) : \
147 (N < 8) ? (((N - 5) * 4) + 32) : \
148 (N < 14) ? (((N - 8) * 10) + 44) : \
149 (((N - 14) * 4) + 104))
150
151 /* Number of bytes of storage in the actual machine representation
152 * for register N. All registers are 4 bytes, except 387 st(0) - st(7),
153 * which are 80 bits each.
154 */
155
156 #define REGISTER_RAW_SIZE(N) \
157 ((N < 3) ? 4 : \
158 (N < 5) ? 10 : \
159 (N < 8) ? 4 : \
160 (N < 14) ? 10 : \
161 4)
162
163 /* Number of bytes of storage in the program's representation
164 for register N. On the vax, all regs are 4 bytes. */
165
166 #define REGISTER_VIRTUAL_SIZE(N) 4
167
168 /* Largest value REGISTER_RAW_SIZE can have. */
169
170 #define MAX_REGISTER_RAW_SIZE 10
171
172 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
173
174 #define MAX_REGISTER_VIRTUAL_SIZE 4
175
176 /* Nonzero if register N requires conversion
177 from raw format to virtual format. */
178
179 #define REGISTER_CONVERTIBLE(N) \
180 ((N < 3) ? 0 : \
181 (N < 5) ? 1 : \
182 (N < 8) ? 0 : \
183 (N < 14) ? 1 : \
184 0)
185
186 /* Convert data from raw format for register REGNUM
187 to virtual format for register REGNUM. */
188
189 #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
190 ((REGNUM < 3) ? bcopy ((FROM), (TO), 4) : \
191 (REGNUM < 5) ? i387_to_double((FROM), (TO)) : \
192 (REGNUM < 8) ? bcopy ((FROM), (TO), 4) : \
193 (REGNUM < 14) ? i387_to_double((FROM), (TO)) : \
194 bcopy ((FROM), (TO), 4))
195
196 extern void
197 i387_to_double PARAMS ((char *, char *));
198
199 /* Convert data from virtual format for register REGNUM
200 to raw format for register REGNUM. */
201
202 #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
203 ((REGNUM < 3) ? bcopy ((FROM), (TO), 4) : \
204 (REGNUM < 5) ? double_to_i387((FROM), (TO)) : \
205 (REGNUM < 8) ? bcopy ((FROM), (TO), 4) : \
206 (REGNUM < 14) ? double_to_i387((FROM), (TO)) : \
207 bcopy ((FROM), (TO), 4))
208
209 extern void
210 double_to_i387 PARAMS ((char *, char *));
211
212 /* Return the GDB type object for the "standard" data type
213 of data in register N. */
214
215 #define REGISTER_VIRTUAL_TYPE(N) \
216 ((N < 3) ? builtin_type_int : \
217 (N < 5) ? builtin_type_double : \
218 (N < 8) ? builtin_type_int : \
219 (N < 14) ? builtin_type_double : \
220 builtin_type_int)
221
222 /* from m-i386.h */
223 /* Store the address of the place in which to copy the structure the
224 subroutine will return. This is called from call_function. */
225
226 #define STORE_STRUCT_RETURN(ADDR, SP) \
227 { (SP) -= sizeof (ADDR); \
228 write_memory ((SP), &(ADDR), sizeof (ADDR)); \
229 write_register(0, (ADDR)); }
230
231 /* Extract from an array REGBUF containing the (raw) register state
232 a function return value of type TYPE, and copy that, in virtual format,
233 into VALBUF. */
234
235 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
236 symmetry_extract_return_value(TYPE, REGBUF, VALBUF)
237
238 /* Write into appropriate registers a function return value
239 of type TYPE, given in virtual format. */
240
241 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
242 write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE))
243
244 /* Extract from an array REGBUF containing the (raw) register state
245 the address in which a function should return its structure value,
246 as a CORE_ADDR (or an expression that can be used as one). */
247
248 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
249
250 \f
251 /* Describe the pointer in each stack frame to the previous stack frame
252 (its caller). */
253
254 /* FRAME_CHAIN takes a frame's nominal address
255 and produces the frame's chain-pointer.
256
257 However, if FRAME_CHAIN_VALID returns zero,
258 it means the given frame is the outermost one and has no caller. */
259
260 /* On Symmetry, %ebp points to caller's %ebp, and the return address
261 is right on top of that. */
262
263 #define FRAME_CHAIN(thisframe) \
264 (!inside_entry_file ((thisframe)->pc) ? \
265 read_memory_integer((thisframe)->frame, 4) :\
266 0)
267
268 #define FRAME_CHAIN_VALID(chain, thisframe) \
269 (chain != 0)
270
271 /* Define other aspects of the stack frame. */
272
273 /* A macro that tells us whether the function invocation represented
274 by FI does not have a frame on the stack associated with it. If it
275 does not, FRAMELESS is set to 1, else 0. */
276 #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \
277 (FRAMELESS) = frameless_look_for_prologue(FI)
278
279 #define FRAME_SAVED_PC(fi) (read_memory_integer((fi)->frame + 4, 4))
280
281 #define FRAME_ARGS_ADDRESS(fi) ((fi)->frame)
282
283 #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
284
285 /* Return number of args passed to a frame.
286 Can return -1, meaning no way to tell.
287
288 The weirdness in the "addl $imm8" case is due to gcc sometimes
289 issuing "addl $-int" after function call returns; this would
290 produce ridiculously huge arg counts. */
291
292 #define FRAME_NUM_ARGS(numargs, fi) \
293 { \
294 int op = read_memory_integer(FRAME_SAVED_PC((fi)), 4); \
295 int narg; \
296 if ((op & 0xff) == 0x59) /* 0x59 'popl %ecx' */ \
297 { \
298 numargs = 1; \
299 } \
300 else if ((op & 0xffff) == 0xc483) /* 0xc483 'addl $imm8' */ \
301 { \
302 narg = ((op >> 16) & 0xff); \
303 numargs = (narg >= 128) ? -1 : narg / 4; \
304 } \
305 else if ((op & 0xffff) == 0xc481) /* 0xc481 'addl $imm32' */ \
306 { \
307 narg = read_memory_integer(FRAME_SAVED_PC((fi))+2,4); \
308 numargs = (narg < 0) ? -1 : narg / 4; \
309 } \
310 else \
311 { \
312 numargs = -1; \
313 } \
314 }
315
316 /* Return number of bytes at start of arglist that are not really args. */
317
318 #define FRAME_ARGS_SKIP 8
319
320 /* Put here the code to store, into a struct frame_saved_regs,
321 the addresses of the saved registers of frame described by FRAME_INFO.
322 This includes special registers such as pc and fp saved in special
323 ways in the stack frame. sp is even more special:
324 the address we return for it IS the sp for the next frame. */
325
326 #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
327 { i386_frame_find_saved_regs ((frame_info), &(frame_saved_regs)); }
328
329 #ifdef __STDC__ /* Forward decl's for prototypes */
330 struct frame_info;
331 struct frame_saved_regs;
332 #endif
333
334 extern void
335 i386_frame_find_saved_regs PARAMS ((struct frame_info *,
336 struct frame_saved_regs *));
337
338 \f
339 /* Things needed for making the inferior call functions. */
340
341 #define PUSH_DUMMY_FRAME \
342 { CORE_ADDR sp = read_register (SP_REGNUM); \
343 int regnum; \
344 sp = push_word (sp, read_register (PC_REGNUM)); \
345 sp = push_word (sp, read_register (FP_REGNUM)); \
346 write_register (FP_REGNUM, sp); \
347 for (regnum = 0; regnum < NUM_REGS; regnum++) \
348 sp = push_word (sp, read_register (regnum)); \
349 write_register (SP_REGNUM, sp); \
350 }
351
352 #define POP_FRAME \
353 { \
354 FRAME frame = get_current_frame (); \
355 CORE_ADDR fp; \
356 int regnum; \
357 struct frame_saved_regs fsr; \
358 struct frame_info *fi; \
359 fi = get_frame_info (frame); \
360 fp = fi->frame; \
361 get_frame_saved_regs (fi, &fsr); \
362 for (regnum = 0; regnum < NUM_REGS; regnum++) { \
363 CORE_ADDR adr; \
364 adr = fsr.regs[regnum]; \
365 if (adr) \
366 write_register (regnum, read_memory_integer (adr, 4)); \
367 } \
368 write_register (FP_REGNUM, read_memory_integer (fp, 4)); \
369 write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \
370 write_register (SP_REGNUM, fp + 8); \
371 flush_cached_frames (); \
372 set_current_frame ( create_new_frame (read_register (FP_REGNUM), \
373 read_pc ())); \
374 }
375
376 /* from i386-dep.c, worked better than my original... */
377 /* This sequence of words is the instructions
378 * call (32-bit offset)
379 * int 3
380 * This is 6 bytes.
381 */
382
383 #define CALL_DUMMY { 0x223344e8, 0xcc11 }
384
385 #define CALL_DUMMY_LENGTH 8
386
387 #define CALL_DUMMY_START_OFFSET 0 /* Start execution at beginning of dummy */
388
389 /* Insert the specified number of args and function address
390 into a call sequence of the above form stored at DUMMYNAME. */
391
392 #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
393 { \
394 int from, to, delta, loc; \
395 loc = (int)(read_register (SP_REGNUM) - CALL_DUMMY_LENGTH); \
396 from = loc + 5; \
397 to = (int)(fun); \
398 delta = to - from; \
399 *(int *)((char *)(dummyname) + 1) = delta; \
400 }
401
402 extern void
403 print_387_control_word PARAMS ((unsigned int));
404
405 extern void
406 print_387_status_word PARAMS ((unsigned int));
This page took 0.063036 seconds and 4 git commands to generate.