1 /* Target-machine dependent code for the AMD 29000
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995
3 Free Software Foundation, Inc.
4 Contributed by Cygnus Support. Written by Jim Kingdon.
6 This file is part of GDB.
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.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
30 /* If all these bits in an instruction word are zero, it is a "tag word"
31 which precedes a function entry point and gives stack traceback info.
32 This used to be defined as 0xff000000, but that treated 0x00000deb as
33 a tag word, while it is really used as a breakpoint. */
34 #define TAGWORD_ZERO_MASK 0xff00f800
36 extern CORE_ADDR text_start
; /* FIXME, kludge... */
38 /* The user-settable top of the register stack in virtual memory. We
39 won't attempt to access any stored registers above this address, if set
42 static CORE_ADDR rstack_high_address
= UINT_MAX
;
45 /* Should call_function allocate stack space for a struct return? */
46 /* On the a29k objects over 16 words require the caller to allocate space. */
48 a29k_use_struct_convention (gcc_p
, type
)
52 return (TYPE_LENGTH (type
) > 16 * 4);
56 /* Structure to hold cached info about function prologues. */
60 CORE_ADDR pc
; /* First addr after fn prologue */
61 unsigned rsize
, msize
; /* register stack frame size, mem stack ditto */
62 unsigned mfp_used
: 1; /* memory frame pointer used */
63 unsigned rsize_valid
: 1; /* Validity bits for the above */
64 unsigned msize_valid
: 1;
65 unsigned mfp_valid
: 1;
68 /* Examine the prologue of a function which starts at PC. Return
69 the first addess past the prologue. If MSIZE is non-NULL, then
70 set *MSIZE to the memory stack frame size. If RSIZE is non-NULL,
71 then set *RSIZE to the register stack frame size (not including
72 incoming arguments and the return address & frame pointer stored
73 with them). If no prologue is found, *RSIZE is set to zero.
74 If no prologue is found, or a prologue which doesn't involve
75 allocating a memory stack frame, then set *MSIZE to zero.
77 Note that both msize and rsize are in bytes. This is not consistent
78 with the _User's Manual_ with respect to rsize, but it is much more
81 If MFP_USED is non-NULL, *MFP_USED is set to nonzero if a memory
82 frame pointer is being used. */
85 examine_prologue (pc
, rsize
, msize
, mfp_used
)
93 struct minimal_symbol
*msymbol
= lookup_minimal_symbol_by_pc (pc
);
94 struct prologue_info
*mi
= 0;
97 mi
= (struct prologue_info
*) msymbol
-> info
;
105 valid
&= mi
->rsize_valid
;
110 valid
&= mi
->msize_valid
;
112 if (mfp_used
!= NULL
)
114 *mfp_used
= mi
->mfp_used
;
115 valid
&= mi
->mfp_valid
;
125 if (mfp_used
!= NULL
)
128 /* Prologue must start with subtracting a constant from gr1.
129 Normally this is sub gr1,gr1,<rsize * 4>. */
130 insn
= read_memory_integer (p
, 4);
131 if ((insn
& 0xffffff00) != 0x25010100)
133 /* If the frame is large, instead of a single instruction it
134 might be a pair of instructions:
135 const <reg>, <rsize * 4>
139 /* Possible value for rsize. */
142 if ((insn
& 0xff000000) != 0x03000000)
147 reg
= (insn
>> 8) & 0xff;
148 rsize0
= (((insn
>> 8) & 0xff00) | (insn
& 0xff));
150 insn
= read_memory_integer (p
, 4);
151 if ((insn
& 0xffffff00) != 0x24010100
152 || (insn
& 0xff) != reg
)
163 *rsize
= (insn
& 0xff);
167 /* Next instruction ought to be asgeu V_SPILL,gr1,rab.
168 * We don't check the vector number to allow for kernel debugging. The
169 * kernel will use a different trap number.
170 * If this insn is missing, we just keep going; Metaware R2.3u compiler
171 * generates prologue that intermixes initializations and puts the asgeu
174 insn
= read_memory_integer (p
, 4);
175 if ((insn
& 0xff00ffff) == (0x5e000100|RAB_HW_REGNUM
))
180 /* Next instruction usually sets the frame pointer (lr1) by adding
181 <size * 4> from gr1. However, this can (and high C does) be
182 deferred until anytime before the first function call. So it is
183 OK if we don't see anything which sets lr1.
184 To allow for alternate register sets (gcc -mkernel-registers) the msp
185 register number is a compile time constant. */
187 /* Normally this is just add lr1,gr1,<size * 4>. */
188 insn
= read_memory_integer (p
, 4);
189 if ((insn
& 0xffffff00) == 0x15810100)
193 /* However, for large frames it can be
194 const <reg>, <size *4>
200 if ((insn
& 0xff000000) == 0x03000000)
202 reg
= (insn
>> 8) & 0xff;
204 insn
= read_memory_integer (q
, 4);
205 if ((insn
& 0xffffff00) == 0x14810100
206 && (insn
& 0xff) == reg
)
211 /* Next comes "add lr{<rsize-1>},msp,0", but only if a memory
212 frame pointer is in use. We just check for add lr<anything>,msp,0;
213 we don't check this rsize against the first instruction, and
214 we don't check that the trace-back tag indicates a memory frame pointer
216 To allow for alternate register sets (gcc -mkernel-registers) the msp
217 register number is a compile time constant.
219 The recommended instruction is actually "sll lr<whatever>,msp,0".
220 We check for that, too. Originally Jim Kingdon's code seemed
221 to be looking for a "sub" instruction here, but the mask was set
222 up to lose all the time. */
223 insn
= read_memory_integer (p
, 4);
224 if (((insn
& 0xff80ffff) == (0x15800000|(MSP_HW_REGNUM
<<8))) /* add */
225 || ((insn
& 0xff80ffff) == (0x81800000|(MSP_HW_REGNUM
<<8)))) /* sll */
228 if (mfp_used
!= NULL
)
232 /* Next comes a subtraction from msp to allocate a memory frame,
233 but only if a memory frame is
234 being used. We don't check msize against the trace-back tag.
236 To allow for alternate register sets (gcc -mkernel-registers) the msp
237 register number is a compile time constant.
239 Normally this is just
242 insn
= read_memory_integer (p
, 4);
243 if ((insn
& 0xffffff00) ==
244 (0x25000000|(MSP_HW_REGNUM
<<16)|(MSP_HW_REGNUM
<<8)))
248 *msize
= insn
& 0xff;
252 /* For large frames, instead of a single instruction it might
256 consth <reg>, <msize> ; optional
263 if ((insn
& 0xff000000) == 0x03000000)
265 reg
= (insn
>> 8) & 0xff;
266 msize0
= ((insn
>> 8) & 0xff00) | (insn
& 0xff);
268 insn
= read_memory_integer (q
, 4);
269 /* Check for consth. */
270 if ((insn
& 0xff000000) == 0x02000000
271 && (insn
& 0x0000ff00) == reg
)
273 msize0
|= (insn
<< 8) & 0xff000000;
274 msize0
|= (insn
<< 16) & 0x00ff0000;
276 insn
= read_memory_integer (q
, 4);
278 /* Check for sub msp,msp,<reg>. */
279 if ((insn
& 0xffffff00) ==
280 (0x24000000|(MSP_HW_REGNUM
<<16)|(MSP_HW_REGNUM
<<8))
281 && (insn
& 0xff) == reg
)
290 /* Next instruction might be asgeu V_SPILL,gr1,rab.
291 * We don't check the vector number to allow for kernel debugging. The
292 * kernel will use a different trap number.
293 * Metaware R2.3u compiler
294 * generates prologue that intermixes initializations and puts the asgeu
295 * way down after everything else.
297 insn
= read_memory_integer (p
, 4);
298 if ((insn
& 0xff00ffff) == (0x5e000100|RAB_HW_REGNUM
))
308 /* Add a new cache entry. */
309 mi
= (struct prologue_info
*)xmalloc (sizeof (struct prologue_info
));
310 msymbol
-> info
= (char *)mi
;
315 /* else, cache entry exists, but info is incomplete. */
327 if (mfp_used
!= NULL
)
329 mi
->mfp_used
= *mfp_used
;
336 /* Advance PC across any function entry prologue instructions
337 to reach some "real" code. */
343 return examine_prologue (pc
, NULL
, NULL
, NULL
);
347 * Examine the one or two word tag at the beginning of a function.
348 * The tag word is expect to be at 'p', if it is not there, we fail
349 * by returning 0. The documentation for the tag word was taken from
350 * page 7-15 of the 29050 User's Manual. We are assuming that the
351 * m bit is in bit 22 of the tag word, which seems to be the agreed upon
352 * convention today (1/15/92).
353 * msize is return in bytes.
356 static int /* 0/1 - failure/success of finding the tag word */
357 examine_tag (p
, is_trans
, argcount
, msize
, mfp_used
)
364 unsigned int tag1
, tag2
;
366 tag1
= read_memory_integer (p
, 4);
367 if ((tag1
& TAGWORD_ZERO_MASK
) != 0) /* Not a tag word */
369 if (tag1
& (1<<23)) /* A two word tag */
371 tag2
= read_memory_integer (p
-4, 4);
375 else /* A one word tag */
378 *msize
= tag1
& 0x7ff;
381 *is_trans
= ((tag1
& (1<<21)) ? 1 : 0);
382 /* Note that this includes the frame pointer and the return address
383 register, so the actual number of registers of arguments is two less.
384 argcount can be zero, however, sometimes, for strange assembler
387 *argcount
= (tag1
>> 16) & 0x1f;
389 *mfp_used
= ((tag1
& (1<<22)) ? 1 : 0);
393 /* Initialize the frame. In addition to setting "extra" frame info,
394 we also set ->frame because we use it in a nonstandard way, and ->pc
395 because we need to know it to get the other stuff. See the diagram
396 of stacks and the frame cache in tm-a29k.h for more detail. */
399 init_frame_info (innermost_frame
, frame
)
401 struct frame_info
*frame
;
413 frame
->frame
= read_register (GR1_REGNUM
);
415 frame
->frame
= frame
->next
->frame
+ frame
->next
->rsize
;
417 #if 0 /* CALL_DUMMY_LOCATION == ON_STACK */
420 if (PC_IN_CALL_DUMMY (p
, 0, 0))
423 frame
->rsize
= DUMMY_FRAME_RSIZE
;
424 /* This doesn't matter since we never try to get locals or args
425 from a dummy frame. */
427 /* Dummy frames always use a memory frame pointer. */
429 read_register_stack_integer (frame
->frame
+ DUMMY_FRAME_RSIZE
- 4, 4);
430 frame
->flags
|= (TRANSPARENT_FRAME
|MFP_USED
);
434 func
= find_pc_function (p
);
436 p
= BLOCK_START (SYMBOL_BLOCK_VALUE (func
));
439 /* Search backward to find the trace-back tag. However,
440 do not trace back beyond the start of the text segment
441 (just as a sanity check to avoid going into never-never land). */
443 while (p
>= text_start
444 && ((insn
= read_memory_integer (p
, 4)) & TAGWORD_ZERO_MASK
) != 0)
447 char pat
[4] = {0, 0, 0, 0};
450 store_unsigned_integer (mask
, 4, TAGWORD_ZERO_MASK
);
451 /* Enable this once target_search is enabled and tested. */
452 target_search (4, pat
, mask
, p
, -4, text_start
, p
+1, &p
, &insn_raw
);
453 insn
= extract_unsigned_integer (insn_raw
, 4);
458 /* Couldn't find the trace-back tag.
459 Something strange is going on. */
460 frame
->saved_msp
= 0;
463 frame
->flags
= TRANSPARENT_FRAME
;
467 /* Advance to the first word of the function, i.e. the word
468 after the trace-back tag. */
472 /* We've found the start of the function.
473 Try looking for a tag word that indicates whether there is a
474 memory frame pointer and what the memory stack allocation is.
475 If one doesn't exist, try using a more exhaustive search of
478 if (examine_tag(p
-4,&trans
,(int *)NULL
,&msize
,&mfp_used
)) /* Found good tag */
479 examine_prologue (p
, &rsize
, 0, 0);
480 else /* No tag try prologue */
481 examine_prologue (p
, &rsize
, &msize
, &mfp_used
);
483 frame
->rsize
= rsize
;
484 frame
->msize
= msize
;
487 frame
->flags
|= MFP_USED
;
489 frame
->flags
|= TRANSPARENT_FRAME
;
492 frame
->saved_msp
= read_register (MSP_REGNUM
) + msize
;
498 read_register_stack_integer (frame
->frame
+ rsize
- 4, 4);
500 frame
->saved_msp
= frame
->next
->saved_msp
+ msize
;
505 init_extra_frame_info (frame
)
506 struct frame_info
*frame
;
508 if (frame
->next
== 0)
509 /* Assume innermost frame. May produce strange results for "info frame"
510 but there isn't any way to tell the difference. */
511 init_frame_info (1, frame
);
513 /* We're in get_prev_frame_info.
514 Take care of everything in init_frame_pc. */
520 init_frame_pc (fromleaf
, frame
)
522 struct frame_info
*frame
;
524 frame
->pc
= (fromleaf
? SAVED_PC_AFTER_CALL (frame
->next
) :
525 frame
->next
? FRAME_SAVED_PC (frame
->next
) : read_pc ());
526 init_frame_info (fromleaf
, frame
);
529 /* Local variables (i.e. LOC_LOCAL) are on the memory stack, with their
530 offsets being relative to the memory stack pointer (high C) or
534 frame_locals_address (fi
)
535 struct frame_info
*fi
;
537 if (fi
->flags
& MFP_USED
)
538 return fi
->saved_msp
;
540 return fi
->saved_msp
- fi
->msize
;
543 /* Routines for reading the register stack. The caller gets to treat
544 the register stack as a uniform stack in memory, from address $gr1
545 straight through $rfb and beyond. */
547 /* Analogous to read_memory except the length is understood to be 4.
548 Also, myaddr can be NULL (meaning don't bother to read), and
549 if actual_mem_addr is non-NULL, store there the address that it
550 was fetched from (or if from a register the offset within
551 registers). Set *LVAL to lval_memory or lval_register, depending
552 on where it came from. The contents written into MYADDR are in
555 read_register_stack (memaddr
, myaddr
, actual_mem_addr
, lval
)
558 CORE_ADDR
*actual_mem_addr
;
559 enum lval_type
*lval
;
561 long rfb
= read_register (RFB_REGNUM
);
562 long rsp
= read_register (RSP_REGNUM
);
564 /* If we don't do this 'info register' stops in the middle. */
565 if (memaddr
>= rstack_high_address
)
568 static char val
[] = {~0, ~0, ~0, ~0};
569 /* It's in a local register, but off the end of the stack. */
570 int regnum
= (memaddr
- rsp
) / 4 + LR0_REGNUM
;
573 /* Provide bogusness */
574 memcpy (myaddr
, val
, 4);
576 supply_register(regnum
, val
); /* More bogusness */
578 *lval
= lval_register
;
579 if (actual_mem_addr
!= NULL
)
580 *actual_mem_addr
= REGISTER_BYTE (regnum
);
582 /* If it's in the part of the register stack that's in real registers,
583 get the value from the registers. If it's anywhere else in memory
584 (e.g. in another thread's saved stack), skip this part and get
585 it from real live memory. */
586 else if (memaddr
< rfb
&& memaddr
>= rsp
)
588 /* It's in a register. */
589 int regnum
= (memaddr
- rsp
) / 4 + LR0_REGNUM
;
590 if (regnum
> LR0_REGNUM
+ 127)
591 error ("Attempt to read register stack out of range.");
593 read_register_gen (regnum
, myaddr
);
595 *lval
= lval_register
;
596 if (actual_mem_addr
!= NULL
)
597 *actual_mem_addr
= REGISTER_BYTE (regnum
);
601 /* It's in the memory portion of the register stack. */
603 read_memory (memaddr
, myaddr
, 4);
606 if (actual_mem_addr
!= NULL
)
607 *actual_mem_addr
= memaddr
;
611 /* Analogous to read_memory_integer
612 except the length is understood to be 4. */
614 read_register_stack_integer (memaddr
, len
)
619 read_register_stack (memaddr
, buf
, NULL
, NULL
);
620 return extract_signed_integer (buf
, 4);
623 /* Copy 4 bytes from GDB memory at MYADDR into inferior memory
624 at MEMADDR and put the actual address written into in
627 write_register_stack (memaddr
, myaddr
, actual_mem_addr
)
630 CORE_ADDR
*actual_mem_addr
;
632 long rfb
= read_register (RFB_REGNUM
);
633 long rsp
= read_register (RSP_REGNUM
);
634 /* If we don't do this 'info register' stops in the middle. */
635 if (memaddr
>= rstack_high_address
)
637 /* It's in a register, but off the end of the stack. */
638 if (actual_mem_addr
!= NULL
)
639 *actual_mem_addr
= 0;
641 else if (memaddr
< rfb
)
643 /* It's in a register. */
644 int regnum
= (memaddr
- rsp
) / 4 + LR0_REGNUM
;
645 if (regnum
< LR0_REGNUM
|| regnum
> LR0_REGNUM
+ 127)
646 error ("Attempt to read register stack out of range.");
648 write_register (regnum
, *(long *)myaddr
);
649 if (actual_mem_addr
!= NULL
)
650 *actual_mem_addr
= 0;
654 /* It's in the memory portion of the register stack. */
656 write_memory (memaddr
, myaddr
, 4);
657 if (actual_mem_addr
!= NULL
)
658 *actual_mem_addr
= memaddr
;
662 /* Find register number REGNUM relative to FRAME and put its
663 (raw) contents in *RAW_BUFFER. Set *OPTIMIZED if the variable
664 was optimized out (and thus can't be fetched). If the variable
665 was fetched from memory, set *ADDRP to where it was fetched from,
666 otherwise it was fetched from a register.
668 The argument RAW_BUFFER must point to aligned memory. */
671 get_saved_register (raw_buffer
, optimized
, addrp
, frame
, regnum
, lvalp
)
675 struct frame_info
*frame
;
677 enum lval_type
*lvalp
;
679 struct frame_info
*fi
;
683 if (!target_has_registers
)
684 error ("No registers.");
686 /* Probably now redundant with the target_has_registers check. */
690 /* Once something has a register number, it doesn't get optimized out. */
691 if (optimized
!= NULL
)
693 if (regnum
== RSP_REGNUM
)
695 if (raw_buffer
!= NULL
)
697 store_address (raw_buffer
, REGISTER_RAW_SIZE (regnum
), frame
->frame
);
703 else if (regnum
== PC_REGNUM
&& frame
->next
!= NULL
)
705 if (raw_buffer
!= NULL
)
707 store_address (raw_buffer
, REGISTER_RAW_SIZE (regnum
), frame
->pc
);
710 /* Not sure we have to do this. */
716 else if (regnum
== MSP_REGNUM
)
718 if (raw_buffer
!= NULL
)
720 if (frame
->next
!= NULL
)
722 store_address (raw_buffer
, REGISTER_RAW_SIZE (regnum
),
723 frame
->next
->saved_msp
);
726 read_register_gen (MSP_REGNUM
, raw_buffer
);
728 /* The value may have been computed, not fetched. */
733 else if (regnum
< LR0_REGNUM
|| regnum
>= LR0_REGNUM
+ 128)
735 /* These registers are not saved over procedure calls,
736 so just print out the current values. */
737 if (raw_buffer
!= NULL
)
738 read_register_gen (regnum
, raw_buffer
);
740 *lvalp
= lval_register
;
742 *addrp
= REGISTER_BYTE (regnum
);
746 addr
= frame
->frame
+ (regnum
- LR0_REGNUM
) * 4;
747 if (raw_buffer
!= NULL
)
748 read_register_stack (addr
, raw_buffer
, &addr
, &lval
);
756 /* Discard from the stack the innermost frame,
757 restoring all saved registers. */
762 struct frame_info
*frame
= get_current_frame ();
763 CORE_ADDR rfb
= read_register (RFB_REGNUM
);
764 CORE_ADDR gr1
= frame
->frame
+ frame
->rsize
;
766 CORE_ADDR original_lr0
;
767 int must_fix_lr0
= 0;
770 /* If popping a dummy frame, need to restore registers. */
771 if (PC_IN_CALL_DUMMY (read_register (PC_REGNUM
),
772 read_register (SP_REGNUM
),
775 int lrnum
= LR0_REGNUM
+ DUMMY_ARG
/4;
776 for (i
= 0; i
< DUMMY_SAVE_SR128
; ++i
)
777 write_register (SR_REGNUM (i
+ 128),read_register (lrnum
++));
778 for (i
= 0; i
< DUMMY_SAVE_SR160
; ++i
)
779 write_register (SR_REGNUM(i
+160), read_register (lrnum
++));
780 for (i
= 0; i
< DUMMY_SAVE_GREGS
; ++i
)
781 write_register (RETURN_REGNUM
+ i
, read_register (lrnum
++));
782 /* Restore the PCs and prepare to restore LR0. */
783 write_register(PC_REGNUM
, read_register (lrnum
++));
784 write_register(NPC_REGNUM
, read_register (lrnum
++));
785 write_register(PC2_REGNUM
, read_register (lrnum
++));
786 original_lr0
= read_register (lrnum
++);
790 /* Restore the memory stack pointer. */
791 write_register (MSP_REGNUM
, frame
->saved_msp
);
792 /* Restore the register stack pointer. */
793 write_register (GR1_REGNUM
, gr1
);
795 /* If we popped a dummy frame, restore lr0 now that gr1 has been restored. */
797 write_register (LR0_REGNUM
, original_lr0
);
799 /* Check whether we need to fill registers. */
800 lr1
= read_register (LR0_REGNUM
+ 1);
804 int num_bytes
= lr1
- rfb
;
808 write_register (RAB_REGNUM
, read_register (RAB_REGNUM
) + num_bytes
);
809 write_register (RFB_REGNUM
, lr1
);
810 for (i
= 0; i
< num_bytes
; i
+= 4)
812 /* Note: word is in host byte order. */
813 word
= read_memory_integer (rfb
+ i
, 4);
814 write_register (LR0_REGNUM
+ ((rfb
- gr1
) % 0x80) + i
/ 4, word
);
817 flush_cached_frames ();
820 /* Push an empty stack frame, to record the current PC, etc. */
827 CORE_ADDR msp
= read_register (MSP_REGNUM
);
829 CORE_ADDR original_lr0
;
831 /* Read original lr0 before changing gr1. This order isn't really needed
832 since GDB happens to have a snapshot of all the regs and doesn't toss
833 it when gr1 is changed. But it's The Right Thing To Do. */
834 original_lr0
= read_register (LR0_REGNUM
);
836 /* Allocate the new frame. */
837 gr1
= read_register (GR1_REGNUM
) - DUMMY_FRAME_RSIZE
;
838 write_register (GR1_REGNUM
, gr1
);
840 #ifdef VXWORKS_TARGET
841 /* We force re-reading all registers to get the new local registers set
842 after gr1 has been modified. This fix is due to the lack of single
843 register read/write operation in the RPC interface between VxGDB and
844 VxWorks. This really must be changed ! */
846 vx_read_register (-1);
848 #endif /* VXWORK_TARGET */
850 rab
= read_register (RAB_REGNUM
);
853 /* We need to spill registers. */
854 int num_bytes
= rab
- gr1
;
855 CORE_ADDR rfb
= read_register (RFB_REGNUM
);
859 write_register (RFB_REGNUM
, rfb
- num_bytes
);
860 write_register (RAB_REGNUM
, gr1
);
861 for (i
= 0; i
< num_bytes
; i
+= 4)
863 /* Note: word is in target byte order. */
864 read_register_gen (LR0_REGNUM
+ i
/ 4, (char *) &word
);
865 write_memory (rfb
- num_bytes
+ i
, (char *) &word
, 4);
869 /* There are no arguments in to the dummy frame, so we don't need
870 more than rsize plus the return address and lr1. */
871 write_register (LR0_REGNUM
+ 1, gr1
+ DUMMY_FRAME_RSIZE
+ 2 * 4);
873 /* Set the memory frame pointer. */
874 write_register (LR0_REGNUM
+ DUMMY_FRAME_RSIZE
/ 4 - 1, msp
);
876 /* Allocate arg_slop. */
877 write_register (MSP_REGNUM
, msp
- 16 * 4);
879 /* Save registers. */
880 lrnum
= LR0_REGNUM
+ DUMMY_ARG
/4;
881 for (i
= 0; i
< DUMMY_SAVE_SR128
; ++i
)
882 write_register (lrnum
++, read_register (SR_REGNUM (i
+ 128)));
883 for (i
= 0; i
< DUMMY_SAVE_SR160
; ++i
)
884 write_register (lrnum
++, read_register (SR_REGNUM (i
+ 160)));
885 for (i
= 0; i
< DUMMY_SAVE_GREGS
; ++i
)
886 write_register (lrnum
++, read_register (RETURN_REGNUM
+ i
));
887 /* Save the PCs and LR0. */
888 write_register (lrnum
++, read_register (PC_REGNUM
));
889 write_register (lrnum
++, read_register (NPC_REGNUM
));
890 write_register (lrnum
++, read_register (PC2_REGNUM
));
892 /* Why are we saving LR0? What would clobber it? (the dummy frame should
893 be below it on the register stack, no?). */
894 write_register (lrnum
++, original_lr0
);
900 This routine takes three arguments and makes the cached frames look
901 as if these arguments defined a frame on the cache. This allows the
902 rest of `info frame' to extract the important arguments without much
903 difficulty. Since an individual frame on the 29K is determined by
904 three values (FP, PC, and MSP), we really need all three to do a
908 setup_arbitrary_frame (argc
, argv
)
912 struct frame_info
*frame
;
915 error ("AMD 29k frame specifications require three arguments: rsp pc msp");
917 frame
= create_new_frame (argv
[0], argv
[1]);
920 fatal ("internal: create_new_frame returned invalid frame id");
922 /* Creating a new frame munges the `frame' value from the current
923 GR1, so we restore it again here. FIXME, untangle all this
924 29K frame stuff... */
925 frame
->frame
= argv
[0];
927 /* Our MSP is in argv[2]. It'd be intelligent if we could just
928 save this value in the FRAME. But the way it's set up (FIXME),
929 we must save our caller's MSP. We compute that by adding our
930 memory stack frame size to our MSP. */
931 frame
->saved_msp
= argv
[2] + frame
->msize
;
937 gdb_print_insn_a29k (memaddr
, info
)
939 disassemble_info
*info
;
941 if (TARGET_BYTE_ORDER
== BIG_ENDIAN
)
942 return print_insn_big_a29k (memaddr
, info
);
944 return print_insn_little_a29k (memaddr
, info
);
947 enum a29k_processor_types processor_type
= a29k_unknown
;
950 a29k_get_processor_type ()
952 unsigned int cfg_reg
= (unsigned int) read_register (CFG_REGNUM
);
954 /* Most of these don't have freeze mode. */
955 processor_type
= a29k_no_freeze_mode
;
957 switch ((cfg_reg
>> 28) & 0xf)
960 fprintf_filtered (gdb_stderr
, "Remote debugging an Am29000");
963 fprintf_filtered (gdb_stderr
, "Remote debugging an Am29005");
966 fprintf_filtered (gdb_stderr
, "Remote debugging an Am29050");
967 processor_type
= a29k_freeze_mode
;
970 fprintf_filtered (gdb_stderr
, "Remote debugging an Am29035");
973 fprintf_filtered (gdb_stderr
, "Remote debugging an Am29030");
976 fprintf_filtered (gdb_stderr
, "Remote debugging an Am2920*");
979 fprintf_filtered (gdb_stderr
, "Remote debugging an Am2924*");
982 fprintf_filtered (gdb_stderr
, "Remote debugging an Am29040");
985 fprintf_filtered (gdb_stderr
, "Remote debugging an unknown Am29k\n");
986 /* Don't bother to print the revision. */
989 fprintf_filtered (gdb_stderr
, " revision %c\n", 'A' + ((cfg_reg
>> 24) & 0x0f));
992 #ifdef GET_LONGJMP_TARGET
993 /* Figure out where the longjmp will land. We expect that we have just entered
994 longjmp and haven't yet setup the stack frame, so the args are still in the
995 output regs. lr2 (LR2_REGNUM) points at the jmp_buf structure from which we
996 extract the pc (JB_PC) that we will land at. The pc is copied into ADDR.
997 This routine returns true on success */
1000 get_longjmp_target(pc
)
1004 char buf
[sizeof(CORE_ADDR
)];
1006 jb_addr
= read_register(LR2_REGNUM
);
1008 if (target_read_memory(jb_addr
+ JB_PC
* JB_ELEMENT_SIZE
, (char *) buf
,
1012 *pc
= extract_address ((PTR
) buf
, sizeof(CORE_ADDR
));
1015 #endif /* GET_LONGJMP_TARGET */
1018 _initialize_a29k_tdep ()
1020 extern CORE_ADDR text_end
;
1022 tm_print_insn
= gdb_print_insn_a29k
;
1024 /* FIXME, there should be a way to make a CORE_ADDR variable settable. */
1026 (add_set_cmd ("rstack_high_address", class_support
, var_uinteger
,
1027 (char *)&rstack_high_address
,
1028 "Set top address in memory of the register stack.\n\
1029 Attempts to access registers saved above this address will be ignored\n\
1030 or will produce the value -1.", &setlist
),
1033 /* FIXME, there should be a way to make a CORE_ADDR variable settable. */
1035 (add_set_cmd ("call_scratch_address", class_support
, var_uinteger
,
1037 "Set address in memory where small amounts of RAM can be used\n\
1038 when making function calls into the inferior.", &setlist
),