PR cli/21688: Fix multi-line/inline command differentiation
[deliverable/binutils-gdb.git] / gdb / m88k-tdep.c
index 0823d4041634c921cc576dfd0b1f15ced97a2a89..d08a9130c727d316308f57a7945c4d2919e7042b 100644 (file)
@@ -1,7 +1,6 @@
 /* Target-dependent code for the Motorola 88000 series.
 
-   Copyright (C) 2004, 2005, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright (C) 2004-2017 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -31,9 +30,7 @@
 #include "symtab.h"
 #include "trad-frame.h"
 #include "value.h"
-
-#include "gdb_assert.h"
-#include "gdb_string.h"
+#include <algorithm>
 
 #include "m88k-tdep.h"
 
@@ -52,7 +49,7 @@ m88k_fetch_instruction (CORE_ADDR pc, enum bfd_endian byte_order)
 static const char *
 m88k_register_name (struct gdbarch *gdbarch, int regnum)
 {
-  static char *register_names[] =
+  static const char *register_names[] =
   {
     "r0",  "r1",  "r2",  "r3",  "r4",  "r5",  "r6",  "r7",
     "r8",  "r9",  "r10", "r11", "r12", "r13", "r14", "r15",
@@ -68,7 +65,7 @@ m88k_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 *
 m88k_register_type (struct gdbarch *gdbarch, int regnum)
@@ -100,16 +97,11 @@ m88k_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR addr)
    encode a breakpoint instruction, store the length of the string in
    *LEN and optionally adjust *PC to point to the correct memory
    location for inserting the breakpoint.  */
-   
-static const gdb_byte *
-m88k_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pc, int *len)
-{
-  /* tb 0,r0,511 */
-  static gdb_byte break_insn[] = { 0xf0, 0x00, 0xd1, 0xff };
 
-  *len = sizeof (break_insn);
-  return break_insn;
-}
+/* tb 0,r0,511 */
+constexpr gdb_byte m88k_break_insn[] = { 0xf0, 0x00, 0xd1, 0xff };
+
+typedef BP_MANIPULATION (m88k_break_insn) m88k_breakpoint;
 
 static CORE_ADDR
 m88k_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
@@ -169,6 +161,7 @@ m88k_integral_or_pointer_p (const struct type *type)
       return 1;
     case TYPE_CODE_PTR:
     case TYPE_CODE_REF:
+    case TYPE_CODE_RVALUE_REF:
       {
        /* Allow only 32-bit pointers.  */
        return (TYPE_LENGTH (type) == 4);
@@ -384,7 +377,7 @@ m88k_dummy_id (struct gdbarch *arch, struct frame_info *this_frame)
    from WRITEBUF into REGCACHE.  */
 
 static enum return_value_convention
-m88k_return_value (struct gdbarch *gdbarch, struct type *func_type,
+m88k_return_value (struct gdbarch *gdbarch, struct value *function,
                   struct type *type, struct regcache *regcache,
                   gdb_byte *readbuf, const gdb_byte *writebuf)
 {
@@ -537,11 +530,9 @@ m88k_analyze_prologue (struct gdbarch *gdbarch,
   /* Provide a dummy cache if necessary.  */
   if (cache == NULL)
     {
-      size_t sizeof_saved_regs =
-       (M88K_R31_REGNUM + 1) * sizeof (struct trad_frame_saved_reg);
-
-      cache = alloca (sizeof (struct m88k_frame_cache));
-      cache->saved_regs = alloca (sizeof_saved_regs);
+      cache = XALLOCA (struct m88k_frame_cache);
+      cache->saved_regs =
+        XALLOCAVEC (struct trad_frame_saved_reg, M88K_R31_REGNUM + 1);
 
       /* We only initialize the members we care about.  */
       cache->saved_regs[M88K_R1_REGNUM].addr = -1;
@@ -564,7 +555,7 @@ m88k_analyze_prologue (struct gdbarch *gdbarch,
              prologue.  */
          if (cache->fp_offset != -1
              && cache->saved_regs[M88K_R1_REGNUM].addr != -1)
-           return min (pc, end);
+           return std::min (pc, end);
          break;
 
        case M88K_PIA_NOTE_ST:
@@ -572,7 +563,7 @@ m88k_analyze_prologue (struct gdbarch *gdbarch,
          /* If no frame has been allocated, the stores aren't part of
              the prologue.  */
          if (cache->sp_offset == 0)
-           return min (pc, end);
+           return std::min (pc, end);
 
          /* Record location of saved registers.  */
          {
@@ -589,7 +580,7 @@ m88k_analyze_prologue (struct gdbarch *gdbarch,
          /* A second stack pointer adjustment isn't part of the
              prologue.  */
          if (cache->sp_offset != 0)
-           return min (pc, end);
+           return std::min (pc, end);
 
          /* Store stack pointer adjustment.  */
          cache->sp_offset = -SUBU_OFFSET (insn);
@@ -599,7 +590,7 @@ m88k_analyze_prologue (struct gdbarch *gdbarch,
          /* A second frame pointer assignment isn't part of the
              prologue.  */
          if (cache->fp_offset != -1)
-           return min (pc, end);
+           return std::min (pc, end);
 
          /* Record frame pointer assignment.  */
          cache->fp_offset = ADDU_OFFSET (insn);
@@ -610,12 +601,12 @@ m88k_analyze_prologue (struct gdbarch *gdbarch,
              the instruction in the delay slot might be.  Limit the
              prologue analysis to the delay slot and record the branch
              instruction as the end of the prologue.  */
-         limit = min (limit, pc + 2 * M88K_INSN_SIZE);
+         limit = std::min (limit, pc + 2 * M88K_INSN_SIZE);
          end = pc;
          break;
 
        case M88K_PIA_NOTE_PROLOGUE_END:
-         return min (pc, end);
+         return std::min (pc, end);
        }
 
       pc += M88K_INSN_SIZE;
@@ -658,7 +649,7 @@ m88k_frame_cache (struct frame_info *this_frame, void **this_cache)
   CORE_ADDR frame_sp;
 
   if (*this_cache)
-    return *this_cache;
+    return (struct m88k_frame_cache *) *this_cache;
 
   cache = FRAME_OBSTACK_ZALLOC (struct m88k_frame_cache);
   cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
@@ -749,6 +740,7 @@ m88k_frame_prev_register (struct frame_info *this_frame,
 static const struct frame_unwind m88k_frame_unwind =
 {
   NORMAL_FRAME,
+  default_frame_unwind_stop_reason,
   m88k_frame_this_id,
   m88k_frame_prev_register,
   NULL,
@@ -787,7 +779,7 @@ m88k_supply_gregset (const struct regset *regset,
                     struct regcache *regcache,
                     int regnum, const void *gregs, size_t len)
 {
-  const gdb_byte *regs = gregs;
+  const gdb_byte *regs = (const gdb_byte *) gregs;
   int i;
 
   for (i = 0; i < M88K_NUM_REGS; i++)
@@ -799,23 +791,21 @@ m88k_supply_gregset (const struct regset *regset,
 
 /* Motorola 88000 register set.  */
 
-static struct regset m88k_gregset =
+static const struct regset m88k_gregset =
 {
   NULL,
   m88k_supply_gregset
 };
 
-/* Return the appropriate register set for the core section identified
-   by SECT_NAME and SECT_SIZE.  */
+/* Iterate over supported core file register note sections. */
 
-static const struct regset *
-m88k_regset_from_core_section (struct gdbarch *gdbarch,
-                              const char *sect_name, size_t sect_size)
+static void
+m88k_iterate_over_regset_sections (struct gdbarch *gdbarch,
+                                  iterate_over_regset_sections_cb *cb,
+                                  void *cb_data,
+                                  const struct regcache *regcache)
 {
-  if (strcmp (sect_name, ".reg") == 0 && sect_size >= M88K_NUM_REGS * 4)
-    return &m88k_gregset;
-
-  return NULL;
+  cb (".reg", M88K_NUM_REGS * 4, &m88k_gregset, NULL, cb_data);
 }
 \f
 
@@ -845,10 +835,8 @@ m88k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_pc_regnum (gdbarch, M88K_SXIP_REGNUM);
 
   /* Core file support.  */
-  set_gdbarch_regset_from_core_section
-    (gdbarch, m88k_regset_from_core_section);
-
-  set_gdbarch_print_insn (gdbarch, print_insn_m88k);
+  set_gdbarch_iterate_over_regset_sections
+    (gdbarch, m88k_iterate_over_regset_sections);
 
   set_gdbarch_skip_prologue (gdbarch, m88k_skip_prologue);
 
@@ -859,11 +847,12 @@ m88k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_push_dummy_call (gdbarch, m88k_push_dummy_call);
   set_gdbarch_dummy_id (gdbarch, m88k_dummy_id);
 
-  /* Return value info */
+  /* Return value info */
   set_gdbarch_return_value (gdbarch, m88k_return_value);
 
   set_gdbarch_addr_bits_remove (gdbarch, m88k_addr_bits_remove);
-  set_gdbarch_breakpoint_from_pc (gdbarch, m88k_breakpoint_from_pc);
+  set_gdbarch_breakpoint_kind_from_pc (gdbarch, m88k_breakpoint::kind_from_pc);
+  set_gdbarch_sw_breakpoint_from_kind (gdbarch, m88k_breakpoint::bp_from_kind);
   set_gdbarch_unwind_pc (gdbarch, m88k_unwind_pc);
   set_gdbarch_write_pc (gdbarch, m88k_write_pc);
 
This page took 0.031778 seconds and 4 git commands to generate.