1999-01-19 Fernando Nasser <fnasser@totem.to.cygnus.com>
[deliverable/binutils-gdb.git] / gdb / i960-tdep.c
index 081ad6f7831e708490523badf93b5e8129e94172..e33415d73999fd3df2f9dde3d9d104c660df6d7e 100644 (file)
@@ -25,11 +25,34 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "frame.h"
 #include "floatformat.h"
 #include "target.h"
+#include "gdbcore.h"
 
 static CORE_ADDR next_insn PARAMS ((CORE_ADDR memaddr,
                                    unsigned int *pword1,
                                    unsigned int *pword2));
 
+/* Does the specified function use the "struct returning" convention
+   or the "value returning" convention?  The "value returning" convention
+   almost invariably returns the entire value in registers.  The
+   "struct returning" convention often returns the entire value in
+   memory, and passes a pointer (out of or into the function) saying
+   where the value (is or should go).
+
+   Since this sometimes depends on whether it was compiled with GCC,
+   this is also an argument.  This is used in call_function to build a
+   stack, and in value_being_returned to print return values.
+
+   On i960, a structure is returned in registers g0-g3, if it will fit.
+   If it's more than 16 bytes long, g13 pointed to it on entry.  */
+
+int
+i960_use_struct_convention (gcc_p, type)
+     int gcc_p;
+     struct type *type;
+{
+  return (TYPE_LENGTH (type) > 16);
+}
+
 /* gdb960 is always running on a non-960 host.  Check its characteristics.
    This routine must be called as part of gdb initialization.  */
 
@@ -308,8 +331,8 @@ skip_prologue (ip)
    ways in the stack frame.  sp is even more special:
    the address we return for it IS the sp for the next frame.
 
-   We cache the result of doing this in the frame_cache_obstack, since
-   it is fairly expensive.  */
+   We cache the result of doing this in the frame_obstack, since it is
+   fairly expensive.  */
 
 void
 frame_find_saved_regs (fi, fsr)
@@ -320,7 +343,6 @@ frame_find_saved_regs (fi, fsr)
   register CORE_ADDR *saved_regs;
   register int regnum;
   register struct frame_saved_regs *cache_fsr;
-  extern struct obstack frame_cache_obstack;
   CORE_ADDR ip;
   struct symtab_and_line sal;
   CORE_ADDR limit;
@@ -328,8 +350,7 @@ frame_find_saved_regs (fi, fsr)
   if (!fi->fsr)
     {
       cache_fsr = (struct frame_saved_regs *)
-                 obstack_alloc (&frame_cache_obstack,
-                                sizeof (struct frame_saved_regs));
+       frame_obstack_alloc (sizeof (struct frame_saved_regs));
       memset (cache_fsr, '\0', sizeof (struct frame_saved_regs));
       fi->fsr = cache_fsr;
 
@@ -521,6 +542,7 @@ saved_pc_after_call (frame)
 /* Discard from the stack the innermost frame,
    restoring all saved registers.  */
 
+void
 pop_frame ()
 {
   register struct frame_info *current_fi, *prev_fi;
@@ -760,6 +782,53 @@ next_insn (memaddr, pword1, pword2)
     return 0;
 }
 
+/* 'start_frame' is a variable in the MON960 runtime startup routine
+   that contains the frame pointer of the 'start' routine (the routine
+   that calls 'main').  By reading its contents out of remote memory,
+   we can tell where the frame chain ends:  backtraces should halt before
+   they display this frame.  */
+
+int
+mon960_frame_chain_valid (chain, curframe)
+    CORE_ADDR chain;
+    struct frame_info *curframe;
+{
+       struct symbol *sym;
+       struct minimal_symbol *msymbol;
+
+       /* crtmon960.o is an assembler module that is assumed to be linked
+        * first in an i80960 executable.  It contains the true entry point;
+        * it performs startup up initialization and then calls 'main'.
+        *
+        * 'sf' is the name of a variable in crtmon960.o that is set
+        *      during startup to the address of the first frame.
+        *
+        * 'a' is the address of that variable in 80960 memory.
+        */
+       static char sf[] = "start_frame";
+       CORE_ADDR a;
+
+
+       chain &= ~0x3f; /* Zero low 6 bits because previous frame pointers
+                          contain return status info in them.  */
+       if ( chain == 0 ){
+               return 0;
+       }
+
+       sym = lookup_symbol(sf, 0, VAR_NAMESPACE, (int *)NULL, 
+                                 (struct symtab **)NULL);
+       if ( sym != 0 ){
+               a = SYMBOL_VALUE (sym);
+       } else {
+               msymbol = lookup_minimal_symbol (sf, NULL, NULL);
+               if (msymbol == NULL)
+                       return 0;
+               a = SYMBOL_VALUE_ADDRESS (msymbol);
+       }
+
+       return ( chain != read_memory_integer(a,4) );
+}
+
 void
 _initialize_i960_tdep ()
 {
This page took 0.024116 seconds and 4 git commands to generate.