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