Restrict ia64_convert_register_p
[deliverable/binutils-gdb.git] / gdb / mips-tdep.c
index 45d1d731b0cd129f58101a7b2ba922974aa11aee..82f91ba2cd950c5f48f8f408f645ea49e952ef29 100644 (file)
@@ -3879,7 +3879,7 @@ mips_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR addr)
 #define SC_OPCODE 0x38
 #define SCD_OPCODE 0x3c
 
-static VEC (CORE_ADDR) *
+static std::vector<CORE_ADDR>
 mips_deal_with_atomic_sequence (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   CORE_ADDR breaks[2] = {-1, -1};
@@ -3890,12 +3890,11 @@ mips_deal_with_atomic_sequence (struct gdbarch *gdbarch, CORE_ADDR pc)
   int index;
   int last_breakpoint = 0; /* Defaults to 0 (no breakpoints placed).  */  
   const int atomic_sequence_length = 16; /* Instruction sequence length.  */
-  VEC (CORE_ADDR) *next_pcs = NULL;
 
   insn = mips_fetch_instruction (gdbarch, ISA_MIPS, loc, NULL);
   /* Assume all atomic sequences start with a ll/lld instruction.  */
   if (itype_op (insn) != LL_OPCODE && itype_op (insn) != LLD_OPCODE)
-    return NULL;
+    return {};
 
   /* Assume that no atomic sequence is longer than "atomic_sequence_length" 
      instructions.  */
@@ -3912,7 +3911,7 @@ mips_deal_with_atomic_sequence (struct gdbarch *gdbarch, CORE_ADDR pc)
        {
        case 0: /* SPECIAL */
          if (rtype_funct (insn) >> 1 == 4) /* JR, JALR */
-           return 0; /* fallback to the standard single-step code.  */
+           return {}; /* fallback to the standard single-step code.  */
          break;
        case 1: /* REGIMM */
          is_branch = ((itype_rt (insn) & 0xc) == 0 /* B{LT,GE}Z* */
@@ -3921,7 +3920,7 @@ mips_deal_with_atomic_sequence (struct gdbarch *gdbarch, CORE_ADDR pc)
          break;
        case 2: /* J */
        case 3: /* JAL */
-         return 0; /* fallback to the standard single-step code.  */
+         return {}; /* fallback to the standard single-step code.  */
        case 4: /* BEQ */
        case 5: /* BNE */
        case 6: /* BLEZ */
@@ -3947,8 +3946,8 @@ mips_deal_with_atomic_sequence (struct gdbarch *gdbarch, CORE_ADDR pc)
        {
          branch_bp = loc + mips32_relative_offset (insn) + 4;
          if (last_breakpoint >= 1)
-           return 0; /* More than one branch found, fallback to the
-                        standard single-step code.  */
+           return {}; /* More than one branch found, fallback to the
+                         standard single-step code.  */
          breaks[1] = branch_bp;
          last_breakpoint++;
        }
@@ -3959,7 +3958,7 @@ mips_deal_with_atomic_sequence (struct gdbarch *gdbarch, CORE_ADDR pc)
 
   /* Assume that the atomic sequence ends with a sc/scd instruction.  */
   if (itype_op (insn) != SC_OPCODE && itype_op (insn) != SCD_OPCODE)
-    return NULL;
+    return {};
 
   loc += MIPS_INSN32_SIZE;
 
@@ -3971,14 +3970,16 @@ mips_deal_with_atomic_sequence (struct gdbarch *gdbarch, CORE_ADDR pc)
   if (last_breakpoint && pc <= breaks[1] && breaks[1] <= breaks[0])
     last_breakpoint = 0;
 
+  std::vector<CORE_ADDR> next_pcs;
+
   /* Effectively inserts the breakpoints.  */
   for (index = 0; index <= last_breakpoint; index++)
-    VEC_safe_push (CORE_ADDR, next_pcs, breaks[index]);
+    next_pcs.push_back (breaks[index]);
 
   return next_pcs;
 }
 
-static VEC (CORE_ADDR) *
+static std::vector<CORE_ADDR>
 micromips_deal_with_atomic_sequence (struct gdbarch *gdbarch,
                                     CORE_ADDR pc)
 {
@@ -3992,17 +3993,16 @@ micromips_deal_with_atomic_sequence (struct gdbarch *gdbarch,
   ULONGEST insn;
   int insn_count;
   int index;
-  VEC (CORE_ADDR) *next_pcs = NULL;
 
   /* Assume all atomic sequences start with a ll/lld instruction.  */
   insn = mips_fetch_instruction (gdbarch, ISA_MICROMIPS, loc, NULL);
   if (micromips_op (insn) != 0x18)     /* POOL32C: bits 011000 */
-    return NULL;
+    return {};
   loc += MIPS_INSN16_SIZE;
   insn <<= 16;
   insn |= mips_fetch_instruction (gdbarch, ISA_MICROMIPS, loc, NULL);
   if ((b12s4_op (insn) & 0xb) != 0x3)  /* LL, LLD: bits 011000 0x11 */
-    return NULL;
+    return {};
   loc += MIPS_INSN16_SIZE;
 
   /* Assume all atomic sequences end with an sc/scd instruction.  Assume
@@ -4072,7 +4072,7 @@ micromips_deal_with_atomic_sequence (struct gdbarch *gdbarch,
            case 0x35: /* J: bits 110101 */
            case 0x3d: /* JAL: bits 111101 */
            case 0x3c: /* JALX: bits 111100 */
-             return 0; /* Fall back to the standard single-step code. */
+             return {}; /* Fall back to the standard single-step code. */
 
            case 0x18: /* POOL32C: bits 011000 */
              if ((b12s4_op (insn) & 0xb) == 0xb)
@@ -4099,24 +4099,24 @@ micromips_deal_with_atomic_sequence (struct gdbarch *gdbarch,
                  && b5s5_op (insn) != 0x18)
                                /* JRADDIUSP: bits 010001 11000 */
                break;
-             return NULL; /* Fall back to the standard single-step code. */
+             return {}; /* Fall back to the standard single-step code. */
 
            case 0x33: /* B16: bits 110011 */
-             return NULL; /* Fall back to the standard single-step code. */
+             return {}; /* Fall back to the standard single-step code. */
            }
          break;
        }
       if (is_branch)
        {
          if (last_breakpoint >= 1)
-           return NULL; /* More than one branch found, fallback to the
-                        standard single-step code.  */
+           return {}; /* More than one branch found, fallback to the
+                         standard single-step code.  */
          breaks[1] = branch_bp;
          last_breakpoint++;
        }
     }
   if (!sc_found)
-    return NULL;
+    return {};
 
   /* Insert a breakpoint right after the end of the atomic sequence.  */
   breaks[0] = loc;
@@ -4126,14 +4126,16 @@ micromips_deal_with_atomic_sequence (struct gdbarch *gdbarch,
   if (last_breakpoint && pc <= breaks[1] && breaks[1] <= breaks[0])
     last_breakpoint = 0;
 
+  std::vector<CORE_ADDR> next_pcs;
+
   /* Effectively inserts the breakpoints.  */
   for (index = 0; index <= last_breakpoint; index++)
-    VEC_safe_push (CORE_ADDR, next_pcs, breaks[index]);
+    next_pcs.push_back (breaks[index]);
 
   return next_pcs;
 }
 
-static VEC (CORE_ADDR) *
+static std::vector<CORE_ADDR>
 deal_with_atomic_sequence (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   if (mips_pc_is_mips (pc))
@@ -4141,7 +4143,7 @@ deal_with_atomic_sequence (struct gdbarch *gdbarch, CORE_ADDR pc)
   else if (mips_pc_is_micromips (gdbarch, pc))
     return micromips_deal_with_atomic_sequence (gdbarch, pc);
   else
-    return NULL;
+    return {};
 }
 
 /* mips_software_single_step() is called just before we want to resume
@@ -4149,22 +4151,21 @@ deal_with_atomic_sequence (struct gdbarch *gdbarch, CORE_ADDR pc)
    or kernel single-step support (MIPS on GNU/Linux for example).  We find
    the target of the coming instruction and breakpoint it.  */
 
-VEC (CORE_ADDR) *
+std::vector<CORE_ADDR>
 mips_software_single_step (struct regcache *regcache)
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   CORE_ADDR pc, next_pc;
-  VEC (CORE_ADDR) *next_pcs;
 
   pc = regcache_read_pc (regcache);
-  next_pcs = deal_with_atomic_sequence (gdbarch, pc);
-  if (next_pcs != NULL)
+  std::vector<CORE_ADDR> next_pcs = deal_with_atomic_sequence (gdbarch, pc);
+
+  if (!next_pcs.empty ())
     return next_pcs;
 
   next_pc = mips_next_pc (regcache, pc);
 
-  VEC_safe_push (CORE_ADDR, next_pcs, next_pc);
-  return next_pcs;
+  return {next_pc};
 }
 
 /* Test whether the PC points to the return instruction at the
@@ -5758,7 +5759,6 @@ mips_o32_return_value (struct gdbarch *gdbarch, struct value *function,
       /* A struct that contains one or two floats.  Each value is part
          in the least significant part of their floating point
          register..  */
-      gdb_byte reg[MAX_REGISTER_SIZE];
       int regnum;
       int field;
       for (field = 0, regnum = mips_regnum (gdbarch)->fp0;
@@ -6473,7 +6473,8 @@ print_gp_register_row (struct ui_file *file, struct frame_info *frame,
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
   /* Do values for GP (int) regs.  */
-  gdb_byte raw_buffer[MAX_REGISTER_SIZE];
+  const gdb_byte *raw_buffer;
+  struct value *value;
   int ncols = (mips_abi_regsize (gdbarch) == 8 ? 4 : 8);    /* display cols
                                                               per row.  */
   int col, byte;
@@ -6532,14 +6533,17 @@ print_gp_register_row (struct ui_file *file, struct frame_info *frame,
        break;                  /* End row: large register.  */
 
       /* OK: get the data in raw format.  */
-      if (!deprecated_frame_register_read (frame, regnum, raw_buffer))
+      value = get_frame_register_value (frame, regnum);
+      if (value_optimized_out (value)
+       || !value_entirely_available (value))
        error (_("can't read register %d (%s)"),
               regnum, gdbarch_register_name (gdbarch, regnum));
+      raw_buffer = value_contents_all (value);
       /* pad small registers */
       for (byte = 0;
           byte < (mips_abi_regsize (gdbarch)
                   - register_size (gdbarch, regnum)); byte++)
-       printf_filtered ("  ");
+       fprintf_filtered (file, "  ");
       /* Now print the register value in hex, endian order.  */
       if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
        for (byte =
@@ -8488,7 +8492,7 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
     }
 
   /* Need a new architecture.  Fill in a target specific vector.  */
-  tdep = XNEW (struct gdbarch_tdep);
+  tdep = XCNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
   tdep->elf_flags = elf_flags;
   tdep->mips64_transfers_32bit_regs_p = mips64_transfers_32bit_regs_p;
This page took 0.027061 seconds and 4 git commands to generate.