Update copyright dates.
[deliverable/binutils-gdb.git] / gdb / sparc64-tdep.c
index 47171a48e5919b18db9dab559510db636c7451d3..24d132dfb8265ce43e30cc681e3a7bc1e7b9cf77 100644 (file)
@@ -1,6 +1,6 @@
 /* Target-dependent code for UltraSPARC.
 
-   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
+   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -103,7 +103,11 @@ sparc64_floating_p (const struct type *type)
   return 0;
 }
 
-/* Check whether TYPE is "Structure or Union".  */
+/* Check whether TYPE is "Structure or Union".
+
+   In terms of Ada subprogram calls, arrays are treated the same as
+   struct and union types.  So this function also returns non-zero
+   for array types.  */
 
 static int
 sparc64_structure_or_union_p (const struct type *type)
@@ -112,6 +116,7 @@ sparc64_structure_or_union_p (const struct type *type)
     {
     case TYPE_CODE_STRUCT:
     case TYPE_CODE_UNION:
+    case TYPE_CODE_ARRAY:
       return 1;
     default:
       break;
@@ -267,7 +272,7 @@ sparc64_register_name (struct gdbarch *gdbarch, int regnum)
 }
 
 /* Return the GDB type object for the "standard" data type of data in
-   register REGNUM. */
+   register REGNUM.  */
 
 static struct type *
 sparc64_register_type (struct gdbarch *gdbarch, int regnum)
@@ -320,6 +325,7 @@ sparc64_pseudo_register_read (struct gdbarch *gdbarch,
                              struct regcache *regcache,
                              int regnum, gdb_byte *buf)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_assert (regnum >= SPARC64_NUM_REGS);
 
   if (regnum >= SPARC64_D0_REGNUM && regnum <= SPARC64_D30_REGNUM)
@@ -370,7 +376,7 @@ sparc64_pseudo_register_read (struct gdbarch *gdbarch,
          state = (state >> 32) & ((1 << 8) - 1);
          break;
        }
-      store_unsigned_integer (buf, 8, state);
+      store_unsigned_integer (buf, 8, byte_order, state);
     }
 }
 
@@ -379,6 +385,7 @@ sparc64_pseudo_register_write (struct gdbarch *gdbarch,
                               struct regcache *regcache,
                               int regnum, const gdb_byte *buf)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_assert (regnum >= SPARC64_NUM_REGS);
 
   if (regnum >= SPARC64_D0_REGNUM && regnum <= SPARC64_D30_REGNUM)
@@ -414,7 +421,7 @@ sparc64_pseudo_register_write (struct gdbarch *gdbarch,
       ULONGEST state, bits;
 
       regcache_raw_read_unsigned (regcache, SPARC64_STATE_REGNUM, &state);
-      bits = extract_unsigned_integer (buf, 8);
+      bits = extract_unsigned_integer (buf, 8, byte_order);
       switch (regnum)
        {
        case SPARC64_CWP_REGNUM:
@@ -486,6 +493,7 @@ static struct value *
 sparc64_frame_prev_register (struct frame_info *this_frame, void **this_cache,
                             int regnum)
 {
+  struct gdbarch *gdbarch = get_frame_arch (this_frame);
   struct sparc_frame_cache *cache =
     sparc64_frame_cache (this_frame, this_cache);
 
@@ -500,7 +508,7 @@ sparc64_frame_prev_register (struct frame_info *this_frame, void **this_cache,
 
   /* Handle StackGhost.  */
   {
-    ULONGEST wcookie = sparc_fetch_wcookie ();
+    ULONGEST wcookie = sparc_fetch_wcookie (gdbarch);
 
     if (wcookie != 0 && !cache->frameless_p && regnum == SPARC_I7_REGNUM)
       {
@@ -929,6 +937,13 @@ sparc64_store_arguments (struct regcache *regcache, int nargs,
   return sp;
 }
 
+static CORE_ADDR
+sparc64_frame_align (struct gdbarch *gdbarch, CORE_ADDR address)
+{
+  /* The ABI requires 16-byte alignment.  */
+  return address & ~0xf;
+}
+
 static CORE_ADDR
 sparc64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                         struct regcache *regcache, CORE_ADDR bp_addr,
@@ -1128,6 +1143,7 @@ sparc64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   set_gdbarch_pc_regnum (gdbarch, SPARC64_PC_REGNUM); /* %pc */
 
   /* Call dummy code.  */
+  set_gdbarch_frame_align (gdbarch, sparc64_frame_align);
   set_gdbarch_call_dummy_location (gdbarch, AT_ENTRY_POINT);
   set_gdbarch_push_dummy_code (gdbarch, NULL);
   set_gdbarch_push_dummy_call (gdbarch, sparc64_push_dummy_call);
@@ -1166,7 +1182,9 @@ sparc64_supply_gregset (const struct sparc_gregset *gregset,
                        struct regcache *regcache,
                        int regnum, const void *gregs)
 {
-  int sparc32 = (gdbarch_ptr_bit (get_regcache_arch (regcache)) == 32);
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  int sparc32 = (gdbarch_ptr_bit (gdbarch) == 32);
   const gdb_byte *regs = gregs;
   int i;
 
@@ -1178,10 +1196,10 @@ sparc64_supply_gregset (const struct sparc_gregset *gregset,
          ULONGEST tstate, psr;
          gdb_byte buf[4];
 
-         tstate = extract_unsigned_integer (regs + offset, 8);
+         tstate = extract_unsigned_integer (regs + offset, 8, byte_order);
          psr = ((tstate & TSTATE_CWP) | PSR_S | ((tstate & TSTATE_ICC) >> 12)
                 | ((tstate & TSTATE_XCC) >> 20) | PSR_V8PLUS);
-         store_unsigned_integer (buf, 4, psr);
+         store_unsigned_integer (buf, 4, byte_order, psr);
          regcache_raw_supply (regcache, SPARC32_PSR_REGNUM, buf);
        }
 
@@ -1280,7 +1298,9 @@ sparc64_collect_gregset (const struct sparc_gregset *gregset,
                         const struct regcache *regcache,
                         int regnum, void *gregs)
 {
-  int sparc32 = (gdbarch_ptr_bit (get_regcache_arch (regcache)) == 32);
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  int sparc32 = (gdbarch_ptr_bit (gdbarch) == 32);
   gdb_byte *regs = gregs;
   int i;
 
@@ -1292,13 +1312,13 @@ sparc64_collect_gregset (const struct sparc_gregset *gregset,
          ULONGEST tstate, psr;
          gdb_byte buf[8];
 
-         tstate = extract_unsigned_integer (regs + offset, 8);
+         tstate = extract_unsigned_integer (regs + offset, 8, byte_order);
          regcache_raw_collect (regcache, SPARC32_PSR_REGNUM, buf);
-         psr = extract_unsigned_integer (buf, 4);
+         psr = extract_unsigned_integer (buf, 4, byte_order);
          tstate |= (psr & PSR_ICC) << 12;
          if ((psr & (PSR_VERS | PSR_IMPL)) == PSR_V8PLUS)
            tstate |= (psr & PSR_XCC) << 20;
-         store_unsigned_integer (buf, 8, tstate);
+         store_unsigned_integer (buf, 8, byte_order, tstate);
          memcpy (regs + offset, buf, 8);
        }
 
This page took 0.025699 seconds and 4 git commands to generate.