Delegate opcodes to select disassembler in GDB
[deliverable/binutils-gdb.git] / gdb / m68hc11-tdep.c
index 60cc2d44eaed3db41da8b714468cb51cb4e015d0..b19ddf7b71d2963ab51e56cd46288d3faddc80a2 100644 (file)
@@ -1,6 +1,6 @@
 /* Target-dependent code for Motorola 68HC11 & 68HC12
 
-   Copyright (C) 1999-2014 Free Software Foundation, Inc.
+   Copyright (C) 1999-2017 Free Software Foundation, Inc.
 
    Contributed by Stephane Carrez, stcarrez@nerim.fr
 
@@ -30,7 +30,6 @@
 #include "gdbtypes.h"
 #include "gdbcmd.h"
 #include "gdbcore.h"
-#include <string.h>
 #include "value.h"
 #include "inferior.h"
 #include "dis-asm.h"  
@@ -167,7 +166,7 @@ struct m68hc11_unwind_cache
 
 /* Table of registers for 68HC11.  This includes the hard registers
    and the soft registers used by GCC.  */
-static char *
+static const char *
 m68hc11_register_names[] =
 {
   "x",    "d",    "y",    "sp",   "pc",   "a",    "b",
@@ -199,12 +198,12 @@ static int soft_reg_initialized = 0;
 static void
 m68hc11_get_register_info (struct m68hc11_soft_reg *reg, const char *name)
 {
-  struct minimal_symbol *msymbol;
+  struct bound_minimal_symbol msymbol;
 
   msymbol = lookup_minimal_symbol (name, NULL, NULL);
-  if (msymbol)
+  if (msymbol.minsym)
     {
-      reg->addr = SYMBOL_VALUE_ADDRESS (msymbol);
+      reg->addr = BMSYMBOL_VALUE_ADDRESS (msymbol);
       reg->name = xstrdup (name);
 
       /* Keep track of the address range for soft registers.  */
@@ -338,7 +337,7 @@ m68hc11_pseudo_register_write (struct gdbarch *gdbarch,
   if (regno == M68HC12_HARD_PC_REGNUM)
     {
       const int regsize = 4;
-      gdb_byte *tmp = alloca (regsize);
+      gdb_byte *tmp = (gdb_byte *) alloca (regsize);
       CORE_ADDR pc;
 
       memcpy (tmp, buf, regsize);
@@ -363,7 +362,7 @@ m68hc11_pseudo_register_write (struct gdbarch *gdbarch,
   if (soft_regs[regno].name)
     {
       const int regsize = 2;
-      gdb_byte *tmp = alloca (regsize);
+      gdb_byte *tmp = (gdb_byte *) alloca (regsize);
       memcpy (tmp, buf, regsize);
       target_write_memory (soft_regs[regno].addr, tmp, regsize);
     }
@@ -391,16 +390,9 @@ m68hc11_register_name (struct gdbarch *gdbarch, int reg_nr)
   return m68hc11_register_names[reg_nr];
 }
 
-static const unsigned char *
-m68hc11_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr,
-                           int *lenptr)
-{
-  static unsigned char breakpoint[] = {0x0};
-
-  *lenptr = sizeof (breakpoint);
-  return breakpoint;
-}
+constexpr gdb_byte m68hc11_break_insn[] = {0x0};
 
+typedef BP_MANIPULATION (m68hc11_break_insn) m68hc11_breakpoint;
 \f
 /* 68HC11 & 68HC12 prologue analysis.  */
 
@@ -793,7 +785,7 @@ m68hc11_frame_unwind_cache (struct frame_info *this_frame,
   int i;
 
   if ((*this_prologue_cache))
-    return (*this_prologue_cache);
+    return (struct m68hc11_unwind_cache *) (*this_prologue_cache);
 
   info = FRAME_OBSTACK_ZALLOC (struct m68hc11_unwind_cache);
   (*this_prologue_cache) = info;
@@ -1352,16 +1344,6 @@ m68hc11_elf_make_msymbol_special (asymbol *sym, struct minimal_symbol *msym)
   if (flags & STO_M68HC12_INTERRUPT)
     MSYMBOL_SET_RTI (msym);
 }
-
-static int
-gdb_print_insn_m68hc11 (bfd_vma memaddr, disassemble_info *info)
-{
-  if (info->arch == bfd_arch_m68hc11)
-    return print_insn_m68hc11 (memaddr, info);
-  else
-    return print_insn_m68hc12 (memaddr, info);
-}
-
 \f
 
 /* 68HC11/68HC12 register groups.
@@ -1452,7 +1434,7 @@ m68hc11_gdbarch_init (struct gdbarch_info info,
     }
 
   /* Need a new architecture.  Fill in a target specific vector.  */
-  tdep = (struct gdbarch_tdep *) xmalloc (sizeof (struct gdbarch_tdep));
+  tdep = XNEW (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
   tdep->elf_flags = elf_flags;
 
@@ -1529,8 +1511,10 @@ m68hc11_gdbarch_init (struct gdbarch_info info,
   set_gdbarch_return_value (gdbarch, m68hc11_return_value);
   set_gdbarch_skip_prologue (gdbarch, m68hc11_skip_prologue);
   set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
-  set_gdbarch_breakpoint_from_pc (gdbarch, m68hc11_breakpoint_from_pc);
-  set_gdbarch_print_insn (gdbarch, gdb_print_insn_m68hc11);
+  set_gdbarch_breakpoint_kind_from_pc (gdbarch,
+                                      m68hc11_breakpoint::kind_from_pc);
+  set_gdbarch_sw_breakpoint_from_kind (gdbarch,
+                                      m68hc11_breakpoint::bp_from_kind);
 
   m68hc11_add_reggroups (gdbarch);
   set_gdbarch_register_reggroup_p (gdbarch, m68hc11_register_reggroup_p);
This page took 0.042699 seconds and 4 git commands to generate.