]>
Commit | Line | Data |
---|---|---|
5076de82 FF |
1 | /* 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. | |
5fc46f6c PS |
3 | Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994 |
4 | Free Software Foundation, Inc. | |
5076de82 FF |
5 | Contributed by Michael Tiemann ([email protected]) |
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., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
22 | ||
23 | #define TARGET_BYTE_ORDER BIG_ENDIAN | |
24 | ||
25 | /* Floating point is IEEE compatible. */ | |
26 | #define IEEE_FLOAT | |
27 | ||
649694ea JK |
28 | /* If an argument is declared "register", Sun cc will keep it in a register, |
29 | never saving it onto the stack. So we better not believe the "p" symbol | |
30 | descriptor stab. */ | |
31 | ||
32 | #define USE_REGISTER_NOT_ARG | |
33 | ||
5076de82 | 34 | /* When passing a structure to a function, Sun cc passes the address |
5afa2040 JK |
35 | not the structure itself. It (under SunOS4) creates two symbols, |
36 | which we need to combine to a LOC_REGPARM. Gcc version two (as of | |
37 | 1.92) behaves like sun cc. REG_STRUCT_HAS_ADDR is smart enough to | |
f2613710 | 38 | distinguish between Sun cc, gcc version 1 and gcc version 2. */ |
5076de82 | 39 | |
84ad95c1 | 40 | #define REG_STRUCT_HAS_ADDR(gcc_p,type) (gcc_p != 1) |
5076de82 | 41 | |
56756a5a JK |
42 | /* Sun /bin/cc gets this right as of SunOS 4.1.x. We need to define |
43 | BELIEVE_PCC_PROMOTION to get this right now that the code which | |
44 | detects gcc2_compiled. is broken. This loses for SunOS 4.0.x and | |
45 | earlier. */ | |
46 | ||
47 | #define BELIEVE_PCC_PROMOTION 1 | |
5076de82 | 48 | |
b8ec9a79 JK |
49 | /* For acc, there's no need to correct LBRAC entries by guessing how |
50 | they should work. In fact, this is harmful because the LBRAC | |
51 | entries now all appear at the end of the function, not intermixed | |
52 | with the SLINE entries. n_opt_found detects acc for Solaris binaries; | |
53 | function_stab_type detects acc for SunOS4 binaries. | |
54 | ||
55 | For binary from SunOS4 /bin/cc, need to correct LBRAC's. | |
56 | ||
57 | For gcc, like acc, don't correct. */ | |
58 | ||
59 | #define SUN_FIXED_LBRAC_BUG \ | |
60 | (n_opt_found \ | |
61 | || function_stab_type == N_STSYM \ | |
62 | || function_stab_type == N_GSYM \ | |
63 | || processing_gcc_compilation) | |
64 | ||
65 | /* Do variables in the debug stabs occur after the N_LBRAC or before it? | |
66 | acc: after, gcc: before, SunOS4 /bin/cc: before. */ | |
67 | ||
68 | #define VARIABLES_INSIDE_BLOCK(desc, gcc_p) \ | |
69 | (!(gcc_p) \ | |
70 | && (n_opt_found \ | |
71 | || function_stab_type == N_STSYM \ | |
72 | || function_stab_type == N_GSYM)) | |
73 | ||
5076de82 FF |
74 | /* Offset from address of function to start of its code. |
75 | Zero on most machines. */ | |
76 | ||
77 | #define FUNCTION_START_OFFSET 0 | |
78 | ||
79 | /* Advance PC across any function entry prologue instructions | |
80 | to reach some "real" code. SKIP_PROLOGUE_FRAMELESS_P advances | |
81 | the PC past some of the prologue, but stops as soon as it | |
82 | knows that the function has a frame. Its result is equal | |
83 | to its input PC if the function is frameless, unequal otherwise. */ | |
84 | ||
85 | #define SKIP_PROLOGUE(pc) \ | |
86 | { pc = skip_prologue (pc, 0); } | |
87 | #define SKIP_PROLOGUE_FRAMELESS_P(pc) \ | |
88 | { pc = skip_prologue (pc, 1); } | |
5fc46f6c | 89 | extern CORE_ADDR skip_prologue PARAMS ((CORE_ADDR, int)); |
5076de82 FF |
90 | |
91 | /* Immediately after a function call, return the saved pc. | |
92 | Can't go through the frames for this because on some machines | |
93 | the new frame is not set up until the new function executes | |
94 | some instructions. */ | |
95 | ||
96 | /* On the Sun 4 under SunOS, the compile will leave a fake insn which | |
97 | encodes the structure size being returned. If we detect such | |
98 | a fake insn, step past it. */ | |
99 | ||
100 | #define PC_ADJUST(pc) sparc_pc_adjust(pc) | |
5fc46f6c | 101 | extern CORE_ADDR sparc_pc_adjust PARAMS ((CORE_ADDR)); |
5076de82 FF |
102 | |
103 | #define SAVED_PC_AFTER_CALL(frame) PC_ADJUST (read_register (RP_REGNUM)) | |
104 | ||
105 | /* Stack grows downward. */ | |
106 | ||
107 | #define INNER_THAN < | |
108 | ||
109 | /* Stack has strict alignment. */ | |
110 | ||
111 | #define STACK_ALIGN(ADDR) (((ADDR)+7)&-8) | |
112 | ||
113 | /* Sequence of bytes for breakpoint instruction. */ | |
114 | ||
115 | #define BREAKPOINT {0x91, 0xd0, 0x20, 0x01} | |
116 | ||
117 | /* Amount PC must be decremented by after a breakpoint. | |
118 | This is often the number of bytes in BREAKPOINT | |
119 | but not always. */ | |
120 | ||
121 | #define DECR_PC_AFTER_BREAK 0 | |
122 | ||
123 | /* Nonzero if instruction at PC is a return instruction. */ | |
124 | /* For SPARC, this is either a "jmpl %o7+8,%g0" or "jmpl %i7+8,%g0". | |
125 | ||
9e350158 DE |
126 | Note: this does not work for functions returning structures under SunOS. |
127 | v9 does not have such critters though. */ | |
5076de82 FF |
128 | #define ABOUT_TO_RETURN(pc) \ |
129 | ((read_memory_integer (pc, 4)|0x00040000) == 0x81c7e008) | |
130 | ||
f4f0d174 JK |
131 | /* Say how long (ordinary) registers are. This is a piece of bogosity |
132 | used in push_word and a few other places; REGISTER_RAW_SIZE is the | |
133 | real way to know how big a register is. */ | |
5076de82 | 134 | |
f4f0d174 | 135 | #define REGISTER_SIZE 4 |
5076de82 FF |
136 | |
137 | /* Number of machine registers */ | |
138 | ||
139 | #define NUM_REGS 72 | |
140 | ||
141 | /* Initializer for an array of names of registers. | |
142 | There should be NUM_REGS strings in this initializer. */ | |
143 | ||
144 | #define REGISTER_NAMES \ | |
145 | { "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7", \ | |
146 | "o0", "o1", "o2", "o3", "o4", "o5", "sp", "o7", \ | |
147 | "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7", \ | |
148 | "i0", "i1", "i2", "i3", "i4", "i5", "fp", "i7", \ | |
149 | \ | |
150 | "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \ | |
151 | "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \ | |
152 | "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", \ | |
153 | "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \ | |
154 | \ | |
155 | "y", "psr", "wim", "tbr", "pc", "npc", "fpsr", "cpsr" } | |
156 | ||
157 | /* Register numbers of various important registers. | |
158 | Note that some of these values are "real" register numbers, | |
159 | and correspond to the general registers of the machine, | |
160 | and some are "phony" register numbers which are too large | |
161 | to be actual register numbers as far as the user is concerned | |
162 | but do serve to get the desired values when passed to read_register. */ | |
163 | ||
164 | #define G0_REGNUM 0 /* %g0 */ | |
165 | #define G1_REGNUM 1 /* %g1 */ | |
166 | #define O0_REGNUM 8 /* %o0 */ | |
167 | #define SP_REGNUM 14 /* Contains address of top of stack, \ | |
168 | which is also the bottom of the frame. */ | |
169 | #define RP_REGNUM 15 /* Contains return address value, *before* \ | |
170 | any windows get switched. */ | |
171 | #define O7_REGNUM 15 /* Last local reg not saved on stack frame */ | |
172 | #define L0_REGNUM 16 /* First local reg that's saved on stack frame | |
173 | rather than in machine registers */ | |
174 | #define I0_REGNUM 24 /* %i0 */ | |
175 | #define FP_REGNUM 30 /* Contains address of executing stack frame */ | |
176 | #define I7_REGNUM 31 /* Last local reg saved on stack frame */ | |
177 | #define FP0_REGNUM 32 /* Floating point register 0 */ | |
178 | #define Y_REGNUM 64 /* Temp register for multiplication, etc. */ | |
179 | #define PS_REGNUM 65 /* Contains processor status */ | |
180 | #define WIM_REGNUM 66 /* Window Invalid Mask (not really supported) */ | |
181 | #define TBR_REGNUM 67 /* Trap Base Register (not really supported) */ | |
182 | #define PC_REGNUM 68 /* Contains program counter */ | |
183 | #define NPC_REGNUM 69 /* Contains next PC */ | |
184 | #define FPS_REGNUM 70 /* Floating point status register */ | |
185 | #define CPS_REGNUM 71 /* Coprocessor status register */ | |
186 | ||
187 | /* Total amount of space needed to store our copies of the machine's | |
c4f8f209 JK |
188 | register state, the array `registers'. On the sparc, `registers' |
189 | contains the ins and locals, even though they are saved on the | |
190 | stack rather than with the other registers, and this causes hair | |
ee7b9e92 | 191 | and confusion in places like pop_frame. It might be |
c4f8f209 JK |
192 | better to remove the ins and locals from `registers', make sure |
193 | that get_saved_register can get them from the stack (even in the | |
194 | innermost frame), and make this the way to access them. For the | |
ee7b9e92 JK |
195 | frame pointer we would do that via TARGET_READ_FP. On the other hand, |
196 | that is likely to be confusing or worse for flat frames. */ | |
c4f8f209 | 197 | |
5076de82 FF |
198 | #define REGISTER_BYTES (32*4+32*4+8*4) |
199 | ||
200 | /* Index within `registers' of the first byte of the space for | |
201 | register N. */ | |
202 | /* ?? */ | |
203 | #define REGISTER_BYTE(N) ((N)*4) | |
204 | ||
ee7b9e92 JK |
205 | /* We need to override GET_SAVED_REGISTER so that we can deal with the way |
206 | outs change into ins in different frames. HAVE_REGISTER_WINDOWS can't | |
207 | deal with this case and also handle flat frames at the same time. */ | |
5076de82 | 208 | |
ee7b9e92 | 209 | #define GET_SAVED_REGISTER 1 |
5076de82 | 210 | |
5076de82 FF |
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 | ||
5076de82 FF |
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. */ | |
247 | ||
248 | #define STORE_STRUCT_RETURN(ADDR, SP) \ | |
249 | { target_write_memory ((SP)+(16*4), (char *)&(ADDR), 4); } | |
250 | ||
251 | /* Extract from an array REGBUF containing the (raw) register state | |
252 | a function return value of type TYPE, and copy that, in virtual format, | |
253 | into VALBUF. */ | |
254 | ||
255 | #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ | |
256 | { \ | |
257 | if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) \ | |
258 | { \ | |
259 | memcpy ((VALBUF), ((int *)(REGBUF))+FP0_REGNUM, TYPE_LENGTH(TYPE));\ | |
260 | } \ | |
261 | else \ | |
262 | memcpy ((VALBUF), \ | |
9e350158 DE |
263 | (char *)(REGBUF) + REGISTER_RAW_SIZE (O0_REGNUM) * 8 + \ |
264 | (TYPE_LENGTH(TYPE) >= REGISTER_RAW_SIZE (O0_REGNUM) \ | |
265 | ? 0 : REGISTER_RAW_SIZE (O0_REGNUM) - TYPE_LENGTH(TYPE)), \ | |
5076de82 FF |
266 | TYPE_LENGTH(TYPE)); \ |
267 | } | |
268 | ||
269 | /* Write into appropriate registers a function return value | |
270 | of type TYPE, given in virtual format. */ | |
271 | /* On sparc, values are returned in register %o0. */ | |
272 | #define STORE_RETURN_VALUE(TYPE,VALBUF) \ | |
273 | { \ | |
274 | if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) \ | |
275 | /* Floating-point values are returned in the register pair */ \ | |
276 | /* formed by %f0 and %f1 (doubles are, anyway). */ \ | |
277 | write_register_bytes (REGISTER_BYTE (FP0_REGNUM), (VALBUF), \ | |
278 | TYPE_LENGTH (TYPE)); \ | |
279 | else \ | |
280 | /* Other values are returned in register %o0. */ \ | |
281 | write_register_bytes (REGISTER_BYTE (O0_REGNUM), (VALBUF), \ | |
282 | TYPE_LENGTH (TYPE)); \ | |
283 | } | |
284 | ||
285 | /* Extract from an array REGBUF containing the (raw) register state | |
286 | the address in which a function should return its structure value, | |
287 | as a CORE_ADDR (or an expression that can be used as one). */ | |
288 | ||
289 | #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \ | |
290 | (sparc_extract_struct_value_address (REGBUF)) | |
291 | ||
292 | extern CORE_ADDR | |
293 | sparc_extract_struct_value_address PARAMS ((char [REGISTER_BYTES])); | |
294 | ||
295 | \f | |
296 | /* Describe the pointer in each stack frame to the previous stack frame | |
297 | (its caller). */ | |
298 | ||
299 | /* FRAME_CHAIN takes a frame's nominal address | |
300 | and produces the frame's chain-pointer. */ | |
301 | ||
302 | /* In the case of the Sun 4, the frame-chain's nominal address | |
303 | is held in the frame pointer register. | |
304 | ||
305 | On the Sun4, the frame (in %fp) is %sp for the previous frame. | |
306 | From the previous frame's %sp, we can find the previous frame's | |
307 | %fp: it is in the save area just above the previous frame's %sp. | |
308 | ||
309 | If we are setting up an arbitrary frame, we'll need to know where | |
310 | it ends. Hence the following. This part of the frame cache | |
311 | structure should be checked before it is assumed that this frame's | |
312 | bottom is in the stack pointer. | |
313 | ||
314 | If there isn't a frame below this one, the bottom of this frame is | |
315 | in the stack pointer. | |
316 | ||
317 | If there is a frame below this one, and the frame pointers are | |
318 | identical, it's a leaf frame and the bottoms are the same also. | |
319 | ||
23a8e291 JK |
320 | Otherwise the bottom of this frame is the top of the next frame. |
321 | ||
322 | The bottom field is misnamed, since it might imply that memory from | |
323 | bottom to frame contains this frame. That need not be true if | |
324 | stack frames are allocated in different segments (e.g. some on a | |
eb891088 SS |
325 | stack, some on a heap in the data segment). |
326 | ||
327 | GCC 2.6 and later can generate ``flat register window'' code that | |
328 | makes frames by explicitly saving those registers that need to be | |
329 | saved. %i7 is used as the frame pointer, and the frame is laid out so | |
330 | that flat and non-flat calls can be intermixed freely within a | |
331 | program. Unfortunately for GDB, this means it must detect and record | |
332 | the flatness of frames. | |
333 | ||
334 | Since the prologue in a flat frame also tells us where fp and pc | |
335 | have been stashed (the frame is of variable size, so their location | |
336 | is not fixed), it's convenient to record them in the frame info. */ | |
337 | ||
338 | #define EXTRA_FRAME_INFO \ | |
339 | CORE_ADDR bottom; \ | |
340 | int flat; \ | |
ee7b9e92 | 341 | /* Following fields only relevant for flat frames. */ \ |
eb891088 SS |
342 | CORE_ADDR pc_addr; \ |
343 | CORE_ADDR fp_addr; \ | |
ee7b9e92 JK |
344 | /* Add this to ->frame to get the value of the stack pointer at the */ \ |
345 | /* time of the register saves. */ \ | |
346 | int sp_offset; | |
eb891088 SS |
347 | |
348 | #define INIT_EXTRA_FRAME_INFO(fromleaf, fci) \ | |
349 | sparc_init_extra_frame_info (fromleaf, fci) | |
350 | extern void sparc_init_extra_frame_info (); | |
351 | ||
352 | #define PRINT_EXTRA_FRAME_INFO(fi) \ | |
353 | { \ | |
354 | if ((fi) && (fi)->flat) \ | |
355 | printf_filtered (" flat, pc saved at 0x%x, fp saved at 0x%x\n", \ | |
356 | (fi)->pc_addr, (fi)->fp_addr); \ | |
357 | } | |
5076de82 | 358 | |
ee7b9e92 JK |
359 | #ifdef __STDC__ |
360 | struct frame_info; | |
361 | #endif | |
362 | ||
5076de82 | 363 | #define FRAME_CHAIN(thisframe) (sparc_frame_chain (thisframe)) |
ee7b9e92 JK |
364 | extern CORE_ADDR sparc_frame_chain PARAMS ((struct frame_info *)); |
365 | ||
366 | /* INIT_EXTRA_FRAME_INFO needs the PC to detect flat frames. */ | |
367 | ||
368 | #define INIT_FRAME_PC(fromleaf, prev) /* nothing */ | |
369 | #define INIT_FRAME_PC_FIRST(fromleaf, prev) \ | |
370 | (prev)->pc = ((fromleaf) ? SAVED_PC_AFTER_CALL ((prev)->next) : \ | |
371 | (prev)->next ? FRAME_SAVED_PC ((prev)->next) : read_pc ()); | |
5076de82 FF |
372 | |
373 | /* Define other aspects of the stack frame. */ | |
374 | ||
375 | /* A macro that tells us whether the function invocation represented | |
376 | by FI does not have a frame on the stack associated with it. If it | |
377 | does not, FRAMELESS is set to 1, else 0. */ | |
378 | #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ | |
379 | (FRAMELESS) = frameless_look_for_prologue(FI) | |
380 | ||
8bf94f44 SG |
381 | /* The location of I0 w.r.t SP. This is actually dependent on how the system's |
382 | window overflow/underflow routines are written. Most vendors save the L regs | |
383 | followed by the I regs (at the higher address). Some vendors get it wrong. | |
384 | */ | |
385 | ||
386 | #define FRAME_SAVED_L0 0 | |
387 | #define FRAME_SAVED_I0 (8 * REGISTER_RAW_SIZE (L0_REGNUM)) | |
388 | ||
5076de82 FF |
389 | /* Where is the PC for a specific frame */ |
390 | ||
8bf94f44 | 391 | #define FRAME_SAVED_PC(FRAME) sparc_frame_saved_pc (FRAME) |
eb891088 | 392 | extern CORE_ADDR sparc_frame_saved_pc (); |
5076de82 FF |
393 | |
394 | /* If the argument is on the stack, it will be here. */ | |
395 | #define FRAME_ARGS_ADDRESS(fi) ((fi)->frame) | |
396 | ||
397 | #define FRAME_STRUCT_ARGS_ADDRESS(fi) ((fi)->frame) | |
398 | ||
399 | #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) | |
400 | ||
401 | /* Set VAL to the number of args passed to frame described by FI. | |
402 | Can set VAL to -1, meaning no way to tell. */ | |
403 | ||
404 | /* We can't tell how many args there are | |
405 | now that the C compiler delays popping them. */ | |
406 | #define FRAME_NUM_ARGS(val,fi) (val = -1) | |
407 | ||
408 | /* Return number of bytes at start of arglist that are not really args. */ | |
409 | ||
410 | #define FRAME_ARGS_SKIP 68 | |
5076de82 FF |
411 | \f |
412 | /* Things needed for making the inferior call functions. */ | |
413 | /* | |
414 | * First of all, let me give my opinion of what the DUMMY_FRAME | |
415 | * actually looks like. | |
416 | * | |
417 | * | | | |
418 | * | | | |
419 | * + - - - - - - - - - - - - - - - - +<-- fp (level 0) | |
420 | * | | | |
421 | * | | | |
422 | * | | | |
423 | * | | | |
424 | * | Frame of innermost program | | |
425 | * | function | | |
426 | * | | | |
427 | * | | | |
428 | * | | | |
429 | * | | | |
430 | * | | | |
431 | * |---------------------------------|<-- sp (level 0), fp (c) | |
432 | * | | | |
433 | * DUMMY | fp0-31 | | |
434 | * | | | |
435 | * | ------ |<-- fp - 0x80 | |
436 | * FRAME | g0-7 |<-- fp - 0xa0 | |
437 | * | i0-7 |<-- fp - 0xc0 | |
438 | * | other |<-- fp - 0xe0 | |
439 | * | ? | | |
440 | * | ? | | |
441 | * |---------------------------------|<-- sp' = fp - 0x140 | |
442 | * | | | |
443 | * xcution start | | | |
444 | * sp' + 0x94 -->| CALL_DUMMY (x code) | | |
445 | * | | | |
446 | * | | | |
447 | * |---------------------------------|<-- sp'' = fp - 0x200 | |
448 | * | align sp to 8 byte boundary | | |
449 | * | ==> args to fn <== | | |
450 | * Room for | | | |
451 | * i & l's + agg | CALL_DUMMY_STACK_ADJUST = 0x0x44| | |
452 | * |---------------------------------|<-- final sp (variable) | |
453 | * | | | |
454 | * | Where function called will | | |
455 | * | build frame. | | |
456 | * | | | |
457 | * | | | |
458 | * | |
459 | * I understand everything in this picture except what the space | |
460 | * between fp - 0xe0 and fp - 0x140 is used for. Oh, and I don't | |
461 | * understand why there's a large chunk of CALL_DUMMY that never gets | |
462 | * executed (its function is superceeded by PUSH_DUMMY_FRAME; they | |
463 | * are designed to do the same thing). | |
464 | * | |
465 | * PUSH_DUMMY_FRAME saves the registers above sp' and pushes the | |
466 | * register file stack down one. | |
467 | * | |
468 | * call_function then writes CALL_DUMMY, pushes the args onto the | |
469 | * stack, and adjusts the stack pointer. | |
470 | * | |
471 | * run_stack_dummy then starts execution (in the middle of | |
472 | * CALL_DUMMY, as directed by call_function). | |
473 | */ | |
474 | ||
475 | /* Push an empty stack frame, to record the current PC, etc. */ | |
476 | ||
477 | #define PUSH_DUMMY_FRAME sparc_push_dummy_frame () | |
478 | #define POP_FRAME sparc_pop_frame () | |
479 | ||
480 | void sparc_push_dummy_frame (), sparc_pop_frame (); | |
481 | /* This sequence of words is the instructions | |
482 | ||
483 | save %sp,-0x140,%sp | |
484 | std %f30,[%fp-0x08] | |
485 | std %f28,[%fp-0x10] | |
486 | std %f26,[%fp-0x18] | |
487 | std %f24,[%fp-0x20] | |
488 | std %f22,[%fp-0x28] | |
489 | std %f20,[%fp-0x30] | |
490 | std %f18,[%fp-0x38] | |
491 | std %f16,[%fp-0x40] | |
492 | std %f14,[%fp-0x48] | |
493 | std %f12,[%fp-0x50] | |
494 | std %f10,[%fp-0x58] | |
495 | std %f8,[%fp-0x60] | |
496 | std %f6,[%fp-0x68] | |
497 | std %f4,[%fp-0x70] | |
498 | std %f2,[%fp-0x78] | |
499 | std %f0,[%fp-0x80] | |
500 | std %g6,[%fp-0x88] | |
501 | std %g4,[%fp-0x90] | |
502 | std %g2,[%fp-0x98] | |
503 | std %g0,[%fp-0xa0] | |
504 | std %i6,[%fp-0xa8] | |
505 | std %i4,[%fp-0xb0] | |
506 | std %i2,[%fp-0xb8] | |
507 | std %i0,[%fp-0xc0] | |
508 | nop ! stcsr [%fp-0xc4] | |
509 | nop ! stfsr [%fp-0xc8] | |
510 | nop ! wr %npc,[%fp-0xcc] | |
511 | nop ! wr %pc,[%fp-0xd0] | |
512 | rd %tbr,%o0 | |
513 | st %o0,[%fp-0xd4] | |
514 | rd %wim,%o1 | |
515 | st %o0,[%fp-0xd8] | |
516 | rd %psr,%o0 | |
517 | st %o0,[%fp-0xdc] | |
518 | rd %y,%o0 | |
519 | st %o0,[%fp-0xe0] | |
520 | ||
521 | /..* The arguments are pushed at this point by GDB; | |
522 | no code is needed in the dummy for this. | |
523 | The CALL_DUMMY_START_OFFSET gives the position of | |
524 | the following ld instruction. *../ | |
525 | ||
526 | ld [%sp+0x58],%o5 | |
527 | ld [%sp+0x54],%o4 | |
528 | ld [%sp+0x50],%o3 | |
529 | ld [%sp+0x4c],%o2 | |
530 | ld [%sp+0x48],%o1 | |
531 | call 0x00000000 | |
532 | ld [%sp+0x44],%o0 | |
533 | nop | |
534 | ta 1 | |
535 | nop | |
536 | ||
537 | note that this is 192 bytes, which is a multiple of 8 (not only 4) bytes. | |
538 | note that the `call' insn is a relative, not an absolute call. | |
539 | note that the `nop' at the end is needed to keep the trap from | |
540 | clobbering things (if NPC pointed to garbage instead). | |
541 | ||
542 | We actually start executing at the `sethi', since the pushing of the | |
543 | registers (as arguments) is done by PUSH_DUMMY_FRAME. If this were | |
544 | real code, the arguments for the function called by the CALL would be | |
545 | pushed between the list of ST insns and the CALL, and we could allow | |
546 | it to execute through. But the arguments have to be pushed by GDB | |
547 | after the PUSH_DUMMY_FRAME is done, and we cannot allow these ST | |
548 | insns to be performed again, lest the registers saved be taken for | |
549 | arguments. */ | |
550 | ||
551 | #define CALL_DUMMY { 0x9de3bee0, 0xfd3fbff8, 0xf93fbff0, 0xf53fbfe8, \ | |
552 | 0xf13fbfe0, 0xed3fbfd8, 0xe93fbfd0, 0xe53fbfc8, \ | |
553 | 0xe13fbfc0, 0xdd3fbfb8, 0xd93fbfb0, 0xd53fbfa8, \ | |
554 | 0xd13fbfa0, 0xcd3fbf98, 0xc93fbf90, 0xc53fbf88, \ | |
555 | 0xc13fbf80, 0xcc3fbf78, 0xc83fbf70, 0xc43fbf68, \ | |
556 | 0xc03fbf60, 0xfc3fbf58, 0xf83fbf50, 0xf43fbf48, \ | |
557 | 0xf03fbf40, 0x01000000, 0x01000000, 0x01000000, \ | |
558 | 0x01000000, 0x91580000, 0xd027bf50, 0x93500000, \ | |
559 | 0xd027bf4c, 0x91480000, 0xd027bf48, 0x91400000, \ | |
560 | 0xd027bf44, 0xda03a058, 0xd803a054, 0xd603a050, \ | |
561 | 0xd403a04c, 0xd203a048, 0x40000000, 0xd003a044, \ | |
562 | 0x01000000, 0x91d02001, 0x01000000, 0x01000000} | |
563 | ||
564 | #define CALL_DUMMY_LENGTH 192 | |
565 | ||
566 | #define CALL_DUMMY_START_OFFSET 148 | |
567 | ||
84d59861 JK |
568 | #define CALL_DUMMY_BREAKPOINT_OFFSET (CALL_DUMMY_START_OFFSET + (8 * 4)) |
569 | ||
5076de82 FF |
570 | #define CALL_DUMMY_STACK_ADJUST 68 |
571 | ||
572 | /* Insert the specified number of args and function address | |
573 | into a call sequence of the above form stored at DUMMYNAME. | |
574 | ||
575 | For structs and unions, if the function was compiled with Sun cc, | |
576 | it expects 'unimp' after the call. But gcc doesn't use that | |
577 | (twisted) convention. So leave a nop there for gcc (FIX_CALL_DUMMY | |
578 | can assume it is operating on a pristine CALL_DUMMY, not one that | |
579 | has already been customized for a different function). */ | |
580 | ||
a706069f | 581 | #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \ |
5076de82 | 582 | { \ |
a706069f SG |
583 | store_unsigned_integer (dummyname + 168, 4, \ |
584 | 0x40000000 | ((fun - (pc + 168)) >> 2)); \ | |
585 | if (!gcc_p \ | |
5076de82 | 586 | && (TYPE_CODE (type) == TYPE_CODE_STRUCT \ |
a706069f SG |
587 | || TYPE_CODE (type) == TYPE_CODE_UNION)) \ |
588 | store_unsigned_integer (dummyname + 176, 4, TYPE_LENGTH (type) & 0x1fff); \ | |
5076de82 FF |
589 | } |
590 | ||
591 | \f | |
592 | /* Sparc has no reliable single step ptrace call */ | |
593 | ||
594 | #define NO_SINGLE_STEP 1 | |
5fc46f6c | 595 | extern void single_step PARAMS ((int)); |
5076de82 FF |
596 | |
597 | /* We need more arguments in a frame specification for the | |
598 | "frame" or "info frame" command. */ | |
599 | ||
600 | #define SETUP_ARBITRARY_FRAME(argc, argv) setup_arbitrary_frame (argc, argv) | |
5076de82 FF |
601 | extern struct frame_info *setup_arbitrary_frame PARAMS ((int, CORE_ADDR *)); |
602 | ||
603 | /* To print every pair of float registers as a double, we use this hook. */ | |
604 | ||
605 | #define PRINT_REGISTER_HOOK(regno) \ | |
606 | if (((regno) >= FP0_REGNUM) \ | |
607 | && ((regno) < FP0_REGNUM + 32) \ | |
8df6afe6 | 608 | && (0 == ((regno) & 1))) { \ |
5076de82 | 609 | char doublereg[8]; /* two float regs */ \ |
8df6afe6 DE |
610 | if (!read_relative_register_raw_bytes ((regno) , doublereg ) \ |
611 | && !read_relative_register_raw_bytes ((regno)+1, doublereg+4)) { \ | |
5076de82 FF |
612 | printf("\t"); \ |
613 | print_floating (doublereg, builtin_type_double, stdout); \ | |
614 | } \ | |
615 | } | |
616 | ||
617 | /* Optimization for storing registers to the inferior. The hook | |
618 | DO_DEFERRED_STORES | |
619 | actually executes any deferred stores. It is called any time | |
620 | we are going to proceed the child, or read its registers. | |
621 | The hook CLEAR_DEFERRED_STORES is called when we want to throw | |
622 | away the inferior process, e.g. when it dies or we kill it. | |
623 | FIXME, this does not handle remote debugging cleanly. */ | |
624 | ||
625 | extern int deferred_stores; | |
626 | #define DO_DEFERRED_STORES \ | |
627 | if (deferred_stores) \ | |
628 | target_store_registers (-2); | |
629 | #define CLEAR_DEFERRED_STORES \ | |
630 | deferred_stores = 0; |