1 |
106 |
markom |
/* Parameters for target machine Intel 960, for GDB, the GNU debugger.
|
2 |
|
|
Copyright (C) 1990, 1991, 1993 Free Software Foundation, Inc.
|
3 |
|
|
Contributed by Intel Corporation.
|
4 |
|
|
This file is part of GDB.
|
5 |
|
|
|
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.
|
10 |
|
|
|
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.
|
15 |
|
|
|
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., 59 Temple Place - Suite 330,
|
19 |
|
|
Boston, MA 02111-1307, USA. */
|
20 |
|
|
|
21 |
|
|
/* Definitions to target GDB to any i960. */
|
22 |
|
|
|
23 |
|
|
#ifndef I80960
|
24 |
|
|
#define I80960
|
25 |
|
|
#endif
|
26 |
|
|
|
27 |
|
|
/* Hook for the SYMBOL_CLASS of a parameter when decoding DBX symbol
|
28 |
|
|
information. In the i960, parameters can be stored as locals or as
|
29 |
|
|
args, depending on the type of the debug record.
|
30 |
|
|
|
31 |
|
|
From empirical observation, gcc960 uses N_LSYM to indicate
|
32 |
|
|
arguments passed in registers and then copied immediately
|
33 |
|
|
to the frame, and N_PSYM to indicate arguments passed in a
|
34 |
|
|
g14-relative argument block. */
|
35 |
|
|
|
36 |
|
|
#define DBX_PARM_SYMBOL_CLASS(type) ((type == N_LSYM)? LOC_LOCAL_ARG: LOC_ARG)
|
37 |
|
|
|
38 |
|
|
/* Byte order is configurable, but this machine runs little-endian. */
|
39 |
|
|
#define TARGET_BYTE_ORDER LITTLE_ENDIAN
|
40 |
|
|
|
41 |
|
|
/* We have IEEE floating point, if we have any float at all. */
|
42 |
|
|
|
43 |
|
|
#define IEEE_FLOAT
|
44 |
|
|
|
45 |
|
|
/* Offset from address of function to start of its code.
|
46 |
|
|
Zero on most machines. */
|
47 |
|
|
|
48 |
|
|
#define FUNCTION_START_OFFSET 0
|
49 |
|
|
|
50 |
|
|
/* Advance ip across any function entry prologue instructions
|
51 |
|
|
to reach some "real" code. */
|
52 |
|
|
|
53 |
|
|
#define SKIP_PROLOGUE(ip) (i960_skip_prologue (ip))
|
54 |
|
|
extern CORE_ADDR i960_skip_prologue ();
|
55 |
|
|
|
56 |
|
|
/* Immediately after a function call, return the saved ip.
|
57 |
|
|
Can't always go through the frames for this because on some machines
|
58 |
|
|
the new frame is not set up until the new function
|
59 |
|
|
executes some instructions. */
|
60 |
|
|
|
61 |
|
|
#define SAVED_PC_AFTER_CALL(frame) (saved_pc_after_call (frame))
|
62 |
|
|
extern CORE_ADDR saved_pc_after_call ();
|
63 |
|
|
|
64 |
|
|
/* Stack grows upward */
|
65 |
|
|
|
66 |
|
|
#define INNER_THAN(lhs,rhs) ((lhs) > (rhs))
|
67 |
|
|
|
68 |
|
|
/* Say how long (ordinary) registers are. This is a piece of bogosity
|
69 |
|
|
used in push_word and a few other places; REGISTER_RAW_SIZE is the
|
70 |
|
|
real way to know how big a register is. */
|
71 |
|
|
|
72 |
|
|
#define REGISTER_SIZE 4
|
73 |
|
|
|
74 |
|
|
/* Number of machine registers */
|
75 |
|
|
#define NUM_REGS 40
|
76 |
|
|
|
77 |
|
|
/* Initializer for an array of names of registers.
|
78 |
|
|
There should be NUM_REGS strings in this initializer. */
|
79 |
|
|
|
80 |
|
|
#define REGISTER_NAMES { \
|
81 |
|
|
/* 0 */ "pfp", "sp", "rip", "r3", "r4", "r5", "r6", "r7", \
|
82 |
|
|
/* 8 */ "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",\
|
83 |
|
|
/* 16 */ "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7", \
|
84 |
|
|
/* 24 */ "g8", "g9", "g10", "g11", "g12", "g13", "g14", "fp", \
|
85 |
|
|
/* 32 */ "pcw", "ac", "tc", "ip", "fp0", "fp1", "fp2", "fp3",\
|
86 |
|
|
}
|
87 |
|
|
|
88 |
|
|
/* Register numbers of various important registers (used to index
|
89 |
|
|
into arrays of register names and register values). */
|
90 |
|
|
|
91 |
|
|
#define R0_REGNUM 0 /* First local register */
|
92 |
|
|
#define SP_REGNUM 1 /* Contains address of top of stack */
|
93 |
|
|
#define RIP_REGNUM 2 /* Return instruction pointer (local r2) */
|
94 |
|
|
#define R15_REGNUM 15 /* Last local register */
|
95 |
|
|
#define G0_REGNUM 16 /* First global register */
|
96 |
|
|
#define G13_REGNUM 29 /* g13 - holds struct return address */
|
97 |
|
|
#define G14_REGNUM 30 /* g14 - ptr to arg block / leafproc return address */
|
98 |
|
|
#define FP_REGNUM 31 /* Contains address of executing stack frame */
|
99 |
|
|
#define PCW_REGNUM 32 /* process control word */
|
100 |
|
|
#define ACW_REGNUM 33 /* arithmetic control word */
|
101 |
|
|
#define TCW_REGNUM 34 /* trace control word */
|
102 |
|
|
#define IP_REGNUM 35 /* instruction pointer */
|
103 |
|
|
#define FP0_REGNUM 36 /* First floating point register */
|
104 |
|
|
|
105 |
|
|
/* Some registers have more than one name */
|
106 |
|
|
|
107 |
|
|
#define PC_REGNUM IP_REGNUM /* GDB refers to ip as the Program Counter */
|
108 |
|
|
#define PFP_REGNUM R0_REGNUM /* Previous frame pointer */
|
109 |
|
|
|
110 |
|
|
/* Total amount of space needed to store our copies of the machine's
|
111 |
|
|
register state, the array `registers'. */
|
112 |
|
|
#define REGISTER_BYTES ((36*4) + (4*10))
|
113 |
|
|
|
114 |
|
|
/* Index within `registers' of the first byte of the space for register N. */
|
115 |
|
|
|
116 |
|
|
#define REGISTER_BYTE(N) ( (N) < FP0_REGNUM ? \
|
117 |
|
|
(4*(N)) : ((10*(N)) - (6*FP0_REGNUM)) )
|
118 |
|
|
|
119 |
|
|
/* The i960 has register windows, sort of. */
|
120 |
|
|
|
121 |
|
|
#define HAVE_REGISTER_WINDOWS
|
122 |
|
|
|
123 |
|
|
/* Is this register part of the register window system? A yes answer
|
124 |
|
|
implies that 1) The name of this register will not be the same in
|
125 |
|
|
other frames, and 2) This register is automatically "saved" upon
|
126 |
|
|
subroutine calls and thus there is no need to search more than one
|
127 |
|
|
stack frame for it.
|
128 |
|
|
|
129 |
|
|
On the i960, in fact, the name of this register in another frame is
|
130 |
|
|
"mud" -- there is no overlap between the windows. Each window is
|
131 |
|
|
simply saved into the stack (true for our purposes, after having been
|
132 |
|
|
flushed; normally they reside on-chip and are restored from on-chip
|
133 |
|
|
without ever going to memory). */
|
134 |
|
|
|
135 |
|
|
#define REGISTER_IN_WINDOW_P(regnum) ((regnum) <= R15_REGNUM)
|
136 |
|
|
|
137 |
|
|
/* Number of bytes of storage in the actual machine representation
|
138 |
|
|
for register N. On the i960, all regs are 4 bytes except for floating
|
139 |
|
|
point, which are 10. NINDY only sends us 8 byte values for these,
|
140 |
|
|
which is a pain, but VxWorks handles this correctly, so we must. */
|
141 |
|
|
|
142 |
|
|
#define REGISTER_RAW_SIZE(N) ( (N) < FP0_REGNUM ? 4 : 10 )
|
143 |
|
|
|
144 |
|
|
/* Number of bytes of storage in the program's representation for register N. */
|
145 |
|
|
|
146 |
|
|
#define REGISTER_VIRTUAL_SIZE(N) ( (N) < FP0_REGNUM ? 4 : 8 )
|
147 |
|
|
|
148 |
|
|
/* Largest value REGISTER_RAW_SIZE can have. */
|
149 |
|
|
|
150 |
|
|
#define MAX_REGISTER_RAW_SIZE 10
|
151 |
|
|
|
152 |
|
|
/* Largest value REGISTER_VIRTUAL_SIZE can have. */
|
153 |
|
|
|
154 |
|
|
#define MAX_REGISTER_VIRTUAL_SIZE 8
|
155 |
|
|
|
156 |
|
|
/* Nonzero if register N requires conversion from raw format to virtual
|
157 |
|
|
format. */
|
158 |
|
|
|
159 |
|
|
#define REGISTER_CONVERTIBLE(N) ((N) >= FP0_REGNUM)
|
160 |
|
|
|
161 |
|
|
#include "floatformat.h"
|
162 |
|
|
|
163 |
|
|
#define TARGET_LONG_DOUBLE_FORMAT &floatformat_i960_ext
|
164 |
|
|
|
165 |
|
|
/* Convert data from raw format for register REGNUM in buffer FROM
|
166 |
|
|
to virtual format with type TYPE in buffer TO. */
|
167 |
|
|
|
168 |
|
|
#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \
|
169 |
|
|
{ \
|
170 |
|
|
DOUBLEST val; \
|
171 |
|
|
floatformat_to_doublest (&floatformat_i960_ext, (FROM), &val); \
|
172 |
|
|
store_floating ((TO), TYPE_LENGTH (TYPE), val); \
|
173 |
|
|
}
|
174 |
|
|
|
175 |
|
|
/* Convert data from virtual format with type TYPE in buffer FROM
|
176 |
|
|
to raw format for register REGNUM in buffer TO. */
|
177 |
|
|
|
178 |
|
|
#define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \
|
179 |
|
|
{ \
|
180 |
|
|
DOUBLEST val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \
|
181 |
|
|
floatformat_from_doublest (&floatformat_i960_ext, &val, (TO)); \
|
182 |
|
|
}
|
183 |
|
|
|
184 |
|
|
/* Return the GDB type object for the "standard" data type
|
185 |
|
|
of data in register N. */
|
186 |
|
|
|
187 |
|
|
#define REGISTER_VIRTUAL_TYPE(N) ((N) < FP0_REGNUM ? \
|
188 |
|
|
builtin_type_int : builtin_type_double)
|
189 |
|
|
|
190 |
|
|
/* Macros for understanding function return values... */
|
191 |
|
|
|
192 |
|
|
/* Does the specified function use the "struct returning" convention
|
193 |
|
|
or the "value returning" convention? The "value returning" convention
|
194 |
|
|
almost invariably returns the entire value in registers. The
|
195 |
|
|
"struct returning" convention often returns the entire value in
|
196 |
|
|
memory, and passes a pointer (out of or into the function) saying
|
197 |
|
|
where the value (is or should go).
|
198 |
|
|
|
199 |
|
|
Since this sometimes depends on whether it was compiled with GCC,
|
200 |
|
|
this is also an argument. This is used in call_function to build a
|
201 |
|
|
stack, and in value_being_returned to print return values.
|
202 |
|
|
|
203 |
|
|
On i960, a structure is returned in registers g0-g3, if it will fit.
|
204 |
|
|
If it's more than 16 bytes long, g13 pointed to it on entry. */
|
205 |
|
|
|
206 |
|
|
extern use_struct_convention_fn i960_use_struct_convention;
|
207 |
|
|
#define USE_STRUCT_CONVENTION(gcc_p, type) i960_use_struct_convention (gcc_p, type)
|
208 |
|
|
|
209 |
|
|
/* Extract from an array REGBUF containing the (raw) register state
|
210 |
|
|
a function return value of type TYPE, and copy that, in virtual format,
|
211 |
|
|
into VALBUF. This is only called if USE_STRUCT_CONVENTION for this
|
212 |
|
|
type is 0.
|
213 |
|
|
|
214 |
|
|
On the i960 we just take as many bytes as we need from G0 through G3. */
|
215 |
|
|
|
216 |
|
|
#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
|
217 |
|
|
memcpy(VALBUF, REGBUF+REGISTER_BYTE(G0_REGNUM), TYPE_LENGTH (TYPE))
|
218 |
|
|
|
219 |
|
|
/* If USE_STRUCT_CONVENTION produces a 1,
|
220 |
|
|
extract from an array REGBUF containing the (raw) register state
|
221 |
|
|
the address in which a function should return its structure value,
|
222 |
|
|
as a CORE_ADDR (or an expression that can be used as one).
|
223 |
|
|
|
224 |
|
|
Address of where to put structure was passed in in global
|
225 |
|
|
register g13 on entry. God knows what's in g13 now. The
|
226 |
|
|
(..., 0) below is to make it appear to return a value, though
|
227 |
|
|
actually all it does is call error(). */
|
228 |
|
|
|
229 |
|
|
#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \
|
230 |
|
|
(error("Don't know where large structure is returned on i960"), 0)
|
231 |
|
|
|
232 |
|
|
/* Write into appropriate registers a function return value
|
233 |
|
|
of type TYPE, given in virtual format, for "value returning" functions.
|
234 |
|
|
|
235 |
|
|
For 'return' command: not (yet) implemented for i960. */
|
236 |
|
|
|
237 |
|
|
#define STORE_RETURN_VALUE(TYPE,VALBUF) \
|
238 |
|
|
error ("Returning values from functions is not implemented in i960 gdb")
|
239 |
|
|
|
240 |
|
|
/* Store the address of the place in which to copy the structure the
|
241 |
|
|
subroutine will return. This is called from call_function. */
|
242 |
|
|
|
243 |
|
|
#define STORE_STRUCT_RETURN(ADDR, SP) \
|
244 |
|
|
error ("Returning values from functions is not implemented in i960 gdb")
|
245 |
|
|
|
246 |
|
|
/* Describe the pointer in each stack frame to the previous stack frame
|
247 |
|
|
(its caller). */
|
248 |
|
|
|
249 |
|
|
/* FRAME_CHAIN takes a frame's nominal address
|
250 |
|
|
and produces the frame's chain-pointer.
|
251 |
|
|
|
252 |
|
|
However, if FRAME_CHAIN_VALID returns zero,
|
253 |
|
|
it means the given frame is the outermost one and has no caller. */
|
254 |
|
|
|
255 |
|
|
/* We cache information about saved registers in the frame structure,
|
256 |
|
|
to save us from having to re-scan function prologues every time
|
257 |
|
|
a register in a non-current frame is accessed. */
|
258 |
|
|
|
259 |
|
|
#define EXTRA_FRAME_INFO \
|
260 |
|
|
struct frame_saved_regs *fsr; \
|
261 |
|
|
CORE_ADDR arg_pointer;
|
262 |
|
|
|
263 |
|
|
/* Zero the frame_saved_regs pointer when the frame is initialized,
|
264 |
|
|
so that FRAME_FIND_SAVED_REGS () will know to allocate and
|
265 |
|
|
initialize a frame_saved_regs struct the first time it is called.
|
266 |
|
|
Set the arg_pointer to -1, which is not valid; 0 and other values
|
267 |
|
|
indicate real, cached values. */
|
268 |
|
|
|
269 |
|
|
#define INIT_EXTRA_FRAME_INFO(fromleaf, fi) \
|
270 |
|
|
((fi)->fsr = 0, (fi)->arg_pointer = -1)
|
271 |
|
|
|
272 |
|
|
/* On the i960, we get the chain pointer by reading the PFP saved
|
273 |
|
|
on the stack and clearing the status bits. */
|
274 |
|
|
|
275 |
|
|
#define FRAME_CHAIN(thisframe) \
|
276 |
|
|
(read_memory_integer (FRAME_FP(thisframe), 4) & ~0xf)
|
277 |
|
|
|
278 |
|
|
/* FRAME_CHAIN_VALID returns zero if the given frame is the outermost one
|
279 |
|
|
and has no caller.
|
280 |
|
|
|
281 |
|
|
On the i960, each various target system type must define FRAME_CHAIN_VALID,
|
282 |
|
|
since it differs between NINDY and VxWorks, the two currently supported
|
283 |
|
|
targets types. We leave it undefined here. */
|
284 |
|
|
|
285 |
|
|
|
286 |
|
|
/* A macro that tells us whether the function invocation represented
|
287 |
|
|
by FI does not have a frame on the stack associated with it. If it
|
288 |
|
|
does not, FRAMELESS is set to 1, else 0. */
|
289 |
|
|
|
290 |
|
|
CORE_ADDR leafproc_return (CORE_ADDR ip);
|
291 |
|
|
#define FRAMELESS_FUNCTION_INVOCATION(FI) \
|
292 |
|
|
(leafproc_return ((FI)->pc) != 0)
|
293 |
|
|
|
294 |
|
|
/* Note that in the i960 architecture the return pointer is saved in the
|
295 |
|
|
*caller's* stack frame.
|
296 |
|
|
|
297 |
|
|
Make sure to zero low-order bits because of bug in 960CA A-step part
|
298 |
|
|
(instruction addresses should always be word-aligned anyway). */
|
299 |
|
|
|
300 |
|
|
#define FRAME_SAVED_PC(frame) \
|
301 |
|
|
((read_memory_integer(FRAME_CHAIN(frame)+8,4)) & ~3)
|
302 |
|
|
|
303 |
|
|
/* On the i960, FRAME_ARGS_ADDRESS should return the value of
|
304 |
|
|
g14 as passed into the frame, if known. We need a function for this.
|
305 |
|
|
We cache this value in the frame info if we've already looked it up. */
|
306 |
|
|
|
307 |
|
|
#define FRAME_ARGS_ADDRESS(fi) \
|
308 |
|
|
(((fi)->arg_pointer != -1)? (fi)->arg_pointer: frame_args_address (fi, 0))
|
309 |
|
|
extern CORE_ADDR frame_args_address (); /* i960-tdep.c */
|
310 |
|
|
|
311 |
|
|
/* This is the same except it should return 0 when
|
312 |
|
|
it does not really know where the args are, rather than guessing.
|
313 |
|
|
This value is not cached since it is only used infrequently. */
|
314 |
|
|
|
315 |
|
|
#define FRAME_ARGS_ADDRESS_CORRECT(fi) (frame_args_address (fi, 1))
|
316 |
|
|
|
317 |
|
|
#define FRAME_LOCALS_ADDRESS(fi) (fi)->frame
|
318 |
|
|
|
319 |
|
|
/* Set NUMARGS to the number of args passed to a frame.
|
320 |
|
|
Can return -1, meaning no way to tell. */
|
321 |
|
|
|
322 |
|
|
#define FRAME_NUM_ARGS(fi) (-1)
|
323 |
|
|
|
324 |
|
|
/* Return number of bytes at start of arglist that are not really args. */
|
325 |
|
|
|
326 |
|
|
#define FRAME_ARGS_SKIP 0
|
327 |
|
|
|
328 |
|
|
/* Produce the positions of the saved registers in a stack frame. */
|
329 |
|
|
|
330 |
|
|
#define FRAME_FIND_SAVED_REGS(frame_info_addr, sr) \
|
331 |
|
|
frame_find_saved_regs (frame_info_addr, &sr)
|
332 |
|
|
extern void frame_find_saved_regs (); /* See i960-tdep.c */
|
333 |
|
|
|
334 |
|
|
/* Things needed for making calls to functions in the inferior process */
|
335 |
|
|
|
336 |
|
|
/* Push an empty stack frame, to record the current ip, etc.
|
337 |
|
|
|
338 |
|
|
Not (yet?) implemented for i960. */
|
339 |
|
|
|
340 |
|
|
#define PUSH_DUMMY_FRAME \
|
341 |
|
|
error("Function calls into the inferior process are not supported on the i960")
|
342 |
|
|
|
343 |
|
|
/* Discard from the stack the innermost frame, restoring all registers. */
|
344 |
|
|
|
345 |
|
|
|
346 |
|
|
void i960_pop_frame (void);
|
347 |
|
|
#define POP_FRAME \
|
348 |
|
|
i960_pop_frame ()
|
349 |
|
|
|
350 |
|
|
|
351 |
|
|
/* This sequence of words is the instructions
|
352 |
|
|
|
353 |
|
|
callx 0x00000000
|
354 |
|
|
fmark
|
355 |
|
|
*/
|
356 |
|
|
|
357 |
|
|
/* #define CALL_DUMMY { 0x86003000, 0x00000000, 0x66003e00 } */
|
358 |
|
|
|
359 |
|
|
/* #define CALL_DUMMY_START_OFFSET 0 *//* Start execution at beginning of dummy */
|
360 |
|
|
|
361 |
|
|
/* Indicate that we don't support calling inferior child functions. */
|
362 |
|
|
|
363 |
|
|
#undef CALL_DUMMY
|
364 |
|
|
|
365 |
|
|
/* Insert the specified number of args and function address
|
366 |
|
|
into a call sequence of the above form stored at 'dummyname'.
|
367 |
|
|
|
368 |
|
|
Ignore arg count on i960. */
|
369 |
|
|
|
370 |
|
|
/* #define FIX_CALL_DUMMY(dummyname, fun, nargs) *(((int *)dummyname)+1) = fun */
|
371 |
|
|
|
372 |
|
|
#undef FIX_CALL_DUMMY
|
373 |
|
|
|
374 |
|
|
|
375 |
|
|
/* Interface definitions for kernel debugger KDB */
|
376 |
|
|
/* (Not relevant to i960.) */
|