sim: allow the assert configure option everywhere
[deliverable/binutils-gdb.git] / gdb / xstormy16-tdep.c
index 53cbecdf9b69a90eaaffd55c172c4bd1019e5d31..af1551ff1d97efcd8ee4c51df21669cf47ff03cb 100644 (file)
@@ -1,7 +1,6 @@
 /* Target-dependent code for the Sanyo Xstormy16a (LC590000) processor.
 
-   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright (C) 2001-2016 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -30,8 +29,6 @@
 #include "value.h"
 #include "dis-asm.h"
 #include "inferior.h"
-#include "gdb_string.h"
-#include "gdb_assert.h"
 #include "arch-utils.h"
 #include "floatformat.h"
 #include "regcache.h"
@@ -161,13 +158,13 @@ xstormy16_use_struct_convention (struct type *type)
 
 static void
 xstormy16_extract_return_value (struct type *type, struct regcache *regcache,
-                               void *valbuf)
+                               gdb_byte *valbuf)
 {
   int len = TYPE_LENGTH (type);
   int i, regnum = E_1ST_ARG_REGNUM;
 
   for (i = 0; i < len; i += xstormy16_reg_size)
-    regcache_raw_read (regcache, regnum++, (char *) valbuf + i);
+    regcache_raw_read (regcache, regnum++, valbuf + i);
 }
 
 /* Function: xstormy16_store_return_value
@@ -177,12 +174,12 @@ xstormy16_extract_return_value (struct type *type, struct regcache *regcache,
 
 static void 
 xstormy16_store_return_value (struct type *type, struct regcache *regcache,
-                             const void *valbuf)
+                             const gdb_byte *valbuf)
 {
   if (TYPE_LENGTH (type) == 1)
     {    
       /* Add leading zeros to the value.  */
-      char buf[xstormy16_reg_size];
+      gdb_byte buf[xstormy16_reg_size];
       memset (buf, 0, xstormy16_reg_size);
       memcpy (buf, valbuf, 1);
       regcache_raw_write (regcache, E_1ST_ARG_REGNUM, buf);
@@ -193,12 +190,12 @@ xstormy16_store_return_value (struct type *type, struct regcache *regcache,
       int i, regnum = E_1ST_ARG_REGNUM;
 
       for (i = 0; i < len; i += xstormy16_reg_size)
-        regcache_raw_write (regcache, regnum++, (char *) valbuf + i);
+        regcache_raw_write (regcache, regnum++, valbuf + i);
     }
 }
 
 static enum return_value_convention
-xstormy16_return_value (struct gdbarch *gdbarch, struct type *func_type,
+xstormy16_return_value (struct gdbarch *gdbarch, struct value *function,
                        struct type *type, struct regcache *regcache,
                        gdb_byte *readbuf, const gdb_byte *writebuf)
 {
@@ -239,7 +236,7 @@ xstormy16_push_dummy_call (struct gdbarch *gdbarch,
   int i, j;
   int typelen, slacklen;
   const gdb_byte *val;
-  char buf[xstormy16_pc_size];
+  gdb_byte buf[xstormy16_pc_size];
 
   /* If struct_return is true, then the struct return address will
      consume one argument-passing register.  */
@@ -263,12 +260,13 @@ xstormy16_push_dummy_call (struct gdbarch *gdbarch,
       /* Put argument into registers wordwise.  */
       val = value_contents (args[i]);
       for (j = 0; j < typelen; j += xstormy16_reg_size)
-       regcache_cooked_write_unsigned (regcache, argreg++,
-                       extract_unsigned_integer (val + j,
-                                                 typelen - j ==
-                                                 1 ? 1 :
-                                                 xstormy16_reg_size,
-                                                 byte_order));
+       {
+         ULONGEST regval;
+         int size = (typelen - j == 1) ? 1 : xstormy16_reg_size;
+
+         regval = extract_unsigned_integer (val + j, size, byte_order);
+         regcache_cooked_write_unsigned (regcache, argreg++, regval);
+       }
     }
 
   /* Align SP */
@@ -278,17 +276,21 @@ xstormy16_push_dummy_call (struct gdbarch *gdbarch,
      wordaligned.  */
   for (j = nargs - 1; j >= i; j--)
     {
-      char *val;
+      gdb_byte *val;
+      struct cleanup *back_to;
+      const gdb_byte *bytes = value_contents (args[j]);
 
       typelen = TYPE_LENGTH (value_enclosing_type (args[j]));
       slacklen = typelen & 1;
-      val = alloca (typelen + slacklen);
-      memcpy (val, value_contents (args[j]), typelen);
+      val = (gdb_byte *) xmalloc (typelen + slacklen);
+      back_to = make_cleanup (xfree, val);
+      memcpy (val, bytes, typelen);
       memset (val + typelen, 0, slacklen);
 
       /* Now write this data to the stack.  The stack grows upwards.  */
       write_memory (stack_dest, val, typelen + slacklen);
       stack_dest += typelen + slacklen;
+      do_cleanups (back_to);
     }
 
   store_unsigned_integer (buf, xstormy16_pc_size, byte_order, bp_addr);
@@ -372,7 +374,7 @@ xstormy16_analyze_prologue (struct gdbarch *gdbarch,
       /* Probably only in optimized case but legal action for prologue.  */
       else if ((inst & 0xff00) == 0x4600       /* 46SD   mov rD, rS */
               && (inst & 0x00f0) >= 0x0020 && (inst & 0x00f0) <= 0x0070
-              && (inst & 0x000f) >= 0x00a0 && (inst & 0x000f) <= 0x000d)
+              && (inst & 0x000f) >= 0x000a && (inst & 0x000f) <= 0x000d)
        ;
 
       /* Optional copying of args in r2-r7 to stack.  */
@@ -413,7 +415,7 @@ static CORE_ADDR
 xstormy16_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   CORE_ADDR func_addr = 0, func_end = 0;
-  char *func_name;
+  const char *func_name;
 
   if (find_pc_partial_function (pc, &func_name, &func_addr, &func_end))
     {
@@ -431,7 +433,7 @@ xstormy16_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
         return plg_end;
 
       /* Found a function.  */
-      sym = lookup_symbol (func_name, NULL, VAR_DOMAIN, NULL);
+      sym = lookup_symbol (func_name, NULL, VAR_DOMAIN, NULL).symbol;
       /* Don't use line number debug info for assembly source files.  */
       if (sym && SYMBOL_LANGUAGE (sym) != language_asm)
        {
@@ -451,11 +453,14 @@ xstormy16_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
   return (CORE_ADDR) pc;
 }
 
-/* The epilogue is defined here as the area at the end of a function,
+/* Implement the stack_frame_destroyed_p gdbarch method.
+
+   The epilogue is defined here as the area at the end of a function,
    either on the `ret' instruction itself or after an instruction which
    destroys the function's stack frame.  */
+
 static int
-xstormy16_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
+xstormy16_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR func_addr = 0, func_end = 0;
@@ -501,7 +506,7 @@ xstormy16_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
   return 0;
 }
 
-const static unsigned char *
+static const unsigned char *
 xstormy16_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr,
                              int *lenptr)
 {
@@ -521,7 +526,7 @@ xstormy16_resolve_jmp_table_entry (struct gdbarch *gdbarch, CORE_ADDR faddr)
   if (faddr_sect)
     {
       LONGEST inst, inst2, addr;
-      char buf[2 * xstormy16_inst_size];
+      gdb_byte buf[2 * xstormy16_inst_size];
 
       /* Return faddr if it's not pointing into the jump table.  */
       if (strcmp (faddr_sect->the_bfd_section->name, ".plt"))
@@ -573,7 +578,7 @@ xstormy16_find_jmp_table_entry (struct gdbarch *gdbarch, CORE_ADDR faddr)
          for (; addr < endaddr; addr += 2 * xstormy16_inst_size)
            {
              LONGEST inst, inst2, faddr2;
-             char buf[2 * xstormy16_inst_size];
+             gdb_byte buf[2 * xstormy16_inst_size];
 
              if (target_read_memory (addr, buf, sizeof buf))
                return 0;
@@ -673,7 +678,7 @@ xstormy16_frame_cache (struct frame_info *this_frame, void **this_cache)
   int i;
 
   if (*this_cache)
-    return *this_cache;
+    return (struct xstormy16_frame_cache *) *this_cache;
 
   cache = xstormy16_alloc_frame_cache ();
   *this_cache = cache;
@@ -833,8 +838,8 @@ xstormy16_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   frame_base_set_default (gdbarch, &xstormy16_frame_base);
 
   set_gdbarch_skip_prologue (gdbarch, xstormy16_skip_prologue);
-  set_gdbarch_in_function_epilogue_p (gdbarch,
-                                     xstormy16_in_function_epilogue_p);
+  set_gdbarch_stack_frame_destroyed_p (gdbarch,
+                                      xstormy16_stack_frame_destroyed_p);
 
   /* These values and methods are used when gdb calls a target function.  */
   set_gdbarch_push_dummy_call (gdbarch, xstormy16_push_dummy_call);
This page took 0.026334 seconds and 4 git commands to generate.