2004-09-14 Andrew Cagney <cagney@gnu.org>
[deliverable/binutils-gdb.git] / gdb / cris-tdep.c
index 14bac098475945256e93f6cc1f04cc66bc2c6e69..1cb0d5293809e98e34c2c190f33a6811137411f7 100644 (file)
@@ -351,8 +351,6 @@ static void cris_version_update (char *ignore_args, int from_tty,
 static void cris_mode_update (char *ignore_args, int from_tty, 
                               struct cmd_list_element *c);
 
-static CORE_ADDR bfd_lookup_symbol (bfd *, const char *);
-
 static CORE_ADDR cris_scan_prologue (CORE_ADDR pc, 
                                     struct frame_info *next_frame,
                                     struct cris_unwind_cache *info);
@@ -472,8 +470,8 @@ cris_frame_prev_register (struct frame_info *next_frame,
 {
   struct cris_unwind_cache *info
     = cris_frame_unwind_cache (next_frame, this_prologue_cache);
-  trad_frame_prev_register (next_frame, info->saved_regs, regnum,
-                           optimizedp, lvalp, addrp, realnump, bufferp);
+  trad_frame_get_prev_register (next_frame, info->saved_regs, regnum,
+                               optimizedp, lvalp, addrp, realnump, bufferp);
 }
 
 /* Assuming NEXT_FRAME->prev is a dummy, return the frame ID of that
@@ -513,7 +511,7 @@ cris_push_dummy_code (struct gdbarch *gdbarch,
 }
 
 static CORE_ADDR
-cris_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
+cris_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                      struct regcache *regcache, CORE_ADDR bp_addr,
                      int nargs, struct value **args, CORE_ADDR sp,
                      int struct_return, CORE_ADDR struct_addr)
@@ -792,6 +790,14 @@ cris_scan_prologue (CORE_ADDR pc, struct frame_info *next_frame,
                  info->leaf_function = 0;
                }
             }
+         else if (insn_next == 0x8FEE)
+            {
+             /* push $r8 */
+             if (info)
+               {
+                 info->r8_offset = info->sp_offset;
+               }
+            }
         }
       else if (insn == 0x866E)
         {
@@ -799,7 +805,6 @@ cris_scan_prologue (CORE_ADDR pc, struct frame_info *next_frame,
          if (info)
            {
              info->uses_frame = 1;
-             info->r8_offset = info->sp_offset;
            }
           continue;
         }
@@ -947,6 +952,8 @@ cris_scan_prologue (CORE_ADDR pc, struct frame_info *next_frame,
       frame_unwind_unsigned_register (next_frame, CRIS_FP_REGNUM, 
                                      &this_base);
       info->base = this_base;
+      info->saved_regs[CRIS_FP_REGNUM].addr = info->base;
+  
       /* The FP points at the last saved register.  Adjust the FP back
          to before the first saved register giving the SP.  */
       info->prev_sp = info->base + info->r8_offset;
@@ -961,8 +968,6 @@ cris_scan_prologue (CORE_ADDR pc, struct frame_info *next_frame,
       info->prev_sp = info->base + info->size;
     }
       
-  info->saved_regs[CRIS_FP_REGNUM].addr = info->base;
-
   /* Calculate the addresses for the saved registers on the stack.  */
   /* FIXME: The address calculation should really be done on the fly while
      we're analyzing the prologue (we only hold one regsave value as it is 
@@ -981,8 +986,17 @@ cris_scan_prologue (CORE_ADDR pc, struct frame_info *next_frame,
 
   if (!info->leaf_function)
     {
-      /* SRP saved on the stack.  */
-      info->saved_regs[SRP_REGNUM].addr = info->base + 4;
+      /* SRP saved on the stack.  But where?  */
+      if (info->r8_offset == 0)
+       {
+         /* R8 not pushed yet.  */
+         info->saved_regs[SRP_REGNUM].addr = info->base;
+       }
+      else
+       {
+         /* R8 pushed, but SP may or may not be moved to R8 yet.  */
+         info->saved_regs[SRP_REGNUM].addr = info->base + 4;
+       }
     }
 
   /* The PC is found in SRP (the actual register or located on the stack).  */
@@ -1197,7 +1211,7 @@ cris_register_offset (int regno)
    of data in register regno.  */
 
 static struct type *
-cris_register_virtual_type (int regno)
+cris_register_type (struct gdbarch *gdbarch, int regno)
 {
   if (regno == SP_REGNUM || regno == PC_REGNUM
       || (regno > P8_REGNUM && regno < USP_REGNUM))
@@ -1306,7 +1320,7 @@ cris_register_name (int regno)
 static int
 cris_register_bytes_ok (long bytes)
 {
-  return (bytes == DEPRECATED_REGISTER_BYTES);
+  return (bytes == deprecated_register_bytes ());
 }
 
 /* Extract from an array regbuf containing the raw register state a function
@@ -1340,6 +1354,28 @@ cris_extract_return_value (struct type *type, struct regcache *regcache,
     error ("cris_extract_return_value: type length too large");
 }
 
+/* Handle the CRIS return value convention.  */
+
+static enum return_value_convention
+cris_return_value (struct gdbarch *gdbarch, struct type *type,
+                  struct regcache *regcache, void *readbuf,
+                  const void *writebuf)
+{
+  if (TYPE_CODE (type) == TYPE_CODE_STRUCT 
+      || TYPE_CODE (type) == TYPE_CODE_UNION
+      || TYPE_LENGTH (type) > 8)
+    /* Structs, unions, and anything larger than 8 bytes (2 registers)
+       goes on the stack.  */
+    return RETURN_VALUE_STRUCT_CONVENTION;
+
+  if (readbuf)
+    cris_extract_return_value (type, regcache, readbuf);
+  if (writebuf)
+    cris_store_return_value (type, regcache, writebuf);
+
+  return RETURN_VALUE_REGISTER_CONVENTION;
+}
+
 /* Returns 1 if the given type will be passed by pointer rather than 
    directly.  */
 
@@ -3300,7 +3336,7 @@ supply_gregset (elf_gregset_t *gregsetp)
      knows about the actual size of each register so that's no problem.  */
   for (i = 0; i < NUM_GENREGS + NUM_SPECREGS; i++)
     {
-      supply_register (i, (char *)&regp[i]);
+      regcache_raw_supply (current_regcache, i, (char *)&regp[i]);
     }
 }
 
@@ -3596,20 +3632,20 @@ _initialize_cris_tdep (void)
                    (char *) &usr_cmd_cris_version, 
                    "Set the current CRIS version.", &setlist);
   set_cmd_sfunc (c, cris_version_update);
-  add_show_from_set (c, &showlist);
+  deprecated_add_show_from_set (c, &showlist);
   
   c = add_set_enum_cmd ("cris-mode", class_support, cris_mode_enums, 
                         &usr_cmd_cris_mode, 
                         "Set the current CRIS mode.", &setlist);
   set_cmd_sfunc (c, cris_mode_update);
-  add_show_from_set (c, &showlist);
+  deprecated_add_show_from_set (c, &showlist);
 
   c = add_cmd ("cris-fpless-backtrace", class_support, cris_fpless_backtrace, 
                "Display call chain using the subroutine return pointer.\n"
                "Note that this displays the address after the jump to the "
                "subroutine.", &cmdlist);
   
-  add_core_fns (&cris_elf_core_fns);
+  deprecated_add_core_fns (&cris_elf_core_fns);
   
 }
 
@@ -3634,14 +3670,15 @@ cris_version_update (char *ignore_args, int from_tty,
 {
   struct gdbarch_info info;
 
-  /* NOTE: cagney/2002-03-17: The add_show_from_set() function clones
-     the set command passed as a parameter.  The clone operation will
-     include (BUG?) any ``set'' command callback, if present.
-     Commands like ``info set'' call all the ``show'' command
-     callbacks.  Unfortunately, for ``show'' commands cloned from
-     ``set'', this includes callbacks belonging to ``set'' commands.
-     Making this worse, this only occures if add_show_from_set() is
-     called after add_cmd_sfunc() (BUG?).  */
+  /* NOTE: cagney/2002-03-17: The deprecated_add_show_from_set()
+     function clones the set command passed as a parameter.  The clone
+     operation will include (BUG?) any ``set'' command callback, if
+     present.  Commands like ``info set'' call all the ``show''
+     command callbacks.  Unfortunately, for ``show'' commands cloned
+     from ``set'', this includes callbacks belonging to ``set''
+     commands.  Making this worse, this only occures if
+     deprecated_add_show_from_set() is called after add_cmd_sfunc()
+     (BUG?).  */
 
   /* From here on, trust the user's CRIS version setting.  */
   if (cmd_type (c) == set_cmd)
@@ -3661,14 +3698,15 @@ cris_mode_update (char *ignore_args, int from_tty,
 {
   struct gdbarch_info info;
   
-  /* NOTE: cagney/2002-03-17: The add_show_from_set() function clones
-     the set command passed as a parameter.  The clone operation will
-     include (BUG?) any ``set'' command callback, if present.
-     Commands like ``info set'' call all the ``show'' command
-     callbacks.  Unfortunately, for ``show'' commands cloned from
-     ``set'', this includes callbacks belonging to ``set'' commands.
-     Making this worse, this only occures if add_show_from_set() is
-     called after add_cmd_sfunc() (BUG?).  */
+  /* NOTE: cagney/2002-03-17: The deprecated_add_show_from_set()
+     function clones the set command passed as a parameter.  The clone
+     operation will include (BUG?) any ``set'' command callback, if
+     present.  Commands like ``info set'' call all the ``show''
+     command callbacks.  Unfortunately, for ``show'' commands cloned
+     from ``set'', this includes callbacks belonging to ``set''
+     commands.  Making this worse, this only occures if
+     deprecated_add_show_from_set() is called after add_cmd_sfunc()
+     (BUG?).  */
 
   /* From here on, trust the user's CRIS mode setting.  */
   if (cmd_type (c) == set_cmd)
@@ -3682,42 +3720,6 @@ cris_mode_update (char *ignore_args, int from_tty,
     }
 }
 
-/* Copied from pa64solib.c, with a couple of minor changes.  */
-
-static CORE_ADDR
-bfd_lookup_symbol (bfd *abfd, const char *symname)
-{
-  unsigned int storage_needed;
-  asymbol *sym;
-  asymbol **symbol_table;
-  unsigned int number_of_symbols;
-  unsigned int i;
-  struct cleanup *back_to;
-  CORE_ADDR symaddr = 0;
-
-  storage_needed = bfd_get_symtab_upper_bound (abfd);
-
-  if (storage_needed > 0)
-    {
-      symbol_table = (asymbol **) xmalloc (storage_needed);
-      back_to = make_cleanup (free, symbol_table);
-      number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);
-
-      for (i = 0; i < number_of_symbols; i++)
-       {
-         sym = *symbol_table++;
-         if (!strcmp (sym->name, symname))
-           {
-             /* Bfd symbols are section relative.  */
-             symaddr = sym->value + sym->section->vma;
-             break;
-           }
-       }
-      do_cleanups (back_to);
-    }
-  return (symaddr);
-}
-
 static struct gdbarch *
 cris_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 {
@@ -3792,12 +3794,10 @@ cris_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
       internal_error (__FILE__, __LINE__, "cris_gdbarch_init: unknown byte order in info");
     }
 
-  /* FIXME: Should be replaced by a cris_return_value implementation.  */
-  set_gdbarch_store_return_value (gdbarch, cris_store_return_value);
-  set_gdbarch_extract_return_value (gdbarch, cris_extract_return_value);
+  set_gdbarch_return_value (gdbarch, cris_return_value);
   set_gdbarch_deprecated_reg_struct_has_addr (gdbarch, 
                                              cris_reg_struct_has_addr);
-  set_gdbarch_use_struct_convention (gdbarch, always_use_struct_convention);
+  set_gdbarch_deprecated_use_struct_convention (gdbarch, always_use_struct_convention);
 
   /* There are 32 registers (some of which may not be implemented).  */
   set_gdbarch_num_regs (gdbarch, 32);
@@ -3806,8 +3806,8 @@ cris_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_register_name (gdbarch, cris_register_name);
   
   /* Length of ordinary registers used in push_word and a few other
-     places.  DEPRECATED_REGISTER_RAW_SIZE is the real way to know how
-     big a register is.  */
+     places.  register_size() is the real way to know how big a
+     register is.  */
   set_gdbarch_deprecated_register_size (gdbarch, 4);
   set_gdbarch_double_bit (gdbarch, 64);
   /* The default definition of a long double is 2 * TARGET_DOUBLE_BIT,
@@ -3850,25 +3850,11 @@ cris_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
       internal_error (__FILE__, __LINE__, "cris_gdbarch_init: unknown CRIS version");
     }
 
-  set_gdbarch_deprecated_register_bytes (gdbarch, register_bytes);
-
   /* Returns the register offset for the first byte of register regno's space 
      in the saved register state.  */
   set_gdbarch_deprecated_register_byte (gdbarch, cris_register_offset);
   
-  /* The length of the registers in the actual machine representation.  */
-  set_gdbarch_deprecated_register_raw_size (gdbarch, cris_register_size);
-  
-  /* The largest value DEPRECATED_REGISTER_RAW_SIZE can have.  */
-  set_gdbarch_deprecated_max_register_raw_size (gdbarch, 32);
-  
-  /* The length of the registers in the program's representation.  */
-  set_gdbarch_deprecated_register_virtual_size (gdbarch, cris_register_size);
-  
-  /* The largest value DEPRECATED_REGISTER_VIRTUAL_SIZE can have.  */
-  set_gdbarch_deprecated_max_register_virtual_size (gdbarch, 32);
-
-  set_gdbarch_deprecated_register_virtual_type (gdbarch, cris_register_virtual_type);
+  set_gdbarch_register_type (gdbarch, cris_register_type);
   
   /* Dummy frame functions.  */
   set_gdbarch_push_dummy_code (gdbarch, cris_push_dummy_code);
@@ -3883,8 +3869,6 @@ cris_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   set_gdbarch_breakpoint_from_pc (gdbarch, cris_breakpoint_from_pc);
   
-  /* Prologue analyzer may have to be able to parse an incomplete
-     prologue (PC in prologue, that is).  Check infrun.c.  */
   set_gdbarch_unwind_pc (gdbarch, cris_unwind_pc);
   set_gdbarch_unwind_sp (gdbarch, cris_unwind_sp);
   set_gdbarch_unwind_dummy_id (gdbarch, cris_unwind_dummy_id);
This page took 0.026955 seconds and 4 git commands to generate.