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