gdb-3.5
[deliverable/binutils-gdb.git] / gdb / m-sparc.h
1 /* Parameters for execution on a Sun 4, for GDB, the GNU debugger.
2 Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
3 Contributed by Michael Tiemann (tiemann@mcc.com)
4 This file is part of GDB.
5
6 GDB 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 1, or (at your option)
9 any later version.
10
11 GDB 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 GDB; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20 #ifndef sun4
21 #define sun4
22 #endif
23
24 /* Define the bit, byte, and word ordering of the machine. */
25 #define BITS_BIG_ENDIAN
26 #define BYTES_BIG_ENDIAN
27 #define WORDS_BIG_ENDIAN
28
29 /* Floating point is IEEE compatible. */
30 #define IEEE_FLOAT
31
32 /* Get rid of any system-imposed stack limit if possible. */
33
34 #define SET_STACK_LIMIT_HUGE
35
36 /* Define this if the C compiler puts an underscore at the front
37 of external names before giving them to the linker. */
38
39 #define NAMES_HAVE_UNDERSCORE
40
41 /* Debugger information will be in DBX format. */
42
43 #define READ_DBX_FORMAT
44
45 /* When passing a structure to a function, Sun cc passes the address
46 in a register, not the structure itself. It (under SunOS4) creates
47 two symbols, so we get a LOC_ARG saying the address is on the stack
48 (a lie, and a serious one since we don't know which register to
49 use), and a LOC_REGISTER saying that the struct is in a register
50 (sort of a lie, but fixable with REG_STRUCT_HAS_ADDR).
51
52 This still doesn't work if the argument is not one passed in a
53 register (i.e. it's the 7th or later argument). */
54 #define REG_STRUCT_HAS_ADDR(gcc_p) (!gcc_p)
55 #define STRUCT_ARG_SYM_GARBAGE(gcc_p) (!gcc_p)
56
57 /* If Pcc says that a parameter is a short, it's a short. This is
58 because the parameter does get passed in in a register as an int,
59 but pcc puts it onto the stack frame as a short (not nailing
60 whatever else might be there. I'm not sure that I consider this
61 swift. Sigh.)
62
63 No, don't do this. The problem here is that pcc says that the
64 argument is in the upper half of the word reserved on the stack,
65 but puts it in the lower half. */
66 /* #define BELIEVE_PCC_PROMOTION 1 */
67 /* OK, I've added code to dbxread.c to deal with this case. */
68 #define BELIEVE_PCC_PROMOTION_TYPE
69
70 /* Offset from address of function to start of its code.
71 Zero on most machines. */
72
73 #define FUNCTION_START_OFFSET 0
74
75 /* Advance PC across any function entry prologue instructions
76 to reach some "real" code. */
77
78 #define SKIP_PROLOGUE(pc) \
79 { pc = skip_prologue (pc); }
80
81 /* Immediately after a function call, return the saved pc.
82 Can't go through the frames for this because on some machines
83 the new frame is not set up until the new function executes
84 some instructions. */
85
86 /* On the Sun 4 under SunOS, the compile will leave a fake insn which
87 encodes the structure size being returned. If we detect such
88 a fake insn, step past it. */
89
90 #define PC_ADJUST(pc) ((read_memory_integer (pc + 8, 4) & 0xfffffe00) == 0 ? \
91 pc+12 : pc+8)
92
93 #define SAVED_PC_AFTER_CALL(frame) PC_ADJUST (read_register (RP_REGNUM))
94
95 /* Address of end of stack space. */
96 #include <sys/types.h>
97 #include <machine/vmparam.h>
98 #define STACK_END_ADDR USRSTACK
99
100 #define INNER_THAN <
101
102 /* Stack has strict alignment. */
103
104 #define STACK_ALIGN(ADDR) (((ADDR)+7)&-8)
105
106 /* Sequence of bytes for breakpoint instruction. */
107
108 #define BREAKPOINT {0x91, 0xd0, 0x20, 0x01}
109
110 /* Amount PC must be decremented by after a breakpoint.
111 This is often the number of bytes in BREAKPOINT
112 but not always. */
113
114 #define DECR_PC_AFTER_BREAK 0
115
116 /* Nonzero if instruction at PC is a return instruction. */
117 /* For SPARC, this is either a "jmpl %o7+8,%g0" or "jmpl %i7+8,%g0".
118
119 Note: this does not work for functions returning structures under SunOS. */
120 #define ABOUT_TO_RETURN(pc) \
121 ((read_memory_integer (pc, 4)|0x00040000) == 0x81c7e008)
122
123 /* Return 1 if P points to an invalid floating point value. */
124
125 #define INVALID_FLOAT(p, len) 0 /* Just a first guess; not checked */
126
127 /* Largest integer type */
128 #define LONGEST long
129
130 /* Name of the builtin type for the LONGEST type above. */
131 #define BUILTIN_TYPE_LONGEST builtin_type_long
132
133 /* Say how long (ordinary) registers are. */
134
135 #define REGISTER_TYPE long
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 FP_REGNUM 30 /* Contains address of executing stack frame */
165 #define RP_REGNUM 15 /* Contains return address value, *before* \
166 any windows get switched. */
167 #define SP_REGNUM 14 /* Contains address of top of stack, \
168 which is also the bottom of the frame. */
169 #define Y_REGNUM 64 /* Temp register for multiplication, etc. */
170 #define PS_REGNUM 65 /* Contains processor status */
171 #define PC_REGNUM 68 /* Contains program counter */
172 #define NPC_REGNUM 69 /* Contains next PC */
173 #define FP0_REGNUM 32 /* Floating point register 0 */
174 #define FPS_REGNUM 70 /* Floating point status register */
175 #define CPS_REGNUM 71 /* Coprocessor status register */
176
177 /* Total amount of space needed to store our copies of the machine's
178 register state, the array `registers'. */
179 #define REGISTER_BYTES (32*4+32*4+8*4)
180
181 /* Index within `registers' of the first byte of the space for
182 register N. */
183 /* ?? */
184 #define REGISTER_BYTE(N) ((N)*4)
185
186 /* The SPARC processor has register windows. */
187
188 #define HAVE_REGISTER_WINDOWS
189
190 /* Is this register part of the register window system? A yes answer
191 implies that 1) The name of this register will not be the same in
192 other frames, and 2) This register is automatically "saved" (out
193 registers shifting into ins counts) upon subroutine calls and thus
194 there is no need to search more than one stack frame for it. */
195
196 #define REGISTER_IN_WINDOW_P(regnum) \
197 ((regnum) >= 8 && (regnum) < 32)
198
199 /* Number of bytes of storage in the actual machine representation
200 for register N. */
201
202 /* On the SPARC, all regs are 4 bytes. */
203
204 #define REGISTER_RAW_SIZE(N) (4)
205
206 /* Number of bytes of storage in the program's representation
207 for register N. */
208
209 /* On the SPARC, all regs are 4 bytes. */
210
211 #define REGISTER_VIRTUAL_SIZE(N) (4)
212
213 /* Largest value REGISTER_RAW_SIZE can have. */
214
215 #define MAX_REGISTER_RAW_SIZE 8
216
217 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
218
219 #define MAX_REGISTER_VIRTUAL_SIZE 8
220
221 /* Nonzero if register N requires conversion
222 from raw format to virtual format. */
223
224 #define REGISTER_CONVERTIBLE(N) (0)
225
226 /* Convert data from raw format for register REGNUM
227 to virtual format for register REGNUM. */
228
229 #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
230 { bcopy ((FROM), (TO), 4); }
231
232 /* Convert data from virtual format for register REGNUM
233 to raw format for register REGNUM. */
234
235 #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
236 { bcopy ((FROM), (TO), 4); }
237
238 /* Return the GDB type object for the "standard" data type
239 of data in register N. */
240
241 #define REGISTER_VIRTUAL_TYPE(N) \
242 ((N) < 32 ? builtin_type_int : (N) < 64 ? builtin_type_float : \
243 builtin_type_int)
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 { write_memory ((SP)+(16*4), &(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 bcopy (((int *)(REGBUF))+FP0_REGNUM, \
260 (VALBUF), TYPE_LENGTH(TYPE)); \
261 } \
262 else \
263 bcopy (((int *)(REGBUF))+8, (VALBUF), TYPE_LENGTH (TYPE)); \
264 }
265
266 /* Write into appropriate registers a function return value
267 of type TYPE, given in virtual format. */
268 /* On sparc, values are returned in register %o0. */
269 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
270 { \
271 if (TYPE_CODE (TYPE) = TYPE_CODE_FLT) \
272 /* Floating-point values are returned in the register pair */ \
273 /* formed by %f0 and %f1 (doubles are, anyway). */ \
274 write_register_bytes (REGISTER_BYTE (FP0_REGNUM), (VALBUF), \
275 TYPE_LENGTH (TYPE)); \
276 else \
277 /* Other values are returned in register %o0. */ \
278 write_register_bytes (REGISTER_BYTE (8), VALBUF, TYPE_LENGTH (TYPE)); \
279 }
280
281 /* Extract from an array REGBUF containing the (raw) register state
282 the address in which a function should return its structure value,
283 as a CORE_ADDR (or an expression that can be used as one). */
284
285 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \
286 (read_memory_integer (((int *)(REGBUF))[SP_REGNUM]+(16*4), 4))
287
288 /* Enable use of alternate code to read and write registers. */
289
290 #define NEW_SUN_PTRACE
291
292 /* Enable use of alternate code for Sun's format of core dump file. */
293
294 #define NEW_SUN_CORE
295
296 /* Do implement the attach and detach commands. */
297
298 #define ATTACH_DETACH
299
300 \f
301 /* Describe the pointer in each stack frame to the previous stack frame
302 (its caller). */
303 #include <machine/reg.h>
304
305 #define GET_RWINDOW_REG(FRAME, REG) \
306 (read_memory_integer (&((struct rwindow *)FRAME)->REG, 4))
307
308 /* FRAME_CHAIN takes a frame's nominal address
309 and produces the frame's chain-pointer.
310
311 FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address
312 and produces the nominal address of the caller frame.
313
314 However, if FRAME_CHAIN_VALID returns zero,
315 it means the given frame is the outermost one and has no caller.
316 In that case, FRAME_CHAIN_COMBINE is not used. */
317
318 /* In the case of the Sun 4, the frame-chain's nominal address
319 is held in the frame pointer register.
320
321 On the Sun4, the frame (in %fp) is %sp for the previous frame.
322 From the previous frame's %sp, we can find the previous frame's
323 %fp: it is in the save area just above the previous frame's %sp.
324
325 If we are setting up an arbitrary frame, we'll need to know where
326 it ends. Hence the following. This part of the frame cache
327 structure should be checked before it is assumed that this frame's
328 bottom is in the stack pointer.
329
330 If there isn't a frame below this one, the bottom of this frame is
331 in the stack pointer.
332
333 If there is a frame below this one, and the frame pointers are
334 identical, it's a leaf frame and the bottoms are the same also.
335
336 Otherwise the bottom of this frame is the top of the next frame. */
337
338 #define EXTRA_FRAME_INFO FRAME_ADDR bottom;
339 #define INIT_EXTRA_FRAME_INFO(fci) \
340 (fci)->bottom = \
341 ((fci)->next ? \
342 ((fci)->frame == (fci)->next_frame ? \
343 (fci)->next->bottom : (fci)->next->frame) : \
344 read_register (SP_REGNUM));
345
346 #define FRAME_CHAIN(thisframe) \
347 GET_RWINDOW_REG ((thisframe)->frame, rw_in[6])
348
349 #define FRAME_CHAIN_VALID(chain, thisframe) \
350 (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe))))
351
352 #define FRAME_CHAIN_COMBINE(chain, thisframe) (chain)
353
354 /* Define other aspects of the stack frame. */
355
356 /* A macro that tells us whether the function invocation represented
357 by FI does not have a frame on the stack associated with it. If it
358 does not, FRAMELESS is set to 1, else 0. */
359 #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \
360 FRAMELESS_LOOK_FOR_PROLOGUE(FI, FRAMELESS)
361
362 /* Where is the PC for a specific frame */
363
364 #define FRAME_SAVED_PC(FRAME) frame_saved_pc (FRAME)
365
366 /* If the argument is on the stack, it will be here. */
367 #define FRAME_ARGS_ADDRESS(fi) ((fi)->frame)
368
369 #define FRAME_STRUCT_ARGS_ADDRESS(fi) ((fi)->frame)
370
371 #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
372
373 /* Set VAL to the number of args passed to frame described by FI.
374 Can set VAL to -1, meaning no way to tell. */
375
376 /* We can't tell how many args there are
377 now that the C compiler delays popping them. */
378 #define FRAME_NUM_ARGS(val,fi) (val = -1)
379
380 /* Return number of bytes at start of arglist that are not really args. */
381
382 #define FRAME_ARGS_SKIP 68
383
384 /* Put here the code to store, into a struct frame_saved_regs,
385 the addresses of the saved registers of frame described by FRAME_INFO.
386 This includes special registers such as pc and fp saved in special
387 ways in the stack frame. sp is even more special:
388 the address we return for it IS the sp for the next frame.
389
390 Note that on register window machines, we are currently making the
391 assumption that window registers are being saved somewhere in the
392 frame in which they are being used. If they are stored in an
393 inferior frame, find_saved_register will break.
394
395 On the Sun 4, the only time all registers are saved is when
396 a dummy frame is involved. Otherwise, the only saved registers
397 are the LOCAL and IN registers which are saved as a result
398 of the "save/restore" opcodes. This condition is determined
399 by address rather than by value. */
400
401 #define FRAME_FIND_SAVED_REGS(fi, frame_saved_regs) \
402 { register int regnum; \
403 register CORE_ADDR pc; \
404 FRAME_ADDR frame = read_register (FP_REGNUM); \
405 FRAME fid = FRAME_INFO_ID (fi); \
406 if (!fid) fatal ("Bad frame info struct in FRAME_FIND_SAVED_REGS"); \
407 bzero (&(frame_saved_regs), sizeof (frame_saved_regs)); \
408 /* Old test. \
409 if ((fi)->pc >= frame - CALL_DUMMY_LENGTH - 0x140 \
410 && (fi)->pc <= frame) */ \
411 if ((fi)->pc >= ((fi)->bottom ? (fi)->bottom : \
412 read_register (SP_REGNUM)) \
413 && (fi)->pc <= FRAME_FP(fi)) \
414 { \
415 for (regnum = 1; regnum < 8; regnum++) \
416 (frame_saved_regs).regs[regnum] = \
417 frame + regnum * 4 - 0xa0; \
418 for (regnum = 24; regnum < 32; regnum++) \
419 (frame_saved_regs).regs[regnum] = \
420 frame + (regnum - 24) * 4 - 0xc0; \
421 for (regnum = FP0_REGNUM; regnum < FP0_REGNUM + 32; regnum++) \
422 (frame_saved_regs).regs[regnum] = \
423 frame + (regnum - FP0_REGNUM) * 4 - 0x80; \
424 for (regnum = 64; regnum < NUM_REGS; regnum++) \
425 (frame_saved_regs).regs[regnum] = \
426 frame + (regnum - 64) * 4 - 0xe0; \
427 frame = (fi)->bottom ? \
428 (fi)->bottom : read_register (SP_REGNUM); \
429 } \
430 else \
431 { \
432 frame = (fi)->bottom ? \
433 (fi)->bottom : read_register (SP_REGNUM); \
434 for (regnum = 16; regnum < 32; regnum++) \
435 (frame_saved_regs).regs[regnum] = frame + (regnum-16) * 4; \
436 } \
437 if ((fi)->next) \
438 { \
439 /* Pull off either the next frame pointer or \
440 the stack pointer */ \
441 FRAME_ADDR next_next_frame = \
442 ((fi)->next->bottom ? \
443 (fi)->next->bottom : \
444 read_register (SP_REGNUM)); \
445 for (regnum = 8; regnum < 16; regnum++) \
446 (frame_saved_regs).regs[regnum] = next_next_frame + regnum * 4; \
447 } \
448 /* Otherwise, whatever we would get from ptrace(GETREGS) */ \
449 /* is accurate */ \
450 for (regnum = 30; regnum < 32; regnum++) \
451 (frame_saved_regs).regs[regnum] = frame + (regnum-16) * 4; \
452 (frame_saved_regs).regs[SP_REGNUM] = FRAME_FP (fi); \
453 (frame_saved_regs).regs[PC_REGNUM] = frame + 15*4; \
454 }
455 \f
456 /* Things needed for making the inferior call functions. */
457 /*
458 * First of all, let me give my opinion of what the DUMMY_FRAME
459 * actually looks like.
460 *
461 * | |
462 * | |
463 * + - - - - - - - - - - - - - - - - +<-- fp (level 0)
464 * | |
465 * | |
466 * | |
467 * | |
468 * | Frame of innermost program |
469 * | function |
470 * | |
471 * | |
472 * | |
473 * | |
474 * | |
475 * |---------------------------------|<-- sp (level 0), fp (c)
476 * | |
477 * DUMMY | fp0-31 |
478 * | |
479 * | ------ |<-- fp - 0x80
480 * FRAME | g0-7 |<-- fp - 0xa0
481 * | i0-7 |<-- fp - 0xc0
482 * | other |<-- fp - 0xe0
483 * | ? |
484 * | ? |
485 * |---------------------------------|<-- sp' = fp - 0x140
486 * | |
487 * xcution start | |
488 * sp' + 0x94 -->| CALL_DUMMY (x code) |
489 * | |
490 * | |
491 * |---------------------------------|<-- sp'' = fp - 0x200
492 * | align sp to 8 byte boundary |
493 * | ==> args to fn <== |
494 * Room for | |
495 * i & l's + agg | CALL_DUMMY_STACK_ADJUST = 0x0x44|
496 * |---------------------------------|<-- final sp (variable)
497 * | |
498 * | Where function called will |
499 * | build frame. |
500 * | |
501 * | |
502 *
503 * I understand everything in this picture except what the space
504 * between fp - 0xe0 and fp - 0x140 is used for. Oh, and I don't
505 * understand why there's a large chunk of CALL_DUMMY that never gets
506 * executed (its function is superceeded by PUSH_DUMMY_FRAME; they
507 * are designed to do the same thing).
508 *
509 * PUSH_DUMMY_FRAME saves the registers above sp' and pushes the
510 * register file stack down one.
511 *
512 * call_function then writes CALL_DUMMY, pushes the args onto the
513 * stack, and adjusts the stack pointer.
514 *
515 * run_stack_dummy then starts execution (in the middle of
516 * CALL_DUMMY, as directed by call_function).
517 */
518
519 /* Push an empty stack frame, to record the current PC, etc. */
520
521 /* Note: to be perfectly correct, we have to restore the
522 IN registers (which were the OUT registers of the calling frame). */
523 /* Note that the write's are of registers in the context of the newly
524 pushed frame. Thus the the fp*'s, the g*'s, the i*'s, and
525 the others, of the new frame, are being saved.
526 The locals are new; they don't need to be saved. The i's and l's of
527 the last frame were saved by the do_save_insn in the register
528 file (ie. on the stack, since a context switch happended imm after) */
529 /* We note that the return pointer register does not *need* to have
530 the pc saved into it (return from this frame will be accomplished
531 by a POP_FRAME), however, just in case it might be needed, we will
532 leave it. However, we will write the original value of RP into the
533 location on the stack for saving i7 (what rp turns into upon call);
534 this way we don't loose the value with our function call. */
535 /* Note that the pc saved must be 8 less than the actual pc, since
536 both POP_FRAME and the normal return sequence on the sparc return
537 to 8 more than the value of RP_REGNUM */
538
539 #define PUSH_DUMMY_FRAME \
540 { extern char registers[]; \
541 register int regnum; \
542 CORE_ADDR fp = read_register (FP_REGNUM); \
543 CORE_ADDR pc = read_register (PC_REGNUM) - 8; \
544 CORE_ADDR rp = read_register (RP_REGNUM); \
545 void do_save_insn (); \
546 supply_register (RP_REGNUM, &pc); \
547 do_save_insn (0x140); \
548 fp = read_register (FP_REGNUM); \
549 write_memory (fp - 0x80, &registers[REGISTER_BYTE (FP0_REGNUM)], 32 * 4);\
550 write_memory (fp - 0xa0, &registers[REGISTER_BYTE (0)], 8 * 4); \
551 write_memory (fp - 0xc0, &registers[REGISTER_BYTE (24)], 7 * 4); \
552 write_memory (fp - 0xa4, &rp, 4); \
553 write_memory (fp - 0xe0, &registers[REGISTER_BYTE (64)], 8 * 4); \
554 }
555
556 /* Discard from the stack the innermost frame,
557 restoring all saved registers.
558 Note that the values stored in fsr by get_frame_saved_regs are *in
559 the context of the inferior frame*. What this means is that the i
560 regs of fsr must be restored into the o regs of the frame popped
561 into. We don't care about the output regs of the inferior frame.
562
563 This is true for dummy frames. Is it true for normal frames? It
564 really does appear so. */
565
566 #define POP_FRAME \
567 { register FRAME frame = get_current_frame (); \
568 register CORE_ADDR fp; \
569 register CORE_ADDR pc; \
570 register int regnum; \
571 struct frame_saved_regs fsr; \
572 struct frame_info *fi; \
573 char raw_buffer[REGISTER_BYTES]; \
574 void do_restore_insn (); \
575 fi = get_frame_info (frame); \
576 fp = fi->frame; \
577 get_frame_saved_regs (fi, &fsr); \
578 pc = read_memory_integer (fsr.regs[PC_REGNUM], 4); \
579 do_restore_insn (PC_ADJUST (pc)); \
580 if (fsr.regs[FP0_REGNUM]) \
581 { \
582 read_memory (fsr.regs[FP0_REGNUM], raw_buffer, 32 * 4); \
583 write_register_bytes (REGISTER_BYTE (FP0_REGNUM), raw_buffer, 32 * 4); \
584 } \
585 if (fsr.regs[1]) \
586 { \
587 read_memory (fsr.regs[1], raw_buffer, 7 * 4); \
588 write_register_bytes (REGISTER_BYTE (1), raw_buffer, 7 * 4); \
589 } \
590 if (fsr.regs[24]) \
591 { \
592 read_memory (fsr.regs[24], raw_buffer, 8 * 4); \
593 write_register_bytes (REGISTER_BYTE (8), raw_buffer, 8 * 4); \
594 } \
595 if (fsr.regs[PS_REGNUM]) \
596 write_register (PS_REGNUM, read_memory_integer (fsr.regs[PS_REGNUM], 4)); \
597 if (fsr.regs[Y_REGNUM]) \
598 write_register (Y_REGNUM, read_memory_integer (fsr.regs[Y_REGNUM], 4)); \
599 if (fsr.regs[NPC_REGNUM]) \
600 write_register (NPC_REGNUM, read_memory_integer (fsr.regs[NPC_REGNUM], 4)); \
601 flush_cached_frames (); \
602 set_current_frame ( create_new_frame (read_register (FP_REGNUM), \
603 read_pc ())); }
604
605 /* This sequence of words is the instructions
606
607 save %sp,-0x140,%sp
608 std %f30,[%fp-0x08]
609 std %f28,[%fp-0x10]
610 std %f26,[%fp-0x18]
611 std %f24,[%fp-0x20]
612 std %f22,[%fp-0x28]
613 std %f20,[%fp-0x30]
614 std %f18,[%fp-0x38]
615 std %f16,[%fp-0x40]
616 std %f14,[%fp-0x48]
617 std %f12,[%fp-0x50]
618 std %f10,[%fp-0x58]
619 std %f8,[%fp-0x60]
620 std %f6,[%fp-0x68]
621 std %f4,[%fp-0x70]
622 std %f2,[%fp-0x78]
623 std %f0,[%fp-0x80]
624 std %g6,[%fp-0x88]
625 std %g4,[%fp-0x90]
626 std %g2,[%fp-0x98]
627 std %g0,[%fp-0xa0]
628 std %i6,[%fp-0xa8]
629 std %i4,[%fp-0xb0]
630 std %i2,[%fp-0xb8]
631 std %i0,[%fp-0xc0]
632 nop ! stcsr [%fp-0xc4]
633 nop ! stfsr [%fp-0xc8]
634 nop ! wr %npc,[%fp-0xcc]
635 nop ! wr %pc,[%fp-0xd0]
636 rd %tbr,%o0
637 st %o0,[%fp-0xd4]
638 rd %wim,%o1
639 st %o0,[%fp-0xd8]
640 rd %psr,%o0
641 st %o0,[%fp-0xdc]
642 rd %y,%o0
643 st %o0,[%fp-0xe0]
644
645 /..* The arguments are pushed at this point by GDB;
646 no code is needed in the dummy for this.
647 The CALL_DUMMY_START_OFFSET gives the position of
648 the following ld instruction. *../
649
650 ld [%sp+0x58],%o5
651 ld [%sp+0x54],%o4
652 ld [%sp+0x50],%o3
653 ld [%sp+0x4c],%o2
654 ld [%sp+0x48],%o1
655 call 0x00000000
656 ld [%sp+0x44],%o0
657 nop
658 ta 1
659 nop
660
661 note that this is 192 bytes, which is a multiple of 8 (not only 4) bytes.
662 note that the `call' insn is a relative, not an absolute call.
663 note that the `nop' at the end is needed to keep the trap from
664 clobbering things (if NPC pointed to garbage instead).
665
666 We actually start executing at the `sethi', since the pushing of the
667 registers (as arguments) is done by PUSH_DUMMY_FRAME. If this were
668 real code, the arguments for the function called by the CALL would be
669 pushed between the list of ST insns and the CALL, and we could allow
670 it to execute through. But the arguments have to be pushed by GDB
671 after the PUSH_DUMMY_FRAME is done, and we cannot allow these ST
672 insns to be performed again, lest the registers saved be taken for
673 arguments. */
674
675 #define CALL_DUMMY { 0x9de3bee0, 0xfd3fbff8, 0xf93fbff0, 0xf53fbfe8, \
676 0xf13fbfe0, 0xed3fbfd8, 0xe93fbfd0, 0xe53fbfc8, \
677 0xe13fbfc0, 0xdd3fbfb8, 0xd93fbfb0, 0xd53fbfa8, \
678 0xd13fbfa0, 0xcd3fbf98, 0xc93fbf90, 0xc53fbf88, \
679 0xc13fbf80, 0xcc3fbf78, 0xc83fbf70, 0xc43fbf68, \
680 0xc03fbf60, 0xfc3fbf58, 0xf83fbf50, 0xf43fbf48, \
681 0xf03fbf40, 0x01000000, 0x01000000, 0x01000000, \
682 0x01000000, 0x91580000, 0xd027bf50, 0x93500000, \
683 0xd027bf4c, 0x91480000, 0xd027bf48, 0x91400000, \
684 0xd027bf44, 0xda03a058, 0xd803a054, 0xd603a050, \
685 0xd403a04c, 0xd203a048, 0x40000000, 0xd003a044, \
686 0x01000000, 0x91d02001, 0x01000000, 0x01000000}
687
688 #define CALL_DUMMY_LENGTH 192
689
690 #define CALL_DUMMY_START_OFFSET 148
691
692 #define CALL_DUMMY_STACK_ADJUST 68
693
694 /* Insert the specified number of args and function address
695 into a call sequence of the above form stored at DUMMYNAME. */
696
697 #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \
698 { \
699 *(int *)((char *) dummyname+168) = (0x40000000|((fun-(pc+168))>>2)); \
700 if (TYPE_CODE (type) == TYPE_CODE_STRUCT \
701 || TYPE_CODE (type) == TYPE_CODE_UNION) \
702 *(int *)((char *) dummyname+176) = (TYPE_LENGTH (type) & 0x1fff); \
703 }
704
705 \f
706 /* Sparc has no reliable single step ptrace call */
707
708 #define NO_SINGLE_STEP 1
709
710 /* It does have a wait structure, and it might help things out . . . */
711
712 #define HAVE_WAIT_STRUCT
713
714 /* Handle a feature in the sun4 compiler ("call .stret4" at the end of
715 functions returning structures). */
716
717 #define SUN4_COMPILER_FEATURE
718
719 /* We need two arguments (in general) to the "info frame" command.
720 Note that the definition of this macro implies that there exists a
721 function "setup_arbitrary_frame" in mach-dep.c */
722
723 #define FRAME_SPECIFICATION_DYADIC
724
725 /* KDB stuff flushed for now. */
This page took 0.044413 seconds and 4 git commands to generate.