* linux-low.c (my_waitpid): Move definition away from being in
[deliverable/binutils-gdb.git] / gdb / alpha-tdep.c
index fe8671f3a5c7497f9b8b0aaa4b8edda1698b0f49..40e9c0a8e55342c038c65a9d757d32c4e92c3086 100644 (file)
@@ -1,7 +1,7 @@
 /* Target-dependent code for the ALPHA architecture, for GDB, the GNU Debugger.
 
    Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-   2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+   2003, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -95,16 +95,16 @@ static struct type *
 alpha_register_type (struct gdbarch *gdbarch, int regno)
 {
   if (regno == ALPHA_SP_REGNUM || regno == ALPHA_GP_REGNUM)
-    return builtin_type_void_data_ptr;
+    return builtin_type (gdbarch)->builtin_data_ptr;
   if (regno == ALPHA_PC_REGNUM)
-    return builtin_type_void_func_ptr;
+    return builtin_type (gdbarch)->builtin_func_ptr;
 
   /* Don't need to worry about little vs big endian until 
      some jerk tries to port to alpha-unicosmk.  */
   if (regno >= ALPHA_FP0_REGNUM && regno < ALPHA_FP0_REGNUM + 31)
-    return builtin_type_ieee_double;
+    return builtin_type (gdbarch)->builtin_double;
 
-  return builtin_type_int64;
+  return builtin_type (gdbarch)->builtin_int64;
 }
 
 /* Is REGNUM a member of REGGROUP?  */
@@ -154,9 +154,10 @@ alpha_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
    floating point and 32-bit integers.  */
 
 static void
-alpha_lds (void *out, const void *in)
+alpha_lds (struct gdbarch *gdbarch, void *out, const void *in)
 {
-  ULONGEST mem     = extract_unsigned_integer (in, 4);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  ULONGEST mem     = extract_unsigned_integer (in, 4, byte_order);
   ULONGEST frac    = (mem >>  0) & 0x7fffff;
   ULONGEST sign    = (mem >> 31) & 1;
   ULONGEST exp_msb = (mem >> 30) & 1;
@@ -176,20 +177,21 @@ alpha_lds (void *out, const void *in)
     }
 
   reg = (sign << 63) | (exp << 52) | (frac << 29);
-  store_unsigned_integer (out, 8, reg);
+  store_unsigned_integer (out, 8, byte_order, reg);
 }
 
 /* Similarly, this represents exactly the conversion performed by
    the STS instruction.  */
 
 static void
-alpha_sts (void *out, const void *in)
+alpha_sts (struct gdbarch *gdbarch, void *out, const void *in)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   ULONGEST reg, mem;
 
-  reg = extract_unsigned_integer (in, 8);
+  reg = extract_unsigned_integer (in, 8, byte_order);
   mem = ((reg >> 32) & 0xc0000000) | ((reg >> 29) & 0x3fffffff);
-  store_unsigned_integer (out, 4, mem);
+  store_unsigned_integer (out, 4, byte_order, mem);
 }
 
 /* The alpha needs a conversion between register and memory format if the
@@ -215,7 +217,7 @@ alpha_register_to_value (struct frame_info *frame, int regnum,
   switch (TYPE_LENGTH (valtype))
     {
     case 4:
-      alpha_sts (out, in);
+      alpha_sts (get_frame_arch (frame), out, in);
       break;
     default:
       error (_("Cannot retrieve value from floating point register"));
@@ -231,7 +233,7 @@ alpha_value_to_register (struct frame_info *frame, int regnum,
   switch (TYPE_LENGTH (valtype))
     {
     case 4:
-      alpha_lds (out, in);
+      alpha_lds (get_frame_arch (frame), out, in);
       break;
     default:
       error (_("Cannot store value in floating point register"));
@@ -258,6 +260,7 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                       int nargs, struct value **args, CORE_ADDR sp,
                       int struct_return, CORE_ADDR struct_addr)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int i;
   int accumulate_size = struct_return ? 8 : 0;
   struct alpha_arg
@@ -298,12 +301,12 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
            {
              /* 32-bit values must be sign-extended to 64 bits
                 even if the base data type is unsigned.  */
-             arg_type = builtin_type_int32;
+             arg_type = builtin_type (gdbarch)->builtin_int32;
              arg = value_cast (arg_type, arg);
            }
          if (TYPE_LENGTH (arg_type) < ALPHA_REGISTER_SIZE)
            {
-             arg_type = builtin_type_int64;
+             arg_type = builtin_type (gdbarch)->builtin_int64;
              arg = value_cast (arg_type, arg);
            }
          break;
@@ -314,7 +317,7 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
          if (accumulate_size < sizeof (arg_reg_buffer)
              && TYPE_LENGTH (arg_type) == 4)
            {
-             arg_type = builtin_type_ieee_double;
+             arg_type = builtin_type (gdbarch)->builtin_double;
              arg = value_cast (arg_type, arg);
            }
          /* Tru64 5.1 has a 128-bit long double, and passes this by
@@ -408,7 +411,8 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
       write_memory (sp + offset - sizeof(arg_reg_buffer), contents, len);
     }
   if (struct_return)
-    store_unsigned_integer (arg_reg_buffer, ALPHA_REGISTER_SIZE, struct_addr);
+    store_unsigned_integer (arg_reg_buffer, ALPHA_REGISTER_SIZE,
+                           byte_order, struct_addr);
 
   /* Load the argument registers.  */
   for (i = 0; i < required_arg_regs; i++)
@@ -432,6 +436,8 @@ static void
 alpha_extract_return_value (struct type *valtype, struct regcache *regcache,
                            gdb_byte *valbuf)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int length = TYPE_LENGTH (valtype);
   gdb_byte raw_buffer[ALPHA_REGISTER_SIZE];
   ULONGEST l;
@@ -443,7 +449,7 @@ alpha_extract_return_value (struct type *valtype, struct regcache *regcache,
        {
        case 4:
          regcache_cooked_read (regcache, ALPHA_FP0_REGNUM, raw_buffer);
-         alpha_sts (valbuf, raw_buffer);
+         alpha_sts (gdbarch, valbuf, raw_buffer);
          break;
 
        case 8:
@@ -486,7 +492,7 @@ alpha_extract_return_value (struct type *valtype, struct regcache *regcache,
     default:
       /* Assume everything else degenerates to an integer.  */
       regcache_cooked_read_unsigned (regcache, ALPHA_V0_REGNUM, &l);
-      store_unsigned_integer (valbuf, length, l);
+      store_unsigned_integer (valbuf, length, byte_order, l);
       break;
     }
 }
@@ -498,6 +504,7 @@ static void
 alpha_store_return_value (struct type *valtype, struct regcache *regcache,
                          const gdb_byte *valbuf)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
   int length = TYPE_LENGTH (valtype);
   gdb_byte raw_buffer[ALPHA_REGISTER_SIZE];
   ULONGEST l;
@@ -508,7 +515,7 @@ alpha_store_return_value (struct type *valtype, struct regcache *regcache,
       switch (length)
        {
        case 4:
-         alpha_lds (raw_buffer, valbuf);
+         alpha_lds (gdbarch, raw_buffer, valbuf);
          regcache_cooked_write (regcache, ALPHA_FP0_REGNUM, raw_buffer);
          break;
 
@@ -556,7 +563,7 @@ alpha_store_return_value (struct type *valtype, struct regcache *regcache,
       /* 32-bit values must be sign-extended to 64 bits
         even if the base data type is unsigned.  */
       if (length == 4)
-       valtype = builtin_type_int32;
+       valtype = builtin_type (gdbarch)->builtin_int32;
       l = unpack_long (valtype, valbuf);
       regcache_cooked_write_unsigned (regcache, ALPHA_V0_REGNUM, l);
       break;
@@ -633,15 +640,16 @@ alpha_after_prologue (CORE_ADDR pc)
 /* Read an instruction from memory at PC, looking through breakpoints.  */
 
 unsigned int
-alpha_read_insn (CORE_ADDR pc)
+alpha_read_insn (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte buf[ALPHA_INSN_SIZE];
   int status;
 
   status = target_read_memory (pc, buf, sizeof (buf));
   if (status)
     memory_error (status, pc);
-  return extract_unsigned_integer (buf, sizeof (buf));
+  return extract_unsigned_integer (buf, sizeof (buf), byte_order);
 }
 
 /* To skip prologues, I use this predicate.  Returns either PC itself
@@ -685,7 +693,7 @@ alpha_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
      or in the gcc frame.  */
   for (offset = 0; offset < 100; offset += ALPHA_INSN_SIZE)
     {
-      inst = alpha_read_insn (pc + offset);
+      inst = alpha_read_insn (gdbarch, pc + offset);
 
       if ((inst & 0xffff0000) == 0x27bb0000)   /* ldah $gp,n($t12) */
        continue;
@@ -720,7 +728,9 @@ alpha_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
 static int
 alpha_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (frame));
+  struct gdbarch *gdbarch = get_frame_arch (frame);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR jb_addr;
   gdb_byte raw_buffer[ALPHA_REGISTER_SIZE];
 
@@ -730,7 +740,7 @@ alpha_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
                          raw_buffer, tdep->jb_elt_size))
     return 0;
 
-  *pc = extract_unsigned_integer (raw_buffer, tdep->jb_elt_size);
+  *pc = extract_unsigned_integer (raw_buffer, tdep->jb_elt_size, byte_order);
   return 1;
 }
 
@@ -809,7 +819,7 @@ alpha_sigtramp_frame_this_id (struct frame_info *this_frame,
     {
       int offset;
       code_addr = get_frame_pc (this_frame);
-      offset = tdep->dynamic_sigtramp_offset (code_addr);
+      offset = tdep->dynamic_sigtramp_offset (gdbarch, code_addr);
       if (offset >= 0)
        code_addr -= offset;
       else
@@ -875,7 +885,7 @@ alpha_sigtramp_frame_sniffer (const struct frame_unwind *self,
 
   /* Otherwise we should be in a signal frame.  */
   find_pc_partial_function (pc, &name, NULL, NULL);
-  if (gdbarch_tdep (gdbarch)->pc_in_sigtramp (pc, name))
+  if (gdbarch_tdep (gdbarch)->pc_in_sigtramp (gdbarch, pc, name))
     return 1;
 
   return 0;
@@ -909,6 +919,7 @@ alpha_heuristic_proc_start (struct gdbarch *gdbarch, CORE_ADDR pc)
   CORE_ADDR fence = pc - heuristic_fence_post;
   CORE_ADDR orig_pc = pc;
   CORE_ADDR func;
+  struct inferior *inf;
 
   if (pc == 0)
     return 0;
@@ -929,7 +940,7 @@ alpha_heuristic_proc_start (struct gdbarch *gdbarch, CORE_ADDR pc)
      nops, since this usually indicates padding between functions.  */
   for (pc -= ALPHA_INSN_SIZE; pc >= fence; pc -= ALPHA_INSN_SIZE)
     {
-      unsigned int insn = alpha_read_insn (pc);
+      unsigned int insn = alpha_read_insn (gdbarch, pc);
       switch (insn)
        {
        case 0:                 /* invalid insn */
@@ -946,19 +957,21 @@ alpha_heuristic_proc_start (struct gdbarch *gdbarch, CORE_ADDR pc)
        }
     }
 
+  inf = current_inferior ();
+
   /* It's not clear to me why we reach this point when stopping quietly,
      but with this test, at least we don't print out warnings for every
      child forked (eg, on decstation).  22apr93 rich@cygnus.com.  */
-  if (stop_soon == NO_STOP_QUIETLY)
+  if (inf->stop_soon == NO_STOP_QUIETLY)
     {
       static int blurb_printed = 0;
 
       if (fence == tdep->vm_min_address)
        warning (_("Hit beginning of text section without finding \
-enclosing function for address 0x%s"), paddr_nz (orig_pc));
+enclosing function for address %s"), paddress (gdbarch, orig_pc));
       else
        warning (_("Hit heuristic-fence-post without finding \
-enclosing function for address 0x%s"), paddr_nz (orig_pc));
+enclosing function for address %s"), paddress (gdbarch, orig_pc));
 
       if (!blurb_printed)
        {
@@ -1023,7 +1036,7 @@ alpha_heuristic_frame_unwind_cache (struct frame_info *this_frame,
 
       for (cur_pc = start_pc; cur_pc < limit_pc; cur_pc += ALPHA_INSN_SIZE)
        {
-         unsigned int word = alpha_read_insn (cur_pc);
+         unsigned int word = alpha_read_insn (gdbarch, cur_pc);
 
          if ((word & 0xffff0000) == 0x23de0000)        /* lda $sp,n($sp) */
            {
@@ -1111,7 +1124,7 @@ alpha_heuristic_frame_unwind_cache (struct frame_info *this_frame,
        {
          while (cur_pc < (limit_pc + 80) && cur_pc < (start_pc + 80))
            {
-             unsigned int word = alpha_read_insn (cur_pc);
+             unsigned int word = alpha_read_insn (gdbarch, cur_pc);
 
              if ((word & 0xfc1f0000) == 0xb41e0000)    /* stq reg,n($sp) */
                {
@@ -1354,13 +1367,14 @@ fp_register_sign_bit (LONGEST reg)
 static CORE_ADDR
 alpha_next_pc (struct frame_info *frame, CORE_ADDR pc)
 {
+  struct gdbarch *gdbarch = get_frame_arch (frame);
   unsigned int insn;
   unsigned int op;
   int regno;
   int offset;
   LONGEST rav;
 
-  insn = alpha_read_insn (pc);
+  insn = alpha_read_insn (gdbarch, pc);
 
   /* Opcode is top 6 bits. */
   op = (insn >> 26) & 0x3f;
@@ -1376,8 +1390,8 @@ alpha_next_pc (struct frame_info *frame, CORE_ADDR pc)
     {
       /* Branch format: target PC is:
         (new PC) + (4 * sext(displacement))  */
-      if (op == 0x30 ||                /* BR */
-         op == 0x34)           /* BSR */
+      if (op == 0x30           /* BR */
+         || op == 0x34)        /* BSR */
        {
  branch_taken:
           offset = (insn & 0x001fffff);
@@ -1397,7 +1411,7 @@ alpha_next_pc (struct frame_info *frame, CORE_ADDR pc)
           case 0x33:              /* FBLE */
           case 0x32:              /* FBLT */
           case 0x35:              /* FBNE */
-            regno += gdbarch_fp0_regnum (get_frame_arch (frame));
+            regno += gdbarch_fp0_regnum (gdbarch);
        }
       
       rav = get_frame_register_signed (frame, regno);
@@ -1474,12 +1488,14 @@ alpha_next_pc (struct frame_info *frame, CORE_ADDR pc)
 int
 alpha_software_single_step (struct frame_info *frame)
 {
+  struct gdbarch *gdbarch = get_frame_arch (frame);
+  struct address_space *aspace = get_frame_address_space (frame);
   CORE_ADDR pc, next_pc;
 
   pc = get_frame_pc (frame);
   next_pc = alpha_next_pc (frame, pc);
 
-  insert_single_step_breakpoint (next_pc);
+  insert_single_step_breakpoint (gdbarch, aspace, next_pc);
   return 1;
 }
 
This page took 0.028782 seconds and 4 git commands to generate.