1 /* Target-machine dependent code for the Intel 960
2 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
3 Free Software Foundation, Inc.
4 Contributed by Intel Corporation.
5 examine_prologue and other parts contributed by Wind River Systems.
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. */
28 #include "floatformat.h"
34 static CORE_ADDR
next_insn (CORE_ADDR memaddr
,
35 unsigned int *pword1
, unsigned int *pword2
);
38 i960_register_type (int regnum
)
40 if (regnum
< FP0_REGNUM
)
41 return builtin_type_int32
;
43 return builtin_type_i960_ext
;
47 /* Does the specified function use the "struct returning" convention
48 or the "value returning" convention? The "value returning" convention
49 almost invariably returns the entire value in registers. The
50 "struct returning" convention often returns the entire value in
51 memory, and passes a pointer (out of or into the function) saying
52 where the value (is or should go).
54 Since this sometimes depends on whether it was compiled with GCC,
55 this is also an argument. This is used in call_function to build a
56 stack, and in value_being_returned to print return values.
58 On i960, a structure is returned in registers g0-g3, if it will fit.
59 If it's more than 16 bytes long, g13 pointed to it on entry. */
62 i960_use_struct_convention (int gcc_p
, struct type
*type
)
64 return (TYPE_LENGTH (type
) > 16);
67 /* gdb960 is always running on a non-960 host. Check its characteristics.
68 This routine must be called as part of gdb initialization. */
75 static struct typestruct
77 int hostsize
; /* Size of type on host */
78 int i960size
; /* Size of type on i960 */
79 char *typename
; /* Name of type, for error msg */
84 sizeof (short), 2, "short"
88 sizeof (int), 4, "int"
92 sizeof (long), 4, "long"
96 sizeof (float), 4, "float"
100 sizeof (double), 8, "double"
104 sizeof (char *), 4, "pointer"
108 #define TYPELEN (sizeof(types) / sizeof(struct typestruct))
110 /* Make sure that host type sizes are same as i960
112 for (i
= 0; i
< TYPELEN
; i
++)
114 if (types
[i
].hostsize
!= types
[i
].i960size
)
116 printf_unfiltered ("sizeof(%s) != %d: PROCEED AT YOUR OWN RISK!\n",
117 types
[i
].typename
, types
[i
].i960size
);
123 /* Examine an i960 function prologue, recording the addresses at which
124 registers are saved explicitly by the prologue code, and returning
125 the address of the first instruction after the prologue (but not
126 after the instruction at address LIMIT, as explained below).
128 LIMIT places an upper bound on addresses of the instructions to be
129 examined. If the prologue code scan reaches LIMIT, the scan is
130 aborted and LIMIT is returned. This is used, when examining the
131 prologue for the current frame, to keep examine_prologue () from
132 claiming that a given register has been saved when in fact the
133 instruction that saves it has not yet been executed. LIMIT is used
134 at other times to stop the scan when we hit code after the true
135 function prologue (e.g. for the first source line) which might
136 otherwise be mistaken for function prologue.
138 The format of the function prologue matched by this routine is
139 derived from examination of the source to gcc960 1.21, particularly
140 the routine i960_function_prologue (). A "regular expression" for
141 the function prologue is given below:
145 (mov 0, g14) | (lda 0, g14))?
147 (mov[qtl]? g[0-15], r[4-15])*
148 ((addo [1-31], sp, sp) | (lda n(sp), sp))?
149 (st[qtl]? g[0-15], n(fp))*
162 /* Macros for extracting fields from i960 instructions. */
164 #define BITMASK(pos, width) (((0x1 << (width)) - 1) << (pos))
165 #define EXTRACT_FIELD(val, pos, width) ((val) >> (pos) & BITMASK (0, width))
167 #define REG_SRC1(insn) EXTRACT_FIELD (insn, 0, 5)
168 #define REG_SRC2(insn) EXTRACT_FIELD (insn, 14, 5)
169 #define REG_SRCDST(insn) EXTRACT_FIELD (insn, 19, 5)
170 #define MEM_SRCDST(insn) EXTRACT_FIELD (insn, 19, 5)
171 #define MEMA_OFFSET(insn) EXTRACT_FIELD (insn, 0, 12)
173 /* Fetch the instruction at ADDR, returning 0 if ADDR is beyond LIM or
174 is not the address of a valid instruction, the address of the next
175 instruction beyond ADDR otherwise. *PWORD1 receives the first word
176 of the instruction, and (for two-word instructions), *PWORD2 receives
179 #define NEXT_PROLOGUE_INSN(addr, lim, pword1, pword2) \
180 (((addr) < (lim)) ? next_insn (addr, pword1, pword2) : 0)
183 examine_prologue (register CORE_ADDR ip
, register CORE_ADDR limit
,
184 CORE_ADDR frame_addr
, struct frame_saved_regs
*fsr
)
186 register CORE_ADDR next_ip
;
187 register int src
, dst
;
188 register unsigned int *pcode
;
189 unsigned int insn1
, insn2
;
191 int within_leaf_prologue
;
193 static unsigned int varargs_prologue_code
[] =
195 0x3507a00c, /* cmpobne 0x0, g14, LFn */
196 0x5cf01601, /* mov sp, g14 */
197 0x8c086030, /* lda 0x30(sp), sp */
198 0xb2879000, /* LFn: stq g0, (g14) */
199 0xb2a7a010, /* stq g4, 0x10(g14) */
200 0xb2c7a020 /* stq g8, 0x20(g14) */
203 /* Accept a leaf procedure prologue code fragment if present.
204 Note that ip might point to either the leaf or non-leaf
205 entry point; we look for the non-leaf entry point first: */
207 within_leaf_prologue
= 0;
208 if ((next_ip
= NEXT_PROLOGUE_INSN (ip
, limit
, &insn1
, &insn2
))
209 && ((insn1
& 0xfffff000) == 0x8cf00000 /* lda LRx, g14 (MEMA) */
210 || (insn1
& 0xfffffc60) == 0x8cf03000)) /* lda LRx, g14 (MEMB) */
212 within_leaf_prologue
= 1;
213 next_ip
= NEXT_PROLOGUE_INSN (next_ip
, limit
, &insn1
, &insn2
);
216 /* Now look for the prologue code at a leaf entry point: */
219 && (insn1
& 0xff87ffff) == 0x5c80161e /* mov g14, gx */
220 && REG_SRCDST (insn1
) <= G0_REGNUM
+ 7)
222 within_leaf_prologue
= 1;
223 if ((next_ip
= NEXT_PROLOGUE_INSN (next_ip
, limit
, &insn1
, &insn2
))
224 && (insn1
== 0x8cf00000 /* lda 0, g14 */
225 || insn1
== 0x5cf01e00)) /* mov 0, g14 */
228 next_ip
= NEXT_PROLOGUE_INSN (ip
, limit
, &insn1
, &insn2
);
229 within_leaf_prologue
= 0;
233 /* If something that looks like the beginning of a leaf prologue
234 has been seen, but the remainder of the prologue is missing, bail.
235 We don't know what we've got. */
237 if (within_leaf_prologue
)
240 /* Accept zero or more instances of "mov[qtl]? gx, ry", where y >= 4.
241 This may cause us to mistake the moving of a register
242 parameter to a local register for the saving of a callee-saved
243 register, but that can't be helped, since with the
244 "-fcall-saved" flag, any register can be made callee-saved. */
247 && (insn1
& 0xfc802fb0) == 0x5c000610
248 && (dst
= REG_SRCDST (insn1
)) >= (R0_REGNUM
+ 4))
250 src
= REG_SRC1 (insn1
);
251 size
= EXTRACT_FIELD (insn1
, 24, 2) + 1;
252 save_addr
= frame_addr
+ ((dst
- R0_REGNUM
) * 4);
255 fsr
->regs
[src
++] = save_addr
;
259 next_ip
= NEXT_PROLOGUE_INSN (ip
, limit
, &insn1
, &insn2
);
262 /* Accept an optional "addo n, sp, sp" or "lda n(sp), sp". */
265 ((insn1
& 0xffffffe0) == 0x59084800 /* addo n, sp, sp */
266 || (insn1
& 0xfffff000) == 0x8c086000 /* lda n(sp), sp (MEMA) */
267 || (insn1
& 0xfffffc60) == 0x8c087400)) /* lda n(sp), sp (MEMB) */
270 next_ip
= NEXT_PROLOGUE_INSN (ip
, limit
, &insn1
, &insn2
);
273 /* Accept zero or more instances of "st[qtl]? gx, n(fp)".
274 This may cause us to mistake the copying of a register
275 parameter to the frame for the saving of a callee-saved
276 register, but that can't be helped, since with the
277 "-fcall-saved" flag, any register can be made callee-saved.
278 We can, however, refuse to accept a save of register g14,
279 since that is matched explicitly below. */
282 ((insn1
& 0xf787f000) == 0x9287e000 /* stl? gx, n(fp) (MEMA) */
283 || (insn1
& 0xf787fc60) == 0x9287f400 /* stl? gx, n(fp) (MEMB) */
284 || (insn1
& 0xef87f000) == 0xa287e000 /* st[tq] gx, n(fp) (MEMA) */
285 || (insn1
& 0xef87fc60) == 0xa287f400) /* st[tq] gx, n(fp) (MEMB) */
286 && ((src
= MEM_SRCDST (insn1
)) != G14_REGNUM
))
288 save_addr
= frame_addr
+ ((insn1
& BITMASK (12, 1))
289 ? insn2
: MEMA_OFFSET (insn1
));
290 size
= (insn1
& BITMASK (29, 1)) ? ((insn1
& BITMASK (28, 1)) ? 4 : 3)
291 : ((insn1
& BITMASK (27, 1)) ? 2 : 1);
294 fsr
->regs
[src
++] = save_addr
;
298 next_ip
= NEXT_PROLOGUE_INSN (ip
, limit
, &insn1
, &insn2
);
301 /* Accept the varargs prologue code if present. */
303 size
= sizeof (varargs_prologue_code
) / sizeof (int);
304 pcode
= varargs_prologue_code
;
305 while (size
-- && next_ip
&& *pcode
++ == insn1
)
308 next_ip
= NEXT_PROLOGUE_INSN (ip
, limit
, &insn1
, &insn2
);
311 /* Accept an optional "st g14, n(fp)". */
314 ((insn1
& 0xfffff000) == 0x92f7e000 /* st g14, n(fp) (MEMA) */
315 || (insn1
& 0xfffffc60) == 0x92f7f400)) /* st g14, n(fp) (MEMB) */
317 fsr
->regs
[G14_REGNUM
] = frame_addr
+ ((insn1
& BITMASK (12, 1))
318 ? insn2
: MEMA_OFFSET (insn1
));
320 next_ip
= NEXT_PROLOGUE_INSN (ip
, limit
, &insn1
, &insn2
);
323 /* Accept zero or one instance of "mov g13, ry", where y >= 4.
324 This is saving the address where a struct should be returned. */
327 && (insn1
& 0xff802fbf) == 0x5c00061d
328 && (dst
= REG_SRCDST (insn1
)) >= (R0_REGNUM
+ 4))
330 save_addr
= frame_addr
+ ((dst
- R0_REGNUM
) * 4);
331 fsr
->regs
[G0_REGNUM
+ 13] = save_addr
;
333 #if 0 /* We'll need this once there is a subsequent instruction examined. */
334 next_ip
= NEXT_PROLOGUE_INSN (ip
, limit
, &insn1
, &insn2
);
341 /* Given an ip value corresponding to the start of a function,
342 return the ip of the first instruction after the function
346 i960_skip_prologue (CORE_ADDR ip
)
348 struct frame_saved_regs saved_regs_dummy
;
349 struct symtab_and_line sal
;
352 sal
= find_pc_line (ip
, 0);
353 limit
= (sal
.end
) ? sal
.end
: 0xffffffff;
355 return (examine_prologue (ip
, limit
, (CORE_ADDR
) 0, &saved_regs_dummy
));
358 /* Put here the code to store, into a struct frame_saved_regs,
359 the addresses of the saved registers of frame described by FRAME_INFO.
360 This includes special registers such as pc and fp saved in special
361 ways in the stack frame. sp is even more special:
362 the address we return for it IS the sp for the next frame.
364 We cache the result of doing this in the frame_obstack, since it is
368 frame_find_saved_regs (struct frame_info
*fi
, struct frame_saved_regs
*fsr
)
370 register CORE_ADDR next_addr
;
371 register CORE_ADDR
*saved_regs
;
373 register struct frame_saved_regs
*cache_fsr
;
375 struct symtab_and_line sal
;
380 cache_fsr
= (struct frame_saved_regs
*)
381 frame_obstack_alloc (sizeof (struct frame_saved_regs
));
382 memset (cache_fsr
, '\0', sizeof (struct frame_saved_regs
));
385 /* Find the start and end of the function prologue. If the PC
386 is in the function prologue, we only consider the part that
387 has executed already. */
389 ip
= get_pc_function_start (fi
->pc
);
390 sal
= find_pc_line (ip
, 0);
391 limit
= (sal
.end
&& sal
.end
< fi
->pc
) ? sal
.end
: fi
->pc
;
393 examine_prologue (ip
, limit
, fi
->frame
, cache_fsr
);
395 /* Record the addresses at which the local registers are saved.
396 Strictly speaking, we should only do this for non-leaf procedures,
397 but no one will ever look at these values if it is a leaf procedure,
398 since local registers are always caller-saved. */
400 next_addr
= (CORE_ADDR
) fi
->frame
;
401 saved_regs
= cache_fsr
->regs
;
402 for (regnum
= R0_REGNUM
; regnum
<= R15_REGNUM
; regnum
++)
404 *saved_regs
++ = next_addr
;
408 cache_fsr
->regs
[FP_REGNUM
] = cache_fsr
->regs
[PFP_REGNUM
];
413 /* Fetch the value of the sp from memory every time, since it
414 is conceivable that it has changed since the cache was flushed.
415 This unfortunately undoes much of the savings from caching the
416 saved register values. I suggest adding an argument to
417 get_frame_saved_regs () specifying the register number we're
418 interested in (or -1 for all registers). This would be passed
419 through to FRAME_FIND_SAVED_REGS (), permitting more efficient
420 computation of saved register addresses (e.g., on the i960,
421 we don't have to examine the prologue to find local registers).
423 FIXME, we don't need to refetch this, since the cache is cleared
424 every time the child process is restarted. If GDB itself
425 modifies SP, it has to clear the cache by hand (does it?). -gnu */
427 fsr
->regs
[SP_REGNUM
] = read_memory_integer (fsr
->regs
[SP_REGNUM
], 4);
430 /* Return the address of the argument block for the frame
431 described by FI. Returns 0 if the address is unknown. */
434 frame_args_address (struct frame_info
*fi
, int must_be_correct
)
436 struct frame_saved_regs fsr
;
439 /* If g14 was saved in the frame by the function prologue code, return
440 the saved value. If the frame is current and we are being sloppy,
441 return the value of g14. Otherwise, return zero. */
443 get_frame_saved_regs (fi
, &fsr
);
444 if (fsr
.regs
[G14_REGNUM
])
445 ap
= read_memory_integer (fsr
.regs
[G14_REGNUM
], 4);
449 return 0; /* Don't cache this result */
450 if (get_next_frame (fi
))
453 ap
= read_register (G14_REGNUM
);
457 fi
->arg_pointer
= ap
; /* Cache it for next time */
461 /* Return the address of the return struct for the frame
462 described by FI. Returns 0 if the address is unknown. */
465 frame_struct_result_address (struct frame_info
*fi
)
467 struct frame_saved_regs fsr
;
470 /* If the frame is non-current, check to see if g14 was saved in the
471 frame by the function prologue code; return the saved value if so,
472 zero otherwise. If the frame is current, return the value of g14.
474 FIXME, shouldn't this use the saved value as long as we are past
475 the function prologue, and only use the current value if we have
476 no saved value and are at TOS? -- gnu@cygnus.com */
478 if (get_next_frame (fi
))
480 get_frame_saved_regs (fi
, &fsr
);
481 if (fsr
.regs
[G13_REGNUM
])
482 ap
= read_memory_integer (fsr
.regs
[G13_REGNUM
], 4);
487 ap
= read_register (G13_REGNUM
);
492 /* Return address to which the currently executing leafproc will return,
493 or 0 if IP, the value of the instruction pointer from the currently
494 executing function, is not in a leafproc (or if we can't tell if it
497 Do this by finding the starting address of the routine in which IP lies.
498 If the instruction there is "mov g14, gx" (where x is in [0,7]), this
499 is a leafproc and the return address is in register gx. Well, this is
500 true unless the return address points at a RET instruction in the current
501 procedure, which indicates that we have a 'dual entry' routine that
502 has been entered through the CALL entry point. */
505 leafproc_return (CORE_ADDR ip
)
507 register struct minimal_symbol
*msymbol
;
510 unsigned int insn1
, insn2
;
511 CORE_ADDR return_addr
;
513 if ((msymbol
= lookup_minimal_symbol_by_pc (ip
)) != NULL
)
515 if ((p
= strchr (SYMBOL_NAME (msymbol
), '.')) && STREQ (p
, ".lf"))
517 if (next_insn (SYMBOL_VALUE_ADDRESS (msymbol
), &insn1
, &insn2
)
518 && (insn1
& 0xff87ffff) == 0x5c80161e /* mov g14, gx */
519 && (dst
= REG_SRCDST (insn1
)) <= G0_REGNUM
+ 7)
521 /* Get the return address. If the "mov g14, gx"
522 instruction hasn't been executed yet, read
523 the return address from g14; otherwise, read it
524 from the register into which g14 was moved. */
527 read_register ((ip
== SYMBOL_VALUE_ADDRESS (msymbol
))
530 /* We know we are in a leaf procedure, but we don't know
531 whether the caller actually did a "bal" to the ".lf"
532 entry point, or a normal "call" to the non-leaf entry
533 point one instruction before. In the latter case, the
534 return address will be the address of a "ret"
535 instruction within the procedure itself. We test for
538 if (!next_insn (return_addr
, &insn1
, &insn2
)
539 || (insn1
& 0xff000000) != 0xa000000 /* ret */
540 || lookup_minimal_symbol_by_pc (return_addr
) != msymbol
)
541 return (return_addr
);
549 /* Immediately after a function call, return the saved pc.
550 Can't go through the frames for this because on some machines
551 the new frame is not set up until the new function executes
553 On the i960, the frame *is* set up immediately after the call,
554 unless the function is a leaf procedure. */
557 saved_pc_after_call (struct frame_info
*frame
)
561 saved_pc
= leafproc_return (get_frame_pc (frame
));
563 saved_pc
= FRAME_SAVED_PC (frame
);
568 /* Discard from the stack the innermost frame,
569 restoring all saved registers. */
572 i960_pop_frame (void)
574 register struct frame_info
*current_fi
, *prev_fi
;
577 CORE_ADDR leaf_return_addr
;
578 struct frame_saved_regs fsr
;
579 char local_regs_buf
[16 * 4];
581 current_fi
= get_current_frame ();
583 /* First, undo what the hardware does when we return.
584 If this is a non-leaf procedure, restore local registers from
585 the save area in the calling frame. Otherwise, load the return
586 address obtained from leafproc_return () into the rip. */
588 leaf_return_addr
= leafproc_return (current_fi
->pc
);
589 if (!leaf_return_addr
)
591 /* Non-leaf procedure. Restore local registers, incl IP. */
592 prev_fi
= get_prev_frame (current_fi
);
593 read_memory (prev_fi
->frame
, local_regs_buf
, sizeof (local_regs_buf
));
594 write_register_bytes (REGISTER_BYTE (R0_REGNUM
), local_regs_buf
,
595 sizeof (local_regs_buf
));
597 /* Restore frame pointer. */
598 write_register (FP_REGNUM
, prev_fi
->frame
);
602 /* Leaf procedure. Just restore the return address into the IP. */
603 write_register (RIP_REGNUM
, leaf_return_addr
);
606 /* Now restore any global regs that the current function had saved. */
607 get_frame_saved_regs (current_fi
, &fsr
);
608 for (i
= G0_REGNUM
; i
< G14_REGNUM
; i
++)
610 save_addr
= fsr
.regs
[i
];
612 write_register (i
, read_memory_integer (save_addr
, 4));
615 /* Flush the frame cache, create a frame for the new innermost frame,
616 and make it the current frame. */
618 flush_cached_frames ();
621 /* Given a 960 stop code (fault or trace), return the signal which
625 i960_fault_to_signal (int fault
)
630 return TARGET_SIGNAL_BUS
; /* parallel fault */
632 return TARGET_SIGNAL_UNKNOWN
;
634 return TARGET_SIGNAL_ILL
; /* operation fault */
636 return TARGET_SIGNAL_FPE
; /* arithmetic fault */
638 return TARGET_SIGNAL_FPE
; /* floating point fault */
640 /* constraint fault. This appears not to distinguish between
641 a range constraint fault (which should be SIGFPE) and a privileged
642 fault (which should be SIGILL). */
644 return TARGET_SIGNAL_ILL
;
647 return TARGET_SIGNAL_SEGV
; /* virtual memory fault */
649 /* protection fault. This is for an out-of-range argument to
650 "calls". I guess it also could be SIGILL. */
652 return TARGET_SIGNAL_SEGV
;
655 return TARGET_SIGNAL_BUS
; /* machine fault */
657 return TARGET_SIGNAL_BUS
; /* structural fault */
659 return TARGET_SIGNAL_ILL
; /* type fault */
661 return TARGET_SIGNAL_UNKNOWN
; /* reserved fault */
663 return TARGET_SIGNAL_BUS
; /* process fault */
665 return TARGET_SIGNAL_SEGV
; /* descriptor fault */
667 return TARGET_SIGNAL_BUS
; /* event fault */
669 return TARGET_SIGNAL_UNKNOWN
; /* reserved fault */
671 return TARGET_SIGNAL_TRAP
; /* single-step trace */
673 return TARGET_SIGNAL_TRAP
; /* branch trace */
675 return TARGET_SIGNAL_TRAP
; /* call trace */
677 return TARGET_SIGNAL_TRAP
; /* return trace */
679 return TARGET_SIGNAL_TRAP
; /* pre-return trace */
681 return TARGET_SIGNAL_TRAP
; /* supervisor call trace */
683 return TARGET_SIGNAL_TRAP
; /* breakpoint trace */
685 return TARGET_SIGNAL_UNKNOWN
;
689 /****************************************/
691 /****************************************/
699 /* Return instruction length, either 4 or 8. When NOPRINT is non-zero
700 (TRUE), don't output any text. (Actually, as implemented, if NOPRINT
701 is 0, abort() is called.) */
704 mem (unsigned long memaddr
, unsigned long word1
, unsigned long word2
,
711 const char *reg1
, *reg2
, *reg3
;
713 /* This lookup table is too sparse to make it worth typing in, but not
714 * so large as to make a sparse array necessary. We allocate the
715 * table at runtime, initialize all entries to empty, and copy the
716 * real ones in from an initialization table.
718 * NOTE: In this table, the meaning of 'numops' is:
720 * 2: 2 operands, load instruction
721 * -2: 2 operands, store instruction
723 static struct tabent
*mem_tab
= NULL
;
724 /* Opcodes of 0x8X, 9X, aX, bX, and cX must be in the table. */
727 #define MEM_SIZ ((MEM_MAX-MEM_MIN+1) * sizeof(struct tabent))
762 mem_tab
= (struct tabent
*) xmalloc (MEM_SIZ
);
763 memset (mem_tab
, '\0', MEM_SIZ
);
764 for (i
= 0; mem_init
[i
].opcode
!= 0; i
++)
766 j
= mem_init
[i
].opcode
- MEM_MIN
;
767 mem_tab
[j
].name
= mem_init
[i
].name
;
768 mem_tab
[j
].numops
= mem_init
[i
].numops
;
772 i
= ((word1
>> 24) & 0xff) - MEM_MIN
;
773 mode
= (word1
>> 10) & 0xf;
775 if ((mem_tab
[i
].name
!= NULL
) /* Valid instruction */
776 && ((mode
== 5) || (mode
>= 12)))
777 { /* With 32-bit displacement */
789 internal_error (__FILE__
, __LINE__
, "failed internal consistency check");
792 /* Read the i960 instruction at 'memaddr' and return the address of
793 the next instruction after that, or 0 if 'memaddr' is not the
794 address of a valid instruction. The first word of the instruction
795 is stored at 'pword1', and the second word, if any, is stored at
799 next_insn (CORE_ADDR memaddr
, unsigned int *pword1
, unsigned int *pword2
)
804 /* Read the two (potential) words of the instruction at once,
805 to eliminate the overhead of two calls to read_memory ().
806 FIXME: Loses if the first one is readable but the second is not
807 (e.g. last word of the segment). */
809 read_memory (memaddr
, buf
, 8);
810 *pword1
= extract_unsigned_integer (buf
, 4);
811 *pword2
= extract_unsigned_integer (buf
+ 4, 4);
813 /* Divide instruction set into classes based on high 4 bits of opcode */
815 switch ((*pword1
>> 28) & 0xf)
834 len
= mem (memaddr
, *pword1
, *pword2
, 1);
837 default: /* invalid instruction */
843 return memaddr
+ len
;
848 /* 'start_frame' is a variable in the MON960 runtime startup routine
849 that contains the frame pointer of the 'start' routine (the routine
850 that calls 'main'). By reading its contents out of remote memory,
851 we can tell where the frame chain ends: backtraces should halt before
852 they display this frame. */
855 mon960_frame_chain_valid (CORE_ADDR chain
, struct frame_info
*curframe
)
858 struct minimal_symbol
*msymbol
;
860 /* crtmon960.o is an assembler module that is assumed to be linked
861 * first in an i80960 executable. It contains the true entry point;
862 * it performs startup up initialization and then calls 'main'.
864 * 'sf' is the name of a variable in crtmon960.o that is set
865 * during startup to the address of the first frame.
867 * 'a' is the address of that variable in 80960 memory.
869 static char sf
[] = "start_frame";
873 chain
&= ~0x3f; /* Zero low 6 bits because previous frame pointers
874 contain return status info in them. */
880 sym
= lookup_symbol (sf
, 0, VAR_NAMESPACE
, (int *) NULL
,
881 (struct symtab
**) NULL
);
884 a
= SYMBOL_VALUE (sym
);
888 msymbol
= lookup_minimal_symbol (sf
, NULL
, NULL
);
891 a
= SYMBOL_VALUE_ADDRESS (msymbol
);
894 return (chain
!= read_memory_integer (a
, 4));
899 _initialize_i960_tdep (void)
903 tm_print_insn
= print_insn_i960
;