1 /* Target-machine dependent code for the AMD 29000
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000,
4 Free Software Foundation, Inc.
5 Contributed by Cygnus Support. Written by Jim Kingdon.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
33 /* If all these bits in an instruction word are zero, it is a "tag word"
34 which precedes a function entry point and gives stack traceback info.
35 This used to be defined as 0xff000000, but that treated 0x00000deb as
36 a tag word, while it is really used as a breakpoint. */
37 #define TAGWORD_ZERO_MASK 0xff00f800
39 extern CORE_ADDR text_start; /* FIXME, kludge... */
41 /* The user-settable top of the register stack in virtual memory. We
42 won't attempt to access any stored registers above this address, if set
45 static CORE_ADDR rstack_high_address = UINT_MAX;
48 /* Should call_function allocate stack space for a struct return? */
49 /* On the a29k objects over 16 words require the caller to allocate space. */
51 a29k_use_struct_convention (int gcc_p, struct type *type)
53 return (TYPE_LENGTH (type) > 16 * 4);
57 /* Structure to hold cached info about function prologues. */
61 CORE_ADDR pc; /* First addr after fn prologue */
62 unsigned rsize, msize; /* register stack frame size, mem stack ditto */
63 unsigned mfp_used:1; /* memory frame pointer used */
64 unsigned rsize_valid:1; /* Validity bits for the above */
65 unsigned msize_valid:1;
69 /* Examine the prologue of a function which starts at PC. Return
70 the first addess past the prologue. If MSIZE is non-NULL, then
71 set *MSIZE to the memory stack frame size. If RSIZE is non-NULL,
72 then set *RSIZE to the register stack frame size (not including
73 incoming arguments and the return address & frame pointer stored
74 with them). If no prologue is found, *RSIZE is set to zero.
75 If no prologue is found, or a prologue which doesn't involve
76 allocating a memory stack frame, then set *MSIZE to zero.
78 Note that both msize and rsize are in bytes. This is not consistent
79 with the _User's Manual_ with respect to rsize, but it is much more
82 If MFP_USED is non-NULL, *MFP_USED is set to nonzero if a memory
83 frame pointer is being used. */
86 examine_prologue (CORE_ADDR pc, unsigned *rsize, unsigned *msize, int *mfp_used)
90 struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (pc);
91 struct prologue_info *mi = 0;
94 mi = (struct prologue_info *) msymbol->info;
102 valid &= mi->rsize_valid;
107 valid &= mi->msize_valid;
109 if (mfp_used != NULL)
111 *mfp_used = mi->mfp_used;
112 valid &= mi->mfp_valid;
122 if (mfp_used != NULL)
125 /* Prologue must start with subtracting a constant from gr1.
126 Normally this is sub gr1,gr1,<rsize * 4>. */
127 insn = read_memory_integer (p, 4);
128 if ((insn & 0xffffff00) != 0x25010100)
130 /* If the frame is large, instead of a single instruction it
131 might be a pair of instructions:
132 const <reg>, <rsize * 4>
136 /* Possible value for rsize. */
139 if ((insn & 0xff000000) != 0x03000000)
144 reg = (insn >> 8) & 0xff;
145 rsize0 = (((insn >> 8) & 0xff00) | (insn & 0xff));
147 insn = read_memory_integer (p, 4);
148 if ((insn & 0xffffff00) != 0x24010100
149 || (insn & 0xff) != reg)
160 *rsize = (insn & 0xff);
164 /* Next instruction ought to be asgeu V_SPILL,gr1,rab.
165 * We don't check the vector number to allow for kernel debugging. The
166 * kernel will use a different trap number.
167 * If this insn is missing, we just keep going; Metaware R2.3u compiler
168 * generates prologue that intermixes initializations and puts the asgeu
171 insn = read_memory_integer (p, 4);
172 if ((insn & 0xff00ffff) == (0x5e000100 | RAB_HW_REGNUM))
177 /* Next instruction usually sets the frame pointer (lr1) by adding
178 <size * 4> from gr1. However, this can (and high C does) be
179 deferred until anytime before the first function call. So it is
180 OK if we don't see anything which sets lr1.
181 To allow for alternate register sets (gcc -mkernel-registers) the msp
182 register number is a compile time constant. */
184 /* Normally this is just add lr1,gr1,<size * 4>. */
185 insn = read_memory_integer (p, 4);
186 if ((insn & 0xffffff00) == 0x15810100)
190 /* However, for large frames it can be
191 const <reg>, <size *4>
197 if ((insn & 0xff000000) == 0x03000000)
199 reg = (insn >> 8) & 0xff;
201 insn = read_memory_integer (q, 4);
202 if ((insn & 0xffffff00) == 0x14810100
203 && (insn & 0xff) == reg)
208 /* Next comes "add lr{<rsize-1>},msp,0", but only if a memory
209 frame pointer is in use. We just check for add lr<anything>,msp,0;
210 we don't check this rsize against the first instruction, and
211 we don't check that the trace-back tag indicates a memory frame pointer
213 To allow for alternate register sets (gcc -mkernel-registers) the msp
214 register number is a compile time constant.
216 The recommended instruction is actually "sll lr<whatever>,msp,0".
217 We check for that, too. Originally Jim Kingdon's code seemed
218 to be looking for a "sub" instruction here, but the mask was set
219 up to lose all the time. */
220 insn = read_memory_integer (p, 4);
221 if (((insn & 0xff80ffff) == (0x15800000 | (MSP_HW_REGNUM << 8))) /* add */
222 || ((insn & 0xff80ffff) == (0x81800000 | (MSP_HW_REGNUM << 8)))) /* sll */
225 if (mfp_used != NULL)
229 /* Next comes a subtraction from msp to allocate a memory frame,
230 but only if a memory frame is
231 being used. We don't check msize against the trace-back tag.
233 To allow for alternate register sets (gcc -mkernel-registers) the msp
234 register number is a compile time constant.
236 Normally this is just
239 insn = read_memory_integer (p, 4);
240 if ((insn & 0xffffff00) ==
241 (0x25000000 | (MSP_HW_REGNUM << 16) | (MSP_HW_REGNUM << 8)))
245 *msize = insn & 0xff;
249 /* For large frames, instead of a single instruction it might
253 consth <reg>, <msize> ; optional
260 if ((insn & 0xff000000) == 0x03000000)
262 reg = (insn >> 8) & 0xff;
263 msize0 = ((insn >> 8) & 0xff00) | (insn & 0xff);
265 insn = read_memory_integer (q, 4);
266 /* Check for consth. */
267 if ((insn & 0xff000000) == 0x02000000
268 && (insn & 0x0000ff00) == reg)
270 msize0 |= (insn << 8) & 0xff000000;
271 msize0 |= (insn << 16) & 0x00ff0000;
273 insn = read_memory_integer (q, 4);
275 /* Check for sub msp,msp,<reg>. */
276 if ((insn & 0xffffff00) ==
277 (0x24000000 | (MSP_HW_REGNUM << 16) | (MSP_HW_REGNUM << 8))
278 && (insn & 0xff) == reg)
287 /* Next instruction might be asgeu V_SPILL,gr1,rab.
288 * We don't check the vector number to allow for kernel debugging. The
289 * kernel will use a different trap number.
290 * Metaware R2.3u compiler
291 * generates prologue that intermixes initializations and puts the asgeu
292 * way down after everything else.
294 insn = read_memory_integer (p, 4);
295 if ((insn & 0xff00ffff) == (0x5e000100 | RAB_HW_REGNUM))
305 /* Add a new cache entry. */
306 mi = (struct prologue_info *) xmalloc (sizeof (struct prologue_info));
307 msymbol->info = (char *) mi;
312 /* else, cache entry exists, but info is incomplete. */
324 if (mfp_used != NULL)
326 mi->mfp_used = *mfp_used;
333 /* Advance PC across any function entry prologue instructions
334 to reach some "real" code. */
337 a29k_skip_prologue (CORE_ADDR pc)
339 return examine_prologue (pc, NULL, NULL, NULL);
343 * Examine the one or two word tag at the beginning of a function.
344 * The tag word is expect to be at 'p', if it is not there, we fail
345 * by returning 0. The documentation for the tag word was taken from
346 * page 7-15 of the 29050 User's Manual. We are assuming that the
347 * m bit is in bit 22 of the tag word, which seems to be the agreed upon
348 * convention today (1/15/92).
349 * msize is return in bytes.
352 static int /* 0/1 - failure/success of finding the tag word */
353 examine_tag (CORE_ADDR p, int *is_trans, int *argcount, unsigned *msize,
356 unsigned int tag1, tag2;
358 tag1 = read_memory_integer (p, 4);
359 if ((tag1 & TAGWORD_ZERO_MASK) != 0) /* Not a tag word */
361 if (tag1 & (1 << 23)) /* A two word tag */
363 tag2 = read_memory_integer (p - 4, 4);
371 *msize = tag1 & 0x7ff;
374 *is_trans = ((tag1 & (1 << 21)) ? 1 : 0);
375 /* Note that this includes the frame pointer and the return address
376 register, so the actual number of registers of arguments is two less.
377 argcount can be zero, however, sometimes, for strange assembler
380 *argcount = (tag1 >> 16) & 0x1f;
382 *mfp_used = ((tag1 & (1 << 22)) ? 1 : 0);
386 /* Initialize the frame. In addition to setting "extra" frame info,
387 we also set ->frame because we use it in a nonstandard way, and ->pc
388 because we need to know it to get the other stuff. See the diagram
389 of stacks and the frame cache in tm-a29k.h for more detail. */
392 init_frame_info (int innermost_frame, struct frame_info *frame)
404 frame->frame = read_register (GR1_REGNUM);
406 frame->frame = frame->next->frame + frame->next->rsize;
408 #if 0 /* CALL_DUMMY_LOCATION == ON_STACK */
411 if (PC_IN_CALL_DUMMY (p, 0, 0))
414 frame->rsize = DUMMY_FRAME_RSIZE;
415 /* This doesn't matter since we never try to get locals or args
416 from a dummy frame. */
418 /* Dummy frames always use a memory frame pointer. */
420 read_register_stack_integer (frame->frame + DUMMY_FRAME_RSIZE - 4, 4);
421 frame->flags |= (TRANSPARENT_FRAME | MFP_USED);
425 func = find_pc_function (p);
427 p = BLOCK_START (SYMBOL_BLOCK_VALUE (func));
430 /* Search backward to find the trace-back tag. However,
431 do not trace back beyond the start of the text segment
432 (just as a sanity check to avoid going into never-never land). */
434 while (p >= text_start
435 && ((insn = read_memory_integer (p, 4)) & TAGWORD_ZERO_MASK) != 0)
442 store_unsigned_integer (mask, 4, TAGWORD_ZERO_MASK);
443 /* Enable this once target_search is enabled and tested. */
444 target_search (4, pat, mask, p, -4, text_start, p + 1, &p, &insn_raw);
445 insn = extract_unsigned_integer (insn_raw, 4);
450 /* Couldn't find the trace-back tag.
451 Something strange is going on. */
452 frame->saved_msp = 0;
455 frame->flags = TRANSPARENT_FRAME;
459 /* Advance to the first word of the function, i.e. the word
460 after the trace-back tag. */
464 /* We've found the start of the function.
465 Try looking for a tag word that indicates whether there is a
466 memory frame pointer and what the memory stack allocation is.
467 If one doesn't exist, try using a more exhaustive search of
470 if (examine_tag (p - 4, &trans, (int *) NULL, &msize, &mfp_used)) /* Found good tag */
471 examine_prologue (p, &rsize, 0, 0);
472 else /* No tag try prologue */
473 examine_prologue (p, &rsize, &msize, &mfp_used);
475 frame->rsize = rsize;
476 frame->msize = msize;
479 frame->flags |= MFP_USED;
481 frame->flags |= TRANSPARENT_FRAME;
484 frame->saved_msp = read_register (MSP_REGNUM) + msize;
490 read_register_stack_integer (frame->frame + rsize - 4, 4);
492 frame->saved_msp = frame->next->saved_msp + msize;
497 init_extra_frame_info (struct frame_info *frame)
499 if (frame->next == 0)
500 /* Assume innermost frame. May produce strange results for "info frame"
501 but there isn't any way to tell the difference. */
502 init_frame_info (1, frame);
505 /* We're in get_prev_frame.
506 Take care of everything in init_frame_pc. */
512 init_frame_pc (int fromleaf, struct frame_info *frame)
514 frame->pc = (fromleaf ? SAVED_PC_AFTER_CALL (frame->next) :
515 frame->next ? FRAME_SAVED_PC (frame->next) : read_pc ());
516 init_frame_info (fromleaf, frame);
519 /* Local variables (i.e. LOC_LOCAL) are on the memory stack, with their
520 offsets being relative to the memory stack pointer (high C) or
524 frame_locals_address (struct frame_info *fi)
526 if (fi->flags & MFP_USED)
527 return fi->saved_msp;
529 return fi->saved_msp - fi->msize;
532 /* Routines for reading the register stack. The caller gets to treat
533 the register stack as a uniform stack in memory, from address $gr1
534 straight through $rfb and beyond. */
536 /* Analogous to read_memory except the length is understood to be 4.
537 Also, myaddr can be NULL (meaning don't bother to read), and
538 if actual_mem_addr is non-NULL, store there the address that it
539 was fetched from (or if from a register the offset within
540 registers). Set *LVAL to lval_memory or lval_register, depending
541 on where it came from. The contents written into MYADDR are in
544 read_register_stack (CORE_ADDR memaddr, char *myaddr,
545 CORE_ADDR *actual_mem_addr, enum lval_type *lval)
547 long rfb = read_register (RFB_REGNUM);
548 long rsp = read_register (RSP_REGNUM);
550 /* If we don't do this 'info register' stops in the middle. */
551 if (memaddr >= rstack_high_address)
556 /* It's in a local register, but off the end of the stack. */
557 int regnum = (memaddr - rsp) / 4 + LR0_REGNUM;
560 /* Provide bogusness */
561 memcpy (myaddr, val, 4);
563 supply_register (regnum, val); /* More bogusness */
565 *lval = lval_register;
566 if (actual_mem_addr != NULL)
567 *actual_mem_addr = REGISTER_BYTE (regnum);
569 /* If it's in the part of the register stack that's in real registers,
570 get the value from the registers. If it's anywhere else in memory
571 (e.g. in another thread's saved stack), skip this part and get
572 it from real live memory. */
573 else if (memaddr < rfb && memaddr >= rsp)
575 /* It's in a register. */
576 int regnum = (memaddr - rsp) / 4 + LR0_REGNUM;
577 if (regnum > LR0_REGNUM + 127)
578 error ("Attempt to read register stack out of range.");
580 read_register_gen (regnum, myaddr);
582 *lval = lval_register;
583 if (actual_mem_addr != NULL)
584 *actual_mem_addr = REGISTER_BYTE (regnum);
588 /* It's in the memory portion of the register stack. */
590 read_memory (memaddr, myaddr, 4);
593 if (actual_mem_addr != NULL)
594 *actual_mem_addr = memaddr;
598 /* Analogous to read_memory_integer
599 except the length is understood to be 4. */
601 read_register_stack_integer (CORE_ADDR memaddr, int len)
604 read_register_stack (memaddr, buf, NULL, NULL);
605 return extract_signed_integer (buf, 4);
608 /* Copy 4 bytes from GDB memory at MYADDR into inferior memory
609 at MEMADDR and put the actual address written into in
612 write_register_stack (CORE_ADDR memaddr, char *myaddr,
613 CORE_ADDR *actual_mem_addr)
615 long rfb = read_register (RFB_REGNUM);
616 long rsp = read_register (RSP_REGNUM);
617 /* If we don't do this 'info register' stops in the middle. */
618 if (memaddr >= rstack_high_address)
620 /* It's in a register, but off the end of the stack. */
621 if (actual_mem_addr != NULL)
622 *actual_mem_addr = 0;
624 else if (memaddr < rfb)
626 /* It's in a register. */
627 int regnum = (memaddr - rsp) / 4 + LR0_REGNUM;
628 if (regnum < LR0_REGNUM || regnum > LR0_REGNUM + 127)
629 error ("Attempt to read register stack out of range.");
631 write_register (regnum, *(long *) myaddr);
632 if (actual_mem_addr != NULL)
633 *actual_mem_addr = 0;
637 /* It's in the memory portion of the register stack. */
639 write_memory (memaddr, myaddr, 4);
640 if (actual_mem_addr != NULL)
641 *actual_mem_addr = memaddr;
645 /* Find register number REGNUM relative to FRAME and put its
646 (raw) contents in *RAW_BUFFER. Set *OPTIMIZED if the variable
647 was optimized out (and thus can't be fetched). If the variable
648 was fetched from memory, set *ADDRP to where it was fetched from,
649 otherwise it was fetched from a register.
651 The argument RAW_BUFFER must point to aligned memory. */
654 a29k_get_saved_register (char *raw_buffer, int *optimized, CORE_ADDR *addrp,
655 struct frame_info *frame, int regnum,
656 enum lval_type *lvalp)
658 struct frame_info *fi;
662 if (!target_has_registers)
663 error ("No registers.");
665 /* Probably now redundant with the target_has_registers check. */
669 /* Once something has a register number, it doesn't get optimized out. */
670 if (optimized != NULL)
672 if (regnum == RSP_REGNUM)
674 if (raw_buffer != NULL)
676 store_address (raw_buffer, REGISTER_RAW_SIZE (regnum), frame->frame);
682 else if (regnum == PC_REGNUM && frame->next != NULL)
684 if (raw_buffer != NULL)
686 store_address (raw_buffer, REGISTER_RAW_SIZE (regnum), frame->pc);
689 /* Not sure we have to do this. */
695 else if (regnum == MSP_REGNUM)
697 if (raw_buffer != NULL)
699 if (frame->next != NULL)
701 store_address (raw_buffer, REGISTER_RAW_SIZE (regnum),
702 frame->next->saved_msp);
705 read_register_gen (MSP_REGNUM, raw_buffer);
707 /* The value may have been computed, not fetched. */
712 else if (regnum < LR0_REGNUM || regnum >= LR0_REGNUM + 128)
714 /* These registers are not saved over procedure calls,
715 so just print out the current values. */
716 if (raw_buffer != NULL)
717 read_register_gen (regnum, raw_buffer);
719 *lvalp = lval_register;
721 *addrp = REGISTER_BYTE (regnum);
725 addr = frame->frame + (regnum - LR0_REGNUM) * 4;
726 if (raw_buffer != NULL)
727 read_register_stack (addr, raw_buffer, &addr, &lval);
735 /* Discard from the stack the innermost frame,
736 restoring all saved registers. */
741 struct frame_info *frame = get_current_frame ();
742 CORE_ADDR rfb = read_register (RFB_REGNUM);
743 CORE_ADDR gr1 = frame->frame + frame->rsize;
745 CORE_ADDR original_lr0;
746 int must_fix_lr0 = 0;
749 /* If popping a dummy frame, need to restore registers. */
750 if (PC_IN_CALL_DUMMY (read_register (PC_REGNUM),
751 read_register (SP_REGNUM),
754 int lrnum = LR0_REGNUM + DUMMY_ARG / 4;
755 for (i = 0; i < DUMMY_SAVE_SR128; ++i)
756 write_register (SR_REGNUM (i + 128), read_register (lrnum++));
757 for (i = 0; i < DUMMY_SAVE_SR160; ++i)
758 write_register (SR_REGNUM (i + 160), read_register (lrnum++));
759 for (i = 0; i < DUMMY_SAVE_GREGS; ++i)
760 write_register (RETURN_REGNUM + i, read_register (lrnum++));
761 /* Restore the PCs and prepare to restore LR0. */
762 write_register (PC_REGNUM, read_register (lrnum++));
763 write_register (NPC_REGNUM, read_register (lrnum++));
764 write_register (PC2_REGNUM, read_register (lrnum++));
765 original_lr0 = read_register (lrnum++);
769 /* Restore the memory stack pointer. */
770 write_register (MSP_REGNUM, frame->saved_msp);
771 /* Restore the register stack pointer. */
772 write_register (GR1_REGNUM, gr1);
774 /* If we popped a dummy frame, restore lr0 now that gr1 has been restored. */
776 write_register (LR0_REGNUM, original_lr0);
778 /* Check whether we need to fill registers. */
779 lr1 = read_register (LR0_REGNUM + 1);
783 int num_bytes = lr1 - rfb;
787 write_register (RAB_REGNUM, read_register (RAB_REGNUM) + num_bytes);
788 write_register (RFB_REGNUM, lr1);
789 for (i = 0; i < num_bytes; i += 4)
791 /* Note: word is in host byte order. */
792 word = read_memory_integer (rfb + i, 4);
793 write_register (LR0_REGNUM + ((rfb - gr1) % 0x80) + i / 4, word);
796 flush_cached_frames ();
799 /* Push an empty stack frame, to record the current PC, etc. */
802 push_dummy_frame (void)
806 CORE_ADDR msp = read_register (MSP_REGNUM);
808 CORE_ADDR original_lr0;
810 /* Read original lr0 before changing gr1. This order isn't really needed
811 since GDB happens to have a snapshot of all the regs and doesn't toss
812 it when gr1 is changed. But it's The Right Thing To Do. */
813 original_lr0 = read_register (LR0_REGNUM);
815 /* Allocate the new frame. */
816 gr1 = read_register (GR1_REGNUM) - DUMMY_FRAME_RSIZE;
817 write_register (GR1_REGNUM, gr1);
819 #ifdef VXWORKS_TARGET
820 /* We force re-reading all registers to get the new local registers set
821 after gr1 has been modified. This fix is due to the lack of single
822 register read/write operation in the RPC interface between VxGDB and
823 VxWorks. This really must be changed ! */
825 vx_read_register (-1);
827 #endif /* VXWORK_TARGET */
829 rab = read_register (RAB_REGNUM);
832 /* We need to spill registers. */
833 int num_bytes = rab - gr1;
834 CORE_ADDR rfb = read_register (RFB_REGNUM);
838 write_register (RFB_REGNUM, rfb - num_bytes);
839 write_register (RAB_REGNUM, gr1);
840 for (i = 0; i < num_bytes; i += 4)
842 /* Note: word is in target byte order. */
843 read_register_gen (LR0_REGNUM + i / 4, (char *) &word);
844 write_memory (rfb - num_bytes + i, (char *) &word, 4);
848 /* There are no arguments in to the dummy frame, so we don't need
849 more than rsize plus the return address and lr1. */
850 write_register (LR0_REGNUM + 1, gr1 + DUMMY_FRAME_RSIZE + 2 * 4);
852 /* Set the memory frame pointer. */
853 write_register (LR0_REGNUM + DUMMY_FRAME_RSIZE / 4 - 1, msp);
855 /* Allocate arg_slop. */
856 write_register (MSP_REGNUM, msp - 16 * 4);
858 /* Save registers. */
859 lrnum = LR0_REGNUM + DUMMY_ARG / 4;
860 for (i = 0; i < DUMMY_SAVE_SR128; ++i)
861 write_register (lrnum++, read_register (SR_REGNUM (i + 128)));
862 for (i = 0; i < DUMMY_SAVE_SR160; ++i)
863 write_register (lrnum++, read_register (SR_REGNUM (i + 160)));
864 for (i = 0; i < DUMMY_SAVE_GREGS; ++i)
865 write_register (lrnum++, read_register (RETURN_REGNUM + i));
866 /* Save the PCs and LR0. */
867 write_register (lrnum++, read_register (PC_REGNUM));
868 write_register (lrnum++, read_register (NPC_REGNUM));
869 write_register (lrnum++, read_register (PC2_REGNUM));
871 /* Why are we saving LR0? What would clobber it? (the dummy frame should
872 be below it on the register stack, no?). */
873 write_register (lrnum++, original_lr0);
879 This routine takes three arguments and makes the cached frames look
880 as if these arguments defined a frame on the cache. This allows the
881 rest of `info frame' to extract the important arguments without much
882 difficulty. Since an individual frame on the 29K is determined by
883 three values (FP, PC, and MSP), we really need all three to do a
887 setup_arbitrary_frame (int argc, CORE_ADDR *argv)
889 struct frame_info *frame;
892 error ("AMD 29k frame specifications require three arguments: rsp pc msp");
894 frame = create_new_frame (argv[0], argv[1]);
897 internal_error (__FILE__, __LINE__,
898 "create_new_frame returned invalid frame id");
900 /* Creating a new frame munges the `frame' value from the current
901 GR1, so we restore it again here. FIXME, untangle all this
902 29K frame stuff... */
903 frame->frame = argv[0];
905 /* Our MSP is in argv[2]. It'd be intelligent if we could just
906 save this value in the FRAME. But the way it's set up (FIXME),
907 we must save our caller's MSP. We compute that by adding our
908 memory stack frame size to our MSP. */
909 frame->saved_msp = argv[2] + frame->msize;
915 gdb_print_insn_a29k (bfd_vma memaddr, disassemble_info *info)
917 if (TARGET_BYTE_ORDER == BIG_ENDIAN)
918 return print_insn_big_a29k (memaddr, info);
920 return print_insn_little_a29k (memaddr, info);
923 enum a29k_processor_types processor_type = a29k_unknown;
926 a29k_get_processor_type (void)
928 unsigned int cfg_reg = (unsigned int) read_register (CFG_REGNUM);
930 /* Most of these don't have freeze mode. */
931 processor_type = a29k_no_freeze_mode;
933 switch ((cfg_reg >> 28) & 0xf)
936 fprintf_filtered (gdb_stderr, "Remote debugging an Am29000");
939 fprintf_filtered (gdb_stderr, "Remote debugging an Am29005");
942 fprintf_filtered (gdb_stderr, "Remote debugging an Am29050");
943 processor_type = a29k_freeze_mode;
946 fprintf_filtered (gdb_stderr, "Remote debugging an Am29035");
949 fprintf_filtered (gdb_stderr, "Remote debugging an Am29030");
952 fprintf_filtered (gdb_stderr, "Remote debugging an Am2920*");
955 fprintf_filtered (gdb_stderr, "Remote debugging an Am2924*");
958 fprintf_filtered (gdb_stderr, "Remote debugging an Am29040");
961 fprintf_filtered (gdb_stderr, "Remote debugging an unknown Am29k\n");
962 /* Don't bother to print the revision. */
965 fprintf_filtered (gdb_stderr, " revision %c\n", 'A' + ((cfg_reg >> 24) & 0x0f));
968 #ifdef GET_LONGJMP_TARGET
969 /* Figure out where the longjmp will land. We expect that we have just entered
970 longjmp and haven't yet setup the stack frame, so the args are still in the
971 output regs. lr2 (LR2_REGNUM) points at the jmp_buf structure from which we
972 extract the pc (JB_PC) that we will land at. The pc is copied into ADDR.
973 This routine returns true on success */
976 get_longjmp_target (CORE_ADDR *pc)
979 char buf[sizeof (CORE_ADDR)];
981 jb_addr = read_register (LR2_REGNUM);
983 if (target_read_memory (jb_addr + JB_PC * JB_ELEMENT_SIZE, (char *) buf,
987 *pc = extract_address ((PTR) buf, sizeof (CORE_ADDR));
990 #endif /* GET_LONGJMP_TARGET */
993 _initialize_a29k_tdep (void)
995 extern CORE_ADDR text_end;
997 tm_print_insn = gdb_print_insn_a29k;
999 /* FIXME, there should be a way to make a CORE_ADDR variable settable. */
1001 (add_set_cmd ("rstack_high_address", class_support, var_uinteger,
1002 (char *) &rstack_high_address,
1003 "Set top address in memory of the register stack.\n\
1004 Attempts to access registers saved above this address will be ignored\n\
1005 or will produce the value -1.", &setlist),
1008 /* FIXME, there should be a way to make a CORE_ADDR variable settable. */
1010 (add_set_cmd ("call_scratch_address", class_support, var_uinteger,
1012 "Set address in memory where small amounts of RAM can be used\n\
1013 when making function calls into the inferior.", &setlist),