daily update
[deliverable/binutils-gdb.git] / gdb / sparc-tdep.c
index 1719109ac288981afef713b736474c699b69e83b..893648c8b361f831ec53dd60fb67eea93688a66c 100644 (file)
 
 struct regset;
 
-/* This file implements the The SPARC 32-bit ABI as defined by the
-   section "Low-Level System Information" of the SPARC Compliance
-   Definition (SCD) 2.4.1, which is the 32-bit System V psABI for
-   SPARC.  The SCD lists changes with respect to the origional 32-bit
-   psABI as defined in the "System V ABI, SPARC Processor
-   Supplement".
+/* This file implements the SPARC 32-bit ABI as defined by the section
+   "Low-Level System Information" of the SPARC Compliance Definition
+   (SCD) 2.4.1, which is the 32-bit System V psABI for SPARC.  The SCD
+   lists changes with respect to the original 32-bit psABI as defined
+   in the "System V ABI, SPARC Processor Supplement".
 
    Note that if we talk about SunOS, we mean SunOS 4.x, which was
    BSD-based, which is sometimes (retroactively?) referred to as
@@ -141,13 +140,21 @@ sparc_fetch_instruction (CORE_ADDR pc)
 ULONGEST
 sparc_fetch_wcookie (void)
 {
-  /* FIXME: kettenis/20040131: We should fetch the cookie from the
-     target.  For now, return zero, which is right for targets without
-     StackGhost.  */
-  return 0;
-}
+  struct target_ops *ops = &current_target;
+  char buf[8];
+  int len;
 
+  len = target_read_partial (ops, TARGET_OBJECT_WCOOKIE, NULL, buf, 0, 8);
+  if (len == -1)
+    return 0;
+
+  /* We should have either an 32-bit or an 64-bit cookie.  */
+  gdb_assert (len == 4 || len == 8);
+
+  return extract_unsigned_integer (buf, len);
+}
 \f
+
 /* Return the contents if register REGNUM as an address.  */
 
 static CORE_ADDR
@@ -178,7 +185,7 @@ sparc_integral_or_pointer_p (const struct type *type)
       {
        /* We have byte, half-word, word and extended-word/doubleword
            integral types.  The doubleword is an extension to the
-           origional 32-bit ABI by the SCD 2.4.x.  */
+           original 32-bit ABI by the SCD 2.4.x.  */
        int len = TYPE_LENGTH (type);
        return (len == 1 || len == 2 || len == 4 || len == 8);
       }
@@ -607,14 +614,6 @@ sparc_frame_cache (struct frame_info *next_frame, void **this_cache)
   cache = sparc_alloc_frame_cache ();
   *this_cache = cache;
 
-  /* In priciple, for normal frames, %fp (%i6) holds the frame
-     pointer, which holds the base address for the current stack
-     frame.  */
-
-  cache->base = frame_unwind_register_unsigned (next_frame, SPARC_FP_REGNUM);
-  if (cache->base == 0)
-    return cache;
-
   cache->pc = frame_func_unwind (next_frame);
   if (cache->pc != 0)
     {
@@ -624,10 +623,18 @@ sparc_frame_cache (struct frame_info *next_frame, void **this_cache)
 
   if (cache->frameless_p)
     {
-      /* We didn't find a valid frame, which means that CACHE->base
-        currently holds the frame pointer for our calling frame.  */
-      cache->base = frame_unwind_register_unsigned (next_frame,
-                                                   SPARC_SP_REGNUM);
+      /* This function is frameless, so %fp (%i6) holds the frame
+         pointer for our calling frame.  Use %sp (%o6) as this frame's
+         base address.  */
+      cache->base =
+       frame_unwind_register_unsigned (next_frame, SPARC_SP_REGNUM);
+    }
+  else
+    {
+      /* For normal frames, %fp (%i6) holds the frame pointer, the
+         base address for the current stack frame.  */
+      cache->base =
+       frame_unwind_register_unsigned (next_frame, SPARC_FP_REGNUM);
     }
 
   return cache;
@@ -721,11 +728,11 @@ sparc32_frame_prev_register (struct frame_info *next_frame, void **this_cache,
        if (valuep)
          {
            CORE_ADDR addr = cache->base + (regnum - SPARC_L0_REGNUM) * 4;
-           ULONGEST i6;
+           ULONGEST i7;
 
            /* Read the value in from memory.  */
-           i6 = get_frame_memory_unsigned (next_frame, addr, 4);
-           store_unsigned_integer (valuep, 4, i6 ^ wcookie);
+           i7 = get_frame_memory_unsigned (next_frame, addr, 4);
+           store_unsigned_integer (valuep, 4, i7 ^ wcookie);
          }
        return;
       }
@@ -1233,9 +1240,9 @@ sparc_supply_rwindow (struct regcache *regcache, CORE_ADDR sp, int regnum)
              if (i == SPARC_I7_REGNUM)
                {
                  ULONGEST wcookie = sparc_fetch_wcookie ();
-                 ULONGEST i6 = extract_unsigned_integer (buf + offset, 4);
+                 ULONGEST i7 = extract_unsigned_integer (buf + offset, 4);
 
-                 store_unsigned_integer (buf + offset, 4, i6 ^ wcookie);
+                 store_unsigned_integer (buf + offset, 4, i7 ^ wcookie);
                }
 
              regcache_raw_supply (regcache, i, buf);
@@ -1286,9 +1293,9 @@ sparc_collect_rwindow (const struct regcache *regcache,
              if (i == SPARC_I7_REGNUM)
                {
                  ULONGEST wcookie = sparc_fetch_wcookie ();
-                 ULONGEST i6 = extract_unsigned_integer (buf + offset, 4);
+                 ULONGEST i7 = extract_unsigned_integer (buf + offset, 4);
 
-                 store_unsigned_integer (buf + offset, 4, i6 ^ wcookie);
+                 store_unsigned_integer (buf + offset, 4, i7 ^ wcookie);
                }
 
              target_write_memory (sp + ((i - SPARC_L0_REGNUM) * 4),
This page took 0.025131 seconds and 4 git commands to generate.