gdb
[deliverable/binutils-gdb.git] / gdb / sparc-tdep.c
index f6dbf3f5aba011aa87bd1c61b13ecebf06ff2971..f129a55003dc86640825b901cd834df6e598ad56 100644 (file)
@@ -1,6 +1,6 @@
 /* Target-dependent code for SPARC.
 
-   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
+   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -152,8 +152,9 @@ sparc_is_unimp_insn (CORE_ADDR pc)
 /* Fetch StackGhost Per-Process XOR cookie.  */
 
 ULONGEST
-sparc_fetch_wcookie (void)
+sparc_fetch_wcookie (struct gdbarch *gdbarch)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct target_ops *ops = &current_target;
   gdb_byte buf[8];
   int len;
@@ -165,7 +166,7 @@ sparc_fetch_wcookie (void)
   /* We should have either an 32-bit or an 64-bit cookie.  */
   gdb_assert (len == 4 || len == 8);
 
-  return extract_unsigned_integer (buf, len);
+  return extract_unsigned_integer (buf, len, byte_order);
 }
 \f
 
@@ -294,7 +295,7 @@ sparc_psr_type (struct gdbarch *gdbarch)
     {
       struct type *type;
 
-      type = init_flags_type ("builtin_type_sparc_psr", 4);
+      type = arch_flags_type (gdbarch, "builtin_type_sparc_psr", 4);
       append_flags_type_flag (type, 5, "ET");
       append_flags_type_flag (type, 6, "PS");
       append_flags_type_flag (type, 7, "S");
@@ -316,7 +317,7 @@ sparc_fsr_type (struct gdbarch *gdbarch)
     {
       struct type *type;
 
-      type = init_flags_type ("builtin_type_sparc_fsr", 4);
+      type = arch_flags_type (gdbarch, "builtin_type_sparc_fsr", 4);
       append_flags_type_flag (type, 0, "NXA");
       append_flags_type_flag (type, 1, "DZA");
       append_flags_type_flag (type, 2, "UFA");
@@ -400,6 +401,8 @@ sparc32_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp,
                         CORE_ADDR *real_pc, CORE_ADDR *bp_addr,
                         struct regcache *regcache)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
   *bp_addr = sp - 4;
   *real_pc = funcaddr;
 
@@ -408,7 +411,8 @@ sparc32_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp,
       gdb_byte buf[4];
 
       /* This is an UNIMP instruction.  */
-      store_unsigned_integer (buf, 4, TYPE_LENGTH (value_type) & 0x1fff);
+      store_unsigned_integer (buf, 4, byte_order,
+                             TYPE_LENGTH (value_type) & 0x1fff);
       write_memory (sp - 8, buf, 4);
       return sp - 8;
     }
@@ -422,6 +426,7 @@ sparc32_store_arguments (struct regcache *regcache, int nargs,
                         int struct_return, CORE_ADDR struct_addr)
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   /* Number of words in the "parameter array".  */
   int num_elements = 0;
   int element = 0;
@@ -504,7 +509,7 @@ sparc32_store_arguments (struct regcache *regcache, int nargs,
     {
       gdb_byte buf[4];
 
-      store_unsigned_integer (buf, 4, struct_addr);
+      store_unsigned_integer (buf, 4, byte_order, struct_addr);
       write_memory (sp, buf, 4);
     }
 
@@ -954,6 +959,7 @@ static struct value *
 sparc32_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 =
     sparc32_frame_cache (this_frame, this_cache);
 
@@ -974,7 +980,7 @@ sparc32_frame_prev_register (struct frame_info *this_frame,
 
   /* Handle StackGhost.  */
   {
-    ULONGEST wcookie = sparc_fetch_wcookie ();
+    ULONGEST wcookie = sparc_fetch_wcookie (gdbarch);
 
     if (wcookie != 0 && !cache->frameless_p && regnum == SPARC_I7_REGNUM)
       {
@@ -1133,6 +1139,8 @@ sparc32_return_value (struct gdbarch *gdbarch, struct type *func_type,
                      struct type *type, struct regcache *regcache,
                      gdb_byte *readbuf, const gdb_byte *writebuf)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
   /* The psABI says that "...every stack frame reserves the word at
      %fp+64.  If a function returns a structure, union, or
      quad-precision value, this word should hold the address of the
@@ -1149,7 +1157,7 @@ sparc32_return_value (struct gdbarch *gdbarch, struct type *func_type,
          CORE_ADDR addr;
 
          regcache_cooked_read_unsigned (regcache, SPARC_SP_REGNUM, &sp);
-         addr = read_memory_unsigned_integer (sp + 64, 4);
+         addr = read_memory_unsigned_integer (sp + 64, 4, byte_order);
          read_memory (addr, readbuf, TYPE_LENGTH (type));
        }
 
@@ -1304,6 +1312,7 @@ sparc_software_single_step (struct frame_info *frame)
 {
   struct gdbarch *arch = get_frame_arch (frame);
   struct gdbarch_tdep *tdep = gdbarch_tdep (arch);
+  struct address_space *aspace = get_frame_address_space (frame);
   CORE_ADDR npc, nnpc;
 
   CORE_ADDR pc, orig_npc;
@@ -1314,10 +1323,10 @@ sparc_software_single_step (struct frame_info *frame)
   /* Analyze the instruction at PC.  */
   nnpc = sparc_analyze_control_transfer (frame, pc, &npc);
   if (npc != 0)
-    insert_single_step_breakpoint (npc);
+    insert_single_step_breakpoint (arch, aspace, npc);
 
   if (nnpc != 0)
-    insert_single_step_breakpoint (nnpc);
+    insert_single_step_breakpoint (arch, aspace, nnpc);
 
   /* Assert that we have set at least one breakpoint, and that
      they're not set at the same spot - unless we're going
@@ -1369,16 +1378,11 @@ sparc32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
     return arches->gdbarch;
 
   /* Allocate space for the new architecture.  */
-  tdep = XMALLOC (struct gdbarch_tdep);
+  tdep = XZALLOC (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
 
   tdep->pc_regnum = SPARC32_PC_REGNUM;
   tdep->npc_regnum = SPARC32_NPC_REGNUM;
-  tdep->gregset = NULL;
-  tdep->sizeof_gregset = 0;
-  tdep->fpregset = NULL;
-  tdep->sizeof_fpregset = 0;
-  tdep->plt_entry_size = 0;
   tdep->step_trap = sparc_step_trap;
 
   set_gdbarch_long_double_bit (gdbarch, 128);
@@ -1448,6 +1452,8 @@ sparc32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 void
 sparc_supply_rwindow (struct regcache *regcache, CORE_ADDR sp, int regnum)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int offset = 0;
   gdb_byte buf[8];
   int i;
@@ -1466,10 +1472,12 @@ sparc_supply_rwindow (struct regcache *regcache, CORE_ADDR sp, int regnum)
              /* Handle StackGhost.  */
              if (i == SPARC_I7_REGNUM)
                {
-                 ULONGEST wcookie = sparc_fetch_wcookie ();
-                 ULONGEST i7 = extract_unsigned_integer (buf + offset, 8);
+                 ULONGEST wcookie = sparc_fetch_wcookie (gdbarch);
+                 ULONGEST i7;
 
-                 store_unsigned_integer (buf + offset, 8, i7 ^ wcookie);
+                 i7 = extract_unsigned_integer (buf + offset, 8, byte_order);
+                 store_unsigned_integer (buf + offset, 8, byte_order,
+                                         i7 ^ wcookie);
                }
 
              regcache_raw_supply (regcache, i, buf);
@@ -1500,10 +1508,12 @@ sparc_supply_rwindow (struct regcache *regcache, CORE_ADDR sp, int regnum)
              /* Handle StackGhost.  */
              if (i == SPARC_I7_REGNUM)
                {
-                 ULONGEST wcookie = sparc_fetch_wcookie ();
-                 ULONGEST i7 = extract_unsigned_integer (buf + offset, 4);
+                 ULONGEST wcookie = sparc_fetch_wcookie (gdbarch);
+                 ULONGEST i7;
 
-                 store_unsigned_integer (buf + offset, 4, i7 ^ wcookie);
+                 i7 = extract_unsigned_integer (buf + offset, 4, byte_order);
+                 store_unsigned_integer (buf + offset, 4, byte_order,
+                                         i7 ^ wcookie);
                }
 
              regcache_raw_supply (regcache, i, buf);
@@ -1516,6 +1526,8 @@ void
 sparc_collect_rwindow (const struct regcache *regcache,
                       CORE_ADDR sp, int regnum)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int offset = 0;
   gdb_byte buf[8];
   int i;
@@ -1534,10 +1546,11 @@ sparc_collect_rwindow (const struct regcache *regcache,
              /* Handle StackGhost.  */
              if (i == SPARC_I7_REGNUM)
                {
-                 ULONGEST wcookie = sparc_fetch_wcookie ();
-                 ULONGEST i7 = extract_unsigned_integer (buf + offset, 8);
+                 ULONGEST wcookie = sparc_fetch_wcookie (gdbarch);
+                 ULONGEST i7;
 
-                 store_unsigned_integer (buf, 8, i7 ^ wcookie);
+                 i7 = extract_unsigned_integer (buf + offset, 8, byte_order);
+                 store_unsigned_integer (buf, 8, byte_order, i7 ^ wcookie);
                }
 
              target_write_memory (sp + ((i - SPARC_L0_REGNUM) * 8), buf, 8);
@@ -1563,10 +1576,12 @@ sparc_collect_rwindow (const struct regcache *regcache,
              /* Handle StackGhost.  */
              if (i == SPARC_I7_REGNUM)
                {
-                 ULONGEST wcookie = sparc_fetch_wcookie ();
-                 ULONGEST i7 = extract_unsigned_integer (buf + offset, 4);
+                 ULONGEST wcookie = sparc_fetch_wcookie (gdbarch);
+                 ULONGEST i7;
 
-                 store_unsigned_integer (buf + offset, 4, i7 ^ wcookie);
+                 i7 = extract_unsigned_integer (buf + offset, 4, byte_order);
+                 store_unsigned_integer (buf + offset, 4, byte_order,
+                                         i7 ^ wcookie);
                }
 
              target_write_memory (sp + ((i - SPARC_L0_REGNUM) * 4),
This page took 0.091926 seconds and 4 git commands to generate.