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., 675 Mass Ave, Cambridge, MA 02139, 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
;
44 /* Structure to hold cached info about function prologues. */
48 CORE_ADDR pc
; /* First addr after fn prologue */
49 unsigned rsize
, msize
; /* register stack frame size, mem stack ditto */
50 unsigned mfp_used
: 1; /* memory frame pointer used */
51 unsigned rsize_valid
: 1; /* Validity bits for the above */
52 unsigned msize_valid
: 1;
53 unsigned mfp_valid
: 1;
56 /* Examine the prologue of a function which starts at PC. Return
57 the first addess past the prologue. If MSIZE is non-NULL, then
58 set *MSIZE to the memory stack frame size. If RSIZE is non-NULL,
59 then set *RSIZE to the register stack frame size (not including
60 incoming arguments and the return address & frame pointer stored
61 with them). If no prologue is found, *RSIZE is set to zero.
62 If no prologue is found, or a prologue which doesn't involve
63 allocating a memory stack frame, then set *MSIZE to zero.
65 Note that both msize and rsize are in bytes. This is not consistent
66 with the _User's Manual_ with respect to rsize, but it is much more
69 If MFP_USED is non-NULL, *MFP_USED is set to nonzero if a memory
70 frame pointer is being used. */
73 examine_prologue (pc
, rsize
, msize
, mfp_used
)
81 struct minimal_symbol
*msymbol
= lookup_minimal_symbol_by_pc (pc
);
82 struct prologue_info
*mi
= 0;
85 mi
= (struct prologue_info
*) msymbol
-> info
;
93 valid
&= mi
->rsize_valid
;
98 valid
&= mi
->msize_valid
;
100 if (mfp_used
!= NULL
)
102 *mfp_used
= mi
->mfp_used
;
103 valid
&= mi
->mfp_valid
;
113 if (mfp_used
!= NULL
)
116 /* Prologue must start with subtracting a constant from gr1.
117 Normally this is sub gr1,gr1,<rsize * 4>. */
118 insn
= read_memory_integer (p
, 4);
119 if ((insn
& 0xffffff00) != 0x25010100)
121 /* If the frame is large, instead of a single instruction it
122 might be a pair of instructions:
123 const <reg>, <rsize * 4>
127 /* Possible value for rsize. */
130 if ((insn
& 0xff000000) != 0x03000000)
135 reg
= (insn
>> 8) & 0xff;
136 rsize0
= (((insn
>> 8) & 0xff00) | (insn
& 0xff));
138 insn
= read_memory_integer (p
, 4);
139 if ((insn
& 0xffffff00) != 0x24010100
140 || (insn
& 0xff) != reg
)
151 *rsize
= (insn
& 0xff);
155 /* Next instruction ought to be asgeu V_SPILL,gr1,rab.
156 * We don't check the vector number to allow for kernel debugging. The
157 * kernel will use a different trap number.
158 * If this insn is missing, we just keep going; Metaware R2.3u compiler
159 * generates prologue that intermixes initializations and puts the asgeu
162 insn
= read_memory_integer (p
, 4);
163 if ((insn
& 0xff00ffff) == (0x5e000100|RAB_HW_REGNUM
))
168 /* Next instruction usually sets the frame pointer (lr1) by adding
169 <size * 4> from gr1. However, this can (and high C does) be
170 deferred until anytime before the first function call. So it is
171 OK if we don't see anything which sets lr1.
172 To allow for alternate register sets (gcc -mkernel-registers) the msp
173 register number is a compile time constant. */
175 /* Normally this is just add lr1,gr1,<size * 4>. */
176 insn
= read_memory_integer (p
, 4);
177 if ((insn
& 0xffffff00) == 0x15810100)
181 /* However, for large frames it can be
182 const <reg>, <size *4>
188 if ((insn
& 0xff000000) == 0x03000000)
190 reg
= (insn
>> 8) & 0xff;
192 insn
= read_memory_integer (q
, 4);
193 if ((insn
& 0xffffff00) == 0x14810100
194 && (insn
& 0xff) == reg
)
199 /* Next comes "add lr{<rsize-1>},msp,0", but only if a memory
200 frame pointer is in use. We just check for add lr<anything>,msp,0;
201 we don't check this rsize against the first instruction, and
202 we don't check that the trace-back tag indicates a memory frame pointer
204 To allow for alternate register sets (gcc -mkernel-registers) the msp
205 register number is a compile time constant.
207 The recommended instruction is actually "sll lr<whatever>,msp,0".
208 We check for that, too. Originally Jim Kingdon's code seemed
209 to be looking for a "sub" instruction here, but the mask was set
210 up to lose all the time. */
211 insn
= read_memory_integer (p
, 4);
212 if (((insn
& 0xff80ffff) == (0x15800000|(MSP_HW_REGNUM
<<8))) /* add */
213 || ((insn
& 0xff80ffff) == (0x81800000|(MSP_HW_REGNUM
<<8)))) /* sll */
216 if (mfp_used
!= NULL
)
220 /* Next comes a subtraction from msp to allocate a memory frame,
221 but only if a memory frame is
222 being used. We don't check msize against the trace-back tag.
224 To allow for alternate register sets (gcc -mkernel-registers) the msp
225 register number is a compile time constant.
227 Normally this is just
230 insn
= read_memory_integer (p
, 4);
231 if ((insn
& 0xffffff00) ==
232 (0x25000000|(MSP_HW_REGNUM
<<16)|(MSP_HW_REGNUM
<<8)))
236 *msize
= insn
& 0xff;
240 /* For large frames, instead of a single instruction it might
244 consth <reg>, <msize> ; optional
251 if ((insn
& 0xff000000) == 0x03000000)
253 reg
= (insn
>> 8) & 0xff;
254 msize0
= ((insn
>> 8) & 0xff00) | (insn
& 0xff);
256 insn
= read_memory_integer (q
, 4);
257 /* Check for consth. */
258 if ((insn
& 0xff000000) == 0x02000000
259 && (insn
& 0x0000ff00) == reg
)
261 msize0
|= (insn
<< 8) & 0xff000000;
262 msize0
|= (insn
<< 16) & 0x00ff0000;
264 insn
= read_memory_integer (q
, 4);
266 /* Check for sub msp,msp,<reg>. */
267 if ((insn
& 0xffffff00) ==
268 (0x24000000|(MSP_HW_REGNUM
<<16)|(MSP_HW_REGNUM
<<8))
269 && (insn
& 0xff) == reg
)
278 /* Next instruction might be asgeu V_SPILL,gr1,rab.
279 * We don't check the vector number to allow for kernel debugging. The
280 * kernel will use a different trap number.
281 * Metaware R2.3u compiler
282 * generates prologue that intermixes initializations and puts the asgeu
283 * way down after everything else.
285 insn
= read_memory_integer (p
, 4);
286 if ((insn
& 0xff00ffff) == (0x5e000100|RAB_HW_REGNUM
))
296 /* Add a new cache entry. */
297 mi
= (struct prologue_info
*)xmalloc (sizeof (struct prologue_info
));
298 msymbol
-> info
= (char *)mi
;
303 /* else, cache entry exists, but info is incomplete. */
315 if (mfp_used
!= NULL
)
317 mi
->mfp_used
= *mfp_used
;
324 /* Advance PC across any function entry prologue instructions
325 to reach some "real" code. */
331 return examine_prologue (pc
, NULL
, NULL
, NULL
);
335 * Examine the one or two word tag at the beginning of a function.
336 * The tag word is expect to be at 'p', if it is not there, we fail
337 * by returning 0. The documentation for the tag word was taken from
338 * page 7-15 of the 29050 User's Manual. We are assuming that the
339 * m bit is in bit 22 of the tag word, which seems to be the agreed upon
340 * convention today (1/15/92).
341 * msize is return in bytes.
344 static int /* 0/1 - failure/success of finding the tag word */
345 examine_tag (p
, is_trans
, argcount
, msize
, mfp_used
)
352 unsigned int tag1
, tag2
;
354 tag1
= read_memory_integer (p
, 4);
355 if ((tag1
& TAGWORD_ZERO_MASK
) != 0) /* Not a tag word */
357 if (tag1
& (1<<23)) /* A two word tag */
359 tag2
= read_memory_integer (p
-4, 4);
363 else /* A one word tag */
366 *msize
= tag1
& 0x7ff;
369 *is_trans
= ((tag1
& (1<<21)) ? 1 : 0);
370 /* Note that this includes the frame pointer and the return address
371 register, so the actual number of registers of arguments is two less.
372 argcount can be zero, however, sometimes, for strange assembler
375 *argcount
= (tag1
>> 16) & 0x1f;
377 *mfp_used
= ((tag1
& (1<<22)) ? 1 : 0);
381 /* Initialize the frame. In addition to setting "extra" frame info,
382 we also set ->frame because we use it in a nonstandard way, and ->pc
383 because we need to know it to get the other stuff. See the diagram
384 of stacks and the frame cache in tm-a29k.h for more detail. */
387 init_frame_info (innermost_frame
, frame
)
389 struct frame_info
*frame
;
401 frame
->frame
= read_register (GR1_REGNUM
);
403 frame
->frame
= frame
->next
->frame
+ frame
->next
->rsize
;
405 #if 0 /* CALL_DUMMY_LOCATION == ON_STACK */
408 if (PC_IN_CALL_DUMMY (p
, 0, 0))
411 frame
->rsize
= DUMMY_FRAME_RSIZE
;
412 /* This doesn't matter since we never try to get locals or args
413 from a dummy frame. */
415 /* Dummy frames always use a memory frame pointer. */
417 read_register_stack_integer (frame
->frame
+ DUMMY_FRAME_RSIZE
- 4, 4);
418 frame
->flags
|= (TRANSPARENT
|MFP_USED
);
422 func
= find_pc_function (p
);
424 p
= BLOCK_START (SYMBOL_BLOCK_VALUE (func
));
427 /* Search backward to find the trace-back tag. However,
428 do not trace back beyond the start of the text segment
429 (just as a sanity check to avoid going into never-never land). */
431 while (p
>= text_start
432 && ((insn
= read_memory_integer (p
, 4)) & TAGWORD_ZERO_MASK
) != 0)
435 char pat
[4] = {0, 0, 0, 0};
438 store_unsigned_integer (mask
, 4, TAGWORD_ZERO_MASK
);
439 /* Enable this once target_search is enabled and tested. */
440 target_search (4, pat
, mask
, p
, -4, text_start
, p
+1, &p
, &insn_raw
);
441 insn
= extract_unsigned_integer (insn_raw
, 4);
446 /* Couldn't find the trace-back tag.
447 Something strange is going on. */
448 frame
->saved_msp
= 0;
451 frame
->flags
= TRANSPARENT
;
455 /* Advance to the first word of the function, i.e. the word
456 after the trace-back tag. */
460 /* We've found the start of the function.
461 Try looking for a tag word that indicates whether there is a
462 memory frame pointer and what the memory stack allocation is.
463 If one doesn't exist, try using a more exhaustive search of
466 if (examine_tag(p
-4,&trans
,(int *)NULL
,&msize
,&mfp_used
)) /* Found good tag */
467 examine_prologue (p
, &rsize
, 0, 0);
468 else /* No tag try prologue */
469 examine_prologue (p
, &rsize
, &msize
, &mfp_used
);
471 frame
->rsize
= rsize
;
472 frame
->msize
= msize
;
475 frame
->flags
|= MFP_USED
;
477 frame
->flags
|= TRANSPARENT
;
480 frame
->saved_msp
= read_register (MSP_REGNUM
) + msize
;
486 read_register_stack_integer (frame
->frame
+ rsize
- 4, 4);
488 frame
->saved_msp
= frame
->next
->saved_msp
+ msize
;
493 init_extra_frame_info (frame
)
494 struct frame_info
*frame
;
496 if (frame
->next
== 0)
497 /* Assume innermost frame. May produce strange results for "info frame"
498 but there isn't any way to tell the difference. */
499 init_frame_info (1, frame
);
501 /* We're in get_prev_frame_info.
502 Take care of everything in init_frame_pc. */
508 init_frame_pc (fromleaf
, frame
)
510 struct frame_info
*frame
;
512 frame
->pc
= (fromleaf
? SAVED_PC_AFTER_CALL (frame
->next
) :
513 frame
->next
? FRAME_SAVED_PC (frame
->next
) : read_pc ());
514 init_frame_info (fromleaf
, frame
);
517 /* Local variables (i.e. LOC_LOCAL) are on the memory stack, with their
518 offsets being relative to the memory stack pointer (high C) or
522 frame_locals_address (fi
)
523 struct frame_info
*fi
;
525 if (fi
->flags
& MFP_USED
)
526 return fi
->saved_msp
;
528 return fi
->saved_msp
- fi
->msize
;
531 /* Routines for reading the register stack. The caller gets to treat
532 the register stack as a uniform stack in memory, from address $gr1
533 straight through $rfb and beyond. */
535 /* Analogous to read_memory except the length is understood to be 4.
536 Also, myaddr can be NULL (meaning don't bother to read), and
537 if actual_mem_addr is non-NULL, store there the address that it
538 was fetched from (or if from a register the offset within
539 registers). Set *LVAL to lval_memory or lval_register, depending
540 on where it came from. The contents written into MYADDR are in
543 read_register_stack (memaddr
, myaddr
, actual_mem_addr
, lval
)
546 CORE_ADDR
*actual_mem_addr
;
547 enum lval_type
*lval
;
549 long rfb
= read_register (RFB_REGNUM
);
550 long rsp
= read_register (RSP_REGNUM
);
552 /* If we don't do this 'info register' stops in the middle. */
553 if (memaddr
>= rstack_high_address
)
556 static char val
[] = {~0, ~0, ~0, ~0};
557 /* It's in a local register, but off the end of the stack. */
558 int regnum
= (memaddr
- rsp
) / 4 + LR0_REGNUM
;
561 /* Provide bogusness */
562 memcpy (myaddr
, val
, 4);
564 supply_register(regnum
, val
); /* More bogusness */
566 *lval
= lval_register
;
567 if (actual_mem_addr
!= NULL
)
568 *actual_mem_addr
= REGISTER_BYTE (regnum
);
570 /* If it's in the part of the register stack that's in real registers,
571 get the value from the registers. If it's anywhere else in memory
572 (e.g. in another thread's saved stack), skip this part and get
573 it from real live memory. */
574 else if (memaddr
< rfb
&& memaddr
>= rsp
)
576 /* It's in a register. */
577 int regnum
= (memaddr
- rsp
) / 4 + LR0_REGNUM
;
578 if (regnum
> LR0_REGNUM
+ 127)
579 error ("Attempt to read register stack out of range.");
581 read_register_gen (regnum
, myaddr
);
583 *lval
= lval_register
;
584 if (actual_mem_addr
!= NULL
)
585 *actual_mem_addr
= REGISTER_BYTE (regnum
);
589 /* It's in the memory portion of the register stack. */
591 read_memory (memaddr
, myaddr
, 4);
594 if (actual_mem_addr
!= NULL
)
595 *actual_mem_addr
= memaddr
;
599 /* Analogous to read_memory_integer
600 except the length is understood to be 4. */
602 read_register_stack_integer (memaddr
, len
)
607 read_register_stack (memaddr
, buf
, NULL
, NULL
);
608 return extract_signed_integer (buf
, 4);
611 /* Copy 4 bytes from GDB memory at MYADDR into inferior memory
612 at MEMADDR and put the actual address written into in
615 write_register_stack (memaddr
, myaddr
, actual_mem_addr
)
618 CORE_ADDR
*actual_mem_addr
;
620 long rfb
= read_register (RFB_REGNUM
);
621 long rsp
= read_register (RSP_REGNUM
);
622 /* If we don't do this 'info register' stops in the middle. */
623 if (memaddr
>= rstack_high_address
)
625 /* It's in a register, but off the end of the stack. */
626 if (actual_mem_addr
!= NULL
)
627 *actual_mem_addr
= 0;
629 else if (memaddr
< rfb
)
631 /* It's in a register. */
632 int regnum
= (memaddr
- rsp
) / 4 + LR0_REGNUM
;
633 if (regnum
< LR0_REGNUM
|| regnum
> LR0_REGNUM
+ 127)
634 error ("Attempt to read register stack out of range.");
636 write_register (regnum
, *(long *)myaddr
);
637 if (actual_mem_addr
!= NULL
)
638 *actual_mem_addr
= 0;
642 /* It's in the memory portion of the register stack. */
644 write_memory (memaddr
, myaddr
, 4);
645 if (actual_mem_addr
!= NULL
)
646 *actual_mem_addr
= memaddr
;
650 /* Find register number REGNUM relative to FRAME and put its
651 (raw) contents in *RAW_BUFFER. Set *OPTIMIZED if the variable
652 was optimized out (and thus can't be fetched). If the variable
653 was fetched from memory, set *ADDRP to where it was fetched from,
654 otherwise it was fetched from a register.
656 The argument RAW_BUFFER must point to aligned memory. */
659 get_saved_register (raw_buffer
, optimized
, addrp
, frame
, regnum
, lvalp
)
663 struct frame_info
*frame
;
665 enum lval_type
*lvalp
;
667 struct frame_info
*fi
;
671 if (!target_has_registers
)
672 error ("No registers.");
674 /* Probably now redundant with the target_has_registers check. */
678 /* Once something has a register number, it doesn't get optimized out. */
679 if (optimized
!= NULL
)
681 if (regnum
== RSP_REGNUM
)
683 if (raw_buffer
!= NULL
)
685 store_address (raw_buffer
, REGISTER_RAW_SIZE (regnum
), frame
->frame
);
691 else if (regnum
== PC_REGNUM
)
693 if (raw_buffer
!= NULL
)
695 store_address (raw_buffer
, REGISTER_RAW_SIZE (regnum
), frame
->pc
);
698 /* Not sure we have to do this. */
704 else if (regnum
== MSP_REGNUM
)
706 if (raw_buffer
!= NULL
)
708 if (frame
->next
!= NULL
)
710 store_address (raw_buffer
, REGISTER_RAW_SIZE (regnum
),
711 frame
->next
->saved_msp
);
714 read_register_gen (MSP_REGNUM
, raw_buffer
);
716 /* The value may have been computed, not fetched. */
721 else if (regnum
< LR0_REGNUM
|| regnum
>= LR0_REGNUM
+ 128)
723 /* These registers are not saved over procedure calls,
724 so just print out the current values. */
725 if (raw_buffer
!= NULL
)
726 read_register_gen (regnum
, raw_buffer
);
728 *lvalp
= lval_register
;
730 *addrp
= REGISTER_BYTE (regnum
);
734 addr
= frame
->frame
+ (regnum
- LR0_REGNUM
) * 4;
735 if (raw_buffer
!= NULL
)
736 read_register_stack (addr
, raw_buffer
, &addr
, &lval
);
744 /* Discard from the stack the innermost frame,
745 restoring all saved registers. */
750 struct frame_info
*frame
= get_current_frame ();
751 CORE_ADDR rfb
= read_register (RFB_REGNUM
);
752 CORE_ADDR gr1
= frame
->frame
+ frame
->rsize
;
754 CORE_ADDR original_lr0
;
755 int must_fix_lr0
= 0;
758 /* If popping a dummy frame, need to restore registers. */
759 if (PC_IN_CALL_DUMMY (read_register (PC_REGNUM
),
760 read_register (SP_REGNUM
),
763 int lrnum
= LR0_REGNUM
+ DUMMY_ARG
/4;
764 for (i
= 0; i
< DUMMY_SAVE_SR128
; ++i
)
765 write_register (SR_REGNUM (i
+ 128),read_register (lrnum
++));
766 for (i
= 0; i
< DUMMY_SAVE_SR160
; ++i
)
767 write_register (SR_REGNUM(i
+160), read_register (lrnum
++));
768 for (i
= 0; i
< DUMMY_SAVE_GREGS
; ++i
)
769 write_register (RETURN_REGNUM
+ i
, read_register (lrnum
++));
770 /* Restore the PCs and prepare to restore LR0. */
771 write_register(PC_REGNUM
, read_register (lrnum
++));
772 write_register(NPC_REGNUM
, read_register (lrnum
++));
773 write_register(PC2_REGNUM
, read_register (lrnum
++));
774 original_lr0
= read_register (lrnum
++);
778 /* Restore the memory stack pointer. */
779 write_register (MSP_REGNUM
, frame
->saved_msp
);
780 /* Restore the register stack pointer. */
781 write_register (GR1_REGNUM
, gr1
);
783 /* If we popped a dummy frame, restore lr0 now that gr1 has been restored. */
785 write_register (LR0_REGNUM
, original_lr0
);
787 /* Check whether we need to fill registers. */
788 lr1
= read_register (LR0_REGNUM
+ 1);
792 int num_bytes
= lr1
- rfb
;
796 write_register (RAB_REGNUM
, read_register (RAB_REGNUM
) + num_bytes
);
797 write_register (RFB_REGNUM
, lr1
);
798 for (i
= 0; i
< num_bytes
; i
+= 4)
800 /* Note: word is in host byte order. */
801 word
= read_memory_integer (rfb
+ i
, 4);
802 write_register (LR0_REGNUM
+ ((rfb
- gr1
) % 0x80) + i
/ 4, word
);
805 flush_cached_frames ();
808 /* Push an empty stack frame, to record the current PC, etc. */
815 CORE_ADDR msp
= read_register (MSP_REGNUM
);
817 CORE_ADDR original_lr0
;
819 /* Read original lr0 before changing gr1. This order isn't really needed
820 since GDB happens to have a snapshot of all the regs and doesn't toss
821 it when gr1 is changed. But it's The Right Thing To Do. */
822 original_lr0
= read_register (LR0_REGNUM
);
824 /* Allocate the new frame. */
825 gr1
= read_register (GR1_REGNUM
) - DUMMY_FRAME_RSIZE
;
826 write_register (GR1_REGNUM
, gr1
);
828 #ifdef VXWORKS_TARGET
829 /* We force re-reading all registers to get the new local registers set
830 after gr1 has been modified. This fix is due to the lack of single
831 register read/write operation in the RPC interface between VxGDB and
832 VxWorks. This really must be changed ! */
834 vx_read_register (-1);
836 #endif /* VXWORK_TARGET */
838 rab
= read_register (RAB_REGNUM
);
841 /* We need to spill registers. */
842 int num_bytes
= rab
- gr1
;
843 CORE_ADDR rfb
= read_register (RFB_REGNUM
);
847 write_register (RFB_REGNUM
, rfb
- num_bytes
);
848 write_register (RAB_REGNUM
, gr1
);
849 for (i
= 0; i
< num_bytes
; i
+= 4)
851 /* Note: word is in target byte order. */
852 read_register_gen (LR0_REGNUM
+ i
/ 4, (char *) &word
);
853 write_memory (rfb
- num_bytes
+ i
, (char *) &word
, 4);
857 /* There are no arguments in to the dummy frame, so we don't need
858 more than rsize plus the return address and lr1. */
859 write_register (LR0_REGNUM
+ 1, gr1
+ DUMMY_FRAME_RSIZE
+ 2 * 4);
861 /* Set the memory frame pointer. */
862 write_register (LR0_REGNUM
+ DUMMY_FRAME_RSIZE
/ 4 - 1, msp
);
864 /* Allocate arg_slop. */
865 write_register (MSP_REGNUM
, msp
- 16 * 4);
867 /* Save registers. */
868 lrnum
= LR0_REGNUM
+ DUMMY_ARG
/4;
869 for (i
= 0; i
< DUMMY_SAVE_SR128
; ++i
)
870 write_register (lrnum
++, read_register (SR_REGNUM (i
+ 128)));
871 for (i
= 0; i
< DUMMY_SAVE_SR160
; ++i
)
872 write_register (lrnum
++, read_register (SR_REGNUM (i
+ 160)));
873 for (i
= 0; i
< DUMMY_SAVE_GREGS
; ++i
)
874 write_register (lrnum
++, read_register (RETURN_REGNUM
+ i
));
875 /* Save the PCs and LR0. */
876 write_register (lrnum
++, read_register (PC_REGNUM
));
877 write_register (lrnum
++, read_register (NPC_REGNUM
));
878 write_register (lrnum
++, read_register (PC2_REGNUM
));
880 /* Why are we saving LR0? What would clobber it? (the dummy frame should
881 be below it on the register stack, no?). */
882 write_register (lrnum
++, original_lr0
);
888 This routine takes three arguments and makes the cached frames look
889 as if these arguments defined a frame on the cache. This allows the
890 rest of `info frame' to extract the important arguments without much
891 difficulty. Since an individual frame on the 29K is determined by
892 three values (FP, PC, and MSP), we really need all three to do a
896 setup_arbitrary_frame (argc
, argv
)
900 struct frame_info
*frame
;
903 error ("AMD 29k frame specifications require three arguments: rsp pc msp");
905 frame
= create_new_frame (argv
[0], argv
[1]);
908 fatal ("internal: create_new_frame returned invalid frame id");
910 /* Creating a new frame munges the `frame' value from the current
911 GR1, so we restore it again here. FIXME, untangle all this
912 29K frame stuff... */
913 frame
->frame
= argv
[0];
915 /* Our MSP is in argv[2]. It'd be intelligent if we could just
916 save this value in the FRAME. But the way it's set up (FIXME),
917 we must save our caller's MSP. We compute that by adding our
918 memory stack frame size to our MSP. */
919 frame
->saved_msp
= argv
[2] + frame
->msize
;
925 gdb_print_insn_a29k (memaddr
, info
)
927 disassemble_info
*info
;
929 if (TARGET_BYTE_ORDER
== BIG_ENDIAN
)
930 return print_insn_big_a29k (memaddr
, info
);
932 return print_insn_little_a29k (memaddr
, info
);
935 enum a29k_processor_types processor_type
= a29k_unknown
;
938 a29k_get_processor_type ()
940 unsigned int cfg_reg
= (unsigned int) read_register (CFG_REGNUM
);
942 /* Most of these don't have freeze mode. */
943 processor_type
= a29k_no_freeze_mode
;
945 switch ((cfg_reg
>> 28) & 0xf)
948 fprintf_filtered (gdb_stderr
, "Remote debugging an Am29000");
951 fprintf_filtered (gdb_stderr
, "Remote debugging an Am29005");
954 fprintf_filtered (gdb_stderr
, "Remote debugging an Am29050");
955 processor_type
= a29k_freeze_mode
;
958 fprintf_filtered (gdb_stderr
, "Remote debugging an Am29035");
961 fprintf_filtered (gdb_stderr
, "Remote debugging an Am29030");
964 fprintf_filtered (gdb_stderr
, "Remote debugging an Am2920*");
967 fprintf_filtered (gdb_stderr
, "Remote debugging an Am2924*");
970 fprintf_filtered (gdb_stderr
, "Remote debugging an Am29040");
973 fprintf_filtered (gdb_stderr
, "Remote debugging an unknown Am29k\n");
974 /* Don't bother to print the revision. */
977 fprintf_filtered (gdb_stderr
, " revision %c\n", 'A' + ((cfg_reg
>> 24) & 0x0f));
980 #ifdef GET_LONGJMP_TARGET
981 /* Figure out where the longjmp will land. We expect that we have just entered
982 longjmp and haven't yet setup the stack frame, so the args are still in the
983 output regs. lr2 (LR2_REGNUM) points at the jmp_buf structure from which we
984 extract the pc (JB_PC) that we will land at. The pc is copied into ADDR.
985 This routine returns true on success */
988 get_longjmp_target(pc
)
992 char buf
[sizeof(CORE_ADDR
)];
994 jb_addr
= read_register(LR2_REGNUM
);
996 if (target_read_memory(jb_addr
+ JB_PC
* JB_ELEMENT_SIZE
, (char *) buf
,
1000 *pc
= extract_address ((PTR
) buf
, sizeof(CORE_ADDR
));
1003 #endif /* GET_LONGJMP_TARGET */
1006 _initialize_a29k_tdep ()
1008 extern CORE_ADDR text_end
;
1010 tm_print_insn
= gdb_print_insn_a29k
;
1012 /* FIXME, there should be a way to make a CORE_ADDR variable settable. */
1014 (add_set_cmd ("rstack_high_address", class_support
, var_uinteger
,
1015 (char *)&rstack_high_address
,
1016 "Set top address in memory of the register stack.\n\
1017 Attempts to access registers saved above this address will be ignored\n\
1018 or will produce the value -1.", &setlist
),
1021 /* FIXME, there should be a way to make a CORE_ADDR variable settable. */
1023 (add_set_cmd ("call_scratch_address", class_support
, var_uinteger
,
1025 "Set address in memory where small amounts of RAM can be used\n\
1026 when making function calls into the inferior.", &setlist
),