* breakpoint.c, breakpoint.h (breakpoint_init_inferior): New function
[deliverable/binutils-gdb.git] / gdb / m88k-tdep.c
index 63a545fd3c70c35e5045bccfdf79b2325c942425..3e0351dbd213fe462a2a0e4e327537fc33dc58c9 100644 (file)
@@ -21,34 +21,28 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "frame.h"
 #include "inferior.h"
 #include "value.h"
-
-#ifdef USG
-#include <sys/types.h>
-#endif
-
-#include <sys/param.h>
-#include <signal.h>
 #include "gdbcore.h"
-#include <sys/user.h>
-#ifndef USER                   /* added to support BCS ptrace_user */
-
-#define USER ptrace_user
-#endif
-#include <sys/ioctl.h>
-#include <fcntl.h>
-
-#include <sys/file.h>
-#include <sys/stat.h>
 
 #include "symtab.h"
 #include "setjmp.h"
 #include "value.h"
+#include "ieee-float.h"        /* for ext_format & friends */
 
 /* Size of an instruction */
 #define        BYTES_PER_88K_INSN      4
 
 void frame_find_saved_regs ();
 
+/* is this target an m88110?  Otherwise assume m88100.  This has
+   relevance for the ways in which we screw with instruction pointers.  */ 
+int target_is_m88110 = 0;
+
+/* FIXME: this is really just a guess based on m88110 being big
+   endian. */
+const struct ext_format ext_format_m88110 = {
+/* tot sbyte smask expbyte     manbyte */
+   10, 0,    0x80, 0,1,                4,8             /* m88110 */
+};
 
 /* Given a GDB frame, determine the address of the calling function's frame.
    This will be used to create a new GDB frame struct, and then
@@ -141,7 +135,7 @@ struct pic_prologue_code {
 
 static struct pic_prologue_code pic_prologue_code [] = {
 /* FIXME -- until this is translated to hex, we won't match it... */
-       0xffffffff, 0,
+  { 0xffffffff, 0 },
                                        /* or r10,r1,0  (if not saved) */
                                        /* bsr.n LabN */
                                        /* or.u r25,r0,const */
@@ -169,8 +163,6 @@ next_insn (memaddr, pword1)
      unsigned long *pword1;
      CORE_ADDR memaddr;
 {
-  unsigned long buf[1];
-
   *pword1 = read_memory_integer (memaddr, BYTES_PER_88K_INSN);
   return memaddr + BYTES_PER_88K_INSN;
 }
@@ -217,7 +209,7 @@ examine_prologue (ip, limit, frame_sp, fsr, fi)
   int fp_offset = -1;          /* -1 means not set */
   CORE_ADDR frame_fp;
 
-  bzero (must_adjust, sizeof (must_adjust));
+  memset (must_adjust, '\0', sizeof (must_adjust));
   next_ip = NEXT_PROLOGUE_INSN (ip, limit, &insn);
 
   /* Accept move of incoming registers to other registers, using
@@ -465,9 +457,6 @@ frame_find_saved_regs (fi, fsr)
      struct frame_info *fi;
      struct frame_saved_regs *fsr;
 {
-  register CORE_ADDR next_addr;
-  register CORE_ADDR *saved_regs;
-  register int regnum;
   register struct frame_saved_regs *cache_fsr;
   extern struct obstack frame_cache_obstack;
   CORE_ADDR ip;
@@ -479,7 +468,7 @@ frame_find_saved_regs (fi, fsr)
       cache_fsr = (struct frame_saved_regs *)
                  obstack_alloc (&frame_cache_obstack,
                                 sizeof (struct frame_saved_regs));
-      bzero (cache_fsr, sizeof (struct frame_saved_regs));
+      memset (cache_fsr, '\0', sizeof (struct frame_saved_regs));
       fi->fsr = cache_fsr;
 
       /* Find the start and end of the function prologue.  If the PC
@@ -507,9 +496,7 @@ CORE_ADDR
 frame_locals_address (fi)
      struct frame_info *fi;
 {
-  register FRAME frame;
   struct frame_saved_regs fsr;
-  CORE_ADDR ap;
 
   if (fi->args_pointer)        /* Cached value is likely there.  */
     return fi->args_pointer;
@@ -528,9 +515,7 @@ CORE_ADDR
 frame_args_address (fi)
      struct frame_info *fi;
 {
-  register FRAME frame;
   struct frame_saved_regs fsr;
-  CORE_ADDR ap;
 
   if (fi->args_pointer)                /* Cached value is likely there.  */
     return fi->args_pointer;
@@ -554,7 +539,8 @@ frame_saved_pc (frame)
   return read_next_frame_reg(frame, SRP_REGNUM);
 }
 
-
+#if 0
+/* I believe this is all obsolete call dummy stuff.  */
 static int
 pushed_size (prev_words, v)
      int prev_words;
@@ -711,7 +697,9 @@ push_parameters (return_type, struct_conv, nargs, args)
  
            write_register (SP_REGNUM, rv_addr); /* push space onto the stack */
            write_register (SRA_REGNUM, rv_addr);/* set return value register */
+          break;
          }
+       default: break;
      }
  
    /* Here we make a pre-pass on the whole parameter list to figure out exactly
@@ -757,13 +745,6 @@ push_parameters (return_type, struct_conv, nargs, args)
      }
 }
 
-void
-pop_frame ()
-{
-  error ("Feature not implemented for the m88k yet.");
-  return;
-}
-
 void
 collect_returned_value (rval, value_type, struct_return, nargs, args)
      value *rval;
@@ -774,50 +755,112 @@ collect_returned_value (rval, value_type, struct_return, nargs, args)
 {
   char retbuf[REGISTER_BYTES];
 
-  bcopy (registers, retbuf, REGISTER_BYTES);
+  memcpy (retbuf, registers, REGISTER_BYTES);
   *rval = value_being_returned (value_type, retbuf, struct_return);
   return;
 }
+#endif /* 0 */
 
-#if 0
-/* Now handled in a machine independent way with CALL_DUMMY_LOCATION.  */
- /* Stuff a breakpoint instruction onto the stack (or elsewhere if the stack
-    is not a good place for it).  Return the address at which the instruction
-    got stuffed, or zero if we were unable to stuff it anywhere.  */
+/*start of lines added by kev*/
+
+#define DUMMY_FRAME_SIZE 192
+
+static void
+write_word (sp, word)
+     CORE_ADDR sp;
+     REGISTER_TYPE word;
+{
+  register int len = sizeof (REGISTER_TYPE);
+  char buffer[MAX_REGISTER_RAW_SIZE];
+
+  store_unsigned_integer (buffer, len, word);
+  write_memory (sp, buffer, len);
+}
+
+void
+m88k_push_dummy_frame()
+{
+  register CORE_ADDR sp = read_register (SP_REGNUM);
+  register int rn;
+  int offset;
+
+  sp -= DUMMY_FRAME_SIZE;      /* allocate a bunch of space */
+
+  for (rn = 0, offset = 0; rn <= SP_REGNUM; rn++, offset+=4)
+    write_word (sp+offset, read_register(rn));
   
-CORE_ADDR
-push_breakpoint ()
+  write_word (sp+offset, read_register (SXIP_REGNUM));
+  offset += 4;
+
+  write_word (sp+offset, read_register (SNIP_REGNUM));
+  offset += 4;
+
+  write_word (sp+offset, read_register (SFIP_REGNUM));
+  offset += 4;
+
+  write_word (sp+offset, read_register (PSR_REGNUM));
+  offset += 4;
+
+  write_word (sp+offset, read_register (FPSR_REGNUM));
+  offset += 4;
+
+  write_word (sp+offset, read_register (FPCR_REGNUM));
+  offset += 4;
+
+  write_register (SP_REGNUM, sp);
+  write_register (ACTUAL_FP_REGNUM, sp);
+}
+
+void
+pop_frame ()
 {
-  static char breakpoint_insn[] = BREAKPOINT;
-  extern CORE_ADDR text_end;   /* of inferior */
-  static char readback_buffer[] = BREAKPOINT;
-  int i;
-  /* With a little bit of luck, we can just stash the breakpoint instruction
-     in the word just beyond the end of normal text space.  For systems on
-     which the hardware will not allow us to execute out of the stack segment,
-     we have to hope that we *are* at least allowed to effectively extend the
-     text segment by one word.  If the actual end of user's the text segment
-     happens to fall right at a page boundary this trick may fail.  Note that
-     we check for this by reading after writing, and comparing in order to
-     be sure that the write worked.  */
+  register FRAME frame = get_current_frame ();
+  register CORE_ADDR fp;
+  register int regnum;
+  struct frame_saved_regs fsr;
+  struct frame_info *fi;
+
+  fi = get_frame_info (frame);
+  fp = fi -> frame;
+  get_frame_saved_regs (fi, &fsr);
 
-  write_memory (text_end, &breakpoint_insn, 4);
+  if (PC_IN_CALL_DUMMY (read_pc(), read_register(SP_REGNUM), FRAME_FP(fi)))
+    {
+      /* FIXME: I think get_frame_saved_regs should be handling this so
+        that we can deal with the saved registers properly (e.g. frame
+        1 is a call dummy, the user types "frame 2" and then "print $ps").  */
+      register CORE_ADDR sp = read_register (ACTUAL_FP_REGNUM);
+      int offset;
+
+      for (regnum = 0, offset = 0; regnum <= SP_REGNUM; regnum++, offset+=4)
+       (void) write_register (regnum, read_memory_integer (sp+offset, 4));
+  
+      write_register (SXIP_REGNUM, read_memory_integer (sp+offset, 4));
+      offset += 4;
+
+      write_register (SNIP_REGNUM, read_memory_integer (sp+offset, 4));
+      offset += 4;
 
-  /* Fill the readback buffer with some garbage which is certain to be
-     unequal to the breakpoint insn.  That way we can tell if the
-     following read doesn't actually succeed.  */
+      write_register (SFIP_REGNUM, read_memory_integer (sp+offset, 4));
+      offset += 4;
 
-  for (i = 0; i < sizeof (readback_buffer); i++)
-    readback_buffer[i] = ~ readback_buffer[i]; /* Invert the bits */
+      write_register (PSR_REGNUM, read_memory_integer (sp+offset, 4));
+      offset += 4;
 
-  /* Now check that the breakpoint insn was successfully installed.  */
+      write_register (FPSR_REGNUM, read_memory_integer (sp+offset, 4));
+      offset += 4;
 
-  read_memory (text_end, readback_buffer, sizeof (readback_buffer));
-  for (i = 0; i < sizeof (readback_buffer); i++)
-    if (readback_buffer[i] != breakpoint_insn[i])
-      return 0;                /* Failed to install! */
+      write_register (FPCR_REGNUM, read_memory_integer (sp+offset, 4));
+      offset += 4;
 
-  return text_end;
+    }
+  else 
+    {
+      for (regnum = FP_REGNUM ; regnum > 0 ; regnum--)
+         if (fsr.regs[regnum])
+             write_register (regnum,
+                             read_memory_integer (fsr.regs[regnum], 4));
+      write_pc(frame_saved_pc(frame));
+    }
+  reinit_frame_cache ();
 }
-#endif
This page took 0.02752 seconds and 4 git commands to generate.