1 |
106 |
markom |
/* Target machine sub-parameters for SPARC, for GDB, the GNU debugger.
|
2 |
|
|
This is included by other tm-*.h files to define SPARC cpu-related info.
|
3 |
|
|
Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994
|
4 |
|
|
Free Software Foundation, Inc.
|
5 |
|
|
Contributed by Michael Tiemann (tiemann@mcc.com)
|
6 |
|
|
|
7 |
|
|
This file is part of GDB.
|
8 |
|
|
|
9 |
|
|
This program is free software; you can redistribute it and/or modify
|
10 |
|
|
it under the terms of the GNU General Public License as published by
|
11 |
|
|
the Free Software Foundation; either version 2 of the License, or
|
12 |
|
|
(at your option) any later version.
|
13 |
|
|
|
14 |
|
|
This program is distributed in the hope that it will be useful,
|
15 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 |
|
|
GNU General Public License for more details.
|
18 |
|
|
|
19 |
|
|
You should have received a copy of the GNU General Public License
|
20 |
|
|
along with this program; if not, write to the Free Software
|
21 |
|
|
Foundation, Inc., 59 Temple Place - Suite 330,
|
22 |
|
|
Boston, MA 02111-1307, USA. */
|
23 |
|
|
|
24 |
|
|
struct frame_info;
|
25 |
|
|
struct type;
|
26 |
|
|
struct value;
|
27 |
|
|
|
28 |
|
|
#define TARGET_BYTE_ORDER BIG_ENDIAN
|
29 |
|
|
|
30 |
|
|
/* Floating point is IEEE compatible. */
|
31 |
|
|
#define IEEE_FLOAT
|
32 |
|
|
|
33 |
|
|
/* If an argument is declared "register", Sun cc will keep it in a register,
|
34 |
|
|
never saving it onto the stack. So we better not believe the "p" symbol
|
35 |
|
|
descriptor stab. */
|
36 |
|
|
|
37 |
|
|
#define USE_REGISTER_NOT_ARG
|
38 |
|
|
|
39 |
|
|
/* When passing a structure to a function, Sun cc passes the address
|
40 |
|
|
not the structure itself. It (under SunOS4) creates two symbols,
|
41 |
|
|
which we need to combine to a LOC_REGPARM. Gcc version two (as of
|
42 |
|
|
1.92) behaves like sun cc. REG_STRUCT_HAS_ADDR is smart enough to
|
43 |
|
|
distinguish between Sun cc, gcc version 1 and gcc version 2. */
|
44 |
|
|
|
45 |
|
|
#define REG_STRUCT_HAS_ADDR(gcc_p,type) (gcc_p != 1)
|
46 |
|
|
|
47 |
|
|
/* Sun /bin/cc gets this right as of SunOS 4.1.x. We need to define
|
48 |
|
|
BELIEVE_PCC_PROMOTION to get this right now that the code which
|
49 |
|
|
detects gcc2_compiled. is broken. This loses for SunOS 4.0.x and
|
50 |
|
|
earlier. */
|
51 |
|
|
|
52 |
|
|
#define BELIEVE_PCC_PROMOTION 1
|
53 |
|
|
|
54 |
|
|
/* For acc, there's no need to correct LBRAC entries by guessing how
|
55 |
|
|
they should work. In fact, this is harmful because the LBRAC
|
56 |
|
|
entries now all appear at the end of the function, not intermixed
|
57 |
|
|
with the SLINE entries. n_opt_found detects acc for Solaris binaries;
|
58 |
|
|
function_stab_type detects acc for SunOS4 binaries.
|
59 |
|
|
|
60 |
|
|
For binary from SunOS4 /bin/cc, need to correct LBRAC's.
|
61 |
|
|
|
62 |
|
|
For gcc, like acc, don't correct. */
|
63 |
|
|
|
64 |
|
|
#define SUN_FIXED_LBRAC_BUG \
|
65 |
|
|
(n_opt_found \
|
66 |
|
|
|| function_stab_type == N_STSYM \
|
67 |
|
|
|| function_stab_type == N_GSYM \
|
68 |
|
|
|| processing_gcc_compilation)
|
69 |
|
|
|
70 |
|
|
/* Do variables in the debug stabs occur after the N_LBRAC or before it?
|
71 |
|
|
acc: after, gcc: before, SunOS4 /bin/cc: before. */
|
72 |
|
|
|
73 |
|
|
#define VARIABLES_INSIDE_BLOCK(desc, gcc_p) \
|
74 |
|
|
(!(gcc_p) \
|
75 |
|
|
&& (n_opt_found \
|
76 |
|
|
|| function_stab_type == N_STSYM \
|
77 |
|
|
|| function_stab_type == N_GSYM))
|
78 |
|
|
|
79 |
|
|
/* Offset from address of function to start of its code.
|
80 |
|
|
Zero on most machines. */
|
81 |
|
|
|
82 |
|
|
#define FUNCTION_START_OFFSET 0
|
83 |
|
|
|
84 |
|
|
/* Advance PC across any function entry prologue instructions
|
85 |
|
|
to reach some "real" code. SKIP_PROLOGUE_FRAMELESS_P advances
|
86 |
|
|
the PC past some of the prologue, but stops as soon as it
|
87 |
|
|
knows that the function has a frame. Its result is equal
|
88 |
|
|
to its input PC if the function is frameless, unequal otherwise. */
|
89 |
|
|
|
90 |
|
|
#define SKIP_PROLOGUE(pc) (sparc_skip_prologue (pc, 0))
|
91 |
|
|
#define SKIP_PROLOGUE_FRAMELESS_P(pc) (sparc_skip_prologue (pc, 1))
|
92 |
|
|
extern CORE_ADDR sparc_skip_prologue PARAMS ((CORE_ADDR, int));
|
93 |
|
|
|
94 |
|
|
/* Immediately after a function call, return the saved pc.
|
95 |
|
|
Can't go through the frames for this because on some machines
|
96 |
|
|
the new frame is not set up until the new function executes
|
97 |
|
|
some instructions. */
|
98 |
|
|
|
99 |
|
|
/* On the Sun 4 under SunOS, the compile will leave a fake insn which
|
100 |
|
|
encodes the structure size being returned. If we detect such
|
101 |
|
|
a fake insn, step past it. */
|
102 |
|
|
|
103 |
|
|
#define PC_ADJUST(pc) sparc_pc_adjust(pc)
|
104 |
|
|
extern CORE_ADDR sparc_pc_adjust PARAMS ((CORE_ADDR));
|
105 |
|
|
|
106 |
|
|
#define SAVED_PC_AFTER_CALL(frame) PC_ADJUST (read_register (RP_REGNUM))
|
107 |
|
|
|
108 |
|
|
/* Stack grows downward. */
|
109 |
|
|
|
110 |
|
|
#define INNER_THAN(lhs,rhs) ((lhs) < (rhs))
|
111 |
|
|
|
112 |
|
|
/* Stack must be aligned on 64-bit boundaries when synthesizing
|
113 |
|
|
function calls. */
|
114 |
|
|
|
115 |
|
|
#define STACK_ALIGN(ADDR) (((ADDR) + 7) & -8)
|
116 |
|
|
|
117 |
|
|
/* Sequence of bytes for breakpoint instruction (ta 1). */
|
118 |
|
|
|
119 |
|
|
#define BREAKPOINT {0x91, 0xd0, 0x20, 0x01}
|
120 |
|
|
|
121 |
|
|
/* Amount PC must be decremented by after a breakpoint.
|
122 |
|
|
This is often the number of bytes in BREAKPOINT
|
123 |
|
|
but not always. */
|
124 |
|
|
|
125 |
|
|
#define DECR_PC_AFTER_BREAK 0
|
126 |
|
|
|
127 |
|
|
/* Say how long (ordinary) registers are. This is a piece of bogosity
|
128 |
|
|
used in push_word and a few other places; REGISTER_RAW_SIZE is the
|
129 |
|
|
real way to know how big a register is. */
|
130 |
|
|
|
131 |
|
|
#define REGISTER_SIZE 4
|
132 |
|
|
|
133 |
|
|
/* Number of machine registers */
|
134 |
|
|
|
135 |
|
|
#define NUM_REGS 72
|
136 |
|
|
|
137 |
|
|
/* Initializer for an array of names of registers.
|
138 |
|
|
There should be NUM_REGS strings in this initializer. */
|
139 |
|
|
|
140 |
|
|
#define REGISTER_NAMES \
|
141 |
|
|
{ "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7", \
|
142 |
|
|
"o0", "o1", "o2", "o3", "o4", "o5", "sp", "o7", \
|
143 |
|
|
"l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7", \
|
144 |
|
|
"i0", "i1", "i2", "i3", "i4", "i5", "fp", "i7", \
|
145 |
|
|
\
|
146 |
|
|
"f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
|
147 |
|
|
"f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
|
148 |
|
|
"f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", \
|
149 |
|
|
"f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \
|
150 |
|
|
\
|
151 |
|
|
"y", "psr", "wim", "tbr", "pc", "npc", "fpsr", "cpsr" }
|
152 |
|
|
|
153 |
|
|
/* Register numbers of various important registers.
|
154 |
|
|
Note that some of these values are "real" register numbers,
|
155 |
|
|
and correspond to the general registers of the machine,
|
156 |
|
|
and some are "phony" register numbers which are too large
|
157 |
|
|
to be actual register numbers as far as the user is concerned
|
158 |
|
|
but do serve to get the desired values when passed to read_register. */
|
159 |
|
|
|
160 |
|
|
#define G0_REGNUM 0 /* %g0 */
|
161 |
|
|
#define G1_REGNUM 1 /* %g1 */
|
162 |
|
|
#define O0_REGNUM 8 /* %o0 */
|
163 |
|
|
#define SP_REGNUM 14 /* Contains address of top of stack, \
|
164 |
|
|
which is also the bottom of the frame. */
|
165 |
|
|
#define RP_REGNUM 15 /* Contains return address value, *before* \
|
166 |
|
|
any windows get switched. */
|
167 |
|
|
#define O7_REGNUM 15 /* Last local reg not saved on stack frame */
|
168 |
|
|
#define L0_REGNUM 16 /* First local reg that's saved on stack frame
|
169 |
|
|
rather than in machine registers */
|
170 |
|
|
#define I0_REGNUM 24 /* %i0 */
|
171 |
|
|
#define FP_REGNUM 30 /* Contains address of executing stack frame */
|
172 |
|
|
#define I7_REGNUM 31 /* Last local reg saved on stack frame */
|
173 |
|
|
#define FP0_REGNUM 32 /* Floating point register 0 */
|
174 |
|
|
#define Y_REGNUM 64 /* Temp register for multiplication, etc. */
|
175 |
|
|
#define PS_REGNUM 65 /* Contains processor status */
|
176 |
|
|
#define PS_FLAG_CARRY 0x100000 /* Carry bit in PS */
|
177 |
|
|
#define WIM_REGNUM 66 /* Window Invalid Mask (not really supported) */
|
178 |
|
|
#define TBR_REGNUM 67 /* Trap Base Register (not really supported) */
|
179 |
|
|
#define PC_REGNUM 68 /* Contains program counter */
|
180 |
|
|
#define NPC_REGNUM 69 /* Contains next PC */
|
181 |
|
|
#define FPS_REGNUM 70 /* Floating point status register */
|
182 |
|
|
#define CPS_REGNUM 71 /* Coprocessor status register */
|
183 |
|
|
|
184 |
|
|
/* Total amount of space needed to store our copies of the machine's
|
185 |
|
|
register state, the array `registers'. On the sparc, `registers'
|
186 |
|
|
contains the ins and locals, even though they are saved on the
|
187 |
|
|
stack rather than with the other registers, and this causes hair
|
188 |
|
|
and confusion in places like pop_frame. It might be
|
189 |
|
|
better to remove the ins and locals from `registers', make sure
|
190 |
|
|
that get_saved_register can get them from the stack (even in the
|
191 |
|
|
innermost frame), and make this the way to access them. For the
|
192 |
|
|
frame pointer we would do that via TARGET_READ_FP. On the other hand,
|
193 |
|
|
that is likely to be confusing or worse for flat frames. */
|
194 |
|
|
|
195 |
|
|
#define REGISTER_BYTES (32*4+32*4+8*4)
|
196 |
|
|
|
197 |
|
|
/* Index within `registers' of the first byte of the space for
|
198 |
|
|
register N. */
|
199 |
|
|
/* ?? */
|
200 |
|
|
#define REGISTER_BYTE(N) ((N)*4)
|
201 |
|
|
|
202 |
|
|
/* We need to override GET_SAVED_REGISTER so that we can deal with the way
|
203 |
|
|
outs change into ins in different frames. HAVE_REGISTER_WINDOWS can't
|
204 |
|
|
deal with this case and also handle flat frames at the same time. */
|
205 |
|
|
|
206 |
|
|
struct frame_info;
|
207 |
|
|
void sparc_get_saved_register PARAMS ((char *raw_buffer, int *optimized, CORE_ADDR * addrp, struct frame_info * frame, int regnum, enum lval_type * lvalp));
|
208 |
|
|
#define GET_SAVED_REGISTER(raw_buffer, optimized, addrp, frame, regnum, lval) \
|
209 |
|
|
sparc_get_saved_register (raw_buffer, optimized, addrp, frame, regnum, lval)
|
210 |
|
|
|
211 |
|
|
/* Number of bytes of storage in the actual machine representation
|
212 |
|
|
for register N. */
|
213 |
|
|
|
214 |
|
|
/* On the SPARC, all regs are 4 bytes. */
|
215 |
|
|
|
216 |
|
|
#define REGISTER_RAW_SIZE(N) (4)
|
217 |
|
|
|
218 |
|
|
/* Number of bytes of storage in the program's representation
|
219 |
|
|
for register N. */
|
220 |
|
|
|
221 |
|
|
/* On the SPARC, all regs are 4 bytes. */
|
222 |
|
|
|
223 |
|
|
#define REGISTER_VIRTUAL_SIZE(N) (4)
|
224 |
|
|
|
225 |
|
|
/* Largest value REGISTER_RAW_SIZE can have. */
|
226 |
|
|
|
227 |
|
|
#define MAX_REGISTER_RAW_SIZE 8
|
228 |
|
|
|
229 |
|
|
/* Largest value REGISTER_VIRTUAL_SIZE can have. */
|
230 |
|
|
|
231 |
|
|
#define MAX_REGISTER_VIRTUAL_SIZE 8
|
232 |
|
|
|
233 |
|
|
/* Return the GDB type object for the "standard" data type
|
234 |
|
|
of data in register N. */
|
235 |
|
|
|
236 |
|
|
#define REGISTER_VIRTUAL_TYPE(N) \
|
237 |
|
|
((N) < 32 ? builtin_type_int : (N) < 64 ? builtin_type_float : \
|
238 |
|
|
builtin_type_int)
|
239 |
|
|
|
240 |
|
|
/* Writing to %g0 is a noop (not an error or exception or anything like
|
241 |
|
|
that, however). */
|
242 |
|
|
|
243 |
|
|
#define CANNOT_STORE_REGISTER(regno) ((regno) == G0_REGNUM)
|
244 |
|
|
|
245 |
|
|
/* Store the address of the place in which to copy the structure the
|
246 |
|
|
subroutine will return. This is called from call_function_by_hand.
|
247 |
|
|
The ultimate mystery is, tho, what is the value "16"? */
|
248 |
|
|
|
249 |
|
|
#define STORE_STRUCT_RETURN(ADDR, SP) \
|
250 |
|
|
{ char val[4]; \
|
251 |
|
|
store_unsigned_integer (val, 4, (ADDR)); \
|
252 |
|
|
write_memory ((SP)+(16*4), val, 4); }
|
253 |
|
|
|
254 |
|
|
/* Extract from an array REGBUF containing the (raw) register state
|
255 |
|
|
a function return value of type TYPE, and copy that, in virtual format,
|
256 |
|
|
into VALBUF. */
|
257 |
|
|
|
258 |
|
|
#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
|
259 |
|
|
sparc_extract_return_value(TYPE, REGBUF, VALBUF)
|
260 |
|
|
extern void
|
261 |
|
|
sparc_extract_return_value PARAMS ((struct type *, char[], char *));
|
262 |
|
|
|
263 |
|
|
/* Write into appropriate registers a function return value
|
264 |
|
|
of type TYPE, given in virtual format. */
|
265 |
|
|
#define STORE_RETURN_VALUE(TYPE,VALBUF) \
|
266 |
|
|
sparc_store_return_value(TYPE, VALBUF)
|
267 |
|
|
extern void sparc_store_return_value PARAMS ((struct type *, char *));
|
268 |
|
|
|
269 |
|
|
/* Extract from an array REGBUF containing the (raw) register state
|
270 |
|
|
the address in which a function should return its structure value,
|
271 |
|
|
as a CORE_ADDR (or an expression that can be used as one). */
|
272 |
|
|
|
273 |
|
|
#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \
|
274 |
|
|
(sparc_extract_struct_value_address (REGBUF))
|
275 |
|
|
|
276 |
|
|
extern CORE_ADDR
|
277 |
|
|
sparc_extract_struct_value_address PARAMS ((char[REGISTER_BYTES]));
|
278 |
|
|
|
279 |
|
|
|
280 |
|
|
/* Describe the pointer in each stack frame to the previous stack frame
|
281 |
|
|
(its caller). */
|
282 |
|
|
|
283 |
|
|
/* FRAME_CHAIN takes a frame's nominal address
|
284 |
|
|
and produces the frame's chain-pointer. */
|
285 |
|
|
|
286 |
|
|
/* In the case of the Sun 4, the frame-chain's nominal address
|
287 |
|
|
is held in the frame pointer register.
|
288 |
|
|
|
289 |
|
|
On the Sun4, the frame (in %fp) is %sp for the previous frame.
|
290 |
|
|
From the previous frame's %sp, we can find the previous frame's
|
291 |
|
|
%fp: it is in the save area just above the previous frame's %sp.
|
292 |
|
|
|
293 |
|
|
If we are setting up an arbitrary frame, we'll need to know where
|
294 |
|
|
it ends. Hence the following. This part of the frame cache
|
295 |
|
|
structure should be checked before it is assumed that this frame's
|
296 |
|
|
bottom is in the stack pointer.
|
297 |
|
|
|
298 |
|
|
If there isn't a frame below this one, the bottom of this frame is
|
299 |
|
|
in the stack pointer.
|
300 |
|
|
|
301 |
|
|
If there is a frame below this one, and the frame pointers are
|
302 |
|
|
identical, it's a leaf frame and the bottoms are the same also.
|
303 |
|
|
|
304 |
|
|
Otherwise the bottom of this frame is the top of the next frame.
|
305 |
|
|
|
306 |
|
|
The bottom field is misnamed, since it might imply that memory from
|
307 |
|
|
bottom to frame contains this frame. That need not be true if
|
308 |
|
|
stack frames are allocated in different segments (e.g. some on a
|
309 |
|
|
stack, some on a heap in the data segment).
|
310 |
|
|
|
311 |
|
|
GCC 2.6 and later can generate ``flat register window'' code that
|
312 |
|
|
makes frames by explicitly saving those registers that need to be
|
313 |
|
|
saved. %i7 is used as the frame pointer, and the frame is laid out so
|
314 |
|
|
that flat and non-flat calls can be intermixed freely within a
|
315 |
|
|
program. Unfortunately for GDB, this means it must detect and record
|
316 |
|
|
the flatness of frames.
|
317 |
|
|
|
318 |
|
|
Since the prologue in a flat frame also tells us where fp and pc
|
319 |
|
|
have been stashed (the frame is of variable size, so their location
|
320 |
|
|
is not fixed), it's convenient to record them in the frame info. */
|
321 |
|
|
|
322 |
|
|
#define EXTRA_FRAME_INFO \
|
323 |
|
|
CORE_ADDR bottom; \
|
324 |
|
|
int in_prologue; \
|
325 |
|
|
int flat; \
|
326 |
|
|
/* Following fields only relevant for flat frames. */ \
|
327 |
|
|
CORE_ADDR pc_addr; \
|
328 |
|
|
CORE_ADDR fp_addr; \
|
329 |
|
|
/* Add this to ->frame to get the value of the stack pointer at the */ \
|
330 |
|
|
/* time of the register saves. */ \
|
331 |
|
|
int sp_offset;
|
332 |
|
|
|
333 |
|
|
#define FRAME_INIT_SAVED_REGS(fp) /*no-op */
|
334 |
|
|
|
335 |
|
|
#define INIT_EXTRA_FRAME_INFO(fromleaf, fci) \
|
336 |
|
|
sparc_init_extra_frame_info (fromleaf, fci)
|
337 |
|
|
extern void sparc_init_extra_frame_info PARAMS ((int, struct frame_info *));
|
338 |
|
|
|
339 |
|
|
#define PRINT_EXTRA_FRAME_INFO(fi) \
|
340 |
|
|
{ \
|
341 |
|
|
if ((fi) && (fi)->flat) \
|
342 |
|
|
printf_filtered (" flat, pc saved at 0x%s, fp saved at 0x%s\n", \
|
343 |
|
|
paddr_nz ((fi)->pc_addr), paddr_nz ((fi)->fp_addr)); \
|
344 |
|
|
}
|
345 |
|
|
|
346 |
|
|
#define FRAME_CHAIN(thisframe) (sparc_frame_chain (thisframe))
|
347 |
|
|
extern CORE_ADDR sparc_frame_chain PARAMS ((struct frame_info *));
|
348 |
|
|
|
349 |
|
|
/* INIT_EXTRA_FRAME_INFO needs the PC to detect flat frames. */
|
350 |
|
|
|
351 |
|
|
#define INIT_FRAME_PC(fromleaf, prev) /* nothing */
|
352 |
|
|
#define INIT_FRAME_PC_FIRST(fromleaf, prev) \
|
353 |
|
|
(prev)->pc = ((fromleaf) ? SAVED_PC_AFTER_CALL ((prev)->next) : \
|
354 |
|
|
(prev)->next ? FRAME_SAVED_PC ((prev)->next) : read_pc ());
|
355 |
|
|
|
356 |
|
|
/* Define other aspects of the stack frame. */
|
357 |
|
|
|
358 |
|
|
/* A macro that tells us whether the function invocation represented
|
359 |
|
|
by FI does not have a frame on the stack associated with it. If it
|
360 |
|
|
does not, FRAMELESS is set to 1, else 0. */
|
361 |
|
|
#define FRAMELESS_FUNCTION_INVOCATION(FI) \
|
362 |
|
|
(frameless_look_for_prologue(FI))
|
363 |
|
|
|
364 |
|
|
/* The location of I0 w.r.t SP. This is actually dependent on how the system's
|
365 |
|
|
window overflow/underflow routines are written. Most vendors save the L regs
|
366 |
|
|
followed by the I regs (at the higher address). Some vendors get it wrong.
|
367 |
|
|
*/
|
368 |
|
|
|
369 |
|
|
#define FRAME_SAVED_L0 0
|
370 |
|
|
#define FRAME_SAVED_I0 (8 * REGISTER_RAW_SIZE (L0_REGNUM))
|
371 |
|
|
|
372 |
|
|
/* Where is the PC for a specific frame */
|
373 |
|
|
|
374 |
|
|
#define FRAME_SAVED_PC(FRAME) sparc_frame_saved_pc (FRAME)
|
375 |
|
|
extern CORE_ADDR sparc_frame_saved_pc PARAMS ((struct frame_info *));
|
376 |
|
|
|
377 |
|
|
/* If the argument is on the stack, it will be here. */
|
378 |
|
|
#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame)
|
379 |
|
|
|
380 |
|
|
#define FRAME_STRUCT_ARGS_ADDRESS(fi) ((fi)->frame)
|
381 |
|
|
|
382 |
|
|
#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
|
383 |
|
|
|
384 |
|
|
/* Set VAL to the number of args passed to frame described by FI.
|
385 |
|
|
Can set VAL to -1, meaning no way to tell. */
|
386 |
|
|
|
387 |
|
|
/* We can't tell how many args there are
|
388 |
|
|
now that the C compiler delays popping them. */
|
389 |
|
|
#define FRAME_NUM_ARGS(fi) (-1)
|
390 |
|
|
|
391 |
|
|
/* Return number of bytes at start of arglist that are not really args. */
|
392 |
|
|
|
393 |
|
|
#define FRAME_ARGS_SKIP 68
|
394 |
|
|
|
395 |
|
|
/* Things needed for making the inferior call functions. */
|
396 |
|
|
/*
|
397 |
|
|
* First of all, let me give my opinion of what the DUMMY_FRAME
|
398 |
|
|
* actually looks like.
|
399 |
|
|
*
|
400 |
|
|
* | |
|
401 |
|
|
* | |
|
402 |
|
|
* + - - - - - - - - - - - - - - - - +<-- fp (level 0)
|
403 |
|
|
* | |
|
404 |
|
|
* | |
|
405 |
|
|
* | |
|
406 |
|
|
* | |
|
407 |
|
|
* | Frame of innermost program |
|
408 |
|
|
* | function |
|
409 |
|
|
* | |
|
410 |
|
|
* | |
|
411 |
|
|
* | |
|
412 |
|
|
* | |
|
413 |
|
|
* | |
|
414 |
|
|
* |---------------------------------|<-- sp (level 0), fp (c)
|
415 |
|
|
* | |
|
416 |
|
|
* DUMMY | fp0-31 |
|
417 |
|
|
* | |
|
418 |
|
|
* | ------ |<-- fp - 0x80
|
419 |
|
|
* FRAME | g0-7 |<-- fp - 0xa0
|
420 |
|
|
* | i0-7 |<-- fp - 0xc0
|
421 |
|
|
* | other |<-- fp - 0xe0
|
422 |
|
|
* | ? |
|
423 |
|
|
* | ? |
|
424 |
|
|
* |---------------------------------|<-- sp' = fp - 0x140
|
425 |
|
|
* | |
|
426 |
|
|
* xcution start | |
|
427 |
|
|
* sp' + 0x94 -->| CALL_DUMMY (x code) |
|
428 |
|
|
* | |
|
429 |
|
|
* | |
|
430 |
|
|
* |---------------------------------|<-- sp'' = fp - 0x200
|
431 |
|
|
* | align sp to 8 byte boundary |
|
432 |
|
|
* | ==> args to fn <== |
|
433 |
|
|
* Room for | |
|
434 |
|
|
* i & l's + agg | CALL_DUMMY_STACK_ADJUST = 0x0x44|
|
435 |
|
|
* |---------------------------------|<-- final sp (variable)
|
436 |
|
|
* | |
|
437 |
|
|
* | Where function called will |
|
438 |
|
|
* | build frame. |
|
439 |
|
|
* | |
|
440 |
|
|
* | |
|
441 |
|
|
*
|
442 |
|
|
* I understand everything in this picture except what the space
|
443 |
|
|
* between fp - 0xe0 and fp - 0x140 is used for. Oh, and I don't
|
444 |
|
|
* understand why there's a large chunk of CALL_DUMMY that never gets
|
445 |
|
|
* executed (its function is superceeded by PUSH_DUMMY_FRAME; they
|
446 |
|
|
* are designed to do the same thing).
|
447 |
|
|
*
|
448 |
|
|
* PUSH_DUMMY_FRAME saves the registers above sp' and pushes the
|
449 |
|
|
* register file stack down one.
|
450 |
|
|
*
|
451 |
|
|
* call_function then writes CALL_DUMMY, pushes the args onto the
|
452 |
|
|
* stack, and adjusts the stack pointer.
|
453 |
|
|
*
|
454 |
|
|
* run_stack_dummy then starts execution (in the middle of
|
455 |
|
|
* CALL_DUMMY, as directed by call_function).
|
456 |
|
|
*/
|
457 |
|
|
|
458 |
|
|
/* Push an empty stack frame, to record the current PC, etc. */
|
459 |
|
|
|
460 |
|
|
#define PUSH_DUMMY_FRAME sparc_push_dummy_frame ()
|
461 |
|
|
#define POP_FRAME sparc_pop_frame ()
|
462 |
|
|
|
463 |
|
|
void sparc_push_dummy_frame PARAMS ((void)), sparc_pop_frame PARAMS ((void));
|
464 |
|
|
|
465 |
|
|
#ifndef CALL_DUMMY
|
466 |
|
|
/* This sequence of words is the instructions
|
467 |
|
|
|
468 |
|
|
0: bc 10 00 01 mov %g1, %fp
|
469 |
|
|
4: 9d e3 80 00 save %sp, %g0, %sp
|
470 |
|
|
8: bc 10 00 02 mov %g2, %fp
|
471 |
|
|
c: be 10 00 03 mov %g3, %i7
|
472 |
|
|
10: da 03 a0 58 ld [ %sp + 0x58 ], %o5
|
473 |
|
|
14: d8 03 a0 54 ld [ %sp + 0x54 ], %o4
|
474 |
|
|
18: d6 03 a0 50 ld [ %sp + 0x50 ], %o3
|
475 |
|
|
1c: d4 03 a0 4c ld [ %sp + 0x4c ], %o2
|
476 |
|
|
20: d2 03 a0 48 ld [ %sp + 0x48 ], %o1
|
477 |
|
|
24: 40 00 00 00 call <fun>
|
478 |
|
|
28: d0 03 a0 44 ld [ %sp + 0x44 ], %o0
|
479 |
|
|
2c: 01 00 00 00 nop
|
480 |
|
|
30: 91 d0 20 01 ta 1
|
481 |
|
|
34: 01 00 00 00 nop
|
482 |
|
|
|
483 |
|
|
NOTES:
|
484 |
|
|
* the first four instructions are necessary only on the simulator.
|
485 |
|
|
* this is a multiple of 8 (not only 4) bytes.
|
486 |
|
|
* the `call' insn is a relative, not an absolute call.
|
487 |
|
|
* the `nop' at the end is needed to keep the trap from
|
488 |
|
|
clobbering things (if NPC pointed to garbage instead).
|
489 |
|
|
*/
|
490 |
|
|
|
491 |
|
|
#define CALL_DUMMY { 0xbc100001, 0x9de38000, 0xbc100002, 0xbe100003, \
|
492 |
|
|
0xda03a058, 0xd803a054, 0xd603a050, 0xd403a04c, \
|
493 |
|
|
0xd203a048, 0x40000000, 0xd003a044, 0x01000000, \
|
494 |
|
|
0x91d02001, 0x01000000 }
|
495 |
|
|
|
496 |
|
|
|
497 |
|
|
/* Size of the call dummy in bytes. */
|
498 |
|
|
|
499 |
|
|
#define CALL_DUMMY_LENGTH 0x38
|
500 |
|
|
|
501 |
|
|
/* Offset within call dummy of first instruction to execute. */
|
502 |
|
|
|
503 |
|
|
#define CALL_DUMMY_START_OFFSET 0
|
504 |
|
|
|
505 |
|
|
/* Offset within CALL_DUMMY of the 'call' instruction. */
|
506 |
|
|
|
507 |
|
|
#define CALL_DUMMY_CALL_OFFSET (CALL_DUMMY_START_OFFSET + 0x24)
|
508 |
|
|
|
509 |
|
|
/* Offset within CALL_DUMMY of the 'ta 1' instruction. */
|
510 |
|
|
|
511 |
|
|
#define CALL_DUMMY_BREAKPOINT_OFFSET (CALL_DUMMY_START_OFFSET + 0x30)
|
512 |
|
|
|
513 |
|
|
#define CALL_DUMMY_STACK_ADJUST 68
|
514 |
|
|
|
515 |
|
|
#endif
|
516 |
|
|
/* Insert the specified number of args and function address
|
517 |
|
|
into a call sequence of the above form stored at DUMMYNAME. */
|
518 |
|
|
|
519 |
|
|
#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
|
520 |
|
|
sparc_fix_call_dummy (dummyname, pc, fun, type, gcc_p)
|
521 |
|
|
void sparc_fix_call_dummy PARAMS ((char *dummy, CORE_ADDR pc, CORE_ADDR fun,
|
522 |
|
|
struct type * value_type, int using_gcc));
|
523 |
|
|
|
524 |
|
|
/* The Sparc returns long doubles on the stack. */
|
525 |
|
|
|
526 |
|
|
#define RETURN_VALUE_ON_STACK(TYPE) \
|
527 |
|
|
(TYPE_CODE(TYPE) == TYPE_CODE_FLT \
|
528 |
|
|
&& TYPE_LENGTH(TYPE) > 8)
|
529 |
|
|
|
530 |
|
|
/* Sparc has no reliable single step ptrace call */
|
531 |
|
|
|
532 |
|
|
#define SOFTWARE_SINGLE_STEP_P 1
|
533 |
|
|
extern void sparc_software_single_step PARAMS ((unsigned int, int));
|
534 |
|
|
#define SOFTWARE_SINGLE_STEP(sig,bp_p) sparc_software_single_step (sig,bp_p)
|
535 |
|
|
|
536 |
|
|
/* We need more arguments in a frame specification for the
|
537 |
|
|
"frame" or "info frame" command. */
|
538 |
|
|
|
539 |
|
|
#define SETUP_ARBITRARY_FRAME(argc, argv) setup_arbitrary_frame (argc, argv)
|
540 |
|
|
extern struct frame_info *setup_arbitrary_frame PARAMS ((int, CORE_ADDR *));
|
541 |
|
|
|
542 |
|
|
/* To print every pair of float registers as a double, we use this hook.
|
543 |
|
|
We also print the condition code registers in a readable format
|
544 |
|
|
(FIXME: can expand this to all control regs). */
|
545 |
|
|
|
546 |
|
|
#undef PRINT_REGISTER_HOOK
|
547 |
|
|
#define PRINT_REGISTER_HOOK(regno) \
|
548 |
|
|
sparc_print_register_hook (regno)
|
549 |
|
|
extern void sparc_print_register_hook PARAMS ((int regno));
|
550 |
|
|
|
551 |
|
|
|
552 |
|
|
/* Optimization for storing registers to the inferior. The hook
|
553 |
|
|
DO_DEFERRED_STORES
|
554 |
|
|
actually executes any deferred stores. It is called any time
|
555 |
|
|
we are going to proceed the child, or read its registers.
|
556 |
|
|
The hook CLEAR_DEFERRED_STORES is called when we want to throw
|
557 |
|
|
away the inferior process, e.g. when it dies or we kill it.
|
558 |
|
|
FIXME, this does not handle remote debugging cleanly. */
|
559 |
|
|
|
560 |
|
|
extern int deferred_stores;
|
561 |
|
|
#define DO_DEFERRED_STORES \
|
562 |
|
|
if (deferred_stores) \
|
563 |
|
|
target_store_registers (-2);
|
564 |
|
|
#define CLEAR_DEFERRED_STORES \
|
565 |
|
|
deferred_stores = 0;
|
566 |
|
|
|
567 |
|
|
/* If the current gcc for for this target does not produce correct debugging
|
568 |
|
|
information for float parameters, both prototyped and unprototyped, then
|
569 |
|
|
define this macro. This forces gdb to always assume that floats are
|
570 |
|
|
passed as doubles and then converted in the callee. */
|
571 |
|
|
|
572 |
|
|
#define COERCE_FLOAT_TO_DOUBLE(formal, actual) (1)
|
573 |
|
|
|
574 |
|
|
/* Select the sparc disassembler */
|
575 |
|
|
|
576 |
|
|
#define TM_PRINT_INSN_MACH bfd_mach_sparc
|
577 |
|
|
|
578 |
|
|
/* Arguments smaller than an int must promoted to ints when synthesizing
|
579 |
|
|
function calls. */
|
580 |
|
|
|
581 |
|
|
#define PUSH_ARGUMENTS(nargs, args, sp, struct_return, struct_addr) \
|
582 |
|
|
(sparc_push_arguments((nargs), (args), (sp), (struct_return), (struct_addr)))
|
583 |
|
|
extern CORE_ADDR
|
584 |
|
|
sparc_push_arguments PARAMS ((int, struct value **, CORE_ADDR, int, CORE_ADDR));
|